显示区域温度
This commit is contained in:
@@ -2927,7 +2927,7 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 只有在全局温度模式下才显示温度数据
|
// 6. 根据温度模式显示温度数据
|
||||||
if (isGlobalTemperatureMode)
|
if (isGlobalTemperatureMode)
|
||||||
{
|
{
|
||||||
// 准备温度文本
|
// 准备温度文本
|
||||||
@@ -2961,6 +2961,54 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
// 调用DrawTextInAreaCentered方法绘制温度文本
|
// 调用DrawTextInAreaCentered方法绘制温度文本
|
||||||
DrawTextInAreaCentered(g, textsArray);
|
DrawTextInAreaCentered(g, textsArray);
|
||||||
}
|
}
|
||||||
|
else if (_showAreaTemperature)
|
||||||
|
{
|
||||||
|
// 区域温度模式:为每个区域计算并显示温度数据
|
||||||
|
using (Font font = new Font("微软雅黑", 10, FontStyle.Bold))
|
||||||
|
{
|
||||||
|
// 遍历已加载的测温区列表,为每个区域显示温度数据
|
||||||
|
foreach (TemperatureZone zone in _loadedTemperatureZones)
|
||||||
|
{
|
||||||
|
// 计算区域在温度矩阵中的实际位置
|
||||||
|
// 注意:温度矩阵是512×384,而区域坐标是基于图像的512×384分辨率
|
||||||
|
int startRow = Math.Max(0, zone.Y);
|
||||||
|
int startCol = Math.Max(0, zone.X);
|
||||||
|
int endRow = Math.Min(383, zone.Y + zone.Height - 1);
|
||||||
|
int endCol = Math.Min(511, zone.X + zone.Width - 1);
|
||||||
|
|
||||||
|
// 获取区域温度统计信息
|
||||||
|
RegionTemperatureStats stats = temperatureData.GetRegionStatistics(startRow, startCol, endRow, endCol);
|
||||||
|
|
||||||
|
// 准备温度文本
|
||||||
|
List<string> areaTemperatureTexts = new List<string>();
|
||||||
|
if (_showMaxTemperature)
|
||||||
|
{
|
||||||
|
areaTemperatureTexts.Add($"最高: {stats.MaxTemperature:F2} °C");
|
||||||
|
}
|
||||||
|
if (_showMinTemperature)
|
||||||
|
{
|
||||||
|
areaTemperatureTexts.Add($"最低: {stats.MinTemperature:F2} °C");
|
||||||
|
}
|
||||||
|
if (_showAverageTemperature)
|
||||||
|
{
|
||||||
|
areaTemperatureTexts.Add($"平均: {stats.AverageTemperature:F2} °C");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建画刷,使用区域的颜色作为文字颜色
|
||||||
|
using (Brush brush = new SolidBrush(zone.Color))
|
||||||
|
{
|
||||||
|
// 绘制温度文本,从区域左上角开始,向下排列
|
||||||
|
float currentY = zone.Y + 20; // 从区域编号下方开始
|
||||||
|
foreach (string text in areaTemperatureTexts)
|
||||||
|
{
|
||||||
|
PointF textPosition = new PointF(zone.X + 5, currentY);
|
||||||
|
g.DrawString(text, font, brush, textPosition);
|
||||||
|
currentY += 20; // 每行间隔20像素
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置显示状态标志
|
// 设置显示状态标志
|
||||||
|
|||||||
@@ -252,11 +252,11 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
/// <returns>区域温度统计信息</returns>
|
/// <returns>区域温度统计信息</returns>
|
||||||
public RegionTemperatureStats GetRegionStatistics(int startRow, int startCol, int endRow, int endCol)
|
public RegionTemperatureStats GetRegionStatistics(int startRow, int startCol, int endRow, int endCol)
|
||||||
{
|
{
|
||||||
// 参数验证和边界检查
|
// 使用RealTemperatureMatrix的固定尺寸(384x512)进行边界检查
|
||||||
startRow = Math.Max(0, startRow);
|
startRow = Math.Max(0, startRow);
|
||||||
startCol = Math.Max(0, startCol);
|
startCol = Math.Max(0, startCol);
|
||||||
endRow = Math.Min(Height - 1, endRow);
|
endRow = Math.Min(383, endRow); // RealTemperatureMatrix高度为384
|
||||||
endCol = Math.Min(Width - 1, endCol);
|
endCol = Math.Min(511, endCol); // RealTemperatureMatrix宽度为512
|
||||||
|
|
||||||
if (startRow > endRow || startCol > endCol)
|
if (startRow > endRow || startCol > endCol)
|
||||||
return new RegionTemperatureStats(0, 0, 0, 0);
|
return new RegionTemperatureStats(0, 0, 0, 0);
|
||||||
@@ -266,11 +266,12 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
float max = float.MinValue;
|
float max = float.MinValue;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
// 使用RealTemperatureMatrix计算统计值
|
||||||
for (int row = startRow; row <= endRow; row++)
|
for (int row = startRow; row <= endRow; row++)
|
||||||
{
|
{
|
||||||
for (int col = startCol; col <= endCol; col++)
|
for (int col = startCol; col <= endCol; col++)
|
||||||
{
|
{
|
||||||
float temp = TemperatureMatrix[row, col];
|
float temp = RealTemperatureMatrix[row, col];
|
||||||
sum += temp;
|
sum += temp;
|
||||||
min = Math.Min(min, temp);
|
min = Math.Min(min, temp);
|
||||||
max = Math.Max(max, temp);
|
max = Math.Max(max, temp);
|
||||||
|
|||||||
Reference in New Issue
Block a user