代码清理
This commit is contained in:
@@ -260,7 +260,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
// 只有在PPT放映模式下且页数有效时才显示翻页按钮
|
||||
if (StackPanelPPTControls.Visibility == Visibility.Visible &&
|
||||
if (StackPanelPPTControls.Visibility == Visibility.Visible &&
|
||||
BtnPPTSlideShowEnd.Visibility == Visibility.Visible &&
|
||||
PPTManager?.IsInSlideShow == true &&
|
||||
PPTManager?.SlidesCount > 0)
|
||||
@@ -288,17 +288,17 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 强制更新布局以确保ActualWidth正确
|
||||
ViewboxFloatingBar.UpdateLayout();
|
||||
|
||||
|
||||
// 等待一小段时间让布局完全更新
|
||||
Task.Delay(50);
|
||||
|
||||
|
||||
// 再次强制更新布局
|
||||
ViewboxFloatingBar.UpdateLayout();
|
||||
|
||||
|
||||
// 强制重新测量和排列
|
||||
ViewboxFloatingBar.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
ViewboxFloatingBar.Arrange(new Rect(ViewboxFloatingBar.DesiredSize));
|
||||
|
||||
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
ViewboxFloatingBarMarginAnimation(60);
|
||||
else
|
||||
@@ -314,7 +314,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 等待UI完全更新
|
||||
await Task.Delay(100);
|
||||
|
||||
|
||||
// 获取当前选中的模式并重新设置高光位置
|
||||
string selectedToolMode = GetCurrentSelectedMode();
|
||||
if (!string.IsNullOrEmpty(selectedToolMode))
|
||||
|
||||
@@ -750,7 +750,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
overlay.CaptureMouse();
|
||||
StartAdvancedEraserOperation(sender);
|
||||
|
||||
|
||||
// 处理单点擦除
|
||||
var position = e.GetPosition((UIElement)FindName("inkCanvas"));
|
||||
UpdateAdvancedEraserPosition(sender, position);
|
||||
@@ -791,7 +791,7 @@ namespace Ink_Canvas
|
||||
overlay.CaptureStylus();
|
||||
}
|
||||
StartAdvancedEraserOperation(sender);
|
||||
|
||||
|
||||
// 处理单点擦除
|
||||
var position = e.GetPosition((UIElement)FindName("inkCanvas"));
|
||||
UpdateAdvancedEraserPosition(sender, position);
|
||||
|
||||
@@ -674,7 +674,7 @@ namespace Ink_Canvas
|
||||
HideSubPanelsImmediately();
|
||||
|
||||
// 只有在PPT放映模式下且页数有效时才显示翻页按钮
|
||||
if (StackPanelPPTControls.Visibility == Visibility.Visible &&
|
||||
if (StackPanelPPTControls.Visibility == Visibility.Visible &&
|
||||
BtnPPTSlideShowEnd.Visibility == Visibility.Visible &&
|
||||
PPTManager?.IsInSlideShow == true &&
|
||||
PPTManager?.SlidesCount > 0)
|
||||
@@ -696,7 +696,7 @@ namespace Ink_Canvas
|
||||
RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
LogHelper.WriteLogToFile($"隐藏PPT翻页按钮 - 放映状态: {PPTManager?.IsInSlideShow}, 页数: {PPTManager?.SlidesCount}", LogHelper.LogType.Trace);
|
||||
}
|
||||
|
||||
|
||||
// 使用PPT UI管理器来正确更新翻页按钮显示状态,确保遵循用户设置
|
||||
if (_pptUIManager != null)
|
||||
{
|
||||
@@ -833,10 +833,10 @@ namespace Ink_Canvas
|
||||
if (sender == SymbolIconSelect && lastBorderMouseDownObject != SymbolIconSelect) return;
|
||||
|
||||
BtnSelect_Click(null, null);
|
||||
|
||||
|
||||
// 更新模式缓存
|
||||
UpdateCurrentToolMode("select");
|
||||
|
||||
|
||||
HideSubPanels("select");
|
||||
|
||||
}
|
||||
@@ -973,7 +973,7 @@ namespace Ink_Canvas
|
||||
|
||||
var randWindow = new RandWindow(Settings);
|
||||
randWindow.Show();
|
||||
|
||||
|
||||
// 使用延迟确保窗口完全显示后再强制置顶
|
||||
randWindow.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
@@ -982,10 +982,10 @@ namespace Ink_Canvas
|
||||
// 强制激活窗口
|
||||
randWindow.Activate();
|
||||
randWindow.Focus();
|
||||
|
||||
|
||||
// 设置置顶
|
||||
randWindow.Topmost = true;
|
||||
|
||||
|
||||
// 使用Win32 API强制置顶
|
||||
var hwnd = new WindowInteropHelper(randWindow).Handle;
|
||||
if (hwnd != IntPtr.Zero)
|
||||
@@ -1410,19 +1410,19 @@ namespace Ink_Canvas
|
||||
// 计算浮动栏位置,考虑快捷调色盘的显示状态
|
||||
// 使用更可靠的方法获取浮动栏宽度
|
||||
double baseWidth = ViewboxFloatingBar.ActualWidth;
|
||||
|
||||
|
||||
// 如果ActualWidth为0,尝试使用DesiredSize
|
||||
if (baseWidth <= 0)
|
||||
{
|
||||
baseWidth = ViewboxFloatingBar.DesiredSize.Width;
|
||||
}
|
||||
|
||||
|
||||
// 如果仍然为0,使用RenderSize
|
||||
if (baseWidth <= 0)
|
||||
{
|
||||
baseWidth = ViewboxFloatingBar.RenderSize.Width;
|
||||
}
|
||||
|
||||
|
||||
// 如果所有方法都失败,使用一个基于内容的估算值
|
||||
if (baseWidth <= 0)
|
||||
{
|
||||
@@ -1430,9 +1430,9 @@ namespace Ink_Canvas
|
||||
baseWidth = 200; // 最小宽度
|
||||
LogHelper.WriteLogToFile($"浮动栏宽度无法获取,使用估算值: {baseWidth}");
|
||||
}
|
||||
|
||||
|
||||
double floatingBarWidth = baseWidth * ViewboxFloatingBarScaleTransform.ScaleX;
|
||||
|
||||
|
||||
|
||||
// 如果快捷调色盘显示,确保有足够空间
|
||||
if ((QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible) ||
|
||||
@@ -1555,19 +1555,19 @@ namespace Ink_Canvas
|
||||
// 计算浮动栏位置,考虑快捷调色盘的显示状态
|
||||
// 使用更可靠的方法获取浮动栏宽度
|
||||
double baseWidth = ViewboxFloatingBar.ActualWidth;
|
||||
|
||||
|
||||
// 如果ActualWidth为0,尝试使用DesiredSize
|
||||
if (baseWidth <= 0)
|
||||
{
|
||||
baseWidth = ViewboxFloatingBar.DesiredSize.Width;
|
||||
}
|
||||
|
||||
|
||||
// 如果仍然为0,使用RenderSize
|
||||
if (baseWidth <= 0)
|
||||
{
|
||||
baseWidth = ViewboxFloatingBar.RenderSize.Width;
|
||||
}
|
||||
|
||||
|
||||
// 如果所有方法都失败,使用一个基于内容的估算值
|
||||
if (baseWidth <= 0)
|
||||
{
|
||||
@@ -1575,9 +1575,9 @@ namespace Ink_Canvas
|
||||
baseWidth = 200; // 最小宽度
|
||||
LogHelper.WriteLogToFile($"浮动栏宽度无法获取,使用估算值: {baseWidth}");
|
||||
}
|
||||
|
||||
|
||||
double floatingBarWidth = baseWidth * ViewboxFloatingBarScaleTransform.ScaleX;
|
||||
|
||||
|
||||
|
||||
// 如果快捷调色盘显示,确保有足够空间
|
||||
if ((QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible) ||
|
||||
@@ -1661,19 +1661,19 @@ namespace Ink_Canvas
|
||||
// 计算浮动栏位置,考虑快捷调色盘的显示状态
|
||||
// 使用更可靠的方法获取浮动栏宽度
|
||||
double baseWidth = ViewboxFloatingBar.ActualWidth;
|
||||
|
||||
|
||||
// 如果ActualWidth为0,尝试使用DesiredSize
|
||||
if (baseWidth <= 0)
|
||||
{
|
||||
baseWidth = ViewboxFloatingBar.DesiredSize.Width;
|
||||
}
|
||||
|
||||
|
||||
// 如果仍然为0,使用RenderSize
|
||||
if (baseWidth <= 0)
|
||||
{
|
||||
baseWidth = ViewboxFloatingBar.RenderSize.Width;
|
||||
}
|
||||
|
||||
|
||||
// 如果所有方法都失败,使用一个基于内容的估算值
|
||||
if (baseWidth <= 0)
|
||||
{
|
||||
@@ -1681,9 +1681,9 @@ namespace Ink_Canvas
|
||||
baseWidth = 200; // 最小宽度
|
||||
LogHelper.WriteLogToFile($"浮动栏宽度无法获取,使用估算值: {baseWidth}");
|
||||
}
|
||||
|
||||
|
||||
double floatingBarWidth = baseWidth * ViewboxFloatingBarScaleTransform.ScaleX;
|
||||
|
||||
|
||||
|
||||
// 如果快捷调色盘显示,确保有足够空间
|
||||
if ((QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible) ||
|
||||
@@ -1741,7 +1741,7 @@ namespace Ink_Canvas
|
||||
// 使用集中化的工具模式切换方法,确保快捷键状态正确更新
|
||||
// 鼠标模式下应该禁用快捷键以放行键盘操作
|
||||
SetCurrentToolMode(InkCanvasEditingMode.None);
|
||||
|
||||
|
||||
// 更新模式缓存,确保后续的模式检测正确
|
||||
UpdateCurrentToolMode("cursor");
|
||||
|
||||
@@ -1880,7 +1880,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 使用集中化的工具模式切换方法
|
||||
SetCurrentToolMode(InkCanvasEditingMode.Ink);
|
||||
|
||||
|
||||
// 更新模式缓存
|
||||
UpdateCurrentToolMode("pen");
|
||||
|
||||
@@ -1917,7 +1917,7 @@ namespace Ink_Canvas
|
||||
CheckEnableTwoFingerGestureBtnVisibility(true);
|
||||
// 使用集中化的工具模式切换方法
|
||||
SetCurrentToolMode(InkCanvasEditingMode.Ink);
|
||||
|
||||
|
||||
// 更新模式缓存
|
||||
UpdateCurrentToolMode("pen");
|
||||
|
||||
@@ -2042,7 +2042,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
// 使用集中化的工具模式切换方法
|
||||
SetCurrentToolMode(InkCanvasEditingMode.Ink);
|
||||
|
||||
|
||||
// 更新模式缓存
|
||||
UpdateCurrentToolMode("pen");
|
||||
|
||||
@@ -2106,10 +2106,10 @@ namespace Ink_Canvas
|
||||
// 使用新的高级橡皮擦系统
|
||||
// 使用集中化的工具模式切换方法
|
||||
SetCurrentToolMode(InkCanvasEditingMode.EraseByPoint);
|
||||
|
||||
|
||||
// 更新模式缓存
|
||||
UpdateCurrentToolMode("eraser");
|
||||
|
||||
|
||||
ApplyAdvancedEraserShape(); // 使用新的橡皮擦形状应用方法
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
HideSubPanels("eraser"); // 高亮橡皮按钮
|
||||
@@ -2150,10 +2150,10 @@ namespace Ink_Canvas
|
||||
// 使用新的高级橡皮擦系统
|
||||
// 使用集中化的工具模式切换方法
|
||||
SetCurrentToolMode(InkCanvasEditingMode.EraseByPoint);
|
||||
|
||||
|
||||
// 更新模式缓存
|
||||
UpdateCurrentToolMode("eraser");
|
||||
|
||||
|
||||
ApplyAdvancedEraserShape(); // 使用新的橡皮擦形状应用方法
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
HideSubPanels("eraser"); // 高亮橡皮按钮
|
||||
@@ -2192,10 +2192,10 @@ namespace Ink_Canvas
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(5, 5);
|
||||
// 使用集中化的工具模式切换方法
|
||||
SetCurrentToolMode(InkCanvasEditingMode.EraseByStroke);
|
||||
|
||||
|
||||
// 更新模式缓存
|
||||
UpdateCurrentToolMode("eraserByStrokes");
|
||||
|
||||
|
||||
drawingShapeMode = 0;
|
||||
|
||||
// 修复:切换到线擦时,保存当前的笔类型状态,而不是强制重置
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Ink_Canvas
|
||||
private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
// 只有在PPT放映模式下才响应鼠标滚轮翻页
|
||||
if (StackPanelPPTControls.Visibility != Visibility.Visible ||
|
||||
currentMode != 0 ||
|
||||
if (StackPanelPPTControls.Visibility != Visibility.Visible ||
|
||||
currentMode != 0 ||
|
||||
BtnPPTSlideShowEnd.Visibility != Visibility.Visible ||
|
||||
PPTManager?.IsInSlideShow != true) return;
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace Ink_Canvas
|
||||
private void Main_Grid_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
// 只有在PPT放映模式下才响应键盘翻页快捷键
|
||||
if (StackPanelPPTControls.Visibility != Visibility.Visible ||
|
||||
currentMode != 0 ||
|
||||
if (StackPanelPPTControls.Visibility != Visibility.Visible ||
|
||||
currentMode != 0 ||
|
||||
BtnPPTSlideShowEnd.Visibility != Visibility.Visible ||
|
||||
PPTManager?.IsInSlideShow != true) return;
|
||||
|
||||
|
||||
@@ -229,10 +229,10 @@ namespace Ink_Canvas
|
||||
|
||||
// 创建新的PowerPoint应用程序实例
|
||||
pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();
|
||||
|
||||
|
||||
// 设置为不可见,作为后台进程
|
||||
pptApplication.Visible = MsoTriState.msoFalse;
|
||||
|
||||
|
||||
// 设置应用程序属性
|
||||
pptApplication.WindowState = PpWindowState.ppWindowMinimized;
|
||||
|
||||
@@ -277,9 +277,9 @@ namespace Ink_Canvas
|
||||
|
||||
// 使用反射调用PPTManager的ConnectToPPT方法
|
||||
var pptManagerType = _pptManager.GetType();
|
||||
var connectMethod = pptManagerType.GetMethod("ConnectToPPT",
|
||||
var connectMethod = pptManagerType.GetMethod("ConnectToPPT",
|
||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
|
||||
|
||||
if (connectMethod != null)
|
||||
{
|
||||
connectMethod.Invoke(_pptManager, new object[] { app });
|
||||
@@ -288,9 +288,9 @@ namespace Ink_Canvas
|
||||
else
|
||||
{
|
||||
// 如果无法通过反射调用,尝试直接设置属性
|
||||
var pptApplicationProperty = pptManagerType.GetProperty("PPTApplication",
|
||||
var pptApplicationProperty = pptManagerType.GetProperty("PPTApplication",
|
||||
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
|
||||
|
||||
|
||||
if (pptApplicationProperty != null && pptApplicationProperty.CanWrite)
|
||||
{
|
||||
pptApplicationProperty.SetValue(_pptManager, app);
|
||||
@@ -317,7 +317,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
if (pptApplication == null) return false;
|
||||
if (!Marshal.IsComObject(pptApplication)) return false;
|
||||
|
||||
|
||||
// 尝试访问一个简单的属性来验证连接是否有效
|
||||
var _ = pptApplication.Name;
|
||||
return true;
|
||||
@@ -362,12 +362,12 @@ namespace Ink_Canvas
|
||||
|
||||
// 退出PowerPoint应用程序
|
||||
pptApplication.Quit();
|
||||
|
||||
|
||||
// 释放COM对象
|
||||
Marshal.ReleaseComObject(pptApplication);
|
||||
pptApplication = null;
|
||||
}
|
||||
|
||||
|
||||
LogHelper.WriteLogToFile("PowerPoint应用程序已关闭", LogHelper.LogType.Event);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -650,7 +650,7 @@ namespace Ink_Canvas
|
||||
// 在PPT模式下根据设置决定是否隐藏手势面板和手势按钮
|
||||
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
|
||||
|
||||
|
||||
// 根据设置决定是否在PPT放映模式下显示手势按钮
|
||||
if (Settings.PowerPointSettings.ShowGestureButtonInSlideShow)
|
||||
{
|
||||
@@ -1066,24 +1066,24 @@ namespace Ink_Canvas
|
||||
private void ToggleSwitchPowerPointEnhancement_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
|
||||
|
||||
Settings.PowerPointSettings.EnablePowerPointEnhancement = ToggleSwitchPowerPointEnhancement.IsOn;
|
||||
|
||||
|
||||
// 与WPS支持互斥
|
||||
if (Settings.PowerPointSettings.EnablePowerPointEnhancement)
|
||||
{
|
||||
Settings.PowerPointSettings.IsSupportWPS = false;
|
||||
ToggleSwitchSupportWPS.IsOn = false;
|
||||
|
||||
|
||||
// 更新PPT管理器的WPS支持设置
|
||||
if (_pptManager != null)
|
||||
{
|
||||
_pptManager.IsSupportWPS = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SaveSettingsToFile();
|
||||
|
||||
|
||||
// 启动或停止PowerPoint进程守护
|
||||
if (Settings.PowerPointSettings.EnablePowerPointEnhancement)
|
||||
{
|
||||
@@ -1100,7 +1100,7 @@ namespace Ink_Canvas
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.PowerPointSettings.IsSupportWPS = ToggleSwitchSupportWPS.IsOn;
|
||||
|
||||
|
||||
// 与PowerPoint联动增强互斥
|
||||
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -8,7 +9,6 @@ using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Ink_Canvas
|
||||
@@ -259,7 +259,7 @@ namespace Ink_Canvas
|
||||
private bool isStrokeDragging = false;
|
||||
private Point strokeDragStartPoint;
|
||||
private StrokeCollection StrokesSelectionClone = new StrokeCollection();
|
||||
|
||||
|
||||
// 选择框和选择点相关变量
|
||||
private bool isResizing = false;
|
||||
private string currentResizeHandle = "";
|
||||
@@ -269,18 +269,18 @@ namespace Ink_Canvas
|
||||
private void GridInkCanvasSelectionCover_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
isGridInkCanvasSelectionCoverMouseDown = true;
|
||||
|
||||
|
||||
// 检查是否有选中的墨迹
|
||||
if (inkCanvas.GetSelectedStrokes().Count > 0)
|
||||
{
|
||||
// 获取鼠标点击位置
|
||||
var clickPoint = e.GetPosition(inkCanvas);
|
||||
var selectionBounds = inkCanvas.GetSelectionBounds();
|
||||
|
||||
|
||||
// 检查点击位置是否在选择框边界内
|
||||
if (clickPoint.X >= selectionBounds.Left &&
|
||||
clickPoint.X <= selectionBounds.Right &&
|
||||
clickPoint.Y >= selectionBounds.Top &&
|
||||
if (clickPoint.X >= selectionBounds.Left &&
|
||||
clickPoint.X <= selectionBounds.Right &&
|
||||
clickPoint.Y >= selectionBounds.Top &&
|
||||
clickPoint.Y <= selectionBounds.Bottom)
|
||||
{
|
||||
// 只有在选择框边界内才允许拖动
|
||||
@@ -301,27 +301,27 @@ namespace Ink_Canvas
|
||||
private void GridInkCanvasSelectionCover_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!isGridInkCanvasSelectionCoverMouseDown) return;
|
||||
|
||||
|
||||
// 如果正在拖动墨迹,执行拖动操作
|
||||
if (isStrokeDragging && GridInkCanvasSelectionCover.IsMouseCaptured)
|
||||
{
|
||||
var currentPoint = e.GetPosition(inkCanvas);
|
||||
var delta = currentPoint - strokeDragStartPoint;
|
||||
|
||||
|
||||
// 创建变换矩阵
|
||||
var matrix = new Matrix();
|
||||
matrix.Translate(delta.X, delta.Y);
|
||||
|
||||
|
||||
// 对选中的墨迹应用变换
|
||||
var selectedStrokes = inkCanvas.GetSelectedStrokes();
|
||||
foreach (var stroke in selectedStrokes)
|
||||
{
|
||||
stroke.Transform(matrix, false);
|
||||
}
|
||||
|
||||
|
||||
// 更新选中栏位置
|
||||
updateBorderStrokeSelectionControlLocation();
|
||||
|
||||
|
||||
// 更新起始点
|
||||
strokeDragStartPoint = currentPoint;
|
||||
}
|
||||
@@ -335,7 +335,7 @@ namespace Ink_Canvas
|
||||
private void GridInkCanvasSelectionCover_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (!isGridInkCanvasSelectionCoverMouseDown) return;
|
||||
|
||||
|
||||
// 结束墨迹拖动
|
||||
if (isStrokeDragging)
|
||||
{
|
||||
@@ -343,9 +343,9 @@ namespace Ink_Canvas
|
||||
GridInkCanvasSelectionCover.ReleaseMouseCapture();
|
||||
GridInkCanvasSelectionCover.Cursor = Cursors.Arrow;
|
||||
}
|
||||
|
||||
|
||||
isGridInkCanvasSelectionCoverMouseDown = false;
|
||||
|
||||
|
||||
// 只有在没有选中墨迹时才隐藏选中栏
|
||||
if (inkCanvas.GetSelectedStrokes().Count == 0)
|
||||
{
|
||||
@@ -404,7 +404,7 @@ namespace Ink_Canvas
|
||||
BorderImageSelectionControl.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 显示墨迹选择栏和选择框
|
||||
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
|
||||
BorderStrokeSelectionClone.Background = Brushes.Transparent;
|
||||
@@ -524,7 +524,7 @@ namespace Ink_Canvas
|
||||
strokes = StrokesSelectionClone;
|
||||
else if (Settings.Gesture.IsEnableTwoFingerRotationOnSelection)
|
||||
m.RotateAt(rotate, center.X, center.Y); // 旋转
|
||||
|
||||
|
||||
// 应用变换到选中的墨迹
|
||||
foreach (var stroke in strokes)
|
||||
{
|
||||
@@ -554,29 +554,29 @@ namespace Ink_Canvas
|
||||
if (inkCanvas.GetSelectedStrokes().Count > 0 && dec.Count == 1)
|
||||
{
|
||||
var currentTouchPoint = e.GetTouchPoint(inkCanvas).Position;
|
||||
|
||||
|
||||
// 检查是否有有效的起始触摸点
|
||||
if (lastTouchPointOnGridInkCanvasCover != new Point(0, 0))
|
||||
{
|
||||
var delta = currentTouchPoint - lastTouchPointOnGridInkCanvasCover;
|
||||
|
||||
|
||||
// 只有当移动距离足够大时才进行拖动(避免微小移动造成的抖动)
|
||||
if (Math.Abs(delta.X) > 1 || Math.Abs(delta.Y) > 1)
|
||||
{
|
||||
// 创建变换矩阵
|
||||
var matrix = new Matrix();
|
||||
matrix.Translate(delta.X, delta.Y);
|
||||
|
||||
|
||||
// 对选中的墨迹应用变换
|
||||
var selectedStrokes = inkCanvas.GetSelectedStrokes();
|
||||
foreach (var stroke in selectedStrokes)
|
||||
{
|
||||
stroke.Transform(matrix, false);
|
||||
}
|
||||
|
||||
|
||||
// 更新选中栏位置
|
||||
updateBorderStrokeSelectionControlLocation();
|
||||
|
||||
|
||||
// 更新最后触摸点
|
||||
lastTouchPointOnGridInkCanvasCover = currentTouchPoint;
|
||||
}
|
||||
@@ -590,29 +590,29 @@ namespace Ink_Canvas
|
||||
if (inkCanvas.GetSelectedStrokes().Count > 0 && dec.Count == 1)
|
||||
{
|
||||
var currentTouchPoint = e.GetTouchPoint(inkCanvas).Position;
|
||||
|
||||
|
||||
// 检查是否有有效的起始触摸点
|
||||
if (lastTouchPointOnGridInkCanvasCover != new Point(0, 0))
|
||||
{
|
||||
var delta = currentTouchPoint - lastTouchPointOnGridInkCanvasCover;
|
||||
|
||||
|
||||
// 只有当移动距离足够大时才进行拖动(避免微小移动造成的抖动)
|
||||
if (Math.Abs(delta.X) > 1 || Math.Abs(delta.Y) > 1)
|
||||
{
|
||||
// 创建变换矩阵
|
||||
var matrix = new Matrix();
|
||||
matrix.Translate(delta.X, delta.Y);
|
||||
|
||||
|
||||
// 对选中的墨迹应用变换
|
||||
var selectedStrokes = inkCanvas.GetSelectedStrokes();
|
||||
foreach (var stroke in selectedStrokes)
|
||||
{
|
||||
stroke.Transform(matrix, false);
|
||||
}
|
||||
|
||||
|
||||
// 更新选中栏位置
|
||||
updateBorderStrokeSelectionControlLocation();
|
||||
|
||||
|
||||
// 更新最后触摸点
|
||||
lastTouchPointOnGridInkCanvasCover = currentTouchPoint;
|
||||
}
|
||||
@@ -638,15 +638,15 @@ namespace Ink_Canvas
|
||||
// 获取触摸点位置
|
||||
var touchPosition = e.GetTouchPoint(inkCanvas).Position;
|
||||
var selectionBounds = inkCanvas.GetSelectionBounds();
|
||||
|
||||
|
||||
// 检查触摸位置是否在选择框边界内
|
||||
if (touchPosition.X >= selectionBounds.Left &&
|
||||
touchPosition.X <= selectionBounds.Right &&
|
||||
touchPosition.Y >= selectionBounds.Top &&
|
||||
if (touchPosition.X >= selectionBounds.Left &&
|
||||
touchPosition.X <= selectionBounds.Right &&
|
||||
touchPosition.Y >= selectionBounds.Top &&
|
||||
touchPosition.Y <= selectionBounds.Bottom)
|
||||
{
|
||||
// 只有在选择框边界内才允许拖动
|
||||
// 触摸拖动状态已通过TouchMove事件处理
|
||||
// 只有在选择框边界内才允许拖动
|
||||
// 触摸拖动状态已通过TouchMove事件处理
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -681,11 +681,11 @@ namespace Ink_Canvas
|
||||
{
|
||||
dec.Remove(e.TouchDevice.Id);
|
||||
if (dec.Count >= 1) return;
|
||||
|
||||
|
||||
// 重置触摸状态
|
||||
lastTouchPointOnGridInkCanvasCover = new Point(0, 0);
|
||||
isProgramChangeStrokeSelection = false;
|
||||
|
||||
|
||||
// 检查是否有点击(没有移动)
|
||||
var currentTouchPoint = e.GetTouchPoint(null).Position;
|
||||
if (Math.Abs(currentTouchPoint.X - centerPoint.X) < 5 && Math.Abs(currentTouchPoint.Y - centerPoint.Y) < 5)
|
||||
@@ -694,9 +694,9 @@ namespace Ink_Canvas
|
||||
if (inkCanvas.GetSelectedStrokes().Count > 0)
|
||||
{
|
||||
var selectionBounds = inkCanvas.GetSelectionBounds();
|
||||
if (currentTouchPoint.X >= selectionBounds.Left &&
|
||||
currentTouchPoint.X <= selectionBounds.Right &&
|
||||
currentTouchPoint.Y >= selectionBounds.Top &&
|
||||
if (currentTouchPoint.X >= selectionBounds.Left &&
|
||||
currentTouchPoint.X <= selectionBounds.Right &&
|
||||
currentTouchPoint.Y >= selectionBounds.Top &&
|
||||
currentTouchPoint.Y <= selectionBounds.Bottom)
|
||||
{
|
||||
// 点击在选择框内,保持选择
|
||||
@@ -705,7 +705,7 @@ namespace Ink_Canvas
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 点击在选择框外,取消选择
|
||||
inkCanvas.Select(new StrokeCollection());
|
||||
StrokesSelectionClone = new StrokeCollection();
|
||||
@@ -720,7 +720,7 @@ namespace Ink_Canvas
|
||||
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
|
||||
StrokesSelectionClone = new StrokeCollection();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void LassoSelect_Click(object sender, RoutedEventArgs e)
|
||||
@@ -799,7 +799,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
var selectionBounds = inkCanvas.GetSelectionBounds();
|
||||
|
||||
|
||||
// 更新选择框
|
||||
SelectionRectangle.Visibility = Visibility.Visible;
|
||||
SelectionRectangle.Margin = new Thickness(selectionBounds.Left, selectionBounds.Top, 0, 0);
|
||||
@@ -853,10 +853,10 @@ namespace Ink_Canvas
|
||||
var delta = new Point(currentPoint.X - resizeStartPoint.X, currentPoint.Y - resizeStartPoint.Y);
|
||||
|
||||
var newBounds = CalculateNewBounds(originalSelectionBounds, delta, currentResizeHandle);
|
||||
|
||||
|
||||
// 应用新的边界到选中的墨迹
|
||||
ApplyBoundsToStrokes(newBounds);
|
||||
|
||||
|
||||
// 更新选择框显示
|
||||
UpdateSelectionDisplay();
|
||||
}
|
||||
@@ -934,11 +934,11 @@ namespace Ink_Canvas
|
||||
if (selectedStrokes.Count == 0) return;
|
||||
|
||||
var originalBounds = inkCanvas.GetSelectionBounds();
|
||||
|
||||
|
||||
// 计算缩放比例
|
||||
var scaleX = newBounds.Width / originalBounds.Width;
|
||||
var scaleY = newBounds.Height / originalBounds.Height;
|
||||
|
||||
|
||||
// 计算平移量
|
||||
var translateX = newBounds.X - originalBounds.X;
|
||||
var translateY = newBounds.Y - originalBounds.Y;
|
||||
|
||||
@@ -197,23 +197,23 @@ namespace Ink_Canvas
|
||||
val > 0.5 && val < 1.25 ? val : val <= 0.5 ? 0.5 : val >= 1.25 ? 1.25 : 1;
|
||||
ViewboxFloatingBarScaleTransform.ScaleY =
|
||||
val > 0.5 && val < 1.25 ? val : val <= 0.5 ? 0.5 : val >= 1.25 ? 1.25 : 1;
|
||||
|
||||
|
||||
// 等待UI更新后再重新计算浮动栏位置,确保居中计算准确
|
||||
Dispatcher.BeginInvoke(new Action(async () =>
|
||||
{
|
||||
// 强制更新布局以确保ActualWidth正确
|
||||
ViewboxFloatingBar.UpdateLayout();
|
||||
|
||||
|
||||
// 等待一小段时间让布局完全更新
|
||||
await Task.Delay(100);
|
||||
|
||||
|
||||
// 再次强制更新布局
|
||||
ViewboxFloatingBar.UpdateLayout();
|
||||
|
||||
|
||||
// 强制重新测量和排列
|
||||
ViewboxFloatingBar.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
ViewboxFloatingBar.Arrange(new Rect(ViewboxFloatingBar.DesiredSize));
|
||||
|
||||
|
||||
// auto align - 新增:只在屏幕模式下重新计算浮动栏位置
|
||||
if (currentMode == 0)
|
||||
{
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace Ink_Canvas
|
||||
_taskbar.Visibility = Settings.Appearance.EnableTrayIcon ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
ViewboxFloatingBar.Opacity = Settings.Appearance.ViewboxFloatingBarOpacityValue;
|
||||
|
||||
|
||||
// 初始化浮动栏透明度滑块值
|
||||
ViewboxFloatingBarOpacityValueSlider.Value = Settings.Appearance.ViewboxFloatingBarOpacityValue;
|
||||
ViewboxFloatingBarOpacityInPPTValueSlider.Value = Settings.Appearance.ViewboxFloatingBarOpacityInPPTValue;
|
||||
|
||||
@@ -107,10 +107,10 @@ namespace Ink_Canvas
|
||||
else if (sender == ImageDrawArrow || sender == BoardImageDrawArrow)
|
||||
drawingShapeMode = 2;
|
||||
else if (sender == ImageDrawParallelLine || sender == BoardImageDrawParallelLine) drawingShapeMode = 15;
|
||||
|
||||
|
||||
// 更新模式缓存
|
||||
UpdateCurrentToolMode("shape");
|
||||
|
||||
|
||||
isLongPressSelected = true;
|
||||
if (isSingleFingerDragMode) BtnFingerDragMode_Click(BtnFingerDragMode, null);
|
||||
}
|
||||
|
||||
@@ -127,15 +127,15 @@ namespace Ink_Canvas
|
||||
{
|
||||
DateTime localTime = DateTime.Now;
|
||||
DateTime displayTime = localTime; // 默认使用本地时间
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
DateTime networkTime = await GetNetworkTimeAsync();
|
||||
|
||||
|
||||
// 计算时间差
|
||||
TimeSpan timeDifference = networkTime - localTime;
|
||||
double timeDifferenceMinutes = Math.Abs(timeDifference.TotalMinutes);
|
||||
|
||||
|
||||
// 如果网络时间与本地时间相差不超过1分钟,则使用本地时间
|
||||
// 否则使用网络时间
|
||||
displayTime = timeDifferenceMinutes <= 1.0 ? localTime : networkTime;
|
||||
@@ -145,7 +145,7 @@ namespace Ink_Canvas
|
||||
// 网络时间获取失败时,使用本地时间
|
||||
displayTime = localTime;
|
||||
}
|
||||
|
||||
|
||||
// 只更新时间,日期由原有逻辑定时更新即可
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
@@ -313,7 +313,7 @@ namespace Ink_Canvas
|
||||
var windowTitle = ForegroundWindowInfo.WindowTitle();
|
||||
var windowRect = ForegroundWindowInfo.WindowRect();
|
||||
var windowProcessName = ForegroundWindowInfo.ProcessName();
|
||||
|
||||
|
||||
// 检测希沃白板五的批注面板
|
||||
// 希沃白板五的批注面板通常具有以下特征:
|
||||
// 1. 窗口标题为空或包含特定关键词
|
||||
@@ -323,32 +323,32 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 检测希沃白板五的批注工具栏
|
||||
// 批注工具栏通常高度在50-200像素之间,宽度在200-800像素之间
|
||||
if (windowRect.Height >= 50 && windowRect.Height <= 200 &&
|
||||
if (windowRect.Height >= 50 && windowRect.Height <= 200 &&
|
||||
windowRect.Width >= 200 && windowRect.Width <= 800)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// 检测希沃白板五的二级菜单面板
|
||||
// 二级菜单面板通常高度在100-400像素之间,宽度在150-400像素之间
|
||||
if (windowRect.Height >= 100 && windowRect.Height <= 400 &&
|
||||
if (windowRect.Height >= 100 && windowRect.Height <= 400 &&
|
||||
windowRect.Width >= 150 && windowRect.Width <= 400)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 检测鸿合软件的批注面板
|
||||
if (windowProcessName == "HiteCamera" || windowProcessName == "HiteTouchPro" || windowProcessName == "HiteLightBoard")
|
||||
{
|
||||
// 鸿合软件的批注面板特征
|
||||
if (windowRect.Height >= 50 && windowRect.Height <= 300 &&
|
||||
if (windowRect.Height >= 50 && windowRect.Height <= 300 &&
|
||||
windowRect.Width >= 200 && windowRect.Width <= 600)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 原有的检测逻辑(保持向后兼容)
|
||||
return windowTitle.Length == 0 && windowRect.Height < 500;
|
||||
}
|
||||
|
||||
@@ -503,7 +503,7 @@ namespace Ink_Canvas
|
||||
|
||||
// 计算触摸面积(使用设备提供的Size)
|
||||
double touchArea = size.Width * size.Height;
|
||||
|
||||
|
||||
// 计算宽高比(使用Bounds确保准确性)
|
||||
double aspectRatio = Math.Min(bounds.Width, bounds.Height) / Math.Max(bounds.Width, bounds.Height);
|
||||
|
||||
@@ -511,7 +511,7 @@ namespace Ink_Canvas
|
||||
bool isLargeTouch = touchArea >= palmAreaThreshold;
|
||||
bool isPalmLikeShape = aspectRatio >= aspectRatioThreshold;
|
||||
bool hasMultipleTouchPoints = dec.Count >= minTouchPoints;
|
||||
|
||||
|
||||
// 新增:额外的判定条件提高准确性
|
||||
bool isReasonableSize = size.Width >= 20 && size.Height >= 20 && size.Width <= 200 && size.Height <= 200; // 合理的触摸尺寸范围
|
||||
bool isNotTooElongated = aspectRatio >= 0.2; // 避免过于细长的触摸(可能是手指)
|
||||
@@ -614,7 +614,7 @@ namespace Ink_Canvas
|
||||
if (isPalmEraserActive && palmEraserTouchIds.Count == 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"Palm eraser recovery triggered - Touch points remaining: {palmEraserTouchIds.Count}, dec.Count: {dec.Count}");
|
||||
|
||||
|
||||
// 恢复高光状态
|
||||
drawingAttributes.IsHighlighter = palmEraserLastIsHighlighter;
|
||||
|
||||
@@ -778,10 +778,10 @@ namespace Ink_Canvas
|
||||
if (isPalmEraserActive)
|
||||
{
|
||||
LogHelper.WriteLogToFile("Palm eraser force recovery - all touch points cleared");
|
||||
|
||||
|
||||
// 恢复高光状态
|
||||
drawingAttributes.IsHighlighter = palmEraserLastIsHighlighter;
|
||||
|
||||
|
||||
// 恢复编辑模式
|
||||
try
|
||||
{
|
||||
@@ -807,7 +807,7 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile($"Palm eraser force recovery failed: {ex.Message}, forcing to Ink mode", LogHelper.LogType.Error);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||
}
|
||||
|
||||
|
||||
// 如果手掌擦还在激活状态但触摸点已清空,强制重置状态
|
||||
isPalmEraserActive = false;
|
||||
palmEraserTouchDownHandled = false;
|
||||
@@ -817,10 +817,10 @@ namespace Ink_Canvas
|
||||
|
||||
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||
|
||||
|
||||
// 停止恢复定时器
|
||||
StopPalmEraserRecoveryTimer();
|
||||
|
||||
|
||||
LogHelper.WriteLogToFile("Palm eraser force recovery completed");
|
||||
}
|
||||
}
|
||||
@@ -865,33 +865,33 @@ namespace Ink_Canvas
|
||||
return;
|
||||
// 三指及以上禁止缩放
|
||||
bool disableScale = dec.Count >= 3;
|
||||
|
||||
|
||||
// 修复:允许单指拖动选中的墨迹,即使禁用了多指手势
|
||||
if (isInMultiTouchMode) return;
|
||||
|
||||
|
||||
// 如果是单指拖动选中的墨迹,允许处理
|
||||
if (dec.Count == 1 && inkCanvas.GetSelectedStrokes().Count > 0)
|
||||
{
|
||||
var md = e.DeltaManipulation;
|
||||
var trans = md.Translation; // 获得位移矢量
|
||||
|
||||
|
||||
if (trans.X != 0 || trans.Y != 0)
|
||||
{
|
||||
var m = new Matrix();
|
||||
m.Translate(trans.X, trans.Y); // 移动
|
||||
|
||||
|
||||
var strokes = inkCanvas.GetSelectedStrokes();
|
||||
foreach (var stroke in strokes)
|
||||
{
|
||||
stroke.Transform(m, false);
|
||||
}
|
||||
|
||||
|
||||
// 更新选择框位置
|
||||
updateBorderStrokeSelectionControlLocation();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!Settings.Gesture.IsEnableTwoFingerGesture) return;
|
||||
if ((dec.Count >= 2 && (Settings.PowerPointSettings.IsEnableTwoFingerGestureInPresentationMode ||
|
||||
StackPanelPPTControls.Visibility != Visibility.Visible ||
|
||||
|
||||
Reference in New Issue
Block a user