修改检测区功能Bug
This commit is contained in:
@@ -89,6 +89,7 @@ namespace JoyD.Windows.CS
|
|||||||
private bool _isAdjustingDetectionZone = false; // 是否正在调整检测区
|
private bool _isAdjustingDetectionZone = false; // 是否正在调整检测区
|
||||||
private ResizeHandle _currentDetectionZoneHandle = ResizeHandle.None; // 当前检测区调整句柄
|
private ResizeHandle _currentDetectionZoneHandle = ResizeHandle.None; // 当前检测区调整句柄
|
||||||
private Point _detectionZoneStartPoint; // 检测区调整开始点
|
private Point _detectionZoneStartPoint; // 检测区调整开始点
|
||||||
|
private Rectangle _originalDetectionZoneRect; // 检测区调整开始时的原始矩形
|
||||||
|
|
||||||
// 定时器字段
|
// 定时器字段
|
||||||
private readonly Timer _timer;
|
private readonly Timer _timer;
|
||||||
@@ -1022,6 +1023,8 @@ namespace JoyD.Windows.CS
|
|||||||
// 显示修改检测区按钮和颜色选择按钮
|
// 显示修改检测区按钮和颜色选择按钮
|
||||||
btnModifyDetectionZone.Visible = true;
|
btnModifyDetectionZone.Visible = true;
|
||||||
btnSelectColor.Visible = true;
|
btnSelectColor.Visible = true;
|
||||||
|
// 更新颜色选择按钮图标,确保显示检测区的颜色
|
||||||
|
UpdateColorButtonIcon();
|
||||||
|
|
||||||
// 更新_selectedColor为检测区的颜色,并更新按钮图标
|
// 更新_selectedColor为检测区的颜色,并更新按钮图标
|
||||||
_selectedColor = _tempDetectionZone.Color;
|
_selectedColor = _tempDetectionZone.Color;
|
||||||
@@ -1115,6 +1118,8 @@ namespace JoyD.Windows.CS
|
|||||||
// 开始调整检测区大小
|
// 开始调整检测区大小
|
||||||
_isAdjustingDetectionZone = true;
|
_isAdjustingDetectionZone = true;
|
||||||
_detectionZoneStartPoint = e.Location;
|
_detectionZoneStartPoint = e.Location;
|
||||||
|
// 保存原始矩形
|
||||||
|
_originalDetectionZoneRect = controlDetectionRect;
|
||||||
}
|
}
|
||||||
else if (controlDetectionRect.Contains(e.Location))
|
else if (controlDetectionRect.Contains(e.Location))
|
||||||
{
|
{
|
||||||
@@ -2222,8 +2227,8 @@ namespace JoyD.Windows.CS
|
|||||||
|
|
||||||
if (_currentDetectionZoneHandle != ResizeHandle.None)
|
if (_currentDetectionZoneHandle != ResizeHandle.None)
|
||||||
{
|
{
|
||||||
// 调整检测区大小
|
// 调整检测区大小,使用原始矩形作为参考
|
||||||
Rectangle newRect = CalculateNewRectangle(controlDetectionRect, _detectionZoneStartPoint, e.Location, _currentDetectionZoneHandle);
|
Rectangle newRect = CalculateNewRectangle(_originalDetectionZoneRect, _detectionZoneStartPoint, e.Location, _currentDetectionZoneHandle);
|
||||||
|
|
||||||
// 确保检测区有最小尺寸
|
// 确保检测区有最小尺寸
|
||||||
if (newRect.Width > 20 && newRect.Height > 20)
|
if (newRect.Width > 20 && newRect.Height > 20)
|
||||||
@@ -4304,7 +4309,7 @@ namespace JoyD.Windows.CS
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理右键点击 - 退出选中状态
|
// 处理右键点击 - 退出选中状态
|
||||||
if (!_isDrawingMode && e.Button == MouseButtons.Right && _selectedRegionIndex != -1)
|
if (!_isDrawingMode && !_isModifyingDetectionZone && e.Button == MouseButtons.Right && _selectedRegionIndex != -1)
|
||||||
{
|
{
|
||||||
// 取消选中状态
|
// 取消选中状态
|
||||||
_selectedRegionIndex = -1;
|
_selectedRegionIndex = -1;
|
||||||
@@ -4320,7 +4325,7 @@ namespace JoyD.Windows.CS
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 仅在就绪状态(非绘制模式)下处理左键点击
|
// 仅在就绪状态(非绘制模式)下处理左键点击
|
||||||
if (!_isDrawingMode && e.Button == MouseButtons.Left && picBoxTemp.Image != null && !_isResizing)
|
if (!_isDrawingMode && !_isModifyingDetectionZone && e.Button == MouseButtons.Left && picBoxTemp.Image != null && !_isResizing)
|
||||||
{
|
{
|
||||||
// 将控件坐标转换为图像坐标
|
// 将控件坐标转换为图像坐标
|
||||||
Point imagePoint = ControlPointToImagePoint(e.Location);
|
Point imagePoint = ControlPointToImagePoint(e.Location);
|
||||||
|
|||||||
Reference in New Issue
Block a user