diff --git a/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml b/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml
index c811439e..2d424b75 100644
--- a/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml
+++ b/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml
@@ -18,14 +18,12 @@
+ Opacity="0.3" />
@@ -45,9 +43,8 @@
(_freehandPoints);
-
+
// 简化路径处理,不强制闭合
// 如果路径没有闭合,自动添加起始点
if (pathPoints.Count > 0)
@@ -301,13 +301,13 @@ namespace Ink_Canvas
// 优化路径:移除重复点和过于接近的点,提高路径质量
var optimizedPath = OptimizePath(pathPoints);
-
+
// 保存选择的路径
SelectedPath = optimizedPath;
// 计算边界矩形用于截图
var bounds = CalculatePathBounds(optimizedPath);
-
+
// 确保边界矩形有效
if (bounds.Width >= 0 && bounds.Height >= 0)
{
@@ -325,7 +325,7 @@ namespace Ink_Canvas
return;
}
}
-
+
// 如果自由绘制失败,清除路径并继续
_freehandPoints.Clear();
_freehandPolyline.Points.Clear();
@@ -363,7 +363,7 @@ namespace Ink_Canvas
_isMoving = true;
_lastMousePosition = e.GetPosition(this);
-
+
// 确定当前控制点类型
var ellipse = sender as Ellipse;
if (ellipse == TopLeftControl) _activeControlPoint = ControlPointType.TopLeft;
@@ -471,6 +471,10 @@ namespace Ink_Canvas
{
// 确保选择矩形在调整模式下可见
SelectionRectangle.Visibility = Visibility.Visible;
+ // 设置选择矩形的Z-index,确保它能够接收鼠标事件
+ WpfCanvas.SetZIndex(SelectionRectangle, 1001);
+ // 确保选择矩形能够接收鼠标事件
+ SelectionRectangle.IsHitTestVisible = true;
ControlPointsCanvas.Visibility = Visibility.Visible;
UpdateControlPointsPosition();
}
@@ -482,26 +486,26 @@ namespace Ink_Canvas
// 更新角控制点位置
WpfCanvas.SetLeft(TopLeftControl, rect.Left - 4);
WpfCanvas.SetTop(TopLeftControl, rect.Top - 4);
-
+
WpfCanvas.SetLeft(TopRightControl, rect.Right - 4);
WpfCanvas.SetTop(TopRightControl, rect.Top - 4);
-
+
WpfCanvas.SetLeft(BottomLeftControl, rect.Left - 4);
WpfCanvas.SetTop(BottomLeftControl, rect.Bottom - 4);
-
+
WpfCanvas.SetLeft(BottomRightControl, rect.Right - 4);
WpfCanvas.SetTop(BottomRightControl, rect.Bottom - 4);
// 更新边控制点位置
WpfCanvas.SetLeft(TopControl, rect.Left + rect.Width / 2 - 4);
WpfCanvas.SetTop(TopControl, rect.Top - 4);
-
+
WpfCanvas.SetLeft(BottomControl, rect.Left + rect.Width / 2 - 4);
WpfCanvas.SetTop(BottomControl, rect.Bottom - 4);
-
+
WpfCanvas.SetLeft(LeftControl, rect.Left - 4);
WpfCanvas.SetTop(LeftControl, rect.Top + rect.Height / 2 - 4);
-
+
WpfCanvas.SetLeft(RightControl, rect.Right - 4);
WpfCanvas.SetTop(RightControl, rect.Top + rect.Height / 2 - 4);
}
@@ -515,6 +519,12 @@ namespace Ink_Canvas
WpfCanvas.SetTop(SelectionRectangle, rect.Y);
SelectionRectangle.Width = rect.Width;
SelectionRectangle.Height = rect.Height;
+
+ // 在选择过程中,禁用选择矩形的鼠标事件,避免干扰选择操作
+ if (_isSelecting)
+ {
+ SelectionRectangle.IsHitTestVisible = false;
+ }
// 更新透明选择区域遮罩
UpdateTransparentSelectionMask(rect);
@@ -537,12 +547,12 @@ namespace Ink_Canvas
{
// 更新选择区域的几何体
SelectionClipGeometry.Rect = selectionRect;
-
+
// 显示透明遮罩,隐藏原始遮罩
TransparentSelectionMask.Visibility = Visibility.Visible;
OverlayRectangle.Visibility = Visibility.Collapsed;
}
- catch (Exception ex)
+ catch (Exception)
{
// 如果几何体操作失败,回退到原始遮罩
TransparentSelectionMask.Visibility = Visibility.Collapsed;
@@ -559,6 +569,13 @@ namespace Ink_Canvas
WpfCanvas.SetTop(SelectionRectangle, rect.Y);
SelectionRectangle.Width = rect.Width;
SelectionRectangle.Height = rect.Height;
+
+ // 确保选择矩形在调整模式下能够接收鼠标事件
+ if (_isAdjusting)
+ {
+ SelectionRectangle.IsHitTestVisible = true;
+ WpfCanvas.SetZIndex(SelectionRectangle, 1001);
+ }
// 更新透明选择区域遮罩
UpdateTransparentSelectionMask(rect);
@@ -595,7 +612,7 @@ namespace Ink_Canvas
{
return;
}
-
+
if (_isAdjusting)
{
// 转换为屏幕坐标,考虑DPI缩放
@@ -711,9 +728,6 @@ namespace Ink_Canvas
private void SelectionRectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
- // 添加调试信息
- System.Diagnostics.Debug.WriteLine($"SelectionRectangle_MouseLeftButtonDown: _isAdjusting={_isAdjusting}");
-
if (!_isAdjusting) return;
_isMoving = true;
@@ -723,8 +737,6 @@ namespace Ink_Canvas
// 捕获鼠标到选择矩形
SelectionRectangle.CaptureMouse();
e.Handled = true;
-
- System.Diagnostics.Debug.WriteLine("SelectionRectangle mouse capture started");
}
private void SelectionRectangle_MouseMove(object sender, MouseEventArgs e)
@@ -753,14 +765,10 @@ namespace Ink_Canvas
_lastMousePosition = currentPosition;
e.Handled = true;
-
- // 添加调试信息
- System.Diagnostics.Debug.WriteLine($"SelectionRectangle moving: delta=({delta.X}, {delta.Y}), newRect=({newRect.X}, {newRect.Y}, {newRect.Width}, {newRect.Height})");
}
- catch (Exception ex)
+ catch (Exception)
{
// 如果出现异常,停止移动
- System.Diagnostics.Debug.WriteLine($"SelectionRectangle move error: {ex.Message}");
_isMoving = false;
_activeControlPoint = ControlPointType.None;
SelectionRectangle.ReleaseMouseCapture();
@@ -785,29 +793,29 @@ namespace Ink_Canvas
_isAdjusting = false;
_isMoving = false;
_activeControlPoint = ControlPointType.None;
-
+
// 清除自由绘制的内容
_freehandPoints.Clear();
_freehandPolyline.Points.Clear();
_freehandPolyline.Visibility = Visibility.Collapsed;
-
+
// 清除矩形选择的内容
SelectionRectangle.Visibility = Visibility.Collapsed;
+ SelectionRectangle.IsHitTestVisible = false;
ControlPointsCanvas.Visibility = Visibility.Collapsed;
SizeInfoBorder.Visibility = Visibility.Collapsed;
SelectionPath.Visibility = Visibility.Collapsed;
AdjustModeHint.Visibility = Visibility.Collapsed;
-
+
// 重置遮罩
TransparentSelectionMask.Visibility = Visibility.Collapsed;
OverlayRectangle.Visibility = Visibility.Visible;
-
+
// 释放鼠标捕获
if (IsMouseCaptured)
{
ReleaseMouseCapture();
}
-<<<<<<< HEAD
// 释放选择矩形的鼠标捕获
if (SelectionRectangle.IsMouseCaptured)
@@ -815,9 +823,6 @@ namespace Ink_Canvas
SelectionRectangle.ReleaseMouseCapture();
}
-=======
-
->>>>>>> ff086e497c2dc751d72f3a6d72ce5d883b297672
// 重置选择区域
_currentSelection = new Rect();
SelectedArea = null;
diff --git a/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache b/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache
index e30091c8..4af914e2 100644
Binary files a/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache and b/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache differ