1145141919810
代码清理
This commit is contained in:
@@ -18,14 +18,14 @@ namespace Ink_Canvas
|
||||
var resourcesToRemove = new List<ResourceDictionary>();
|
||||
foreach (var dict in Application.Current.Resources.MergedDictionaries)
|
||||
{
|
||||
if (dict.Source != null &&
|
||||
(dict.Source.ToString().Contains("Light.xaml") ||
|
||||
if (dict.Source != null &&
|
||||
(dict.Source.ToString().Contains("Light.xaml") ||
|
||||
dict.Source.ToString().Contains("Dark.xaml")))
|
||||
{
|
||||
resourcesToRemove.Add(dict);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (var dict in resourcesToRemove)
|
||||
{
|
||||
Application.Current.Resources.MergedDictionaries.Remove(dict);
|
||||
@@ -36,7 +36,7 @@ namespace Ink_Canvas
|
||||
var rd1 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/Styles/Light.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
||||
|
||||
|
||||
// 在主题资源之后添加其他资源
|
||||
var rd2 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||
@@ -53,10 +53,10 @@ namespace Ink_Canvas
|
||||
ThemeManager.SetRequestedTheme(window, ElementTheme.Light);
|
||||
|
||||
InitializeFloatBarForegroundColor();
|
||||
|
||||
|
||||
// 刷新快速面板图标
|
||||
RefreshQuickPanelIcons();
|
||||
|
||||
|
||||
// 强制刷新UI
|
||||
window.InvalidateVisual();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
var rd1 = new ResourceDictionary { Source = new Uri("Resources/Styles/Dark.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
||||
|
||||
|
||||
// 在主题资源之后添加其他资源
|
||||
var rd2 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||
@@ -81,10 +81,10 @@ namespace Ink_Canvas
|
||||
ThemeManager.SetRequestedTheme(window, ElementTheme.Dark);
|
||||
|
||||
InitializeFloatBarForegroundColor();
|
||||
|
||||
|
||||
// 刷新快速面板图标
|
||||
RefreshQuickPanelIcons();
|
||||
|
||||
|
||||
// 强制刷新UI
|
||||
window.InvalidateVisual();
|
||||
}
|
||||
@@ -98,17 +98,17 @@ namespace Ink_Canvas
|
||||
try
|
||||
{
|
||||
FloatBarForegroundColor = (Color)Application.Current.FindResource("FloatBarForegroundColor");
|
||||
|
||||
|
||||
// 强制刷新浮动工具栏按钮颜色
|
||||
RefreshFloatingBarButtonColors();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// 如果无法从资源中加载,使用默认颜色
|
||||
FloatBarForegroundColor = Color.FromRgb(0, 0, 0);
|
||||
FloatBarForegroundColor = Color.FromRgb(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 刷新快速面板图标
|
||||
/// </summary>
|
||||
@@ -147,7 +147,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 选中状态的颜色(蓝底)
|
||||
var selectedColor = Color.FromRgb(30, 58, 138);
|
||||
|
||||
|
||||
// 根据当前模式设置按钮颜色
|
||||
switch (_currentToolMode)
|
||||
{
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace Ink_Canvas
|
||||
private StrokeCollection lastTouchDownStrokeCollection = new StrokeCollection();
|
||||
private int CurrentWhiteboardIndex = 1;
|
||||
private int WhiteboardTotalCount = 1;
|
||||
private TimeMachineHistory[][] TimeMachineHistories = new TimeMachineHistory[101][];
|
||||
private bool[] savedMultiTouchModeStates = new bool[101];
|
||||
private TimeMachineHistory[][] TimeMachineHistories = new TimeMachineHistory[101][];
|
||||
private bool[] savedMultiTouchModeStates = new bool[101];
|
||||
|
||||
// 保存每页白板图片信息
|
||||
private void SaveStrokes(bool isBackupMain = false)
|
||||
@@ -197,20 +197,20 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 恢复多指书写模式
|
||||
EnterMultiTouchModeIfNeeded();
|
||||
|
||||
|
||||
// 更新UI状态
|
||||
if (ToggleSwitchEnableMultiTouchMode != null)
|
||||
{
|
||||
ToggleSwitchEnableMultiTouchMode.IsOn = true;
|
||||
}
|
||||
|
||||
|
||||
LogHelper.WriteLogToFile($"恢复多指书写模式状态 - 页面索引: {pageIndex}", LogHelper.LogType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 确保多指书写模式关闭
|
||||
ExitMultiTouchModeIfNeeded();
|
||||
|
||||
|
||||
// 更新UI状态
|
||||
if (ToggleSwitchEnableMultiTouchMode != null)
|
||||
{
|
||||
|
||||
@@ -1585,7 +1585,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
isResizingImage = true;
|
||||
imageResizeStartPoint = e.GetPosition(inkCanvas);
|
||||
|
||||
|
||||
// 确定是哪个控制点
|
||||
activeResizeHandle = ellipse.Name;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
@@ -46,29 +45,35 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
// 绑定事件处理
|
||||
canvas.StylusDown += ((o, args) => {
|
||||
canvas.StylusDown += ((o, args) =>
|
||||
{
|
||||
e.Handled = true;
|
||||
if (args.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) canvas.CaptureStylus();
|
||||
EraserOverlay_PointerDown(sender);
|
||||
});
|
||||
canvas.StylusUp += ((o, args) => {
|
||||
canvas.StylusUp += ((o, args) =>
|
||||
{
|
||||
e.Handled = true;
|
||||
if (args.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) canvas.ReleaseStylusCapture();
|
||||
EraserOverlay_PointerUp(sender);
|
||||
});
|
||||
canvas.StylusMove += ((o, args) => {
|
||||
canvas.StylusMove += ((o, args) =>
|
||||
{
|
||||
e.Handled = true;
|
||||
EraserOverlay_PointerMove(sender, args.GetPosition(inkCanvas));
|
||||
});
|
||||
canvas.MouseDown += ((o, args) => {
|
||||
canvas.MouseDown += ((o, args) =>
|
||||
{
|
||||
canvas.CaptureMouse();
|
||||
EraserOverlay_PointerDown(sender);
|
||||
});
|
||||
canvas.MouseUp += ((o, args) => {
|
||||
canvas.MouseUp += ((o, args) =>
|
||||
{
|
||||
canvas.ReleaseMouseCapture();
|
||||
EraserOverlay_PointerUp(sender);
|
||||
});
|
||||
canvas.MouseMove += ((o, args) => {
|
||||
canvas.MouseMove += ((o, args) =>
|
||||
{
|
||||
EraserOverlay_PointerMove(sender, args.GetPosition(inkCanvas));
|
||||
});
|
||||
|
||||
@@ -86,7 +91,7 @@ namespace Ink_Canvas
|
||||
// 根据橡皮擦形状选择对应的图像资源
|
||||
string resourceKey = isEraserCircleShape ? "EllipseEraserImageSource" : "RectangleEraserImageSource";
|
||||
var imageSource = TryFindResource(resourceKey) as DrawingImage;
|
||||
|
||||
|
||||
if (imageSource != null)
|
||||
{
|
||||
eraserFeedback.Source = imageSource;
|
||||
@@ -301,8 +306,8 @@ namespace Ink_Canvas
|
||||
if (isEraserCircleShape)
|
||||
{
|
||||
eraserWidth = k * 90; // 圆形橡皮擦
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
eraserWidth = k * 90 * 0.6; // 矩形橡皮擦宽度
|
||||
}
|
||||
|
||||
@@ -86,19 +86,19 @@ namespace Ink_Canvas
|
||||
// 根据主题设置颜色
|
||||
if (Settings.Appearance.Theme == 1) // 深色主题
|
||||
{
|
||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
}
|
||||
else // 浅色主题或跟随系统
|
||||
{
|
||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
}
|
||||
BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.DisabledGestureIcon);
|
||||
BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z");
|
||||
@@ -111,10 +111,10 @@ namespace Ink_Canvas
|
||||
// 多指书写模式禁用时,根据实际手势功能状态显示
|
||||
TwoFingerGestureSimpleStackPanel.Opacity = 1;
|
||||
TwoFingerGestureSimpleStackPanel.IsHitTestVisible = true;
|
||||
|
||||
|
||||
// 检查是否有任何手势功能启用
|
||||
bool hasGestureEnabled = Settings.Gesture.IsEnableTwoFingerGesture;
|
||||
|
||||
|
||||
if (hasGestureEnabled)
|
||||
{
|
||||
EnableTwoFingerGestureBtn.Source =
|
||||
@@ -136,19 +136,19 @@ namespace Ink_Canvas
|
||||
// 根据主题设置颜色
|
||||
if (Settings.Appearance.Theme == 1) // 深色主题
|
||||
{
|
||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
}
|
||||
else // 浅色主题或跟随系统
|
||||
{
|
||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
}
|
||||
BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.DisabledGestureIcon);
|
||||
BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z");
|
||||
@@ -443,33 +443,33 @@ namespace Ink_Canvas
|
||||
// 根据主题设置颜色
|
||||
if (Settings.Appearance.Theme == 1) // 深色主题
|
||||
{
|
||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardSelect.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardEraser.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardSelectGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardEraserGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardSelectLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardEraserLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardSelect.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
BoardEraser.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardSelect.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardEraser.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardSelectGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardEraserGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardSelectLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardEraserLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardSelect.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
BoardEraser.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
}
|
||||
else // 浅色主题或跟随系统
|
||||
{
|
||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardSelect.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardEraser.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardSelectGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardEraserGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardSelectLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardEraserLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardSelect.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
BoardEraser.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardSelect.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardEraser.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardSelectGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardEraserGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardSelectLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardEraserLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardSelect.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
BoardEraser.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
}
|
||||
|
||||
HideFloatingBarHighlight();
|
||||
@@ -537,17 +537,17 @@ namespace Ink_Canvas
|
||||
// 根据主题设置颜色
|
||||
if (Settings.Appearance.Theme == 1) // 深色主题
|
||||
{
|
||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
}
|
||||
else // 浅色主题或跟随系统
|
||||
{
|
||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
}
|
||||
|
||||
SetFloatingBarHighlightPosition("cursor");
|
||||
@@ -1357,12 +1357,12 @@ namespace Ink_Canvas
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||
inkCanvas.IsHitTestVisible = true;
|
||||
inkCanvas.IsManipulationEnabled = true;
|
||||
|
||||
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||
}
|
||||
|
||||
|
||||
ResetTouchStates();
|
||||
});
|
||||
}).Start();
|
||||
@@ -1388,12 +1388,12 @@ namespace Ink_Canvas
|
||||
isStopInkReplay = true;
|
||||
inkCanvas.IsHitTestVisible = true;
|
||||
inkCanvas.IsManipulationEnabled = true;
|
||||
|
||||
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||
}
|
||||
|
||||
|
||||
ResetTouchStates();
|
||||
}
|
||||
}
|
||||
@@ -1975,7 +1975,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
// 禁用高级橡皮擦系统
|
||||
DisableEraserOverlay();
|
||||
DisableEraserOverlay();
|
||||
|
||||
ExitMultiTouchModeIfNeeded();
|
||||
|
||||
@@ -2222,7 +2222,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
// 启用新的高级橡皮擦系统
|
||||
EnableEraserOverlay();
|
||||
EnableEraserOverlay();
|
||||
|
||||
// 使用新的高级橡皮擦系统
|
||||
// 使用集中化的工具模式切换方法
|
||||
@@ -2234,7 +2234,7 @@ namespace Ink_Canvas
|
||||
ApplyAdvancedEraserShape(); // 使用新的橡皮擦形状应用方法
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
HideSubPanels("eraser"); // 高亮橡皮按钮
|
||||
Trace.WriteLine($"Eraser: Eraser button clicked, current size: {eraserWidth}, circle: {isEraserCircleShape}");
|
||||
Trace.WriteLine($"Eraser: Eraser button clicked, current size: {eraserWidth}, circle: {isEraserCircleShape}");
|
||||
|
||||
if (isAlreadyEraser)
|
||||
{
|
||||
@@ -2263,7 +2263,7 @@ namespace Ink_Canvas
|
||||
drawingShapeMode = 0;
|
||||
|
||||
// 启用新的高级橡皮擦系统
|
||||
EnableEraserOverlay();
|
||||
EnableEraserOverlay();
|
||||
|
||||
// 使用新的高级橡皮擦系统
|
||||
// 使用集中化的工具模式切换方法
|
||||
@@ -2578,7 +2578,7 @@ namespace Ink_Canvas
|
||||
private void SelectIcon_MouseUp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 禁用高级橡皮擦系统
|
||||
DisableEraserOverlay();
|
||||
DisableEraserOverlay();
|
||||
|
||||
forceEraser = true;
|
||||
drawingShapeMode = 0;
|
||||
@@ -2687,12 +2687,12 @@ namespace Ink_Canvas
|
||||
if (!userChangedNoFocusModeInSettings && wasNoFocusModeBeforeSettings)
|
||||
{
|
||||
Settings.Advanced.IsNoFocusMode = true;
|
||||
ToggleSwitchNoFocusMode.IsOn = true;
|
||||
ToggleSwitchNoFocusMode.IsOn = true;
|
||||
ApplyNoFocusMode();
|
||||
}
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
|
||||
App.IsAppExitByUser = true;
|
||||
// 不设置 CloseIsFromButton = true,让它也经过确认流程
|
||||
Close();
|
||||
@@ -2706,12 +2706,12 @@ namespace Ink_Canvas
|
||||
if (!userChangedNoFocusModeInSettings && wasNoFocusModeBeforeSettings)
|
||||
{
|
||||
Settings.Advanced.IsNoFocusMode = true;
|
||||
ToggleSwitchNoFocusMode.IsOn = true;
|
||||
ToggleSwitchNoFocusMode.IsOn = true;
|
||||
ApplyNoFocusMode();
|
||||
}
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
|
||||
Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m");
|
||||
App.IsAppExitByUser = true;
|
||||
// 不设置 CloseIsFromButton = true,让它也经过确认流程
|
||||
@@ -2847,7 +2847,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 先关闭多指书写模式
|
||||
ToggleSwitchEnableMultiTouchMode.IsOn = false;
|
||||
|
||||
|
||||
// 使用Dispatcher.BeginInvoke确保UI更新完成后再重新开启
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
@@ -2873,7 +2873,7 @@ namespace Ink_Canvas
|
||||
|
||||
ResetTouchStates();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重置所有触摸相关状态,
|
||||
/// </summary>
|
||||
@@ -2883,8 +2883,8 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 清空触摸点计数器
|
||||
dec.Clear();
|
||||
|
||||
|
||||
|
||||
|
||||
// 重置单指拖动模式状态
|
||||
if (isSingleFingerDragMode)
|
||||
{
|
||||
@@ -2894,25 +2894,25 @@ namespace Ink_Canvas
|
||||
BtnFingerDragMode.Content = "单指\n拖动";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 重置手掌擦状态
|
||||
if (isPalmEraserActive)
|
||||
{
|
||||
isPalmEraserActive = false;
|
||||
}
|
||||
|
||||
|
||||
// 确保触摸事件能正常响应
|
||||
inkCanvas.IsHitTestVisible = true;
|
||||
inkCanvas.IsManipulationEnabled = true;
|
||||
|
||||
|
||||
// 释放所有触摸捕获
|
||||
inkCanvas.ReleaseAllTouchCaptures();
|
||||
|
||||
|
||||
// 恢复UI元素的触摸响应
|
||||
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -3007,7 +3007,7 @@ namespace Ink_Canvas
|
||||
// 使用异步延迟,等待浮动栏展开动画完成后再收纳
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(700);
|
||||
await Task.Delay(700);
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
FoldFloatingBar_MouseUp(new object(), null);
|
||||
|
||||
@@ -18,17 +18,17 @@ namespace Ink_Canvas
|
||||
try
|
||||
{
|
||||
_floatingWindowInterceptorManager = new FloatingWindowInterceptorManager();
|
||||
|
||||
|
||||
// 订阅事件
|
||||
_floatingWindowInterceptorManager.WindowIntercepted += OnFloatingWindowIntercepted;
|
||||
_floatingWindowInterceptorManager.WindowRestored += OnFloatingWindowRestored;
|
||||
|
||||
|
||||
// 初始化拦截器
|
||||
_floatingWindowInterceptorManager.Initialize(Settings.Automation.FloatingWindowInterceptor);
|
||||
|
||||
|
||||
// 加载UI状态
|
||||
LoadFloatingWindowInterceptorUI();
|
||||
|
||||
|
||||
LogHelper.WriteLogToFile("悬浮窗拦截管理器初始化完成", LogHelper.LogType.Event);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -48,7 +48,7 @@ namespace Ink_Canvas
|
||||
|
||||
// 设置主开关状态
|
||||
ToggleSwitchFloatingWindowInterceptorEnabled.IsOn = Settings.Automation.FloatingWindowInterceptor.IsEnabled;
|
||||
|
||||
|
||||
// 设置各个拦截规则的状态
|
||||
foreach (var kvp in Settings.Automation.FloatingWindowInterceptor.InterceptRules)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace Ink_Canvas
|
||||
toggle.IsOn = kvp.Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 更新UI可见性
|
||||
UpdateFloatingWindowInterceptorUI();
|
||||
}
|
||||
@@ -78,16 +78,16 @@ namespace Ink_Canvas
|
||||
{
|
||||
var isEnabled = Settings.Automation.FloatingWindowInterceptor.IsEnabled;
|
||||
FloatingWindowInterceptorGrid.Visibility = isEnabled ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
|
||||
// 计算启用的规则数量
|
||||
var enabledRulesCount = Settings.Automation.FloatingWindowInterceptor.InterceptRules.Where(kvp => kvp.Value).Count();
|
||||
var totalRulesCount = Settings.Automation.FloatingWindowInterceptor.InterceptRules.Count;
|
||||
|
||||
|
||||
// 更新状态文本
|
||||
if (_floatingWindowInterceptorManager != null)
|
||||
{
|
||||
var stats = _floatingWindowInterceptorManager.GetStatistics();
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = stats.IsRunning
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = stats.IsRunning
|
||||
? $"拦截器运行中 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则"
|
||||
: $"拦截器未启动 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则";
|
||||
}
|
||||
@@ -150,11 +150,11 @@ namespace Ink_Canvas
|
||||
private void ToggleSwitchFloatingWindowInterceptorEnabled_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
Settings.Automation.FloatingWindowInterceptor.IsEnabled = ToggleSwitchFloatingWindowInterceptorEnabled.IsOn;
|
||||
|
||||
|
||||
if (_floatingWindowInterceptorManager != null)
|
||||
{
|
||||
if (Settings.Automation.FloatingWindowInterceptor.IsEnabled)
|
||||
@@ -166,7 +166,7 @@ namespace Ink_Canvas
|
||||
_floatingWindowInterceptorManager.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UpdateFloatingWindowInterceptorUI();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
@@ -304,7 +304,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
_floatingWindowInterceptorManager.SetInterceptRule(type, enabled);
|
||||
}
|
||||
|
||||
|
||||
// 更新设置
|
||||
var ruleName = type.ToString();
|
||||
if (Settings.Automation.FloatingWindowInterceptor.InterceptRules.ContainsKey(ruleName))
|
||||
@@ -342,10 +342,10 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 更新UI显示
|
||||
UpdateFloatingWindowInterceptorUI();
|
||||
|
||||
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace Ink_Canvas
|
||||
|
||||
// 将Bitmap转换为WPF BitmapSource
|
||||
var bitmapSource = ConvertBitmapToBitmapSource(bitmap);
|
||||
|
||||
|
||||
if (bitmapSource == null)
|
||||
{
|
||||
ShowNotification("转换截图失败");
|
||||
@@ -649,7 +649,7 @@ namespace Ink_Canvas
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"转换位图失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
|
||||
|
||||
// 尝试使用备用方法:内存流转换
|
||||
try
|
||||
{
|
||||
@@ -658,7 +658,7 @@ namespace Ink_Canvas
|
||||
catch (Exception fallbackEx)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"备用转换方法也失败: {fallbackEx.Message}", LogHelper.LogType.Error);
|
||||
|
||||
|
||||
// 最后尝试:使用最简单的转换方法
|
||||
try
|
||||
{
|
||||
@@ -723,18 +723,18 @@ namespace Ink_Canvas
|
||||
|
||||
// 使用最基础的方法:直接保存为PNG然后加载
|
||||
var tempFile = Path.GetTempFileName() + ".png";
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
bitmap.Save(tempFile, ImageFormat.Png);
|
||||
|
||||
|
||||
var bitmapImage = new BitmapImage();
|
||||
bitmapImage.BeginInit();
|
||||
bitmapImage.UriSource = new Uri(tempFile);
|
||||
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmapImage.EndInit();
|
||||
bitmapImage.Freeze();
|
||||
|
||||
|
||||
return bitmapImage;
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -89,11 +89,11 @@ namespace Ink_Canvas
|
||||
// PowerPoint应用程序守护相关字段
|
||||
private DispatcherTimer _powerPointProcessMonitorTimer;
|
||||
private const int ProcessMonitorInterval = 1000; // 应用程序监控间隔(毫秒)
|
||||
|
||||
|
||||
// 上次播放位置相关字段
|
||||
private int _lastPlaybackPage = 0;
|
||||
private bool _shouldNavigateToLastPage = false;
|
||||
|
||||
|
||||
// 页面切换防抖机制
|
||||
private DateTime _lastSlideSwitchTime = DateTime.MinValue;
|
||||
private int _pendingSlideIndex = -1;
|
||||
@@ -800,7 +800,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
|
||||
{
|
||||
if (isFloatingBarFolded)
|
||||
if (isFloatingBarFolded)
|
||||
{
|
||||
await UnFoldFloatingBar(new object());
|
||||
}
|
||||
@@ -808,7 +808,7 @@ namespace Ink_Canvas
|
||||
else
|
||||
{
|
||||
// 如果两个功能都关闭,确保浮动栏展开
|
||||
if (isFloatingBarFolded)
|
||||
if (isFloatingBarFolded)
|
||||
{
|
||||
await UnFoldFloatingBar(new object());
|
||||
}
|
||||
@@ -819,7 +819,7 @@ namespace Ink_Canvas
|
||||
isEnteredSlideShowEndEvent = true;
|
||||
|
||||
// 保存所有墨迹
|
||||
_multiPPTInkManager?.SaveAllStrokesToFile(pres);
|
||||
_multiPPTInkManager?.SaveAllStrokesToFile(pres);
|
||||
|
||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
@@ -1086,7 +1086,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 切换到对应的墨迹管理器
|
||||
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
|
||||
|
||||
|
||||
// 重置锁定状态
|
||||
_multiPPTInkManager?.ResetCurrentPresentationLockState();
|
||||
}
|
||||
@@ -1106,21 +1106,21 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 重置进入PPT时的浮动栏收纳状态记录
|
||||
wasFloatingBarFoldedWhenEnterSlideShow = false;
|
||||
|
||||
|
||||
// 重置PPT放映结束事件标志
|
||||
isEnteredSlideShowEndEvent = false;
|
||||
|
||||
|
||||
// 重置演示文稿黑边状态
|
||||
isPresentationHaveBlackSpace = false;
|
||||
|
||||
|
||||
// 重置上次播放位置相关字段
|
||||
_lastPlaybackPage = 0;
|
||||
_shouldNavigateToLastPage = false;
|
||||
|
||||
|
||||
// 重置页面切换防抖机制
|
||||
_lastSlideSwitchTime = DateTime.MinValue;
|
||||
_pendingSlideIndex = -1;
|
||||
|
||||
|
||||
LogHelper.WriteLogToFile("PPT状态变量已重置", LogHelper.LogType.Trace);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1137,15 +1137,15 @@ namespace Ink_Canvas
|
||||
try
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
|
||||
|
||||
// 如果距离上次切换时间太短,使用防抖机制
|
||||
if (now - _lastSlideSwitchTime < TimeSpan.FromMilliseconds(SlideSwitchDebounceMs))
|
||||
{
|
||||
_pendingSlideIndex = currentSlide;
|
||||
|
||||
|
||||
// 停止之前的定时器
|
||||
_slideSwitchDebounceTimer?.Stop();
|
||||
|
||||
|
||||
// 创建新的定时器
|
||||
_slideSwitchDebounceTimer = new System.Timers.Timer(SlideSwitchDebounceMs);
|
||||
_slideSwitchDebounceTimer.Elapsed += (sender, e) =>
|
||||
@@ -1169,7 +1169,7 @@ namespace Ink_Canvas
|
||||
SwitchSlideInk(currentSlide);
|
||||
_pptUIManager?.UpdateCurrentSlideNumber(currentSlide, totalSlides);
|
||||
}
|
||||
|
||||
|
||||
_lastSlideSwitchTime = now;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1190,21 +1190,21 @@ namespace Ink_Canvas
|
||||
|
||||
// 获取当前页面索引
|
||||
var currentSlideIndex = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
||||
|
||||
|
||||
|
||||
|
||||
// 验证页面索引的有效性
|
||||
if (newSlideIndex <= 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"无效的新页面索引: {newSlideIndex},跳过页面切换", LogHelper.LogType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 如果有当前墨迹且不是第一次切换,先保存到当前页面
|
||||
if (inkCanvas.Strokes.Count > 0 && currentSlideIndex > 0 && currentSlideIndex != newSlideIndex)
|
||||
{
|
||||
// 检查是否可以写入墨迹
|
||||
bool canWrite = _multiPPTInkManager?.CanWriteInk(currentSlideIndex) == true;
|
||||
|
||||
|
||||
if (canWrite)
|
||||
{
|
||||
// 正常保存
|
||||
@@ -1219,7 +1219,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 无法获取当前页面索引时,不保存墨迹,直接清空
|
||||
}
|
||||
|
||||
|
||||
// 切换到新页面并加载墨迹
|
||||
var newStrokes = _multiPPTInkManager?.SwitchToSlide(newSlideIndex, null);
|
||||
if (newStrokes != null)
|
||||
@@ -1590,7 +1590,7 @@ namespace Ink_Canvas
|
||||
|
||||
HideSubPanels("cursor");
|
||||
SetCurrentToolMode(InkCanvasEditingMode.None);
|
||||
|
||||
|
||||
await Task.Delay(150);
|
||||
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow)
|
||||
{
|
||||
@@ -1628,7 +1628,7 @@ namespace Ink_Canvas
|
||||
|
||||
// 异常情况下也手动处理收纳状态恢复
|
||||
await HandleManualSlideShowEnd();
|
||||
|
||||
|
||||
// 异常情况下也要根据设置决定浮动栏边距
|
||||
await Task.Delay(150);
|
||||
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow)
|
||||
@@ -1678,7 +1678,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
|
||||
{
|
||||
if (isFloatingBarFolded)
|
||||
if (isFloatingBarFolded)
|
||||
{
|
||||
await UnFoldFloatingBar(new object());
|
||||
}
|
||||
@@ -1686,7 +1686,7 @@ namespace Ink_Canvas
|
||||
else
|
||||
{
|
||||
// 如果两个功能都关闭,确保浮动栏展开
|
||||
if (isFloatingBarFolded)
|
||||
if (isFloatingBarFolded)
|
||||
{
|
||||
await UnFoldFloatingBar(new object());
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var tarPos = transform.Transform(point);
|
||||
scrollViewer.ScrollToVerticalOffset(tarPos.Y);
|
||||
}
|
||||
|
||||
@@ -1029,41 +1029,41 @@ namespace Ink_Canvas
|
||||
// 获取当前屏幕的实际尺寸(考虑DPI缩放)
|
||||
var actualScreenWidth = SystemParameters.PrimaryScreenWidth;
|
||||
var actualScreenHeight = SystemParameters.PrimaryScreenHeight;
|
||||
|
||||
|
||||
// 预览区域固定尺寸
|
||||
const double previewWidth = 324.0;
|
||||
const double previewHeight = 182.0;
|
||||
|
||||
|
||||
// 计算缩放比例(预览区域与实际屏幕的比例)
|
||||
double scaleX = previewWidth / actualScreenWidth;
|
||||
double scaleY = previewHeight / actualScreenHeight;
|
||||
|
||||
|
||||
// 获取按钮位置设置
|
||||
double rsPosition = Settings.PowerPointSettings.PPTRSButtonPosition;
|
||||
double lsPosition = Settings.PowerPointSettings.PPTLSButtonPosition;
|
||||
double lbPosition = Settings.PowerPointSettings.PPTLBButtonPosition;
|
||||
double rbPosition = Settings.PowerPointSettings.PPTRBButtonPosition;
|
||||
|
||||
|
||||
bool showSidePageButton = sopt.Length >= 1 && sopt[0] == '2';
|
||||
bool showBottomPageButton = bopt.Length >= 1 && bopt[0] == '2';
|
||||
|
||||
|
||||
// 页码按钮的实际尺寸
|
||||
const double pageButtonWidth = 50.0;
|
||||
const double pageButtonHeight = 50.0;
|
||||
|
||||
const double pageButtonWidth = 50.0;
|
||||
const double pageButtonHeight = 50.0;
|
||||
|
||||
// 计算侧边按钮位置(Y轴偏移)
|
||||
double sideOffsetY = showSidePageButton ? pageButtonHeight * scaleY : 0;
|
||||
PPTBtnPreviewRSTransform.Y = -(rsPosition * scaleY) - sideOffsetY;
|
||||
PPTBtnPreviewLSTransform.Y = -(lsPosition * scaleY) - sideOffsetY;
|
||||
|
||||
|
||||
// 计算底部按钮位置(X轴偏移)
|
||||
const double bottomMarginOffset = 6.0;
|
||||
const double bottomMarginOffset = 6.0;
|
||||
double scaledMarginOffset = bottomMarginOffset * scaleX;
|
||||
|
||||
|
||||
double bottomOffsetX = showBottomPageButton ? pageButtonWidth * scaleX : 0;
|
||||
PPTBtnPreviewLBTransform.X = scaledMarginOffset + (lbPosition * scaleX) + bottomOffsetX;
|
||||
PPTBtnPreviewRBTransform.X = -(scaledMarginOffset + (rbPosition * scaleX) + bottomOffsetX);
|
||||
|
||||
|
||||
// 计算工具栏尺寸
|
||||
var dpiScaleX = 1.0;
|
||||
var dpiScaleY = 1.0;
|
||||
@@ -1082,17 +1082,17 @@ namespace Ink_Canvas
|
||||
dpiScaleX = 1.0;
|
||||
dpiScaleY = 1.0;
|
||||
}
|
||||
|
||||
|
||||
// 计算工具栏的实际尺寸
|
||||
const double baseToolbarHeight = 24.0;
|
||||
|
||||
const double baseToolbarHeight = 24.0;
|
||||
|
||||
double actualToolbarHeight = baseToolbarHeight * dpiScaleY;
|
||||
double scaledToolbarHeight = actualToolbarHeight * scaleY;
|
||||
double scaledToolbarWidth = previewWidth;
|
||||
|
||||
|
||||
// 设置工具栏尺寸
|
||||
PPTBtnPreviewToolbar.Height = scaledToolbarHeight;
|
||||
PPTBtnPreviewToolbar.Width = scaledToolbarWidth;
|
||||
PPTBtnPreviewToolbar.Width = scaledToolbarWidth;
|
||||
}
|
||||
|
||||
private void ToggleSwitchShowCursor_Toggled(object sender, RoutedEventArgs e)
|
||||
@@ -1495,18 +1495,18 @@ namespace Ink_Canvas
|
||||
private void ToggleSwitchAutoFoldInPPTSlideShow_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
|
||||
|
||||
// 记录设置变更前的状态
|
||||
bool previousState = Settings.Automation.IsAutoFoldInPPTSlideShow;
|
||||
Settings.Automation.IsAutoFoldInPPTSlideShow = ToggleSwitchAutoFoldInPPTSlideShow.IsOn;
|
||||
|
||||
|
||||
// 如果设置状态发生变化,重置PPT相关状态变量
|
||||
if (previousState != Settings.Automation.IsAutoFoldInPPTSlideShow)
|
||||
{
|
||||
ResetPPTStateVariables();
|
||||
LogHelper.WriteLogToFile($"PPT自动收纳设置已变更: {Settings.Automation.IsAutoFoldInPPTSlideShow}, 已重置相关状态变量", LogHelper.LogType.Trace);
|
||||
}
|
||||
|
||||
|
||||
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
|
||||
{
|
||||
SettingsPPTInkingAndAutoFoldExplictBorder.Visibility = Visibility.Visible;
|
||||
@@ -1887,7 +1887,7 @@ namespace Ink_Canvas
|
||||
private void ToggleSwitchEnableTwoFingerZoom_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
|
||||
|
||||
// 如果多指书写模式启用,强制禁用双指手势
|
||||
if (ToggleSwitchEnableMultiTouchMode.IsOn)
|
||||
{
|
||||
@@ -1898,7 +1898,7 @@ namespace Ink_Canvas
|
||||
SaveSettingsToFile();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (sender == ToggleSwitchEnableTwoFingerZoom)
|
||||
BoardToggleSwitchEnableTwoFingerZoom.IsOn = ToggleSwitchEnableTwoFingerZoom.IsOn;
|
||||
else
|
||||
@@ -1978,7 +1978,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
Settings.Gesture.IsEnableMultiTouchMode = ToggleSwitchEnableMultiTouchMode.IsOn;
|
||||
|
||||
|
||||
// 如果启用多指书写模式,强制禁用所有双指手势
|
||||
if (ToggleSwitchEnableMultiTouchMode.IsOn)
|
||||
{
|
||||
@@ -2003,7 +2003,7 @@ namespace Ink_Canvas
|
||||
if (BoardToggleSwitchEnableTwoFingerRotation != null)
|
||||
BoardToggleSwitchEnableTwoFingerRotation.IsOn = false;
|
||||
}
|
||||
|
||||
|
||||
CheckEnableTwoFingerGestureBtnColorPrompt();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
@@ -2011,7 +2011,7 @@ namespace Ink_Canvas
|
||||
private void ToggleSwitchEnableTwoFingerTranslate_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
|
||||
|
||||
// 如果多指书写模式启用,强制禁用双指手势
|
||||
if (ToggleSwitchEnableMultiTouchMode.IsOn)
|
||||
{
|
||||
@@ -2022,7 +2022,7 @@ namespace Ink_Canvas
|
||||
SaveSettingsToFile();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (sender == ToggleSwitchEnableTwoFingerTranslate)
|
||||
BoardToggleSwitchEnableTwoFingerTranslate.IsOn = ToggleSwitchEnableTwoFingerTranslate.IsOn;
|
||||
else
|
||||
@@ -3074,7 +3074,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
Directory.CreateDirectory(configsDir);
|
||||
}
|
||||
|
||||
|
||||
File.WriteAllText(App.RootPath + settingsFileName, text);
|
||||
}
|
||||
catch { }
|
||||
|
||||
@@ -11,9 +11,9 @@ using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using WinForms = System.Windows.Forms;
|
||||
using File = System.IO.File;
|
||||
using OperatingSystem = OSVersionExtension.OperatingSystem;
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
string text = File.ReadAllText(App.RootPath + settingsFileName);
|
||||
Settings = JsonConvert.DeserializeObject<Settings>(text);
|
||||
|
||||
|
||||
// 验证设置是否成功加载
|
||||
if (Settings == null)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 如果仍然失败,使用默认设置
|
||||
if (Settings == null)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ namespace Ink_Canvas
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"配置文件加载失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
|
||||
|
||||
// 尝试从备份恢复
|
||||
LogHelper.WriteLogToFile("尝试从备份恢复配置文件", LogHelper.LogType.Warning);
|
||||
if (AutoBackupManager.TryRestoreFromBackup())
|
||||
@@ -75,7 +75,7 @@ namespace Ink_Canvas
|
||||
BtnResetToSuggestion_Click(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 如果仍然失败,使用默认设置
|
||||
if (Settings == null)
|
||||
{
|
||||
@@ -109,7 +109,7 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile("备份恢复失败,使用默认设置", LogHelper.LogType.Warning);
|
||||
BtnResetToSuggestion_Click(null, null);
|
||||
}
|
||||
|
||||
|
||||
// 如果仍然失败,使用默认设置
|
||||
if (Settings == null)
|
||||
{
|
||||
@@ -427,7 +427,7 @@ namespace Ink_Canvas
|
||||
|
||||
// 应用浮动栏按钮可见性设置
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
|
||||
|
||||
// 更新浮动栏图标
|
||||
UpdateFloatingBarIcons();
|
||||
|
||||
@@ -806,7 +806,7 @@ namespace Ink_Canvas
|
||||
ToggleSwitchIsEnableAvoidFullScreenHelper.IsOn = Settings.Advanced.IsEnableAvoidFullScreenHelper;
|
||||
ToggleSwitchIsAutoBackupBeforeUpdate.IsOn = Settings.Advanced.IsAutoBackupBeforeUpdate;
|
||||
ToggleSwitchIsAutoBackupEnabled.IsOn = Settings.Advanced.IsAutoBackupEnabled;
|
||||
|
||||
|
||||
// 设置备份间隔下拉框
|
||||
foreach (ComboBoxItem item in ComboBoxAutoBackupInterval.Items)
|
||||
{
|
||||
@@ -911,7 +911,7 @@ namespace Ink_Canvas
|
||||
if (Settings.ModeSettings != null)
|
||||
{
|
||||
ToggleSwitchMode.IsOn = Settings.ModeSettings.IsPPTOnlyMode;
|
||||
|
||||
|
||||
// 根据加载的配置状态执行相应的窗口显示/隐藏逻辑
|
||||
if (isStartup && Settings.ModeSettings.IsPPTOnlyMode)
|
||||
{
|
||||
@@ -1026,7 +1026,7 @@ namespace Ink_Canvas
|
||||
|
||||
// 加载退出收纳模式自动切换至批注模式设置
|
||||
ToggleSwitchAutoEnterAnnotationModeWhenExitFoldMode.IsOn = Settings.Automation.IsAutoEnterAnnotationModeWhenExitFoldMode;
|
||||
|
||||
|
||||
// 加载退出白板时自动收纳设置
|
||||
ToggleSwitchAutoFoldWhenExitWhiteboard.IsOn = Settings.Automation.IsAutoFoldWhenExitWhiteboard;
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ namespace Ink_Canvas
|
||||
await CheckIsDrawingShapesInMultiTouchMode();
|
||||
EnterShapeDrawingMode(3);
|
||||
CancelSingleFingerDragMode();
|
||||
isLongPressSelected = false;
|
||||
isLongPressSelected = false;
|
||||
lastMouseDownSender = null;
|
||||
DrawShapePromptToPen();
|
||||
}
|
||||
@@ -496,7 +496,7 @@ namespace Ink_Canvas
|
||||
if (!isTouchDown) return;
|
||||
|
||||
if (isWaitUntilNextTouchDown && dec.Count > 1) return;
|
||||
|
||||
|
||||
// 对于多笔图形绘制,允许第二笔绘制,即使dec.Count > 1
|
||||
if (dec.Count > 1 && !((drawingShapeMode == 24 || drawingShapeMode == 25) && drawMultiStepShapeCurrentStep == 1))
|
||||
{
|
||||
@@ -512,7 +512,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 第二笔绘制双曲线时,只删除第二笔的临时笔画,保留第一笔的辅助线
|
||||
if ((drawingShapeMode == 24 || drawingShapeMode == 25) && drawMultiStepShapeCurrentStep == 1)
|
||||
{
|
||||
@@ -584,19 +584,19 @@ namespace Ink_Canvas
|
||||
{
|
||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||
};
|
||||
|
||||
|
||||
UpdateTempStrokeSafely(stroke);
|
||||
break;
|
||||
case 8:
|
||||
_currentCommitType = CommitReason.ShapeDrawing;
|
||||
strokes.Add(GenerateDashedLineStrokeCollection(iniP, endP));
|
||||
|
||||
|
||||
UpdateTempStrokeCollectionSafely(strokes);
|
||||
break;
|
||||
case 18:
|
||||
_currentCommitType = CommitReason.ShapeDrawing;
|
||||
strokes.Add(GenerateDotLineStrokeCollection(iniP, endP));
|
||||
|
||||
|
||||
UpdateTempStrokeCollectionSafely(strokes);
|
||||
break;
|
||||
case 2:
|
||||
@@ -618,7 +618,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||
};
|
||||
|
||||
|
||||
// 优化:使用更安全的临时笔画更新方式,减少闪烁
|
||||
UpdateTempStrokeSafely(stroke);
|
||||
break;
|
||||
@@ -1503,12 +1503,12 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 先添加新笔画,再删除旧笔画,减少视觉闪烁
|
||||
inkCanvas.Strokes.Add(newStroke);
|
||||
|
||||
|
||||
if (lastTempStroke != null && inkCanvas.Strokes.Contains(lastTempStroke))
|
||||
{
|
||||
inkCanvas.Strokes.Remove(lastTempStroke);
|
||||
}
|
||||
|
||||
|
||||
lastTempStroke = newStroke;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1553,7 +1553,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 先添加新笔画集合,再删除旧笔画集合,减少视觉闪烁
|
||||
inkCanvas.Strokes.Add(newStrokeCollection);
|
||||
|
||||
|
||||
if (lastTempStrokeCollection != null && lastTempStrokeCollection.Count > 0)
|
||||
{
|
||||
foreach (var stroke in lastTempStrokeCollection)
|
||||
@@ -1564,7 +1564,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lastTempStrokeCollection = newStrokeCollection;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -744,13 +744,13 @@ namespace Ink_Canvas
|
||||
// 应用高级贝塞尔曲线平滑(仅在未进行直线拉直时)
|
||||
Debug.WriteLine($"墨迹平滑检查: UseAdvancedBezierSmoothing={Settings.Canvas.UseAdvancedBezierSmoothing}, wasStraightened={wasStraightened}");
|
||||
Debug.WriteLine($"异步平滑设置: UseAsyncInkSmoothing={Settings.Canvas.UseAsyncInkSmoothing}, _inkSmoothingManager={_inkSmoothingManager != null}");
|
||||
|
||||
|
||||
if (Settings.Canvas.UseAdvancedBezierSmoothing && !wasStraightened)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.WriteLine($"开始墨迹平滑处理: 原始点数={e.Stroke.StylusPoints.Count}, 直线拉直={wasStraightened}");
|
||||
|
||||
|
||||
// 检查原始笔画是否仍然存在于画布中
|
||||
if (inkCanvas.Strokes.Contains(e.Stroke))
|
||||
{
|
||||
@@ -807,7 +807,7 @@ namespace Ink_Canvas
|
||||
Debug.WriteLine($"异步平滑完成: 原始点数={original.StylusPoints.Count}, 平滑后点数={smoothed.StylusPoints.Count}");
|
||||
Debug.WriteLine($"墨迹比较: smoothed != original = {smoothed != original}");
|
||||
Debug.WriteLine($"画布包含原始墨迹: {inkCanvas.Strokes.Contains(original)}");
|
||||
|
||||
|
||||
// 在UI线程上执行笔画替换
|
||||
if (inkCanvas.Strokes.Contains(original) && smoothed != original)
|
||||
{
|
||||
@@ -1424,7 +1424,7 @@ namespace Ink_Canvas
|
||||
// 修复灵敏度逻辑:灵敏度越大,容许的偏差越大,更容易将线条识别为直线
|
||||
// 将灵敏度转换为阈值:灵敏度0.05-1.0映射到阈值0.01-0.2
|
||||
double threshold = Math.Max(0.01, sensitivity * 0.2); // 确保最小阈值为0.01
|
||||
|
||||
|
||||
if ((maxDeviation / lineLength) > threshold)
|
||||
{
|
||||
Debug.WriteLine($"拒绝拉直:最大偏差过大 {maxDeviation / lineLength:F3} > {threshold:F3}");
|
||||
|
||||
@@ -70,8 +70,8 @@ namespace Ink_Canvas
|
||||
private TimeViewModel nowTimeVM = new TimeViewModel();
|
||||
private DateTime cachedNetworkTime = DateTime.Now;
|
||||
private DateTime lastNtpSyncTime = DateTime.MinValue;
|
||||
private string lastDisplayedTime = "";
|
||||
private bool useNetworkTime = false;
|
||||
private string lastDisplayedTime = "";
|
||||
private bool useNetworkTime = false;
|
||||
private TimeSpan networkTimeOffset = TimeSpan.Zero;
|
||||
private DateTime lastLocalTime = DateTime.Now; // 记录上次的本地时间,用于检测时间跳跃
|
||||
private bool isNtpSyncing = false; // 防止重复NTP同步的标志
|
||||
@@ -87,7 +87,7 @@ namespace Ink_Canvas
|
||||
var ipEndPoint = new IPEndPoint(addresses[0], 123);
|
||||
using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
|
||||
{
|
||||
socket.ReceiveTimeout = 5000;
|
||||
socket.ReceiveTimeout = 5000;
|
||||
socket.Connect(ipEndPoint);
|
||||
await Task.Factory.FromAsync(socket.BeginSend(ntpData, 0, ntpData.Length, SocketFlags.None, null, socket), socket.EndSend);
|
||||
await Task.Factory.FromAsync(socket.BeginReceive(ntpData, 0, ntpData.Length, SocketFlags.None, null, socket), socket.EndReceive);
|
||||
@@ -131,7 +131,7 @@ namespace Ink_Canvas
|
||||
timerKillProcess.Start();
|
||||
nowTimeVM.nowDate = DateTime.Now.ToString("yyyy'年'MM'月'dd'日' dddd");
|
||||
nowTimeVM.nowTime = DateTime.Now.ToString("tt hh'时'mm'分'ss'秒'");
|
||||
|
||||
|
||||
// 程序启动时立即进行一次NTP同步
|
||||
Task.Run(async () =>
|
||||
{
|
||||
@@ -151,17 +151,17 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 防止重复同步
|
||||
if (isNtpSyncing) return;
|
||||
|
||||
|
||||
isNtpSyncing = true;
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
// 添加超时机制,最多等待10秒
|
||||
var timeoutTask = Task.Delay(10000);
|
||||
var ntpTask = GetNetworkTimeAsync();
|
||||
|
||||
|
||||
var completedTask = await Task.WhenAny(ntpTask, timeoutTask);
|
||||
|
||||
|
||||
if (completedTask == timeoutTask)
|
||||
{
|
||||
cachedNetworkTime = DateTime.Now;
|
||||
@@ -170,20 +170,20 @@ namespace Ink_Canvas
|
||||
networkTimeOffset = TimeSpan.Zero;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
DateTime networkTime = await ntpTask;
|
||||
DateTime localTime = DateTime.Now;
|
||||
|
||||
|
||||
cachedNetworkTime = networkTime;
|
||||
lastNtpSyncTime = localTime;
|
||||
|
||||
|
||||
// 计算网络时间与本地时间的偏移量
|
||||
networkTimeOffset = networkTime - localTime;
|
||||
|
||||
|
||||
// 如果时间差超过3分钟,则使用网络时间
|
||||
useNetworkTime = Math.Abs(networkTimeOffset.TotalMinutes) > 3.0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// NTP同步失败时,保持使用本地时间
|
||||
@@ -191,7 +191,7 @@ namespace Ink_Canvas
|
||||
lastNtpSyncTime = DateTime.Now;
|
||||
useNetworkTime = false;
|
||||
networkTimeOffset = TimeSpan.Zero;
|
||||
|
||||
|
||||
LogHelper.WriteLogToFile($"NTP同步失败: {ex.Message}", LogHelper.LogType.Warning);
|
||||
}
|
||||
finally
|
||||
@@ -209,7 +209,7 @@ namespace Ink_Canvas
|
||||
// 检测系统时间是否发生重大跳跃(超过2分钟)
|
||||
TimeSpan timeJump = localTime - lastLocalTime;
|
||||
double timeJumpMinutes = Math.Abs(timeJump.TotalMinutes);
|
||||
|
||||
|
||||
if (timeJumpMinutes > 3 && !isNtpSyncing)
|
||||
{
|
||||
// 系统时间发生重大变化(超过3分钟),立即触发NTP同步
|
||||
@@ -237,12 +237,12 @@ namespace Ink_Canvas
|
||||
// 格式化时间字符串
|
||||
string timeString = displayTime.ToString("tt hh'时'mm'分'ss'秒'");
|
||||
|
||||
|
||||
|
||||
// 只有当时间字符串发生变化时才更新UI,避免不必要的UI刷新
|
||||
if (timeString != lastDisplayedTime)
|
||||
{
|
||||
lastDisplayedTime = timeString;
|
||||
|
||||
|
||||
// 使用BeginInvoke异步更新UI,避免阻塞
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
@@ -477,7 +477,7 @@ namespace Ink_Canvas
|
||||
{ // EasiNote5
|
||||
// 检查是否是桌面批注窗口
|
||||
bool isAnnotationWindow = windowTitle.Length == 0 && ForegroundWindowInfo.WindowRect().Height < 500;
|
||||
|
||||
|
||||
// 如果启用了忽略桌面批注窗口功能,且当前是批注窗口
|
||||
if (Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno && isAnnotationWindow)
|
||||
{
|
||||
|
||||
@@ -23,9 +23,9 @@ namespace Ink_Canvas
|
||||
private Point centerPoint = new Point(0, 0);
|
||||
private InkCanvasEditingMode lastInkCanvasEditingMode = InkCanvasEditingMode.Ink;
|
||||
private DateTime lastTouchDownTime = DateTime.MinValue;
|
||||
private const double MULTI_TOUCH_DELAY_MS = 100;
|
||||
private const double MULTI_TOUCH_DELAY_MS = 100;
|
||||
private bool isMultiTouchTimerActive = false;
|
||||
|
||||
|
||||
/// </summary>
|
||||
/// 保存画布上的非笔画元素(如图片、媒体元素等)
|
||||
/// </summary>
|
||||
@@ -64,13 +64,13 @@ namespace Ink_Canvas
|
||||
if (originalElement is Image originalImage)
|
||||
{
|
||||
var clonedImage = new Image();
|
||||
|
||||
|
||||
// 复制图片源
|
||||
if (originalImage.Source is BitmapSource bitmapSource)
|
||||
{
|
||||
clonedImage.Source = bitmapSource;
|
||||
}
|
||||
|
||||
|
||||
// 复制属性
|
||||
clonedImage.Width = originalImage.Width;
|
||||
clonedImage.Height = originalImage.Height;
|
||||
@@ -81,23 +81,23 @@ namespace Ink_Canvas
|
||||
clonedImage.Focusable = originalImage.Focusable;
|
||||
clonedImage.Cursor = originalImage.Cursor;
|
||||
clonedImage.IsManipulationEnabled = originalImage.IsManipulationEnabled;
|
||||
|
||||
|
||||
// 复制位置
|
||||
InkCanvas.SetLeft(clonedImage, InkCanvas.GetLeft(originalImage));
|
||||
InkCanvas.SetTop(clonedImage, InkCanvas.GetTop(originalImage));
|
||||
|
||||
|
||||
// 复制变换
|
||||
if (originalImage.RenderTransform != null)
|
||||
{
|
||||
clonedImage.RenderTransform = originalImage.RenderTransform.Clone();
|
||||
}
|
||||
|
||||
|
||||
return clonedImage;
|
||||
}
|
||||
else if (originalElement is MediaElement originalMedia)
|
||||
{
|
||||
var clonedMedia = new MediaElement();
|
||||
|
||||
|
||||
// 复制媒体属性
|
||||
clonedMedia.Source = originalMedia.Source;
|
||||
clonedMedia.Width = originalMedia.Width;
|
||||
@@ -105,23 +105,23 @@ namespace Ink_Canvas
|
||||
clonedMedia.Name = originalMedia.Name;
|
||||
clonedMedia.IsHitTestVisible = originalMedia.IsHitTestVisible;
|
||||
clonedMedia.Focusable = originalMedia.Focusable;
|
||||
|
||||
|
||||
// 复制位置
|
||||
InkCanvas.SetLeft(clonedMedia, InkCanvas.GetLeft(originalMedia));
|
||||
InkCanvas.SetTop(clonedMedia, InkCanvas.GetTop(originalMedia));
|
||||
|
||||
|
||||
// 复制变换
|
||||
if (originalMedia.RenderTransform != null)
|
||||
{
|
||||
clonedMedia.RenderTransform = originalMedia.RenderTransform.Clone();
|
||||
}
|
||||
|
||||
|
||||
return clonedMedia;
|
||||
}
|
||||
else if (originalElement is Border originalBorder)
|
||||
{
|
||||
var clonedBorder = new Border();
|
||||
|
||||
|
||||
// 复制边框属性
|
||||
clonedBorder.Width = originalBorder.Width;
|
||||
clonedBorder.Height = originalBorder.Height;
|
||||
@@ -132,17 +132,17 @@ namespace Ink_Canvas
|
||||
clonedBorder.BorderBrush = originalBorder.BorderBrush;
|
||||
clonedBorder.BorderThickness = originalBorder.BorderThickness;
|
||||
clonedBorder.CornerRadius = originalBorder.CornerRadius;
|
||||
|
||||
|
||||
// 复制位置
|
||||
InkCanvas.SetLeft(clonedBorder, InkCanvas.GetLeft(originalBorder));
|
||||
InkCanvas.SetTop(clonedBorder, InkCanvas.GetTop(originalBorder));
|
||||
|
||||
|
||||
// 复制变换
|
||||
if (originalBorder.RenderTransform != null)
|
||||
{
|
||||
clonedBorder.RenderTransform = originalBorder.RenderTransform.Clone();
|
||||
}
|
||||
|
||||
|
||||
return clonedBorder;
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
LogHelper.WriteLogToFile($"克隆UI元素失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -246,14 +246,14 @@ namespace Ink_Canvas
|
||||
if (drawingShapeMode != 0)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
|
||||
|
||||
isTouchDown = true;
|
||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||
|
||||
|
||||
// 设置起始点
|
||||
if (NeedUpdateIniP()) iniP = e.GetTouchPoint(inkCanvas).Position;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -292,14 +292,14 @@ namespace Ink_Canvas
|
||||
if (drawingShapeMode != 0)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
|
||||
|
||||
isTouchDown = true;
|
||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||
|
||||
|
||||
// 设置起始点
|
||||
if (NeedUpdateIniP()) iniP = e.GetPosition(inkCanvas);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke)
|
||||
@@ -354,7 +354,7 @@ namespace Ink_Canvas
|
||||
isTouchDown = false;
|
||||
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||
|
||||
|
||||
// 对于双曲线等需要多步绘制的图形,手写笔抬起时应该进入下一步
|
||||
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
||||
{
|
||||
@@ -384,7 +384,7 @@ namespace Ink_Canvas
|
||||
};
|
||||
inkCanvas_MouseUp(inkCanvas, mouseArgs);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ namespace Ink_Canvas
|
||||
var stroke = GetStrokeVisual(e.StylusDevice.Id).Stroke;
|
||||
|
||||
inkCanvas.Strokes.Add(stroke);
|
||||
await Task.Delay(5);
|
||||
await Task.Delay(5);
|
||||
inkCanvas.Children.Remove(GetVisualCanvas(e.StylusDevice.Id));
|
||||
|
||||
inkCanvas_StrokeCollected(inkCanvas,
|
||||
@@ -464,7 +464,7 @@ namespace Ink_Canvas
|
||||
var strokeVisual = GetStrokeVisual(e.StylusDevice.Id);
|
||||
var stylusPointCollection = e.GetStylusPoints(this);
|
||||
foreach (var stylusPoint in stylusPointCollection)
|
||||
strokeVisual.Add(new StylusPoint(stylusPoint.X, stylusPoint.Y, stylusPoint.PressureFactor));
|
||||
strokeVisual.Add(new StylusPoint(stylusPoint.X, stylusPoint.Y, stylusPoint.PressureFactor));
|
||||
strokeVisual.Redraw();
|
||||
}
|
||||
catch { }
|
||||
@@ -538,15 +538,15 @@ namespace Ink_Canvas
|
||||
if (drawingShapeMode != 0)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
|
||||
|
||||
// 设置触摸状态,类似鼠标事件处理
|
||||
isTouchDown = true;
|
||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||
|
||||
|
||||
// 设置起始点
|
||||
if (NeedUpdateIniP()) iniP = e.GetTouchPoint(inkCanvas).Position;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
||||
@@ -604,7 +604,7 @@ namespace Ink_Canvas
|
||||
inkCanvas.CaptureTouch(e.TouchDevice);
|
||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||
|
||||
|
||||
isTouchDown = true;
|
||||
|
||||
if (dec.Count == 0)
|
||||
@@ -646,7 +646,7 @@ namespace Ink_Canvas
|
||||
double boundWidth = GetTouchBoundWidth(e);
|
||||
|
||||
|
||||
if ((Settings.Advanced.TouchMultiplier != 0 || !Settings.Advanced.IsSpecialScreen)
|
||||
if ((Settings.Advanced.TouchMultiplier != 0 || !Settings.Advanced.IsSpecialScreen)
|
||||
&& (boundWidth > BoundsWidth))
|
||||
{
|
||||
// 根据敏感度调整阈值倍数
|
||||
@@ -665,10 +665,10 @@ namespace Ink_Canvas
|
||||
break;
|
||||
}
|
||||
|
||||
double EraserThresholdValue = Settings.Startup.IsEnableNibMode ?
|
||||
Settings.Advanced.NibModeBoundsWidthThresholdValue :
|
||||
double EraserThresholdValue = Settings.Startup.IsEnableNibMode ?
|
||||
Settings.Advanced.NibModeBoundsWidthThresholdValue :
|
||||
Settings.Advanced.FingerModeBoundsWidthThresholdValue;
|
||||
|
||||
|
||||
if (boundWidth > BoundsWidth * EraserThresholdValue * thresholdMultiplier)
|
||||
{
|
||||
// 记录当前编辑模式和高光状态
|
||||
@@ -676,17 +676,17 @@ namespace Ink_Canvas
|
||||
palmEraserLastIsHighlighter = drawingAttributes.IsHighlighter;
|
||||
|
||||
// 动态调整橡皮大小
|
||||
boundWidth *= (Settings.Startup.IsEnableNibMode ?
|
||||
Settings.Advanced.NibModeBoundsWidthEraserSize :
|
||||
boundWidth *= (Settings.Startup.IsEnableNibMode ?
|
||||
Settings.Advanced.NibModeBoundsWidthEraserSize :
|
||||
Settings.Advanced.FingerModeBoundsWidthEraserSize);
|
||||
|
||||
if (Settings.Advanced.IsSpecialScreen)
|
||||
|
||||
if (Settings.Advanced.IsSpecialScreen)
|
||||
boundWidth *= Settings.Advanced.TouchMultiplier;
|
||||
|
||||
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(boundWidth, boundWidth);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
|
||||
isPalmEraserActive = true;
|
||||
|
||||
|
||||
// 启用橡皮擦覆盖层显示手掌擦样式
|
||||
EnableEraserOverlay();
|
||||
// 更新橡皮擦大小以匹配手掌擦面积
|
||||
@@ -746,7 +746,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
isMultiTouchTimerActive = true;
|
||||
var remainingTime = MULTI_TOUCH_DELAY_MS - timeSinceLastTouch;
|
||||
System.Threading.Tasks.Task.Delay((int)remainingTime).ContinueWith(_ =>
|
||||
System.Threading.Tasks.Task.Delay((int)remainingTime).ContinueWith(_ =>
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
@@ -760,7 +760,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
lastInkCanvasEditingMode = inkCanvas.EditingMode;
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint
|
||||
&& inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke
|
||||
@@ -773,7 +773,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void inkCanvas_PreviewTouchMove(object sender, TouchEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
// 如果手掌擦激活,更新橡皮擦反馈位置
|
||||
if (isPalmEraserActive)
|
||||
{
|
||||
@@ -795,13 +795,13 @@ namespace Ink_Canvas
|
||||
|
||||
// Palm Eraser 逻辑
|
||||
dec.Remove(e.TouchDevice.Id);
|
||||
|
||||
|
||||
// 重置多触控点定时器状态
|
||||
if (dec.Count <= 1)
|
||||
{
|
||||
isMultiTouchTimerActive = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 当手掌擦激活且所有触摸点都抬起时,恢复原编辑模式
|
||||
if (isPalmEraserActive && dec.Count == 0)
|
||||
@@ -842,7 +842,7 @@ namespace Ink_Canvas
|
||||
|
||||
// 重置手掌擦状态
|
||||
isPalmEraserActive = false;
|
||||
|
||||
|
||||
// 禁用橡皮擦覆盖层
|
||||
DisableEraserOverlay();
|
||||
if (Settings.Canvas.IsShowCursor)
|
||||
@@ -859,7 +859,7 @@ namespace Ink_Canvas
|
||||
isTouchDown = false;
|
||||
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||
|
||||
|
||||
// 对于双曲线等需要多步绘制的图形,触摸抬手时应该进入下一步
|
||||
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
||||
{
|
||||
@@ -917,7 +917,7 @@ namespace Ink_Canvas
|
||||
inkCanvas.EditingMode = lastInkCanvasEditingMode;
|
||||
}
|
||||
|
||||
if (isPalmEraserActive)
|
||||
if (isPalmEraserActive)
|
||||
{
|
||||
LogHelper.WriteLogToFile("Palm eraser force recovery - all touch points cleared");
|
||||
|
||||
@@ -1010,7 +1010,7 @@ namespace Ink_Canvas
|
||||
bool disableScale = dec.Count >= 3;
|
||||
|
||||
if (isInMultiTouchMode) return;
|
||||
|
||||
|
||||
if (dec.Count == 0 && (isSingleFingerDragMode || isInMultiTouchMode))
|
||||
{
|
||||
ResetTouchStates();
|
||||
@@ -1113,7 +1113,7 @@ namespace Ink_Canvas
|
||||
else
|
||||
{
|
||||
foreach (var stroke in inkCanvas.Strokes) stroke.Transform(m, false);
|
||||
|
||||
|
||||
// 同时变换画布上的图片元素
|
||||
TransformCanvasImages(m);
|
||||
}
|
||||
@@ -1144,7 +1144,7 @@ namespace Ink_Canvas
|
||||
for (int i = inkCanvas.Children.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var child = inkCanvas.Children[i];
|
||||
|
||||
|
||||
if (child is Image image)
|
||||
{
|
||||
// 应用矩阵变换到图片
|
||||
|
||||
@@ -209,15 +209,15 @@ namespace Ink_Canvas
|
||||
try
|
||||
{
|
||||
// 获取全局快捷键管理器
|
||||
var hotkeyManagerField = typeof(MainWindow).GetField("_globalHotkeyManager",
|
||||
var hotkeyManagerField = typeof(MainWindow).GetField("_globalHotkeyManager",
|
||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
var hotkeyManager = hotkeyManagerField?.GetValue(mainWin) as GlobalHotkeyManager;
|
||||
|
||||
|
||||
if (hotkeyManager != null)
|
||||
{
|
||||
// 禁用所有快捷键
|
||||
hotkeyManager.DisableHotkeyRegistration();
|
||||
|
||||
|
||||
// 更新菜单项文本和状态
|
||||
var menuItem = sender as MenuItem;
|
||||
if (menuItem != null)
|
||||
|
||||
Reference in New Issue
Block a user