add:新设置
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
@@ -223,8 +224,29 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint
|
||||
|| inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke
|
||||
|| inkCanvas.EditingMode == InkCanvasEditingMode.Select) return;
|
||||
|| inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke) return;
|
||||
|
||||
// 处理选择模式下的触摸事件:检查是否有选中的墨迹,如果有,检查触摸点是否在选中区域外
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select)
|
||||
{
|
||||
if (inkCanvas.GetSelectedStrokes().Count > 0)
|
||||
{
|
||||
var touchPosition = e.GetTouchPoint(inkCanvas).Position;
|
||||
var selectionBounds = inkCanvas.GetSelectionBounds();
|
||||
|
||||
// 检查触摸位置是否在选择框边界外
|
||||
if (touchPosition.X < selectionBounds.Left ||
|
||||
touchPosition.X > selectionBounds.Right ||
|
||||
touchPosition.Y < selectionBounds.Top ||
|
||||
touchPosition.Y > selectionBounds.Bottom)
|
||||
{
|
||||
// 触摸在选择框外,取消选择
|
||||
inkCanvas.Select(new StrokeCollection());
|
||||
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isHidingSubPanelsWhenInking)
|
||||
{
|
||||
@@ -541,6 +563,25 @@ namespace Ink_Canvas
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select)
|
||||
{
|
||||
dec.Add(e.TouchDevice.Id);
|
||||
|
||||
// 检查是否有选中的墨迹,如果有,检查触摸点是否在选中区域外
|
||||
if (dec.Count == 1 && inkCanvas.GetSelectedStrokes().Count > 0)
|
||||
{
|
||||
var touchPosition = e.GetTouchPoint(inkCanvas).Position;
|
||||
var selectionBounds = inkCanvas.GetSelectionBounds();
|
||||
|
||||
// 检查触摸位置是否在选择框边界外
|
||||
if (touchPosition.X < selectionBounds.Left ||
|
||||
touchPosition.X > selectionBounds.Right ||
|
||||
touchPosition.Y < selectionBounds.Top ||
|
||||
touchPosition.Y > selectionBounds.Bottom)
|
||||
{
|
||||
// 触摸在选择框外,取消选择
|
||||
inkCanvas.Select(new StrokeCollection());
|
||||
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
||||
@@ -581,6 +622,24 @@ namespace Ink_Canvas
|
||||
var touchPoint = e.GetTouchPoint(inkCanvas);
|
||||
centerPoint = touchPoint.Position;
|
||||
|
||||
// 检查是否有选中的墨迹,如果有,检查触摸点是否在选中区域外
|
||||
if (inkCanvas.GetSelectedStrokes().Count > 0)
|
||||
{
|
||||
var touchPosition = touchPoint.Position;
|
||||
var selectionBounds = inkCanvas.GetSelectionBounds();
|
||||
|
||||
// 检查触摸位置是否在选择框边界外
|
||||
if (touchPosition.X < selectionBounds.Left ||
|
||||
touchPosition.X > selectionBounds.Right ||
|
||||
touchPosition.Y < selectionBounds.Top ||
|
||||
touchPosition.Y > selectionBounds.Bottom)
|
||||
{
|
||||
// 触摸在选择框外,取消选择
|
||||
inkCanvas.Select(new StrokeCollection());
|
||||
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
//记录第一根手指点击时的 StrokeCollection
|
||||
lastTouchDownStrokeCollection = inkCanvas.Strokes.Clone();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user