温度显示为居中模式
This commit is contained in:
@@ -3029,7 +3029,7 @@ namespace JoyD.Windows.CS.Toprie
|
||||
StringFormat format = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Near, // 左对齐
|
||||
LineAlignment = StringAlignment.Center // 垂直居中
|
||||
LineAlignment = StringAlignment.Near // 顶部对齐,由代码控制垂直居中
|
||||
};
|
||||
|
||||
// 如果没有指定区域,使用整个图像框作为默认区域
|
||||
@@ -3170,9 +3170,6 @@ namespace JoyD.Windows.CS.Toprie
|
||||
else if (_showAreaTemperature)
|
||||
{
|
||||
// 区域温度模式:为每个区域计算并显示温度数据
|
||||
using (Font font = new Font("微软雅黑", 10, FontStyle.Bold))
|
||||
{
|
||||
// 遍历已加载的测温区列表,为每个区域显示温度数据
|
||||
foreach (TemperatureZone zone in _loadedTemperatureZones)
|
||||
{
|
||||
// 准备温度文本
|
||||
@@ -3199,18 +3196,17 @@ namespace JoyD.Windows.CS.Toprie
|
||||
int absoluteX = _detectionZone.X + zone.X;
|
||||
int absoluteY = _detectionZone.Y + zone.Y;
|
||||
|
||||
// 创建画刷,使用区域的颜色作为文字颜色
|
||||
using (Brush brush = new SolidBrush(zone.Color))
|
||||
// 如果有温度文本需要绘制
|
||||
if (areaTemperatureTexts.Count > 0)
|
||||
{
|
||||
// 绘制温度文本,从区域左上角开始,向下排列
|
||||
float currentY = absoluteY + 20; // 从区域编号下方开始,使用绝对坐标
|
||||
foreach (string text in areaTemperatureTexts)
|
||||
{
|
||||
PointF textPosition = new PointF(absoluteX + 5, currentY);
|
||||
g.DrawString(text, font, brush, textPosition);
|
||||
currentY += 20; // 每行间隔20像素
|
||||
}
|
||||
}
|
||||
// 创建表示测温区的矩形区域
|
||||
RectangleF zoneArea = new RectangleF(absoluteX, absoluteY, zone.Width, zone.Height);
|
||||
|
||||
// 将List<string>转换为string[],以便传递给DrawTextInAreaCentered方法
|
||||
string[] textsArray = areaTemperatureTexts.ToArray();
|
||||
|
||||
// 调用DrawTextInAreaCentered方法绘制温度文本,文本会在区域内垂直居中
|
||||
DrawTextInAreaCentered(g, textsArray, zone.Color, zoneArea);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user