修改显示逻辑

This commit is contained in:
zqm
2025-10-30 15:25:59 +08:00
parent 58ac23b57b
commit a6bb9b8812

View File

@@ -112,32 +112,32 @@ namespace JoyD.Windows.CS.Toprie
g.FillRectangle(brush, 0, 0, BUFFER_WIDTH, BUFFER_HEIGHT); g.FillRectangle(brush, 0, 0, BUFFER_WIDTH, BUFFER_HEIGHT);
} }
if (isPaused) if (isPaused)
{ {
// 暂停状态 - 最高优先级 // 暂停状态 - 最高优先级
// 绘制暂停文本 // 绘制暂停文本
string text = "暂停"; string text = "暂停";
Color textColor = Color.Red; Color textColor = Color.Red;
using (Font font = new Font("Arial", 48, FontStyle.Bold)) using (Font font = new Font("Arial", 48, FontStyle.Bold))
using (SolidBrush textBrush = new SolidBrush(textColor)) using (SolidBrush textBrush = new SolidBrush(textColor))
{ {
StringFormat format = new StringFormat(); StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center; format.Alignment = StringAlignment.Center;
// 将主文本居中显示 // 将主文本居中显示
g.DrawString(text, font, textBrush, g.DrawString(text, font, textBrush,
new RectangleF(0, BUFFER_HEIGHT / 3, BUFFER_WIDTH, BUFFER_HEIGHT / 3), new RectangleF(0, BUFFER_HEIGHT / 3, BUFFER_WIDTH, BUFFER_HEIGHT / 3),
format); format);
} }
} }
else if (isPingFailed || isDisconnected || isReconnecting) else if (isPingFailed || isDisconnected || isReconnecting)
{ {
// 非暂停状态下检查Ping状态和连接状态 // 非暂停状态下检查Ping状态和连接状态
// 确定显示的文本和颜色 // 确定显示的文本和颜色
string text = ""; string text = "";
Color textColor = Color.White; Color textColor = Color.White;
if (isReconnecting) if (isReconnecting)
{ {
text = "正在重连..."; text = "正在重连...";
@@ -153,20 +153,21 @@ namespace JoyD.Windows.CS.Toprie
text = "连接断开"; text = "连接断开";
textColor = Color.Red; textColor = Color.Red;
} }
// 绘制文本 // 绘制文本
using (Font font = new Font("Arial", 48, FontStyle.Bold)) using (Font font = new Font("Arial", 48, FontStyle.Bold))
using (SolidBrush textBrush = new SolidBrush(textColor)) using (SolidBrush textBrush = new SolidBrush(textColor))
{ {
StringFormat format = new StringFormat(); StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center; format.Alignment = StringAlignment.Center;
// 将主文本居中显示 // 将主文本居中显示
g.DrawString(text, font, textBrush, g.DrawString(text, font, textBrush,
new RectangleF(0, BUFFER_HEIGHT / 3, BUFFER_WIDTH, BUFFER_HEIGHT / 3), new RectangleF(0, BUFFER_HEIGHT / 3, BUFFER_WIDTH, BUFFER_HEIGHT / 3),
format); format);
} }
} }
else g.Clear(Color.Transparent);
} }
// 否则清空InfoImage已在开头处理 // 否则清空InfoImage已在开头处理