优化UpdateInfo方法,实现透明色清空和状态显示逻辑

This commit is contained in:
zqm
2025-11-05 11:24:56 +08:00
parent 97543e297f
commit 85e65929bf

View File

@@ -173,57 +173,6 @@ namespace JoyD.Windows.CS.Toprie
format); format);
} }
} }
else if (isReady)
{
// 就绪条件下,根据用户选择显示温度数据
if ((_showGlobalTemperature || _showAreaTemperature) && _deviceManager != null && _deviceManager.ConnectionStatus == ConnectionStatus.Connected)
{
TemperatureData temperatureData = _deviceManager.LastTemperature;
if (temperatureData != null && temperatureData.Timestamp != null)
{
// 检查温度数据时间是否在最近3秒内
TimeSpan timeDiff = DateTime.Now - temperatureData.Timestamp;
if (timeDiff.TotalSeconds <= 3)
{
using (Font font = new Font("Arial", 20, FontStyle.Bold))
using (SolidBrush textBrush = new SolidBrush(Color.White))
{
StringFormat format = new StringFormat() { Alignment = StringAlignment.Center };
// 绘制温度信息
StringBuilder tempInfoBuilder = new StringBuilder();
// 添加温度标题
tempInfoBuilder.AppendLine(_showGlobalTemperature ? "全局温度" : "区域温度");
tempInfoBuilder.AppendLine();
// 根据勾选状态添加最高温度
if (_showMaxTemperature)
{
tempInfoBuilder.AppendLine($"最高温度: {temperatureData.MaxTemperature:F2} °C");
}
// 根据勾选状态添加平均温度
if (_showAverageTemperature)
{
tempInfoBuilder.AppendLine($"平均温度: {temperatureData.AverageTemperature:F2} °C");
}
// 根据勾选状态添加最低温度
if (_showMinTemperature)
{
tempInfoBuilder.AppendLine($"最低温度: {temperatureData.MinTemperature:F2} °C");
}
// 将温度信息居中显示
g.DrawString(tempInfoBuilder.ToString(), font, textBrush,
new RectangleF(0, BUFFER_HEIGHT / 4, BUFFER_WIDTH, BUFFER_HEIGHT / 2),
format);
}
}
}
}
}
} }
// 设置显示标志 // 设置显示标志