修复加载测温区后新绘制区域索引冲突的问题
This commit is contained in:
@@ -3024,13 +3024,15 @@ namespace JoyD.Windows.CS
|
|||||||
// 用透明色清空叠加层图像
|
// 用透明色清空叠加层图像
|
||||||
CreateRectangleOverlayImage();
|
CreateRectangleOverlayImage();
|
||||||
|
|
||||||
|
// 重置区域计数器
|
||||||
|
_regionCounter = 0;
|
||||||
|
|
||||||
// 从CSV文件中读取所有测温区位置大小和颜色信息
|
// 从CSV文件中读取所有测温区位置大小和颜色信息
|
||||||
using (StreamReader reader = new StreamReader(openFileDialog.FileName, Encoding.UTF8))
|
using (StreamReader reader = new StreamReader(openFileDialog.FileName, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
// 跳过标题行
|
// 跳过标题行
|
||||||
string headerLine = reader.ReadLine();
|
string headerLine = reader.ReadLine();
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
string line;
|
string line;
|
||||||
// 逐行读取数据
|
// 逐行读取数据
|
||||||
while ((line = reader.ReadLine()) != null)
|
while ((line = reader.ReadLine()) != null)
|
||||||
@@ -3090,6 +3092,12 @@ namespace JoyD.Windows.CS
|
|||||||
// 更新按钮可见性
|
// 更新按钮可见性
|
||||||
UpdateButtonsVisibility(0);
|
UpdateButtonsVisibility(0);
|
||||||
|
|
||||||
|
// 更新_regionCounter为当前最大索引值+1,避免后续绘制新区域时索引冲突
|
||||||
|
if (_drawnRectangles.Count > 0)
|
||||||
|
{
|
||||||
|
_regionCounter = _drawnRectangles.Max(r => r.Index) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
// 加载成功后提示用户
|
// 加载成功后提示用户
|
||||||
MessageBox.Show("测温区信息加载成功,共加载 " + _drawnRectangles.Count + " 个测温区", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("测温区信息加载成功,共加载 " + _drawnRectangles.Count + " 个测温区", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user