修改鼠标移动事件逻辑,实现多个重叠区域时选择索引号最大的区域进行半透明填充
This commit is contained in:
@@ -149,5 +149,5 @@
|
||||
3. 图像合并机制 :在Paint事件中先绘制叠加层,再绘制临时矩形。
|
||||
4. 保存的矩形框位置和大小信息应该是相对于图像的,而不是相对于控件的。
|
||||
5. 当btnDrawRegion按下后,处于绘制状态, btnSelectColor才显示出来
|
||||
6. 当就绪状态时,鼠标移到区域内,该区域内填充半透明色,当有多个重叠时,只填充索引最大的区域
|
||||
6. 当就绪状态时,鼠标移到区域内,该区域内填充半透明色,当有多个重叠时,填充索引号最大的区域
|
||||
7. 当鼠标在半透明区域内单击时,该区域填充半透明色,且显示八个句柄,表示选中该区域。
|
||||
@@ -142,6 +142,7 @@
|
||||
this.ClientSize = new System.Drawing.Size(649, 450);
|
||||
this.Controls.Add(this.splitContainer);
|
||||
this.Name = "Setting";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "检测配置";
|
||||
this.splitContainer.Panel1.ResumeLayout(false);
|
||||
this.splitContainer.Panel2.ResumeLayout(false);
|
||||
|
||||
@@ -189,14 +189,15 @@ namespace JoyD.Windows.CS
|
||||
// 将鼠标坐标转换为图像坐标
|
||||
Point imagePoint = ControlPointToImagePoint(e.Location);
|
||||
|
||||
// 检查鼠标是否在某个区域内
|
||||
// 检查鼠标是否在某个区域内,选择索引号最大的区域
|
||||
int newHoveredRegionIndex = -1;
|
||||
int maxIndex = -1;
|
||||
foreach (RegionInfo region in _drawnRectangles)
|
||||
{
|
||||
if (region.ImageRectangle.Contains(imagePoint))
|
||||
if (region.ImageRectangle.Contains(imagePoint) && region.Index > maxIndex)
|
||||
{
|
||||
maxIndex = region.Index;
|
||||
newHoveredRegionIndex = region.Index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user