字體顯示調整
This commit is contained in:
parent
9156983dee
commit
da3b238d30
@ -263,9 +263,9 @@ namespace DualScreenDemo
|
|||||||
artistLabel.AutoSize = false;
|
artistLabel.AutoSize = false;
|
||||||
|
|
||||||
// 計算文字寬度
|
// 計算文字寬度
|
||||||
Font normalFont = new Font("微軟正黑體", 26, FontStyle.Bold);
|
Font normalFont = new Font("微軟正黑體", 24, FontStyle.Bold);
|
||||||
Font mediumFont = new Font("微軟正黑體", 20, FontStyle.Bold);
|
Font mediumFont = new Font("微軟正黑體", 18, FontStyle.Bold);
|
||||||
Font smallFont = new Font("微軟正黑體", 16, FontStyle.Bold);
|
Font smallFont = new Font("微軟正黑體", 14, FontStyle.Bold);
|
||||||
|
|
||||||
// 根據文字長度設置字體大小
|
// 根據文字長度設置字體大小
|
||||||
if (artistLabel.Text.Length > 18)
|
if (artistLabel.Text.Length > 18)
|
||||||
@ -452,9 +452,9 @@ namespace DualScreenDemo
|
|||||||
int textLength = fullText.Length;
|
int textLength = fullText.Length;
|
||||||
|
|
||||||
// 計算文字寬度
|
// 計算文字寬度
|
||||||
Font normalFont = new Font("微軟正黑體", 26, FontStyle.Bold);
|
Font normalFont = new Font("微軟正黑體", 22, FontStyle.Bold);
|
||||||
Font mediumFont = new Font("微軟正黑體", 20, FontStyle.Bold);
|
Font mediumFont = new Font("微軟正黑體", 16, FontStyle.Bold);
|
||||||
Font smallFont = new Font("微軟正黑體", 16, FontStyle.Bold);
|
Font smallFont = new Font("微軟正黑體", 12, FontStyle.Bold);
|
||||||
// 根據文字長度設置字體大小
|
// 根據文字長度設置字體大小
|
||||||
if (textLength > 18)
|
if (textLength > 18)
|
||||||
{
|
{
|
||||||
@ -536,8 +536,23 @@ namespace DualScreenDemo
|
|||||||
BackColor = Color.FromArgb(80, 255, 255, 255),
|
BackColor = Color.FromArgb(80, 255, 255, 255),
|
||||||
Name = "SeparatorPanel_" + index.ToString()
|
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);
|
artistLabel.ForeColor = Color.FromArgb(30,144,255);
|
||||||
songLabel.TextAlign = ContentAlignment.MiddleLeft;
|
songLabel.TextAlign = ContentAlignment.MiddleLeft;
|
||||||
artistLabel.TextAlign = ContentAlignment.MiddleRight;
|
artistLabel.TextAlign = ContentAlignment.MiddleRight;
|
||||||
|
@ -1823,11 +1823,28 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
using (Graphics g = Graphics.FromImage(originalImage))
|
using (Graphics g = Graphics.FromImage(originalImage))
|
||||||
{
|
{
|
||||||
|
// 計算文字寬度
|
||||||
float dpiX = g.DpiX;
|
float dpiX = g.DpiX;
|
||||||
float points = 25;
|
float points = 25;
|
||||||
float pixels = points * (dpiX / 72);
|
float pixels = points * (dpiX / 72);
|
||||||
|
|
||||||
Font font = new Font("微軟正黑體", points, FontStyle.Bold);
|
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;
|
Brush textBrush = Brushes.Black;
|
||||||
|
|
||||||
string songInfo = songData.Song ?? "未提供歌曲信息";
|
string songInfo = songData.Song ?? "未提供歌曲信息";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user