fix:触摸墨迹选中问题
This commit is contained in:
@@ -627,36 +627,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
var touchPoint = e.GetTouchPoint(null);
|
var touchPoint = e.GetTouchPoint(null);
|
||||||
centerPoint = touchPoint.Position;
|
centerPoint = touchPoint.Position;
|
||||||
lastTouchPointOnGridInkCanvasCover = e.GetTouchPoint(inkCanvas).Position;
|
lastTouchPointOnGridInkCanvasCover = touchPoint.Position;
|
||||||
|
|
||||||
// 检查是否有选中的墨迹
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
// 只有在选择框边界内才允许拖动
|
|
||||||
// 触摸拖动状态已通过TouchMove事件处理
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 触摸在选择框外,取消选择
|
|
||||||
inkCanvas.Select(new StrokeCollection());
|
|
||||||
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SetCurrentToolMode(InkCanvasEditingMode.Select);
|
|
||||||
inkCanvas.Select(new StrokeCollection());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,33 +635,25 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
dec.Remove(e.TouchDevice.Id);
|
dec.Remove(e.TouchDevice.Id);
|
||||||
if (dec.Count >= 1) return;
|
if (dec.Count >= 1) return;
|
||||||
|
|
||||||
// 重置触摸状态
|
|
||||||
lastTouchPointOnGridInkCanvasCover = new Point(0, 0);
|
|
||||||
isProgramChangeStrokeSelection = false;
|
isProgramChangeStrokeSelection = false;
|
||||||
|
|
||||||
// 检查是否有点击(没有移动)
|
var touchUpPoint = e.GetTouchPoint(null).Position;
|
||||||
var currentTouchPoint = e.GetTouchPoint(null).Position;
|
if (lastTouchPointOnGridInkCanvasCover == touchUpPoint)
|
||||||
if (Math.Abs(currentTouchPoint.X - centerPoint.X) < 5 && Math.Abs(currentTouchPoint.Y - centerPoint.Y) < 5)
|
|
||||||
{
|
{
|
||||||
// 点击在选择框内,保持选择状态
|
var touchPointInCanvas = e.GetTouchPoint(inkCanvas).Position;
|
||||||
if (inkCanvas.GetSelectedStrokes().Count > 0)
|
var selectionBounds = inkCanvas.GetSelectionBounds();
|
||||||
{
|
|
||||||
var selectionBounds = inkCanvas.GetSelectionBounds();
|
|
||||||
if (currentTouchPoint.X >= selectionBounds.Left &&
|
|
||||||
currentTouchPoint.X <= selectionBounds.Right &&
|
|
||||||
currentTouchPoint.Y >= selectionBounds.Top &&
|
|
||||||
currentTouchPoint.Y <= selectionBounds.Bottom)
|
|
||||||
{
|
|
||||||
// 点击在选择框内,保持选择
|
|
||||||
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
|
|
||||||
StrokesSelectionClone = new StrokeCollection();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 点击在选择框外,取消选择
|
if (!(touchPointInCanvas.X < selectionBounds.Left) &&
|
||||||
|
!(touchPointInCanvas.Y < selectionBounds.Top) &&
|
||||||
|
!(touchPointInCanvas.X > selectionBounds.Right) &&
|
||||||
|
!(touchPointInCanvas.Y > selectionBounds.Bottom))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isProgramChangeStrokeSelection = true;
|
||||||
inkCanvas.Select(new StrokeCollection());
|
inkCanvas.Select(new StrokeCollection());
|
||||||
|
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
||||||
|
isProgramChangeStrokeSelection = false;
|
||||||
StrokesSelectionClone = new StrokeCollection();
|
StrokesSelectionClone = new StrokeCollection();
|
||||||
}
|
}
|
||||||
else if (inkCanvas.GetSelectedStrokes().Count == 0)
|
else if (inkCanvas.GetSelectedStrokes().Count == 0)
|
||||||
@@ -703,7 +666,6 @@ namespace Ink_Canvas
|
|||||||
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
|
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
|
||||||
StrokesSelectionClone = new StrokeCollection();
|
StrokesSelectionClone = new StrokeCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LassoSelect_Click(object sender, RoutedEventArgs e)
|
private void LassoSelect_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -224,29 +224,8 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint
|
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint
|
||||||
|| inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke) return;
|
|| inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke
|
||||||
|
|| inkCanvas.EditingMode == InkCanvasEditingMode.Select) 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)
|
if (!isHidingSubPanelsWhenInking)
|
||||||
{
|
{
|
||||||
@@ -562,26 +541,6 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
||||||
@@ -622,24 +581,6 @@ namespace Ink_Canvas
|
|||||||
var touchPoint = e.GetTouchPoint(inkCanvas);
|
var touchPoint = e.GetTouchPoint(inkCanvas);
|
||||||
centerPoint = touchPoint.Position;
|
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
|
//记录第一根手指点击时的 StrokeCollection
|
||||||
lastTouchDownStrokeCollection = inkCanvas.Strokes.Clone();
|
lastTouchDownStrokeCollection = inkCanvas.Strokes.Clone();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user