2509051441

字體大小,UIq排版調整
This commit is contained in:
jasonchenwork 2025-09-05 14:42:34 +08:00
parent bca39d98e2
commit ba2a07041a
5 changed files with 116 additions and 61 deletions

View File

@ -1,7 +1,9 @@
using DualScreenDemo;
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Windows.Markup;
namespace DBObj
{
@ -75,21 +77,41 @@ namespace DBObj
{
try
{
var check = IsFtpUriReachable(new Uri(new Uri(server), basic.getFileName()).ToString());
Uri fullUri = new Uri(new Uri(server), basic.getFileName());
//string fullPath = Path.Combine(server, basic.getFileName());
//string fileName = Path.GetFileName(basic.getFileName());
//if (File.Exists(fullPath))
//{
// //Console.WriteLine($"找到檔案: {fullPath}");
// //if (!File.Exists(Application.StartupPath + fileName)) File.Copy(fullPath, Application.StartupPath + fileName);
// return true;
//}
if (check)
string fullPath = Path.Combine(server, basic.getFileName());
string fileName = Path.GetFileName(basic.getFileName());
string folderName = basic.getFileName().Replace(fileName, "");
string folderPath = Application.StartupPath + "Temp";
// Directory.CreateDirectory(folderPath);
// Directory.CreateDirectory(folderPath + "\\" +folderName);
// bool isTooBig = FolderSizeChecker.IsFolderSizeExceeded(folderPath, 50.0);
// if (isTooBig) FolderSizeChecker.TrimFolderToSize(folderPath, 50.0);
if (File.Exists(fullPath))
{
// Console.WriteLine($"找到檔案: {new Uri(new Uri(server), basic.getFileName())}");
//Console.WriteLine($"找到檔案: {fullPath}");
// if (!File.Exists(folderPath + "\\" + folderName + "\\" + fileName))
// {
// Task copyTask = Task.Run(() =>
// {
// var copyQueue = new FileCopyQueue();
// copyQueue.Enqueue(fullPath, folderPath + "\\" + folderName + "\\" + fileName);
// });
// copyTask.Wait(); // Wait for the copy to complete before returning
// }
return true;
}
//var check = IsHttpAddressReachable(new Uri(new Uri(server), basic.getFileName()).ToString());
//Uri fullUri = new Uri(new Uri(server), basic.getFileName());
//if (check)
//{
// // if (!File.Exists(folderPath + "\\" + fileName))PrimaryForm.Instance.HttpDownload(fullUri.ToString(), folderPath+"\\"+fileName);
// // Console.WriteLine($"找到檔案: {new Uri(new Uri(server), basic.getFileName())}");
// return true;
//}
}
catch (Exception ex)
{
@ -159,29 +181,62 @@ namespace DBObj
{
return String.Format("{0} {1}", basic.getName(), state.GetDescription());
}
public bool IsFtpUriReachable(string ftpUri)
// public bool IsFtpUriReachable(string ftpUri)
// {
// try
// {
// #pragma warning disable SYSLIB0014 // 類型或成員已經過時
// var request = (FtpWebRequest)WebRequest.Create(ftpUri);
// #pragma warning restore SYSLIB0014 // 類型或成員已經過時
// request.Method = WebRequestMethods.Ftp.ListDirectory; // Lightweight check
// // request.Credentials = new NetworkCredential("svr", "svr"); // Replace with actual username/password
// request.Timeout = 5000;
// using var response = (FtpWebResponse)request.GetResponse();
// return response.StatusCode == FtpStatusCode.OpeningData || response.StatusCode == FtpStatusCode.DataAlreadyOpen;
// }
// catch (WebException ex)
// {
// if (ex.Response is FtpWebResponse ftpResponse)
// {
// Console.WriteLine($"FTP error: {ftpResponse.StatusDescription}");
// Console.WriteLine($"FTP error: {ftpResponse.BannerMessage}");
// return false;
// }
// Console.WriteLine($"Connection error: {ex.Message}");
// return false;
// }
// catch (Exception ex)
// {
// Console.WriteLine($"Unexpected error: {ex.Message}");
// return false;
// }
// }
public static bool IsHttpAddressReachable(string url)
{
try
{
#pragma warning disable SYSLIB0014 // 類型或成員已經過時
var request = (FtpWebRequest)WebRequest.Create(ftpUri);
var request = (HttpWebRequest)WebRequest.Create(url);
#pragma warning restore SYSLIB0014 // 類型或成員已經過時
request.Method = WebRequestMethods.Ftp.ListDirectory; // Lightweight check
// request.Credentials = new NetworkCredential("svr", "svr"); // Replace with actual username/password
request.Method = "HEAD";
request.Timeout = 5000;
using var response = (FtpWebResponse)request.GetResponse();
return response.StatusCode == FtpStatusCode.OpeningData || response.StatusCode == FtpStatusCode.DataAlreadyOpen;
using var response = (HttpWebResponse)request.GetResponse();
return (int)response.StatusCode >= 200 && (int)response.StatusCode < 300;
}
catch (WebException ex)
{
if (ex.Response is FtpWebResponse ftpResponse)
if (ex.Response is HttpWebResponse httpResponse)
{
Console.WriteLine($"FTP error: {ftpResponse.StatusDescription}");
return false;
Console.WriteLine($"HTTP error: {httpResponse.StatusCode} - {httpResponse.StatusDescription}");
}
else
{
Console.WriteLine($"Connection error: {ex.Message}");
}
return false;
}
catch (Exception ex)
@ -191,10 +246,6 @@ namespace DBObj
}
}
public static bool IsFtpUri(Uri uri)
{
return uri != null && uri.Scheme == Uri.UriSchemeFtp;
}
}
}

6
Env.cs
View File

@ -62,8 +62,10 @@ namespace Utils
// .Select(s => s.Trim('\'', '"').TrimEnd('\\')) // 清理
// .ToArray();
return new string[] { @"ftp://svr:svr@svr",@"ftp://song1:song1@svr01", @"ftp://song2:song2@svr02",@"ftp://song3:song3@svr03" };
// return new string[] { @"ftp://svr:svr@svr", @"ftp://song1:song1@svr01", @"ftp://song2:song2@svr02", @"ftp://song3:song3@svr03" };
// return new string[] { @"http://svr:8080", @"http://svr01:8080", @"http://svr02:8080", @"http://svr03:8080" };
// return new string[] { Application.StartupPath+@"\\Temp", @"\\svr01", @"\\svr02" };
return new string[] { @"\\svr01", @"\\svr02" };
}
public static string Get(string key, string fallback = "") =>

View File

@ -289,7 +289,7 @@ namespace DualScreenDemo
artistLabel.AutoSize = false;
// 計算文字寬度
artistLabel.Font = new Font("微軟正黑體", 22, FontStyle.Bold);
artistLabel.Font = new Font("微軟正黑體", 24, FontStyle.Bold);
Screen screen = Screen.PrimaryScreen;
int screenWidth = screen.Bounds.Width;
int screenHeight = screen.Bounds.Height;
@ -409,7 +409,7 @@ namespace DualScreenDemo
int textLength = fullText.Length;
// 計算文字寬度
songLabel.Font = new Font("微軟正黑體", 22, FontStyle.Bold);
songLabel.Font = new Font("微軟正黑體", 24, FontStyle.Bold);
songLabel.Text = fullText;
songLabel.Tag = song;
songLabel.AutoSize = false;
@ -457,26 +457,26 @@ namespace DualScreenDemo
{
Image = Image.FromFile(Path.Combine(serverPath, data["PrimaryFormBtn"]["Voice"])),
SizeMode = PictureBoxSizeMode.Zoom,
Size = new Size(26, 26),
Location = new Point(songX + 5, y + 8)
Size = new Size(30, 30),
Location = new Point(songX + 5, y + 10)
};
this.Controls.Add(icon);
icon.BringToFront();
// 有圖標時歌名右移
songLabel.Location = new Point(songX + 42, y);
songLabel.Location = new Point(songX + 42, y+3);
//songLabel.Size = new Size(songWidth - 47, ItemHeight - 20);
songLabel.Size = new Size(700, 66);
}
else
{
// 沒有圖標時歌名置中
songLabel.Location = new Point(songX, y);
songLabel.Location = new Point(songX, y+3);
//songLabel.Size = new Size(songWidth - 10, ItemHeight - 20);
songLabel.Size = new Size(700, 66);
}
// 歌手標籤位置調整
artistLabel.Location = new Point(artistX, y + 33);
artistLabel.Location = new Point(artistX, y + 33 + 10);
artistLabel.Size = new Size(artistWidth - 10, ItemHeight - 35);
if (song.getB() != null)
@ -488,7 +488,7 @@ namespace DualScreenDemo
if (artistText.Length > 3)
{
artistLabel.Location = new Point(artistX - 502, y + 33);
artistLabel.Location = new Point(artistX - 502, y + 33 + 10);
artistLabel.Size = new Size(artistWidth + 490, ItemHeight - 35);
}
@ -496,7 +496,7 @@ namespace DualScreenDemo
// 創建分隔線面板
Panel separatorPanel = new Panel
{
Location = new Point(songX - 5, y + ItemHeight - 2),
Location = new Point(songX - 5, y + ItemHeight - 2 + 5),
//Size = new Size(songWidth + artistWidth + 20, 2),
Size = new Size(730, 2),
BackColor = Color.FromArgb(80, 255, 255, 255),
@ -504,7 +504,7 @@ namespace DualScreenDemo
};
// 根據文字長度設置字體大小
int fold = 14;
int fold = 16;
//if (artistText.Length > 6)
// fold = 10;
//else if (artistText.Length > 3)
@ -560,6 +560,8 @@ namespace DualScreenDemo
artistLabel.BringToFront();
songLabel.TextAlign = ContentAlignment.TopLeft;
this.Controls.SetChildIndex(separatorPanel, 0);
}

View File

@ -253,7 +253,7 @@ namespace DualScreenDemo
// 取主機名稱的最後 20 個字元 (如果長度不足 20則取全部)
string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 3)) + " " + Rtime;
string totalPages = multiPagePanel.totalPages.ToString() == "0" ? "1" : multiPagePanel.totalPages.ToString();
string pageNumber = (multiPagePanel.currentPageIndex + 1).ToString() + "/" + totalPages;
string pageNumber = (multiPagePanel.currentPageIndex + 1).ToString() + "/" + totalPages+"頁";
// 基準解析度(你目前的設計基準)
@ -959,36 +959,36 @@ namespace DualScreenDemo
{
var data = LoadBtnConfigData();
InitializeButton(ref newSongAlertButton, ref newSongAlertNormalBackground, ref newSongAlertActiveBackground, "newSongAlertButton", 20, 98, 105, 120, data["PrimaryFormBtn"]["AlertNormal"], data["PrimaryFormBtn"]["AlertActive"], NewSongAlertButton_Click);
InitializeButton(ref newSongAlertButton, ref newSongAlertNormalBackground, ref newSongAlertActiveBackground, "newSongAlertButton", 20, 98, 105, 118, data["PrimaryFormBtn"]["AlertNormal"], data["PrimaryFormBtn"]["AlertActive"], NewSongAlertButton_Click);
InitializeButton(ref hotPlayButton, ref hotPlayNormalBackground, ref hotPlayActiveBackground, "hotPlayButton", 137, 98, 106, 120, data["PrimaryFormBtn"]["HotNormal"], data["PrimaryFormBtn"]["HotActive"], HotPlayButton_Click);
InitializeButton(ref hotPlayButton, ref hotPlayNormalBackground, ref hotPlayActiveBackground, "hotPlayButton", 137, 98, 106, 118, data["PrimaryFormBtn"]["HotNormal"], data["PrimaryFormBtn"]["HotActive"], HotPlayButton_Click);
InitializeButton(ref singerSearchButton, ref singerSearchNormalBackground, ref singerSearchActiveBackground, "singerSearchButton", 255, 98, 106, 120, data["PrimaryFormBtn"]["SingerNormal"], data["PrimaryFormBtn"]["SingerActive"], SingerSearchButton_Click);
InitializeButton(ref singerSearchButton, ref singerSearchNormalBackground, ref singerSearchActiveBackground, "singerSearchButton", 255, 98, 106, 118, data["PrimaryFormBtn"]["SingerNormal"], data["PrimaryFormBtn"]["SingerActive"], SingerSearchButton_Click);
InitializeButton(ref songSearchButton, ref songSearchNormalBackground, ref songSearchActiveBackground, "songSearchButton", 373, 98, 106, 120, data["PrimaryFormBtn"]["SongNormal"], data["PrimaryFormBtn"]["SongActive"], SongSearchButton_Click);
InitializeButton(ref songSearchButton, ref songSearchNormalBackground, ref songSearchActiveBackground, "songSearchButton", 373, 98, 106, 118, data["PrimaryFormBtn"]["SongNormal"], data["PrimaryFormBtn"]["SongActive"], SongSearchButton_Click);
InitializeButton(ref languageSearchButton, ref languageSearchNormalBackground, ref languageSearchActiveBackground, "languageSearchButton", 491, 98, 106, 120, data["PrimaryFormBtn"]["LangNormal"], data["PrimaryFormBtn"]["LangActive"], LanguageSongSelectionButton_Click);
InitializeButton(ref languageSearchButton, ref languageSearchNormalBackground, ref languageSearchActiveBackground, "languageSearchButton", 491, 98, 106, 118, data["PrimaryFormBtn"]["LangNormal"], data["PrimaryFormBtn"]["LangActive"], LanguageSongSelectionButton_Click);
InitializeButton(ref groupSearchButton, ref groupSearchNormalBackground, ref groupSearchActiveBackground, "groupSearchButton", 608, 98, 106, 120, data["PrimaryFormBtn"]["GroupNormal"], data["PrimaryFormBtn"]["GroupActive"], GroupSongSelectionButton_Click);
InitializeButton(ref groupSearchButton, ref groupSearchNormalBackground, ref groupSearchActiveBackground, "groupSearchButton", 608, 98, 106, 118, data["PrimaryFormBtn"]["GroupNormal"], data["PrimaryFormBtn"]["GroupActive"], GroupSongSelectionButton_Click);
InitializeButton(ref categorySearchButton, ref categorySearchNormalBackground, ref categorySearchActiveBackground, "categorySearchButton", 726, 98, 106, 120, data["PrimaryFormBtn"]["CategNormal"], data["PrimaryFormBtn"]["CategActive"], CategorySearchButton_Click);
InitializeButton(ref categorySearchButton, ref categorySearchNormalBackground, ref categorySearchActiveBackground, "categorySearchButton", 726, 98, 106, 118, data["PrimaryFormBtn"]["CategNormal"], data["PrimaryFormBtn"]["CategActive"], CategorySearchButton_Click);
serviceBellButton = new Button { Text = "" };
ConfigureButton(serviceBellButton, 843, 98, 107, 120,
ConfigureButton(serviceBellButton, 843, 98, 107, 118,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["BellNormal"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["BellActive"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["BellActive"])),
(sender, e) => OnServiceBellButtonClick(sender, e));
InitializeButton(ref orderedSongsButton, ref orderedSongsNormalBackground, ref orderedSongsActiveBackground, "orderedSongsButton", 961, 98, 107, 120, data["PrimaryFormBtn"]["OrderSongNormal"], data["PrimaryFormBtn"]["OrderSongActive"], OrderedSongsButton_Click);
InitializeButton(ref orderedSongsButton, ref orderedSongsNormalBackground, ref orderedSongsActiveBackground, "orderedSongsButton", 961, 98, 107, 118, data["PrimaryFormBtn"]["OrderSongNormal"], data["PrimaryFormBtn"]["OrderSongActive"], OrderedSongsButton_Click);
InitializeButton(ref myFavoritesButton, ref myFavoritesNormalBackground, ref myFavoritesActiveBackground, "myFavoritesButton", 1079, 98, 107, 120, data["PrimaryFormBtn"]["FavoriteNormal"], data["PrimaryFormBtn"]["FavoriteActive"], MyFavoritesButton_Click);
InitializeButton(ref myFavoritesButton, ref myFavoritesNormalBackground, ref myFavoritesActiveBackground, "myFavoritesButton", 1079, 98, 107, 118, data["PrimaryFormBtn"]["FavoriteNormal"], data["PrimaryFormBtn"]["FavoriteActive"], MyFavoritesButton_Click);
InitializeButton(ref promotionsButton, ref promotionsNormalBackground, ref promotionsActiveBackground, "promotionsButton", 1197, 98, 107, 120, data["PrimaryFormBtn"]["PromotNormal"], data["PrimaryFormBtn"]["PromotActive"], promotionsButton_Click);
InitializeButton(ref promotionsButton, ref promotionsNormalBackground, ref promotionsActiveBackground, "promotionsButton", 1197, 98, 107, 118, data["PrimaryFormBtn"]["PromotNormal"], data["PrimaryFormBtn"]["PromotActive"], promotionsButton_Click);
InitializeButton(ref deliciousFoodButton, ref deliciousFoodNormalBackground, ref deliciousFoodActiveBackground, "deliciousFoodButton", 1315, 98, 107, 120, data["PrimaryFormBtn"]["FoodNormal"], data["PrimaryFormBtn"]["FoodActive"], DeliciousFoodButton_Click);
InitializeButton(ref deliciousFoodButton, ref deliciousFoodNormalBackground, ref deliciousFoodActiveBackground, "deliciousFoodButton", 1315, 98, 107, 118, data["PrimaryFormBtn"]["FoodNormal"], data["PrimaryFormBtn"]["FoodActive"], DeliciousFoodButton_Click);
mobileSongRequestButton = new Button { Text = "" };

View File

@ -14,7 +14,7 @@ namespace DualScreenDemo
private static PrimaryForm primaryForm; // 儲存實例的參考
public static Room room = new Room();
public static string verSion = "Server V2.10 202509031254";
public static string verSion = "Server V2.10 202509051440";
[STAThread]
static void Main()