优化区域编号计算逻辑,确保绘制状态下正确显示和分配下一个区域编号
This commit is contained in:
@@ -185,14 +185,14 @@
|
||||
1. 初始状态/就绪状态:
|
||||
- 显示btnDrawRegion和btnDrawTempDiff按钮、dataGridViewTempDiff
|
||||
- 显示btnNewTempRegion按钮、btnLoadTempRegion按钮、btnSaveTempRegion按钮、btnNewTempDiff按钮、btnLoadTempDiff按钮、btnSaveTempDiff按钮
|
||||
- 隐藏btnSelectColor、btnDeleteRegion按钮、btnAddTempDiff、btnDeleteTempDiff、btnBrushSize1、btnBrushSize3、btnBrushSize5、btnBrushSize10、btnBrushSize15、btnBrushSize25
|
||||
- 隐藏btnSelectColor、btnDeleteRegion按钮、btnAddTempDiff、btnDeleteTempDiff、btnBrushSize1、btnBrushSize3、btnBrushSize5、btnBrushSize10、btnBrushSize15、btnBrushSize25、txtRegionNumber
|
||||
2. 选中区域状态:
|
||||
- 显示btnDeleteRegion和btnSelectColor按钮
|
||||
- 显示btnDeleteRegion和btnSelectColor按钮、txtRegionNumber
|
||||
- 隐藏btnDrawRegion和btnDrawTempDiff按钮、dataGridViewTempDiff、btnAddTempDiff、btnDeleteTempDiff、btnBrushSize1、btnBrushSize3、btnBrushSize5、btnBrushSize10、btnBrushSize15、btnBrushSize25
|
||||
- 隐藏btnNewTempRegion按钮、btnLoadTempRegion按钮、btnSaveTempRegion按钮、btnNewTempDiff按钮、btnLoadTempDiff按钮、btnSaveTempDiff按钮
|
||||
3. 绘制状态:
|
||||
- 显示btnSelectColor按钮
|
||||
- 显示btnDrawRegion按钮
|
||||
- 显示btnDrawRegion按钮、txtRegionNumber
|
||||
- 隐藏btnDeleteRegion按钮
|
||||
- 隐藏btnDrawTempDiff按钮、dataGridViewTempDiff、btnAddTempDiff、btnDeleteTempDiff、btnBrushSize1、btnBrushSize3、btnBrushSize5、btnBrushSize10、btnBrushSize15、btnBrushSize25
|
||||
- 隐藏btnNewTempRegion按钮、btnLoadTempRegion按钮、btnSaveTempRegion按钮、btnNewTempDiff按钮、btnLoadTempDiff按钮、btnSaveTempDiff按钮
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace JoyD.Windows.CS
|
||||
this.btnSelectColor = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnDeleteRegion = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnDrawTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnEraseTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnAddTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnDeleteTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnBrushSize1 = new System.Windows.Forms.ToolStripButton();
|
||||
@@ -46,7 +47,13 @@ namespace JoyD.Windows.CS
|
||||
this.btnBrushSize10 = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnBrushSize15 = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnBrushSize25 = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnEraseTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
this.txtRegionNumber = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.btnNewTempRegion = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnLoadTempRegion = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnSaveTempRegion = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnNewTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnLoadTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnSaveTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
|
||||
this.splitContainer.Panel1.SuspendLayout();
|
||||
this.splitContainer.Panel2.SuspendLayout();
|
||||
@@ -100,10 +107,10 @@ namespace JoyD.Windows.CS
|
||||
this.picBoxTemp.SizeChanged += new System.EventHandler(this.PicBoxTemp_SizeChanged);
|
||||
this.picBoxTemp.Paint += new System.Windows.Forms.PaintEventHandler(this.PicBoxTemp_Paint);
|
||||
this.picBoxTemp.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PicBoxTemp_MouseClick);
|
||||
this.picBoxTemp.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.PicBoxTemp_MouseDoubleClick);
|
||||
this.picBoxTemp.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PicBoxTemp_MouseDown);
|
||||
this.picBoxTemp.MouseMove += new System.Windows.Forms.MouseEventHandler(this.PicBoxTemp_MouseMove);
|
||||
this.picBoxTemp.MouseUp += new System.Windows.Forms.MouseEventHandler(this.PicBoxTemp_MouseUp);
|
||||
this.picBoxTemp.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.PicBoxTemp_MouseDoubleClick);
|
||||
//
|
||||
// toolStripContainer
|
||||
//
|
||||
@@ -136,87 +143,6 @@ namespace JoyD.Windows.CS
|
||||
this.dataGridViewTempDiff.Size = new System.Drawing.Size(250, 400);
|
||||
this.dataGridViewTempDiff.TabIndex = 0;
|
||||
//
|
||||
// btnNewTempRegion
|
||||
//
|
||||
this.btnNewTempRegion = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnNewTempRegion.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.btnNewTempRegion.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnNewTempRegion.Name = "btnNewTempRegion";
|
||||
this.btnNewTempRegion.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnNewTempRegion.Text = "新建测温区";
|
||||
this.btnNewTempRegion.ToolTipText = "新建测温区";
|
||||
this.btnNewTempRegion.Click += new System.EventHandler(this.BtnNewTempRegion_Click);
|
||||
//
|
||||
// btnLoadTempRegion
|
||||
//
|
||||
this.btnLoadTempRegion = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnLoadTempRegion.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.btnLoadTempRegion.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnLoadTempRegion.Name = "btnLoadTempRegion";
|
||||
this.btnLoadTempRegion.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnLoadTempRegion.Text = "加载测温区";
|
||||
this.btnLoadTempRegion.ToolTipText = "加载测温区";
|
||||
this.btnLoadTempRegion.Click += new System.EventHandler(this.BtnLoadTempRegion_Click);
|
||||
//
|
||||
// btnSaveTempRegion
|
||||
//
|
||||
this.btnSaveTempRegion = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnSaveTempRegion.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.btnSaveTempRegion.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnSaveTempRegion.Name = "btnSaveTempRegion";
|
||||
this.btnSaveTempRegion.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnSaveTempRegion.Text = "保存测温区";
|
||||
this.btnSaveTempRegion.ToolTipText = "保存测温区";
|
||||
this.btnSaveTempRegion.Click += new System.EventHandler(this.BtnSaveTempRegion_Click);
|
||||
//
|
||||
// btnNewTempDiff
|
||||
//
|
||||
this.btnNewTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnNewTempDiff.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.btnNewTempDiff.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnNewTempDiff.Name = "btnNewTempDiff";
|
||||
this.btnNewTempDiff.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnNewTempDiff.Text = "新建温差图";
|
||||
this.btnNewTempDiff.ToolTipText = "新建温差图";
|
||||
//
|
||||
// btnLoadTempDiff
|
||||
//
|
||||
this.btnLoadTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnLoadTempDiff.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.btnLoadTempDiff.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnLoadTempDiff.Name = "btnLoadTempDiff";
|
||||
this.btnLoadTempDiff.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnLoadTempDiff.Text = "加载温差图";
|
||||
this.btnLoadTempDiff.ToolTipText = "加载温差图";
|
||||
//
|
||||
// btnSaveTempDiff
|
||||
//
|
||||
this.btnSaveTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnSaveTempDiff.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.btnSaveTempDiff.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnSaveTempDiff.Name = "btnSaveTempDiff";
|
||||
this.btnSaveTempDiff.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnSaveTempDiff.Text = "保存温差图";
|
||||
this.btnSaveTempDiff.ToolTipText = "保存温差图";
|
||||
//
|
||||
// 确保在添加到toolStrip前初始化以下控件
|
||||
//
|
||||
|
||||
this.txtRegionNumber = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.txtRegionNumber.Name = "txtRegionNumber";
|
||||
this.txtRegionNumber.Size = new System.Drawing.Size(60, 25);
|
||||
this.txtRegionNumber.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TxtRegionNumber_KeyDown);
|
||||
this.txtRegionNumber.TextChanged += new System.EventHandler(this.TxtRegionNumber_TextChanged);
|
||||
// 设置合适的边距
|
||||
this.txtRegionNumber.Margin = new System.Windows.Forms.Padding(0, 2, 3, 2);
|
||||
// 添加工具提示信息
|
||||
this.txtRegionNumber.ToolTipText = "区域编号";
|
||||
// 确保控件不会被拆分到不同行
|
||||
this.txtRegionNumber.AutoSize = true;
|
||||
// 设置文本靠右显示
|
||||
this.txtRegionNumber.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
|
||||
this.txtRegionNumber.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// toolStrip
|
||||
//
|
||||
this.toolStrip.AllowDrop = true;
|
||||
@@ -231,30 +157,23 @@ namespace JoyD.Windows.CS
|
||||
this.btnEraseTempDiff,
|
||||
this.btnAddTempDiff,
|
||||
this.btnDeleteTempDiff,
|
||||
new System.Windows.Forms.ToolStripSeparator(),
|
||||
this.btnBrushSize1,
|
||||
this.btnBrushSize3,
|
||||
this.btnBrushSize5,
|
||||
this.btnBrushSize10,
|
||||
this.btnBrushSize15,
|
||||
this.btnBrushSize25,
|
||||
new System.Windows.Forms.ToolStripSeparator(),
|
||||
this.txtRegionNumber,
|
||||
new System.Windows.Forms.ToolStripSeparator(),
|
||||
this.btnNewTempRegion,
|
||||
this.btnLoadTempRegion,
|
||||
this.btnSaveTempRegion,
|
||||
this.btnNewTempDiff,
|
||||
this.btnLoadTempDiff,
|
||||
this.btnSaveTempDiff});
|
||||
// 使用Flow布局允许按钮多行显示
|
||||
this.toolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
|
||||
this.toolStrip.Location = new System.Drawing.Point(3, 0);
|
||||
// 增加最大高度以允许多行显示
|
||||
this.toolStrip.MaximumSize = new System.Drawing.Size(0, 200);
|
||||
this.toolStrip.MinimumSize = new System.Drawing.Size(100, 50);
|
||||
// 保留AutoSize以确保良好显示
|
||||
this.toolStrip.AutoSize = true;
|
||||
this.toolStrip.Name = "toolStrip";
|
||||
this.toolStrip.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.toolStrip.Size = new System.Drawing.Size(247, 50);
|
||||
@@ -302,6 +221,16 @@ namespace JoyD.Windows.CS
|
||||
this.btnDrawTempDiff.ToolTipText = "绘制温差图";
|
||||
this.btnDrawTempDiff.Click += new System.EventHandler(this.BtnDrawTempDiff_Click);
|
||||
//
|
||||
// btnEraseTempDiff
|
||||
//
|
||||
this.btnEraseTempDiff.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.btnEraseTempDiff.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnEraseTempDiff.Name = "btnEraseTempDiff";
|
||||
this.btnEraseTempDiff.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnEraseTempDiff.Text = "擦除温差图";
|
||||
this.btnEraseTempDiff.ToolTipText = "使用透明色擦除温差图";
|
||||
this.btnEraseTempDiff.Click += new System.EventHandler(this.BtnEraseTempDiff_Click);
|
||||
//
|
||||
// btnAddTempDiff
|
||||
//
|
||||
this.btnAddTempDiff.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
@@ -382,15 +311,17 @@ namespace JoyD.Windows.CS
|
||||
this.btnBrushSize25.ToolTipText = "选择25像素画笔";
|
||||
this.btnBrushSize25.Click += new System.EventHandler(this.BtnBrushSize25_Click);
|
||||
//
|
||||
// btnEraseTempDiff
|
||||
// txtRegionNumber
|
||||
//
|
||||
this.btnEraseTempDiff.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.btnEraseTempDiff.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnEraseTempDiff.Name = "btnEraseTempDiff";
|
||||
this.btnEraseTempDiff.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnEraseTempDiff.Text = "擦除温差图";
|
||||
this.btnEraseTempDiff.ToolTipText = "使用透明色擦除温差图";
|
||||
this.btnEraseTempDiff.Click += new System.EventHandler(this.BtnEraseTempDiff_Click);
|
||||
this.txtRegionNumber.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
|
||||
this.txtRegionNumber.Margin = new System.Windows.Forms.Padding(0, 2, 3, 2);
|
||||
this.txtRegionNumber.Name = "txtRegionNumber";
|
||||
this.txtRegionNumber.Size = new System.Drawing.Size(60, 27);
|
||||
this.txtRegionNumber.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.txtRegionNumber.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
this.txtRegionNumber.ToolTipText = "区域编号";
|
||||
this.txtRegionNumber.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TxtRegionNumber_KeyDown);
|
||||
this.txtRegionNumber.TextChanged += new System.EventHandler(this.TxtRegionNumber_TextChanged);
|
||||
//
|
||||
// btnNewTempRegion
|
||||
//
|
||||
@@ -400,6 +331,7 @@ namespace JoyD.Windows.CS
|
||||
this.btnNewTempRegion.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnNewTempRegion.Text = "新建测温区";
|
||||
this.btnNewTempRegion.ToolTipText = "新建测温区";
|
||||
this.btnNewTempRegion.Click += new System.EventHandler(this.BtnNewTempRegion_Click);
|
||||
//
|
||||
// btnLoadTempRegion
|
||||
//
|
||||
@@ -409,6 +341,7 @@ namespace JoyD.Windows.CS
|
||||
this.btnLoadTempRegion.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnLoadTempRegion.Text = "加载测温区";
|
||||
this.btnLoadTempRegion.ToolTipText = "加载测温区";
|
||||
this.btnLoadTempRegion.Click += new System.EventHandler(this.BtnLoadTempRegion_Click);
|
||||
//
|
||||
// btnSaveTempRegion
|
||||
//
|
||||
@@ -418,6 +351,7 @@ namespace JoyD.Windows.CS
|
||||
this.btnSaveTempRegion.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnSaveTempRegion.Text = "保存测温区";
|
||||
this.btnSaveTempRegion.ToolTipText = "保存测温区";
|
||||
this.btnSaveTempRegion.Click += new System.EventHandler(this.BtnSaveTempRegion_Click);
|
||||
//
|
||||
// btnNewTempDiff
|
||||
//
|
||||
@@ -445,7 +379,6 @@ namespace JoyD.Windows.CS
|
||||
this.btnSaveTempDiff.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnSaveTempDiff.Text = "保存温差图";
|
||||
this.btnSaveTempDiff.ToolTipText = "保存温差图";
|
||||
// 控件初始化已移至toolStrip.Items.AddRange调用前
|
||||
//
|
||||
// Setting
|
||||
//
|
||||
|
||||
@@ -1124,9 +1124,11 @@ namespace JoyD.Windows.CS
|
||||
btnSaveTempDiff.Visible = false;
|
||||
// 显示区域编号设置控件
|
||||
txtRegionNumber.Visible = true;
|
||||
// 在绘制状态下,显示下一个测温区的编号(当前已绘制数量 + 1)
|
||||
int nextRegionNumber = _drawnRectangles.Count + 1;
|
||||
// 在绘制状态下,显示下一个测温区的编号(当前所有区域编号最大值 + 1)
|
||||
int nextRegionNumber = _drawnRectangles.Count > 0 ? _drawnRectangles.Max(r => r.Index) + 1 : 1;
|
||||
txtRegionNumber.Text = nextRegionNumber.ToString();
|
||||
// 同步更新_regionCounter,确保与显示的下一个编号一致
|
||||
_regionCounter = nextRegionNumber - 1;
|
||||
// 隐藏所有画笔大小按钮
|
||||
btnBrushSize1.Visible = false;
|
||||
btnBrushSize3.Visible = false;
|
||||
@@ -2316,6 +2318,7 @@ namespace JoyD.Windows.CS
|
||||
int imageY = Math.Min(imageStartPoint.Y, imageEndPoint.Y);
|
||||
|
||||
// 增加计数器并创建新的区域信息(存储图像坐标)
|
||||
// 保持简单的递增方式,因为在UpdateButtonsVisibility方法中已经正确设置了下一个应该使用的编号
|
||||
_regionCounter++;
|
||||
RegionInfo regionInfo = new RegionInfo
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user