From 8c6507582370dc20328db887164d42eef36eae0b Mon Sep 17 00:00:00 2001 From: doudou0720 <98651603+doudou0720@users.noreply.github.com> Date: Sun, 15 Feb 2026 08:07:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(MW=5FSelectionGestures.cs):=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E9=80=89=E6=8B=A9=E6=A1=86=E5=92=8C=E6=89=8B=E6=9F=84?= =?UTF-8?q?=E7=9A=84=E6=89=A9=E5=B1=95=E5=81=8F=E7=A7=BB=E9=87=8F=20(#373)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> --- .../MainWindow_cs/MW_SelectionGestures.cs | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs b/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs index e0639030..b8b900a6 100644 --- a/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs +++ b/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs @@ -743,11 +743,14 @@ namespace Ink_Canvas var selectionBounds = inkCanvas.GetSelectionBounds(); - // 更新选择框 + // 向外扩展8像素 + double expandOffset = 8; + + // 更新选择框,向外扩展8像素 SelectionRectangle.Visibility = Visibility.Visible; - SelectionRectangle.Margin = new Thickness(selectionBounds.Left, selectionBounds.Top, 0, 0); - SelectionRectangle.Width = selectionBounds.Width; - SelectionRectangle.Height = selectionBounds.Height; + SelectionRectangle.Margin = new Thickness(selectionBounds.Left - expandOffset, selectionBounds.Top - expandOffset, 0, 0); + SelectionRectangle.Width = selectionBounds.Width + expandOffset * 2; + SelectionRectangle.Height = selectionBounds.Height + expandOffset * 2; // 更新选择点位置 UpdateSelectionHandles(selectionBounds); @@ -762,17 +765,17 @@ namespace Ink_Canvas private void UpdateSelectionHandles(Rect bounds) { - // 四个角选择点 - TopLeftHandle.Margin = new Thickness(bounds.Left - 4, bounds.Top - 4, 0, 0); - TopRightHandle.Margin = new Thickness(bounds.Right - 4, bounds.Top - 4, 0, 0); - BottomLeftHandle.Margin = new Thickness(bounds.Left - 4, bounds.Bottom - 4, 0, 0); - BottomRightHandle.Margin = new Thickness(bounds.Right - 4, bounds.Bottom - 4, 0, 0); + // 四个边选择点,向外扩展8像素 + TopHandle.Margin = new Thickness(bounds.Left + bounds.Width / 2 - 4, bounds.Top - 12, 0, 0); + BottomHandle.Margin = new Thickness(bounds.Left + bounds.Width / 2 - 4, bounds.Bottom + 4 , 0, 0); + LeftHandle.Margin = new Thickness(bounds.Left - 12 , bounds.Top + bounds.Height / 2 - 4, 0, 0); + RightHandle.Margin = new Thickness(bounds.Right + 4, bounds.Top + bounds.Height / 2 - 4, 0, 0); - // 四个边选择点 - TopHandle.Margin = new Thickness(bounds.Left + bounds.Width / 2 - 4, bounds.Top - 4, 0, 0); - BottomHandle.Margin = new Thickness(bounds.Left + bounds.Width / 2 - 4, bounds.Bottom - 4, 0, 0); - LeftHandle.Margin = new Thickness(bounds.Left - 4, bounds.Top + bounds.Height / 2 - 4, 0, 0); - RightHandle.Margin = new Thickness(bounds.Right - 4, bounds.Top + bounds.Height / 2 - 4, 0, 0); + // 四个角选择点,完全位于选择框外部 + TopLeftHandle.Margin = new Thickness(bounds.Left - 12, bounds.Top - 12, 0, 0); + TopRightHandle.Margin = new Thickness(bounds.Right + 4, bounds.Top - 12, 0, 0); + BottomLeftHandle.Margin = new Thickness(bounds.Left - 12, bounds.Bottom + 4, 0, 0); + BottomRightHandle.Margin = new Thickness(bounds.Right + 4, bounds.Bottom + 4, 0, 0); } private void SelectionHandle_MouseDown(object sender, MouseButtonEventArgs e)