From eb09890c9476ffe6059576a07beac1bb4884d1bd Mon Sep 17 00:00:00 2001 From: zqm Date: Tue, 11 Nov 2025 14:43:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=A0=E8=BD=BD=E6=B5=8B?= =?UTF-8?q?=E6=B8=A9=E5=8C=BA=E5=90=8E=E6=96=B0=E7=BB=98=E5=88=B6=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E7=B4=A2=E5=BC=95=E5=86=B2=E7=AA=81=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Windows/CS/Framework4.0/Toprie/Toprie/Setting.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Windows/CS/Framework4.0/Toprie/Toprie/Setting.cs b/Windows/CS/Framework4.0/Toprie/Toprie/Setting.cs index b108697..3a943b2 100644 --- a/Windows/CS/Framework4.0/Toprie/Toprie/Setting.cs +++ b/Windows/CS/Framework4.0/Toprie/Toprie/Setting.cs @@ -3024,13 +3024,15 @@ namespace JoyD.Windows.CS // 用透明色清空叠加层图像 CreateRectangleOverlayImage(); + // 重置区域计数器 + _regionCounter = 0; + // 从CSV文件中读取所有测温区位置大小和颜色信息 using (StreamReader reader = new StreamReader(openFileDialog.FileName, Encoding.UTF8)) { // 跳过标题行 string headerLine = reader.ReadLine(); - int index = 0; string line; // 逐行读取数据 while ((line = reader.ReadLine()) != null) @@ -3090,6 +3092,12 @@ namespace JoyD.Windows.CS // 更新按钮可见性 UpdateButtonsVisibility(0); + // 更新_regionCounter为当前最大索引值+1,避免后续绘制新区域时索引冲突 + if (_drawnRectangles.Count > 0) + { + _regionCounter = _drawnRectangles.Max(r => r.Index) + 1; + } + // 加载成功后提示用户 MessageBox.Show("测温区信息加载成功,共加载 " + _drawnRectangles.Count + " 个测温区", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); }