From da3b238d307f10591593d4fd72a7b0d38a9da7cb Mon Sep 17 00:00:00 2001 From: jasonchenwork Date: Wed, 21 May 2025 15:42:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E9=AB=94=E9=A1=AF=E7=A4=BA=E8=AA=BF?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PrimaryForm.MultiPagePanel.cs | 31 ++++++++++++++----- PrimaryFormParts/PrimaryForm.cs | 21 +++++++++++-- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/PrimaryFormParts/PrimaryForm.MultiPagePanel.cs b/PrimaryFormParts/PrimaryForm.MultiPagePanel.cs index 86a08bb..5851852 100644 --- a/PrimaryFormParts/PrimaryForm.MultiPagePanel.cs +++ b/PrimaryFormParts/PrimaryForm.MultiPagePanel.cs @@ -263,9 +263,9 @@ namespace DualScreenDemo artistLabel.AutoSize = false; // 計算文字寬度 - Font normalFont = new Font("微軟正黑體", 26, FontStyle.Bold); - Font mediumFont = new Font("微軟正黑體", 20, FontStyle.Bold); - Font smallFont = new Font("微軟正黑體", 16, FontStyle.Bold); + Font normalFont = new Font("微軟正黑體", 24, FontStyle.Bold); + Font mediumFont = new Font("微軟正黑體", 18, FontStyle.Bold); + Font smallFont = new Font("微軟正黑體", 14, FontStyle.Bold); // 根據文字長度設置字體大小 if (artistLabel.Text.Length > 18) @@ -452,9 +452,9 @@ namespace DualScreenDemo int textLength = fullText.Length; // 計算文字寬度 - Font normalFont = new Font("微軟正黑體", 26, FontStyle.Bold); - Font mediumFont = new Font("微軟正黑體", 20, FontStyle.Bold); - Font smallFont = new Font("微軟正黑體", 16, FontStyle.Bold); + Font normalFont = new Font("微軟正黑體", 22, FontStyle.Bold); + Font mediumFont = new Font("微軟正黑體", 16, FontStyle.Bold); + Font smallFont = new Font("微軟正黑體", 12, FontStyle.Bold); // 根據文字長度設置字體大小 if (textLength > 18) { @@ -536,8 +536,23 @@ namespace DualScreenDemo BackColor = Color.FromArgb(80, 255, 255, 255), Name = "SeparatorPanel_" + index.ToString() }; - // 設置字體樣式 - artistLabel.Font = new Font("微軟正黑體", 16, FontStyle.Bold); + + // 根據文字長度設置字體大小 + if (artistText.Length > 6) + { + artistLabel.Font = new Font("微軟正黑體", 12, FontStyle.Bold); + } + else if (artistText.Length > 4) + { + artistLabel.Font = new Font("微軟正黑體", 14, FontStyle.Bold); + } + else + { + artistLabel.Font = new Font("微軟正黑體", 16, FontStyle.Bold); + } + + //artistLabel.Font = new Font("微軟正黑體", 16, FontStyle.Bold); + artistLabel.ForeColor = Color.FromArgb(30,144,255); songLabel.TextAlign = ContentAlignment.MiddleLeft; artistLabel.TextAlign = ContentAlignment.MiddleRight; diff --git a/PrimaryFormParts/PrimaryForm.cs b/PrimaryFormParts/PrimaryForm.cs index ccff339..de3ee11 100644 --- a/PrimaryFormParts/PrimaryForm.cs +++ b/PrimaryFormParts/PrimaryForm.cs @@ -1823,11 +1823,28 @@ namespace DualScreenDemo using (Graphics g = Graphics.FromImage(originalImage)) { + // 計算文字寬度 float dpiX = g.DpiX; float points = 25; - float pixels = points * (dpiX / 72); - + float pixels = points * (dpiX / 72); Font font = new Font("微軟正黑體", points, FontStyle.Bold); + // 根據文字長度設置字體大小 + + if (songData.Song.Length > 18) + { + font = new Font("微軟正黑體", 17, FontStyle.Bold); + } + else if (songData.Song.Length > 13) + { + font = new Font("微軟正黑體", 21, FontStyle.Bold); + } + else + { + font = new Font("微軟正黑體", 25, FontStyle.Bold); + } + + + Brush textBrush = Brushes.Black; string songInfo = songData.Song ?? "未提供歌曲信息";