fix:issue #217
This commit is contained in:
@@ -175,7 +175,6 @@ namespace Ink_Canvas
|
|||||||
lastIsInMultiTouchMode = true;
|
lastIsInMultiTouchMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修复:几何绘制模式下确保不切换到Ink模式,避免触摸轨迹被收集
|
|
||||||
if (drawingShapeMode != 0)
|
if (drawingShapeMode != 0)
|
||||||
{
|
{
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||||
@@ -490,16 +489,16 @@ namespace Ink_Canvas
|
|||||||
SetCursorBasedOnEditingMode(inkCanvas);
|
SetCursorBasedOnEditingMode(inkCanvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修复:几何绘制模式下完全禁止触摸轨迹收集
|
|
||||||
if (drawingShapeMode != 0)
|
if (drawingShapeMode != 0)
|
||||||
{
|
{
|
||||||
// 确保几何绘制模式下不切换到Ink模式,避免触摸轨迹被收集
|
// 确保几何绘制模式下不切换到Ink模式,避免触摸轨迹被收集
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||||
|
|
||||||
|
if (!isTouchDown) return;
|
||||||
|
|
||||||
if (isWaitUntilNextTouchDown && dec.Count > 1) return;
|
if (isWaitUntilNextTouchDown && dec.Count > 1) return;
|
||||||
if (dec.Count > 1)
|
if (dec.Count > 1)
|
||||||
{
|
{
|
||||||
// 修复:双曲线绘制时,多指触摸不应该删除第一笔的辅助线
|
|
||||||
if ((drawingShapeMode == 24 || drawingShapeMode == 25) && drawMultiStepShapeCurrentStep == 1)
|
if ((drawingShapeMode == 24 || drawingShapeMode == 25) && drawMultiStepShapeCurrentStep == 1)
|
||||||
{
|
{
|
||||||
// 第二笔绘制双曲线时,只删除第二笔的临时笔画,保留第一笔的辅助线
|
// 第二笔绘制双曲线时,只删除第二笔的临时笔画,保留第一笔的辅助线
|
||||||
@@ -524,7 +523,6 @@ namespace Ink_Canvas
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修复:双曲线绘制时,第二笔应该基于第一笔的起点,而不是触摸实时位置
|
|
||||||
Point touchPoint = e.GetTouchPoint(inkCanvas).Position;
|
Point touchPoint = e.GetTouchPoint(inkCanvas).Position;
|
||||||
if ((drawingShapeMode == 24 || drawingShapeMode == 25) && drawMultiStepShapeCurrentStep == 1)
|
if ((drawingShapeMode == 24 || drawingShapeMode == 25) && drawMultiStepShapeCurrentStep == 1)
|
||||||
{
|
{
|
||||||
@@ -1004,7 +1002,6 @@ namespace Ink_Canvas
|
|||||||
drawMultiStepShapeSpecialParameter3 = k;
|
drawMultiStepShapeSpecialParameter3 = k;
|
||||||
drawMultiStepShapeSpecialStrokeCollection = strokes;
|
drawMultiStepShapeSpecialStrokeCollection = strokes;
|
||||||
|
|
||||||
// 修复:第一笔绘制的辅助线应该立即显示在画布上
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
inkCanvas.Strokes.Remove(lastTempStrokeCollection);
|
inkCanvas.Strokes.Remove(lastTempStrokeCollection);
|
||||||
@@ -1097,7 +1094,6 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修复:双曲线绘制完成后,需要将第一笔的辅助线和第二笔的双曲线合并
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 删除第二笔的临时笔画
|
// 删除第二笔的临时笔画
|
||||||
@@ -1759,6 +1755,7 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bool isMouseDown;
|
private bool isMouseDown;
|
||||||
|
private bool isTouchDown;
|
||||||
|
|
||||||
private void inkCanvas_MouseDown(object sender, MouseButtonEventArgs e)
|
private void inkCanvas_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -2024,7 +2021,6 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
private bool NeedUpdateIniP()
|
private bool NeedUpdateIniP()
|
||||||
{
|
{
|
||||||
// 修复:双曲线绘制时,第二笔不应该更新起点,保持第一笔的起点
|
|
||||||
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
||||||
{
|
{
|
||||||
if (drawMultiStepShapeCurrentStep == 1)
|
if (drawMultiStepShapeCurrentStep == 1)
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ namespace Ink_Canvas
|
|||||||
private InkCanvasEditingMode lastInkCanvasEditingMode = InkCanvasEditingMode.Ink;
|
private InkCanvasEditingMode lastInkCanvasEditingMode = InkCanvasEditingMode.Ink;
|
||||||
private DateTime lastTouchDownTime = DateTime.MinValue;
|
private DateTime lastTouchDownTime = DateTime.MinValue;
|
||||||
private const double MULTI_TOUCH_DELAY_MS = 100;
|
private const double MULTI_TOUCH_DELAY_MS = 100;
|
||||||
private bool isInWritingMode = false;
|
|
||||||
private bool isMultiTouchTimerActive = false;
|
private bool isMultiTouchTimerActive = false;
|
||||||
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -244,11 +243,18 @@ namespace Ink_Canvas
|
|||||||
HideSubPanels(); // 书写时自动隐藏二级菜单
|
HideSubPanels(); // 书写时自动隐藏二级菜单
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修复:几何绘制模式下完全禁止触摸轨迹收集
|
|
||||||
if (drawingShapeMode != 0)
|
if (drawingShapeMode != 0)
|
||||||
{
|
{
|
||||||
// 确保几何绘制模式下不切换到Ink模式,避免触摸轨迹被收集
|
// 确保几何绘制模式下不切换到Ink模式,避免触摸轨迹被收集
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||||
|
|
||||||
|
isTouchDown = true;
|
||||||
|
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||||
|
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||||
|
|
||||||
|
// 设置起始点
|
||||||
|
if (NeedUpdateIniP()) iniP = e.GetTouchPoint(inkCanvas).Position;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +293,14 @@ namespace Ink_Canvas
|
|||||||
if (drawingShapeMode != 0)
|
if (drawingShapeMode != 0)
|
||||||
{
|
{
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||||
|
|
||||||
|
isTouchDown = true;
|
||||||
|
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||||
|
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||||
|
|
||||||
|
// 设置起始点
|
||||||
|
if (NeedUpdateIniP()) iniP = e.GetPosition(inkCanvas);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke)
|
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke)
|
||||||
@@ -335,6 +349,46 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
private async void MainWindow_StylusUp(object sender, StylusEventArgs e)
|
private async void MainWindow_StylusUp(object sender, StylusEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (drawingShapeMode != 0)
|
||||||
|
{
|
||||||
|
// 重置触摸状态
|
||||||
|
isTouchDown = false;
|
||||||
|
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||||
|
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||||
|
|
||||||
|
// 对于双曲线等需要多步绘制的图形,手写笔抬起时应该进入下一步
|
||||||
|
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
||||||
|
{
|
||||||
|
if (drawMultiStepShapeCurrentStep == 0)
|
||||||
|
{
|
||||||
|
// 第一笔完成,进入第二笔
|
||||||
|
drawMultiStepShapeCurrentStep = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 第二笔完成,完成绘制
|
||||||
|
var mouseArgs = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left)
|
||||||
|
{
|
||||||
|
RoutedEvent = MouseLeftButtonUpEvent,
|
||||||
|
Source = inkCanvas
|
||||||
|
};
|
||||||
|
inkCanvas_MouseUp(inkCanvas, mouseArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 其他单步绘制的图形,手写笔抬起时完成绘制
|
||||||
|
var mouseArgs = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left)
|
||||||
|
{
|
||||||
|
RoutedEvent = MouseLeftButtonUpEvent,
|
||||||
|
Source = inkCanvas
|
||||||
|
};
|
||||||
|
inkCanvas_MouseUp(inkCanvas, mouseArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var stroke = GetStrokeVisual(e.StylusDevice.Id).Stroke;
|
var stroke = GetStrokeVisual(e.StylusDevice.Id).Stroke;
|
||||||
@@ -383,6 +437,16 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (drawingShapeMode != 0)
|
||||||
|
{
|
||||||
|
if (isTouchDown)
|
||||||
|
{
|
||||||
|
Point stylusPoint = e.GetPosition(inkCanvas);
|
||||||
|
MouseTouchMove(stylusPoint);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (GetTouchDownPointsList(e.StylusDevice.Id) != InkCanvasEditingMode.None) return;
|
if (GetTouchDownPointsList(e.StylusDevice.Id) != InkCanvasEditingMode.None) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -472,11 +536,19 @@ namespace Ink_Canvas
|
|||||||
dec.Add(e.TouchDevice.Id);
|
dec.Add(e.TouchDevice.Id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 修复:几何绘制模式下完全禁止触摸轨迹收集
|
|
||||||
if (drawingShapeMode != 0)
|
if (drawingShapeMode != 0)
|
||||||
{
|
{
|
||||||
// 确保几何绘制模式下不切换到Ink模式,避免触摸轨迹被收集
|
// 确保几何绘制模式下不切换到Ink模式,避免触摸轨迹被收集
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||||
|
|
||||||
|
// 设置触摸状态,类似鼠标事件处理
|
||||||
|
isTouchDown = true;
|
||||||
|
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||||
|
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||||
|
|
||||||
|
// 设置起始点
|
||||||
|
if (NeedUpdateIniP()) iniP = e.GetTouchPoint(inkCanvas).Position;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
||||||
@@ -527,7 +599,6 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 修复:几何绘制模式下完全禁止触摸轨迹收集
|
|
||||||
if (drawingShapeMode != 0)
|
if (drawingShapeMode != 0)
|
||||||
{
|
{
|
||||||
// 确保几何绘制模式下不切换到Ink模式,避免触摸轨迹收集
|
// 确保几何绘制模式下不切换到Ink模式,避免触摸轨迹收集
|
||||||
@@ -538,7 +609,6 @@ namespace Ink_Canvas
|
|||||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||||
|
|
||||||
// 修复:几何绘制模式下,只记录几何绘制的起点,不记录触摸轨迹
|
|
||||||
if (dec.Count == 0)
|
if (dec.Count == 0)
|
||||||
{
|
{
|
||||||
var inkTouchPoint = e.GetTouchPoint(inkCanvas);
|
var inkTouchPoint = e.GetTouchPoint(inkCanvas);
|
||||||
@@ -776,9 +846,12 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile("Palm eraser state reset completed");
|
LogHelper.WriteLogToFile("Palm eraser state reset completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修复:几何绘制模式下,触摸抬手时应该正确处理,而不是简单模拟鼠标事件
|
|
||||||
if (drawingShapeMode != 0)
|
if (drawingShapeMode != 0)
|
||||||
{
|
{
|
||||||
|
isTouchDown = false;
|
||||||
|
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||||
|
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||||
|
|
||||||
// 对于双曲线等需要多步绘制的图形,触摸抬手时应该进入下一步
|
// 对于双曲线等需要多步绘制的图形,触摸抬手时应该进入下一步
|
||||||
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
||||||
{
|
{
|
||||||
@@ -836,8 +909,7 @@ namespace Ink_Canvas
|
|||||||
inkCanvas.EditingMode = lastInkCanvasEditingMode;
|
inkCanvas.EditingMode = lastInkCanvasEditingMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修复:确保手掌擦除后触摸事件能正常响应
|
if (isPalmEraserActive)
|
||||||
if (isPalmEraserActive)
|
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile("Palm eraser force recovery - all touch points cleared");
|
LogHelper.WriteLogToFile("Palm eraser force recovery - all touch points cleared");
|
||||||
|
|
||||||
@@ -923,7 +995,6 @@ namespace Ink_Canvas
|
|||||||
// 三指及以上禁止缩放
|
// 三指及以上禁止缩放
|
||||||
bool disableScale = dec.Count >= 3;
|
bool disableScale = dec.Count >= 3;
|
||||||
|
|
||||||
// 修复:允许单指拖动选中的墨迹,即使禁用了多指手势
|
|
||||||
if (isInMultiTouchMode) return;
|
if (isInMultiTouchMode) return;
|
||||||
|
|
||||||
if (dec.Count == 0 && (isSingleFingerDragMode || isInMultiTouchMode))
|
if (dec.Count == 0 && (isSingleFingerDragMode || isInMultiTouchMode))
|
||||||
@@ -1138,7 +1209,6 @@ namespace Ink_Canvas
|
|||||||
inkCanvas.StylusUp -= MainWindow_StylusUp;
|
inkCanvas.StylusUp -= MainWindow_StylusUp;
|
||||||
inkCanvas.TouchDown -= MainWindow_TouchDown;
|
inkCanvas.TouchDown -= MainWindow_TouchDown;
|
||||||
inkCanvas.TouchDown += Main_Grid_TouchDown;
|
inkCanvas.TouchDown += Main_Grid_TouchDown;
|
||||||
// 修复:几何绘制模式下不自动切换到Ink模式,避免触摸轨迹被收集
|
|
||||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint
|
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint
|
||||||
&& inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke
|
&& inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke
|
||||||
&& drawingShapeMode == 0)
|
&& drawingShapeMode == 0)
|
||||||
@@ -1171,7 +1241,6 @@ namespace Ink_Canvas
|
|||||||
inkCanvas.StylusUp += MainWindow_StylusUp;
|
inkCanvas.StylusUp += MainWindow_StylusUp;
|
||||||
inkCanvas.TouchDown += MainWindow_TouchDown;
|
inkCanvas.TouchDown += MainWindow_TouchDown;
|
||||||
inkCanvas.TouchDown -= Main_Grid_TouchDown;
|
inkCanvas.TouchDown -= Main_Grid_TouchDown;
|
||||||
// 修复:几何绘制模式下不自动切换到Ink模式,避免触摸轨迹被收集
|
|
||||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint
|
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint
|
||||||
&& inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke
|
&& inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke
|
||||||
&& drawingShapeMode == 0)
|
&& drawingShapeMode == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user