实现当鼠标在半透明区域内单击时显示八个句柄的选中功能

This commit is contained in:
zqm
2025-11-07 10:25:55 +08:00
parent bb995fd603
commit da03a71c04
3 changed files with 7 additions and 9 deletions

View File

@@ -149,4 +149,5 @@
3. 图像合并机制 在Paint事件中先绘制叠加层再绘制临时矩形。 3. 图像合并机制 在Paint事件中先绘制叠加层再绘制临时矩形。
4. 保存的矩形框位置和大小信息应该是相对于图像的,而不是相对于控件的。 4. 保存的矩形框位置和大小信息应该是相对于图像的,而不是相对于控件的。
5. 当btnDrawRegion按下后处于绘制状态 btnSelectColor才显示出来 5. 当btnDrawRegion按下后处于绘制状态 btnSelectColor才显示出来
6. 当就绪状态时,鼠标移到区域内,该区域内填充半透明色 6. 当就绪状态时,鼠标移到区域内,该区域内填充半透明色,当有多个重叠时,只填充索引最大的区域
7. 当鼠标在半透明区域内单击时,该区域填充半透明色,且显示八个句柄,表示选中该区域。

View File

@@ -84,6 +84,9 @@
this.picBoxTemp.TabIndex = 0; this.picBoxTemp.TabIndex = 0;
this.picBoxTemp.TabStop = false; this.picBoxTemp.TabStop = false;
this.picBoxTemp.Paint += new System.Windows.Forms.PaintEventHandler(this.PicBoxTemp_Paint); this.picBoxTemp.Paint += new System.Windows.Forms.PaintEventHandler(this.PicBoxTemp_Paint);
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);
// //
// toolStripContainer // toolStripContainer
// //
@@ -109,7 +112,7 @@
this.toolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow; this.toolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
this.toolStrip.Location = new System.Drawing.Point(0, 0); this.toolStrip.Location = new System.Drawing.Point(0, 0);
this.toolStrip.Name = "toolStrip"; this.toolStrip.Name = "toolStrip";
this.toolStrip.Size = new System.Drawing.Size(24, 7); this.toolStrip.Size = new System.Drawing.Size(47, 7);
this.toolStrip.TabIndex = 1; this.toolStrip.TabIndex = 1;
this.toolStrip.Text = "toolStrip"; this.toolStrip.Text = "toolStrip";
// //
@@ -128,7 +131,7 @@
this.btnSelectColor.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.btnSelectColor.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.btnSelectColor.ImageTransparentColor = System.Drawing.Color.Transparent; this.btnSelectColor.ImageTransparentColor = System.Drawing.Color.Transparent;
this.btnSelectColor.Name = "btnSelectColor"; this.btnSelectColor.Name = "btnSelectColor";
this.btnSelectColor.Size = new System.Drawing.Size(23, 22); this.btnSelectColor.Size = new System.Drawing.Size(23, 4);
this.btnSelectColor.Text = "选择颜色"; this.btnSelectColor.Text = "选择颜色";
this.btnSelectColor.ToolTipText = "选择绘制区域的颜色(点击更换颜色)"; this.btnSelectColor.ToolTipText = "选择绘制区域的颜色(点击更换颜色)";
// //

View File

@@ -69,9 +69,6 @@ namespace JoyD.Windows.CS
if (_isDrawingMode) if (_isDrawingMode)
{ {
// 启用绘制模式 // 启用绘制模式
picBoxTemp.MouseDown += PicBoxTemp_MouseDown;
picBoxTemp.MouseMove += PicBoxTemp_MouseMove;
picBoxTemp.MouseUp += PicBoxTemp_MouseUp;
picBoxTemp.Cursor = Cursors.Cross; picBoxTemp.Cursor = Cursors.Cross;
btnDrawRegion.ToolTipText = "绘制模式已启用,点击图片区域绘制矩形框(点击关闭)"; btnDrawRegion.ToolTipText = "绘制模式已启用,点击图片区域绘制矩形框(点击关闭)";
@@ -81,9 +78,6 @@ namespace JoyD.Windows.CS
else else
{ {
// 禁用绘制模式 // 禁用绘制模式
picBoxTemp.MouseDown -= PicBoxTemp_MouseDown;
picBoxTemp.MouseMove -= PicBoxTemp_MouseMove;
picBoxTemp.MouseUp -= PicBoxTemp_MouseUp;
picBoxTemp.Cursor = Cursors.Default; picBoxTemp.Cursor = Cursors.Default;
_currentRectangle = Rectangle.Empty; _currentRectangle = Rectangle.Empty;
btnDrawRegion.ToolTipText = "绘制温度检测区域(点击开启/关闭)"; btnDrawRegion.ToolTipText = "绘制温度检测区域(点击开启/关闭)";