1145141919810
代码清理
This commit is contained in:
+21
-25
@@ -1,19 +1,15 @@
|
|||||||
using Hardcodet.Wpf.TaskbarNotification;
|
using Hardcodet.Wpf.TaskbarNotification;
|
||||||
using Ink_Canvas.Helpers;
|
using Ink_Canvas.Helpers;
|
||||||
using Ink_Canvas.Windows;
|
|
||||||
using iNKORE.UI.WPF.Modern.Controls;
|
using iNKORE.UI.WPF.Modern.Controls;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -36,7 +32,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
public static string[] StartArgs;
|
public static string[] StartArgs;
|
||||||
public static string RootPath = Environment.GetEnvironmentVariable("APPDATA") + "\\Ink Canvas\\";
|
public static string RootPath = Environment.GetEnvironmentVariable("APPDATA") + "\\Ink Canvas\\";
|
||||||
|
|
||||||
// 新增:标记是否通过--board参数启动
|
// 新增:标记是否通过--board参数启动
|
||||||
public static bool StartWithBoardMode = false;
|
public static bool StartWithBoardMode = false;
|
||||||
// 新增:标记是否通过--show参数启动
|
// 新增:标记是否通过--show参数启动
|
||||||
@@ -302,7 +298,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
string reason = e.Reason == SessionEndReasons.Logoff ? "用户注销" : "系统关机";
|
string reason = e.Reason == SessionEndReasons.Logoff ? "用户注销" : "系统关机";
|
||||||
WriteCrashLog($"系统会话即将结束: {reason}");
|
WriteCrashLog($"系统会话即将结束: {reason}");
|
||||||
|
|
||||||
// 清理PowerPoint进程守护和悬浮窗拦截器
|
// 清理PowerPoint进程守护和悬浮窗拦截器
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -311,13 +307,13 @@ namespace Ink_Canvas
|
|||||||
if (mainWindow != null)
|
if (mainWindow != null)
|
||||||
{
|
{
|
||||||
// 清理PowerPoint进程守护
|
// 清理PowerPoint进程守护
|
||||||
var method = mainWindow.GetType().GetMethod("StopPowerPointProcessMonitoring",
|
var method = mainWindow.GetType().GetMethod("StopPowerPointProcessMonitoring",
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance);
|
BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
method?.Invoke(mainWindow, null);
|
method?.Invoke(mainWindow, null);
|
||||||
WriteCrashLog("PowerPoint进程守护已在系统关机时清理");
|
WriteCrashLog("PowerPoint进程守护已在系统关机时清理");
|
||||||
|
|
||||||
// 清理悬浮窗拦截器
|
// 清理悬浮窗拦截器
|
||||||
var interceptorField = mainWindow.GetType().GetField("_floatingWindowInterceptorManager",
|
var interceptorField = mainWindow.GetType().GetField("_floatingWindowInterceptorManager",
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance);
|
BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
var interceptorManager = interceptorField?.GetValue(mainWindow);
|
var interceptorManager = interceptorField?.GetValue(mainWindow);
|
||||||
if (interceptorManager != null)
|
if (interceptorManager != null)
|
||||||
@@ -331,7 +327,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
WriteCrashLog($"清理资源失败: {ex.Message}");
|
WriteCrashLog($"清理资源失败: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceIdentifier.SaveUsageStatsOnShutdown();
|
DeviceIdentifier.SaveUsageStatsOnShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,12 +405,12 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
public static void ShowSplashScreen()
|
public static void ShowSplashScreen()
|
||||||
{
|
{
|
||||||
if (_isSplashScreenShown)
|
if (_isSplashScreenShown)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile("启动画面已经显示,跳过重复显示");
|
LogHelper.WriteLogToFile("启动画面已经显示,跳过重复显示");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile("开始创建启动画面...");
|
LogHelper.WriteLogToFile("开始创建启动画面...");
|
||||||
@@ -435,7 +431,7 @@ namespace Ink_Canvas
|
|||||||
public static void CloseSplashScreen()
|
public static void CloseSplashScreen()
|
||||||
{
|
{
|
||||||
if (!_isSplashScreenShown || _splashScreen == null) return;
|
if (!_isSplashScreenShown || _splashScreen == null) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_splashScreen.CloseSplashScreen();
|
_splashScreen.CloseSplashScreen();
|
||||||
@@ -481,7 +477,7 @@ namespace Ink_Canvas
|
|||||||
return (bool)obj["appearance"]["enableSplashScreen"];
|
return (bool)obj["appearance"]["enableSplashScreen"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果设置文件不存在或没有该设置,返回默认值false
|
// 如果设置文件不存在或没有该设置,返回默认值false
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -596,8 +592,8 @@ namespace Ink_Canvas
|
|||||||
ShowSplashScreen();
|
ShowSplashScreen();
|
||||||
SetSplashMessage("正在启动 Ink Canvas...");
|
SetSplashMessage("正在启动 Ink Canvas...");
|
||||||
SetSplashProgress(20);
|
SetSplashProgress(20);
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
|
|
||||||
// 强制刷新UI,确保启动画面显示
|
// 强制刷新UI,确保启动画面显示
|
||||||
Application.Current.Dispatcher.Invoke(() => { }, DispatcherPriority.Render);
|
Application.Current.Dispatcher.Invoke(() => { }, DispatcherPriority.Render);
|
||||||
}
|
}
|
||||||
@@ -610,7 +606,7 @@ namespace Ink_Canvas
|
|||||||
// 检查是否为最终应用启动(更新后的应用)
|
// 检查是否为最终应用启动(更新后的应用)
|
||||||
bool isFinalApp = e.Args.Contains("--final-app");
|
bool isFinalApp = e.Args.Contains("--final-app");
|
||||||
bool skipMutexCheck = e.Args.Contains("--skip-mutex-check");
|
bool skipMutexCheck = e.Args.Contains("--skip-mutex-check");
|
||||||
|
|
||||||
// 检查是否通过--board参数启动
|
// 检查是否通过--board参数启动
|
||||||
bool hasBoardArg = e.Args.Contains("--board");
|
bool hasBoardArg = e.Args.Contains("--board");
|
||||||
if (hasBoardArg)
|
if (hasBoardArg)
|
||||||
@@ -638,8 +634,8 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
SetSplashMessage("正在初始化组件...");
|
SetSplashMessage("正在初始化组件...");
|
||||||
SetSplashProgress(40);
|
SetSplashProgress(40);
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IACoreDllExtractor.ExtractIACoreDlls();
|
IACoreDllExtractor.ExtractIACoreDlls();
|
||||||
@@ -654,8 +650,8 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
SetSplashMessage("正在加载配置...");
|
SetSplashMessage("正在加载配置...");
|
||||||
SetSplashProgress(60);
|
SetSplashProgress(60);
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
}
|
}
|
||||||
DeviceIdentifier.RecordAppLaunch();
|
DeviceIdentifier.RecordAppLaunch();
|
||||||
LogHelper.WriteLogToFile($"App | 设备ID: {DeviceIdentifier.GetDeviceId()}");
|
LogHelper.WriteLogToFile($"App | 设备ID: {DeviceIdentifier.GetDeviceId()}");
|
||||||
LogHelper.WriteLogToFile($"App | 使用频率: {DeviceIdentifier.GetUsageFrequency()}");
|
LogHelper.WriteLogToFile($"App | 使用频率: {DeviceIdentifier.GetUsageFrequency()}");
|
||||||
@@ -902,11 +898,11 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
SetSplashMessage("正在初始化主界面...");
|
SetSplashMessage("正在初始化主界面...");
|
||||||
SetSplashProgress(80);
|
SetSplashProgress(80);
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
}
|
}
|
||||||
var mainWindow = new MainWindow();
|
var mainWindow = new MainWindow();
|
||||||
MainWindow = mainWindow;
|
MainWindow = mainWindow;
|
||||||
|
|
||||||
// 主窗口加载完成后关闭启动画面
|
// 主窗口加载完成后关闭启动画面
|
||||||
mainWindow.Loaded += (s, args) =>
|
mainWindow.Loaded += (s, args) =>
|
||||||
{
|
{
|
||||||
@@ -929,7 +925,7 @@ namespace Ink_Canvas
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mainWindow.Show();
|
mainWindow.Show();
|
||||||
|
|
||||||
// 注册.icstk文件关联
|
// 注册.icstk文件关联
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
using Ink_Canvas.Helpers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Ink_Canvas.Helpers;
|
|
||||||
|
|
||||||
namespace Ink_Canvas
|
namespace Ink_Canvas
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
_settings = settings ?? new FloatingWindowInterceptorSettings();
|
_settings = settings ?? new FloatingWindowInterceptorSettings();
|
||||||
_interceptor = new FloatingWindowInterceptor();
|
_interceptor = new FloatingWindowInterceptor();
|
||||||
|
|
||||||
// 订阅事件
|
// 订阅事件
|
||||||
_interceptor.WindowIntercepted += OnWindowIntercepted;
|
_interceptor.WindowIntercepted += OnWindowIntercepted;
|
||||||
_interceptor.WindowRestored += OnWindowRestored;
|
_interceptor.WindowRestored += OnWindowRestored;
|
||||||
@@ -116,7 +116,7 @@ namespace Ink_Canvas
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_interceptor.SetInterceptRule(type, enabled);
|
_interceptor.SetInterceptRule(type, enabled);
|
||||||
|
|
||||||
// 更新设置
|
// 更新设置
|
||||||
var ruleName = type.ToString();
|
var ruleName = type.ToString();
|
||||||
if (_settings.InterceptRules.ContainsKey(ruleName))
|
if (_settings.InterceptRules.ContainsKey(ruleName))
|
||||||
@@ -258,7 +258,7 @@ namespace Ink_Canvas
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_settings.ScanIntervalMs = intervalMs;
|
_settings.ScanIntervalMs = intervalMs;
|
||||||
|
|
||||||
// 如果正在运行,重启以应用新间隔
|
// 如果正在运行,重启以应用新间隔
|
||||||
if (IsRunning)
|
if (IsRunning)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -732,9 +732,9 @@ namespace Ink_Canvas.Helpers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class AdvancedBezierSmoothing
|
public class AdvancedBezierSmoothing
|
||||||
{
|
{
|
||||||
public double SmoothingStrength { get; set; } = 0.6;
|
public double SmoothingStrength { get; set; } = 0.6;
|
||||||
public double ResampleInterval { get; set; } = 2.0;
|
public double ResampleInterval { get; set; } = 2.0;
|
||||||
public int InterpolationSteps { get; set; } = 12;
|
public int InterpolationSteps { get; set; } = 12;
|
||||||
|
|
||||||
public Stroke SmoothStroke(Stroke stroke)
|
public Stroke SmoothStroke(Stroke stroke)
|
||||||
{
|
{
|
||||||
@@ -764,7 +764,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
DrawingAttributes = stroke.DrawingAttributes.Clone()
|
DrawingAttributes = stroke.DrawingAttributes.Clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine($"AdvancedBezierSmoothing: 创建平滑笔画成功");
|
System.Diagnostics.Debug.WriteLine($"AdvancedBezierSmoothing: 创建平滑笔画成功");
|
||||||
return smoothedStroke;
|
return smoothedStroke;
|
||||||
}
|
}
|
||||||
@@ -797,7 +797,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
|
|
||||||
// 只生成2-3个插值点
|
// 只生成2-3个插值点
|
||||||
int steps = 2;
|
int steps = 2;
|
||||||
|
|
||||||
// 生成贝塞尔曲线点
|
// 生成贝塞尔曲线点
|
||||||
for (int j = 1; j <= steps; j++)
|
for (int j = 1; j <= steps; j++)
|
||||||
{
|
{
|
||||||
@@ -808,7 +808,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.Add(points[points.Length - 1]);
|
result.Add(points[points.Length - 1]);
|
||||||
|
|
||||||
// 去重处理
|
// 去重处理
|
||||||
return RemoveDuplicatePoints(result.ToArray());
|
return RemoveDuplicatePoints(result.ToArray());
|
||||||
}
|
}
|
||||||
@@ -827,10 +827,10 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
var lastPoint = result[result.Count - 1];
|
var lastPoint = result[result.Count - 1];
|
||||||
var currentPoint = points[i];
|
var currentPoint = points[i];
|
||||||
|
|
||||||
double distance = Math.Sqrt(Math.Pow(currentPoint.X - lastPoint.X, 2) +
|
double distance = Math.Sqrt(Math.Pow(currentPoint.X - lastPoint.X, 2) +
|
||||||
Math.Pow(currentPoint.Y - lastPoint.Y, 2));
|
Math.Pow(currentPoint.Y - lastPoint.Y, 2));
|
||||||
|
|
||||||
if (distance > minDistance)
|
if (distance > minDistance)
|
||||||
{
|
{
|
||||||
result.Add(currentPoint);
|
result.Add(currentPoint);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Ink_Canvas.Helpers;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|||||||
@@ -31,22 +31,22 @@ namespace Ink_Canvas.Helpers
|
|||||||
public FilterInfo CurrentCamera { get; private set; }
|
public FilterInfo CurrentCamera { get; private set; }
|
||||||
|
|
||||||
// 新增属性
|
// 新增属性
|
||||||
public int RotationAngle
|
public int RotationAngle
|
||||||
{
|
{
|
||||||
get => _rotationAngle;
|
get => _rotationAngle;
|
||||||
set => _rotationAngle = Math.Max(0, Math.Min(3, value));
|
set => _rotationAngle = Math.Max(0, Math.Min(3, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ResolutionWidth
|
public int ResolutionWidth
|
||||||
{
|
{
|
||||||
get => _resolutionWidth;
|
get => _resolutionWidth;
|
||||||
set => _resolutionWidth = Math.Max(320, Math.Min(1920, value));
|
set => _resolutionWidth = Math.Max(320, Math.Min(1920, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ResolutionHeight
|
public int ResolutionHeight
|
||||||
{
|
{
|
||||||
get => _resolutionHeight;
|
get => _resolutionHeight;
|
||||||
set => _resolutionHeight = Math.Max(240, Math.Min(1080, value));
|
set => _resolutionHeight = Math.Max(240, Math.Min(1080, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CameraService()
|
public CameraService()
|
||||||
@@ -75,7 +75,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
AvailableCameras.Clear();
|
AvailableCameras.Clear();
|
||||||
var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
|
var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
|
||||||
|
|
||||||
foreach (FilterInfo device in videoDevices)
|
foreach (FilterInfo device in videoDevices)
|
||||||
{
|
{
|
||||||
AvailableCameras.Add(device);
|
AvailableCameras.Add(device);
|
||||||
@@ -265,27 +265,27 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
// 释放之前的帧
|
// 释放之前的帧
|
||||||
_currentFrame?.Dispose();
|
_currentFrame?.Dispose();
|
||||||
|
|
||||||
// 创建新的位图,避免Clone的问题
|
// 创建新的位图,避免Clone的问题
|
||||||
var sourceFrame = eventArgs.Frame;
|
var sourceFrame = eventArgs.Frame;
|
||||||
|
|
||||||
if (sourceFrame != null)
|
if (sourceFrame != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var width = sourceFrame.Width;
|
var width = sourceFrame.Width;
|
||||||
var height = sourceFrame.Height;
|
var height = sourceFrame.Height;
|
||||||
|
|
||||||
if (width > 0 && height > 0)
|
if (width > 0 && height > 0)
|
||||||
{
|
{
|
||||||
// 应用旋转
|
// 应用旋转
|
||||||
Bitmap rotatedFrame = ApplyRotation(sourceFrame);
|
Bitmap rotatedFrame = ApplyRotation(sourceFrame);
|
||||||
|
|
||||||
// 应用分辨率调整
|
// 应用分辨率调整
|
||||||
_currentFrame = ResizeImage(rotatedFrame, _resolutionWidth, _resolutionHeight);
|
_currentFrame = ResizeImage(rotatedFrame, _resolutionWidth, _resolutionHeight);
|
||||||
|
|
||||||
rotatedFrame?.Dispose();
|
rotatedFrame?.Dispose();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_currentFrame = null;
|
_currentFrame = null;
|
||||||
@@ -379,7 +379,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
StopPreview();
|
StopPreview();
|
||||||
|
|
||||||
lock (_frameLock)
|
lock (_frameLock)
|
||||||
{
|
{
|
||||||
_currentFrame?.Dispose();
|
_currentFrame?.Dispose();
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string tempDir = Path.GetTempPath();
|
string tempDir = Path.GetTempPath();
|
||||||
|
|
||||||
// 处理文件路径IPC文件
|
// 处理文件路径IPC文件
|
||||||
string[] ipcFiles = Directory.GetFiles(tempDir, IpcFilePrefix + "*.tmp");
|
string[] ipcFiles = Directory.GetFiles(tempDir, IpcFilePrefix + "*.tmp");
|
||||||
foreach (string ipcFile in ipcFiles)
|
foreach (string ipcFile in ipcFiles)
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public InterceptType? ParentType { get; set; }
|
public InterceptType? ParentType { get; set; }
|
||||||
public List<InterceptType> ChildTypes { get; set; } = new List<InterceptType>();
|
public List<InterceptType> ChildTypes { get; set; } = new List<InterceptType>();
|
||||||
|
|
||||||
// 新增的精确匹配字段
|
// 新增的精确匹配字段
|
||||||
public bool HasWindowStyle { get; set; }
|
public bool HasWindowStyle { get; set; }
|
||||||
public uint WindowStyle { get; set; }
|
public uint WindowStyle { get; set; }
|
||||||
@@ -251,7 +251,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
public int WindowHeight { get; set; }
|
public int WindowHeight { get; set; }
|
||||||
public bool ExactTitleMatch { get; set; } = false;
|
public bool ExactTitleMatch { get; set; } = false;
|
||||||
public bool ExactClassNameMatch { get; set; } = false;
|
public bool ExactClassNameMatch { get; set; } = false;
|
||||||
|
|
||||||
// 运行时状态字段
|
// 运行时状态字段
|
||||||
public bool foundHwnd { get; set; } = false;
|
public bool foundHwnd { get; set; } = false;
|
||||||
public IntPtr outHwnd { get; set; } = IntPtr.Zero;
|
public IntPtr outHwnd { get; set; } = IntPtr.Zero;
|
||||||
@@ -267,7 +267,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
private readonly Dispatcher _dispatcher;
|
private readonly Dispatcher _dispatcher;
|
||||||
private bool _isRunning;
|
private bool _isRunning;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
// 简化的性能统计
|
// 简化的性能统计
|
||||||
private int _consecutiveEmptyScans = 0;
|
private int _consecutiveEmptyScans = 0;
|
||||||
private DateTime _lastSuccessfulScan = DateTime.Now;
|
private DateTime _lastSuccessfulScan = DateTime.Now;
|
||||||
@@ -466,15 +466,15 @@ namespace Ink_Canvas.Helpers
|
|||||||
RequiresAdmin = true,
|
RequiresAdmin = true,
|
||||||
Description = "畅言智慧课堂 主栏悬浮窗",
|
Description = "畅言智慧课堂 主栏悬浮窗",
|
||||||
ParentType = null,
|
ParentType = null,
|
||||||
ChildTypes = new List<InterceptType>
|
ChildTypes = new List<InterceptType>
|
||||||
{
|
{
|
||||||
InterceptType.ChangYanBrushSettings,
|
InterceptType.ChangYanBrushSettings,
|
||||||
InterceptType.ChangYanSwipeClear,
|
InterceptType.ChangYanSwipeClear,
|
||||||
InterceptType.ChangYanInteraction,
|
InterceptType.ChangYanInteraction,
|
||||||
InterceptType.ChangYanSubjectApp,
|
InterceptType.ChangYanSubjectApp,
|
||||||
InterceptType.ChangYanControl,
|
InterceptType.ChangYanControl,
|
||||||
InterceptType.ChangYanCommonTools,
|
InterceptType.ChangYanCommonTools,
|
||||||
InterceptType.ChangYanSceneToolbar,
|
InterceptType.ChangYanSceneToolbar,
|
||||||
InterceptType.ChangYanDrawWindow
|
InterceptType.ChangYanDrawWindow
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -713,7 +713,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
if (_isRunning) return;
|
if (_isRunning) return;
|
||||||
|
|
||||||
_isRunning = true;
|
_isRunning = true;
|
||||||
_scanTimer.Change(0, Math.Max(scanIntervalMs, 2000));
|
_scanTimer.Change(0, Math.Max(scanIntervalMs, 2000));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -725,7 +725,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
|
|
||||||
_isRunning = false;
|
_isRunning = false;
|
||||||
_scanTimer.Change(Timeout.Infinite, Timeout.Infinite);
|
_scanTimer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
|
|
||||||
// 恢复所有被拦截的窗口
|
// 恢复所有被拦截的窗口
|
||||||
RestoreAllWindows();
|
RestoreAllWindows();
|
||||||
}
|
}
|
||||||
@@ -774,9 +774,9 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
var parentRule = _interceptRules[rule.ParentType.Value];
|
var parentRule = _interceptRules[rule.ParentType.Value];
|
||||||
// 检查是否还有其他启用的子规则
|
// 检查是否还有其他启用的子规则
|
||||||
bool hasEnabledChildren = parentRule.ChildTypes.Any(childType =>
|
bool hasEnabledChildren = parentRule.ChildTypes.Any(childType =>
|
||||||
_interceptRules.ContainsKey(childType) && _interceptRules[childType].IsEnabled);
|
_interceptRules.ContainsKey(childType) && _interceptRules[childType].IsEnabled);
|
||||||
|
|
||||||
// 如果没有启用的子规则,则禁用父规则
|
// 如果没有启用的子规则,则禁用父规则
|
||||||
if (!hasEnabledChildren)
|
if (!hasEnabledChildren)
|
||||||
{
|
{
|
||||||
@@ -831,7 +831,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
var windowsToRestore = new List<IntPtr>(_interceptedWindows.Keys);
|
var windowsToRestore = new List<IntPtr>(_interceptedWindows.Keys);
|
||||||
var restoredCount = 0;
|
var restoredCount = 0;
|
||||||
|
|
||||||
foreach (var hWnd in windowsToRestore)
|
foreach (var hWnd in windowsToRestore)
|
||||||
{
|
{
|
||||||
if (RestoreWindow(hWnd))
|
if (RestoreWindow(hWnd))
|
||||||
@@ -839,7 +839,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
restoredCount++;
|
restoredCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -864,7 +864,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
restoredCount++;
|
restoredCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -875,22 +875,22 @@ namespace Ink_Canvas.Helpers
|
|||||||
if (!_interceptedWindows.ContainsKey(hWnd)) return false;
|
if (!_interceptedWindows.ContainsKey(hWnd)) return false;
|
||||||
|
|
||||||
var interceptType = _interceptedWindows[hWnd];
|
var interceptType = _interceptedWindows[hWnd];
|
||||||
|
|
||||||
if (IsWindow(hWnd))
|
if (IsWindow(hWnd))
|
||||||
{
|
{
|
||||||
// 使用多种方法确保窗口恢复显示
|
// 使用多种方法确保窗口恢复显示
|
||||||
ShowWindow(hWnd, SW_RESTORE);
|
ShowWindow(hWnd, SW_RESTORE);
|
||||||
ShowWindow(hWnd, SW_SHOW);
|
ShowWindow(hWnd, SW_SHOW);
|
||||||
ShowWindow(hWnd, SW_SHOWNORMAL);
|
ShowWindow(hWnd, SW_SHOWNORMAL);
|
||||||
|
|
||||||
// 将窗口置于前台并显示
|
// 将窗口置于前台并显示
|
||||||
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0,
|
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0,
|
||||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
|
||||||
|
|
||||||
// 强制将窗口带到前台
|
// 强制将窗口带到前台
|
||||||
BringWindowToTop(hWnd);
|
BringWindowToTop(hWnd);
|
||||||
SetForegroundWindow(hWnd);
|
SetForegroundWindow(hWnd);
|
||||||
|
|
||||||
_interceptedWindows.Remove(hWnd);
|
_interceptedWindows.Remove(hWnd);
|
||||||
|
|
||||||
WindowRestored?.Invoke(this, new WindowRestoredEventArgs
|
WindowRestored?.Invoke(this, new WindowRestoredEventArgs
|
||||||
@@ -916,7 +916,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
private void CleanupInvalidWindows()
|
private void CleanupInvalidWindows()
|
||||||
{
|
{
|
||||||
var invalidWindows = new List<IntPtr>();
|
var invalidWindows = new List<IntPtr>();
|
||||||
|
|
||||||
foreach (var kvp in _interceptedWindows)
|
foreach (var kvp in _interceptedWindows)
|
||||||
{
|
{
|
||||||
var hWnd = kvp.Key;
|
var hWnd = kvp.Key;
|
||||||
@@ -940,7 +940,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
// 简化的扫描逻辑
|
// 简化的扫描逻辑
|
||||||
var interceptedCount = 0;
|
var interceptedCount = 0;
|
||||||
CleanupInvalidWindows();
|
CleanupInvalidWindows();
|
||||||
|
|
||||||
// 重置所有规则的发现状态
|
// 重置所有规则的发现状态
|
||||||
foreach (var rule in _interceptRules.Values)
|
foreach (var rule in _interceptRules.Values)
|
||||||
{
|
{
|
||||||
@@ -958,9 +958,9 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
if (rule.IsEnabled && rule.foundHwnd && rule.outHwnd != IntPtr.Zero)
|
if (rule.IsEnabled && rule.foundHwnd && rule.outHwnd != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
bool shouldIntercept = !_interceptedWindows.ContainsKey(rule.outHwnd) ||
|
bool shouldIntercept = !_interceptedWindows.ContainsKey(rule.outHwnd) ||
|
||||||
(_interceptedWindows.ContainsKey(rule.outHwnd) && IsWindowVisible(rule.outHwnd));
|
(_interceptedWindows.ContainsKey(rule.outHwnd) && IsWindowVisible(rule.outHwnd));
|
||||||
|
|
||||||
if (shouldIntercept)
|
if (shouldIntercept)
|
||||||
{
|
{
|
||||||
InterceptWindow(rule.outHwnd, rule);
|
InterceptWindow(rule.outHwnd, rule);
|
||||||
@@ -1068,7 +1068,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
var className = new StringBuilder(256);
|
var className = new StringBuilder(256);
|
||||||
GetClassName(hWnd, className, className.Capacity);
|
GetClassName(hWnd, className, className.Capacity);
|
||||||
var classNameStr = className.ToString();
|
var classNameStr = className.ToString();
|
||||||
|
|
||||||
if (rule.ExactClassNameMatch)
|
if (rule.ExactClassNameMatch)
|
||||||
{
|
{
|
||||||
if (!classNameStr.Equals(rule.ClassNamePattern, StringComparison.OrdinalIgnoreCase))
|
if (!classNameStr.Equals(rule.ClassNamePattern, StringComparison.OrdinalIgnoreCase))
|
||||||
@@ -1087,7 +1087,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
var windowTitle = new StringBuilder(256);
|
var windowTitle = new StringBuilder(256);
|
||||||
GetWindowText(hWnd, windowTitle, windowTitle.Capacity);
|
GetWindowText(hWnd, windowTitle, windowTitle.Capacity);
|
||||||
var titleStr = windowTitle.ToString();
|
var titleStr = windowTitle.ToString();
|
||||||
|
|
||||||
if (rule.ExactTitleMatch)
|
if (rule.ExactTitleMatch)
|
||||||
{
|
{
|
||||||
if (!titleStr.Equals(rule.WindowTitlePattern, StringComparison.OrdinalIgnoreCase))
|
if (!titleStr.Equals(rule.WindowTitlePattern, StringComparison.OrdinalIgnoreCase))
|
||||||
@@ -1126,7 +1126,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
var horizontalDPI = GetDeviceCaps(hdc, LOGPIXELSX);
|
var horizontalDPI = GetDeviceCaps(hdc, LOGPIXELSX);
|
||||||
var verticalDPI = GetDeviceCaps(hdc, LOGPIXELSY);
|
var verticalDPI = GetDeviceCaps(hdc, LOGPIXELSY);
|
||||||
ReleaseDC(IntPtr.Zero, hdc);
|
ReleaseDC(IntPtr.Zero, hdc);
|
||||||
|
|
||||||
var scale = (horizontalDPI + verticalDPI) / 2.0f / 96.0f;
|
var scale = (horizontalDPI + verticalDPI) / 2.0f / 96.0f;
|
||||||
var scaledWidth = (int)(rule.WindowWidth * scale);
|
var scaledWidth = (int)(rule.WindowWidth * scale);
|
||||||
var scaledHeight = (int)(rule.WindowHeight * scale);
|
var scaledHeight = (int)(rule.WindowHeight * scale);
|
||||||
@@ -1164,10 +1164,10 @@ namespace Ink_Canvas.Helpers
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 直接隐藏窗口,不发送关闭消息
|
// 直接隐藏窗口,不发送关闭消息
|
||||||
ShowWindow(hWnd, SW_HIDE);
|
ShowWindow(hWnd, SW_HIDE);
|
||||||
|
|
||||||
// 记录拦截的窗口
|
// 记录拦截的窗口
|
||||||
_interceptedWindows[hWnd] = rule.Type;
|
_interceptedWindows[hWnd] = rule.Type;
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ using System.IO;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Ink_Canvas.Helpers
|
namespace Ink_Canvas.Helpers
|
||||||
{
|
{
|
||||||
@@ -21,12 +21,12 @@ namespace Ink_Canvas.Helpers
|
|||||||
private readonly MainWindow _mainWindow;
|
private readonly MainWindow _mainWindow;
|
||||||
private bool _isDisposed;
|
private bool _isDisposed;
|
||||||
private bool _hotkeysShouldBeRegistered = true; // 启动时注册热键
|
private bool _hotkeysShouldBeRegistered = true; // 启动时注册热键
|
||||||
|
|
||||||
// 多屏幕支持相关字段
|
// 多屏幕支持相关字段
|
||||||
private Screen _currentScreen;
|
private Screen _currentScreen;
|
||||||
private bool _isMultiScreenMode = false;
|
private bool _isMultiScreenMode = false;
|
||||||
private bool _enableScreenSpecificHotkeys = true; // 是否启用基于屏幕的热键注册
|
private bool _enableScreenSpecificHotkeys = true; // 是否启用基于屏幕的热键注册
|
||||||
|
|
||||||
// 智能热键管理相关字段
|
// 智能热键管理相关字段
|
||||||
private bool _isWindowFocused = false;
|
private bool _isWindowFocused = false;
|
||||||
private bool _isMouseOverWindow = false;
|
private bool _isMouseOverWindow = false;
|
||||||
@@ -42,10 +42,10 @@ namespace Ink_Canvas.Helpers
|
|||||||
_mainWindow = mainWindow ?? throw new ArgumentNullException(nameof(mainWindow));
|
_mainWindow = mainWindow ?? throw new ArgumentNullException(nameof(mainWindow));
|
||||||
_registeredHotkeys = new Dictionary<string, HotkeyInfo>();
|
_registeredHotkeys = new Dictionary<string, HotkeyInfo>();
|
||||||
_hotkeysShouldBeRegistered = true; // 启动时注册热键
|
_hotkeysShouldBeRegistered = true; // 启动时注册热键
|
||||||
|
|
||||||
// 初始化多屏幕支持
|
// 初始化多屏幕支持
|
||||||
InitializeMultiScreenSupport();
|
InitializeMultiScreenSupport();
|
||||||
|
|
||||||
// 启动时确保配置文件存在
|
// 启动时确保配置文件存在
|
||||||
EnsureConfigFileExists();
|
EnsureConfigFileExists();
|
||||||
}
|
}
|
||||||
@@ -106,10 +106,10 @@ namespace Ink_Canvas.Helpers
|
|||||||
});
|
});
|
||||||
|
|
||||||
_registeredHotkeys[hotkeyName] = hotkeyInfo;
|
_registeredHotkeys[hotkeyName] = hotkeyInfo;
|
||||||
|
|
||||||
// 记录注册信息
|
// 记录注册信息
|
||||||
var screenInfo = _isMultiScreenMode ? $" (屏幕: {_currentScreen?.DeviceName})" : "";
|
var screenInfo = _isMultiScreenMode ? $" (屏幕: {_currentScreen?.DeviceName})" : "";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -506,7 +506,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_enableScreenSpecificHotkeys = true;
|
_enableScreenSpecificHotkeys = true;
|
||||||
|
|
||||||
// 如果当前在多屏幕环境下,刷新热键注册
|
// 如果当前在多屏幕环境下,刷新热键注册
|
||||||
if (_isMultiScreenMode)
|
if (_isMultiScreenMode)
|
||||||
{
|
{
|
||||||
@@ -527,7 +527,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_enableScreenSpecificHotkeys = false;
|
_enableScreenSpecificHotkeys = false;
|
||||||
|
|
||||||
// 重新注册热键(全局模式)
|
// 重新注册热键(全局模式)
|
||||||
if (_hotkeysShouldBeRegistered)
|
if (_hotkeysShouldBeRegistered)
|
||||||
{
|
{
|
||||||
@@ -599,15 +599,15 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
// 检测是否有多个屏幕
|
// 检测是否有多个屏幕
|
||||||
_isMultiScreenMode = ScreenDetectionHelper.HasMultipleScreens();
|
_isMultiScreenMode = ScreenDetectionHelper.HasMultipleScreens();
|
||||||
|
|
||||||
if (_isMultiScreenMode)
|
if (_isMultiScreenMode)
|
||||||
{
|
{
|
||||||
// 获取当前窗口所在的屏幕
|
// 获取当前窗口所在的屏幕
|
||||||
_currentScreen = ScreenDetectionHelper.GetWindowScreen(_mainWindow);
|
_currentScreen = ScreenDetectionHelper.GetWindowScreen(_mainWindow);
|
||||||
|
|
||||||
// 监听窗口位置变化事件
|
// 监听窗口位置变化事件
|
||||||
_mainWindow.LocationChanged += OnWindowLocationChanged;
|
_mainWindow.LocationChanged += OnWindowLocationChanged;
|
||||||
|
|
||||||
// 初始化智能热键管理
|
// 初始化智能热键管理
|
||||||
InitializeSmartHotkeyManagement();
|
InitializeSmartHotkeyManagement();
|
||||||
}
|
}
|
||||||
@@ -634,16 +634,16 @@ namespace Ink_Canvas.Helpers
|
|||||||
// 监听窗口焦点事件
|
// 监听窗口焦点事件
|
||||||
_mainWindow.GotFocus += OnWindowGotFocus;
|
_mainWindow.GotFocus += OnWindowGotFocus;
|
||||||
_mainWindow.LostFocus += OnWindowLostFocus;
|
_mainWindow.LostFocus += OnWindowLostFocus;
|
||||||
|
|
||||||
// 监听鼠标进入/离开事件
|
// 监听鼠标进入/离开事件
|
||||||
_mainWindow.MouseEnter += OnMouseEnterWindow;
|
_mainWindow.MouseEnter += OnMouseEnterWindow;
|
||||||
_mainWindow.MouseLeave += OnMouseLeaveWindow;
|
_mainWindow.MouseLeave += OnMouseLeaveWindow;
|
||||||
|
|
||||||
// 初始化鼠标位置监控定时器
|
// 初始化鼠标位置监控定时器
|
||||||
_mousePositionTimer = new System.Windows.Threading.DispatcherTimer();
|
_mousePositionTimer = new System.Windows.Threading.DispatcherTimer();
|
||||||
_mousePositionTimer.Interval = TimeSpan.FromMilliseconds(500); // 每500ms检查一次
|
_mousePositionTimer.Interval = TimeSpan.FromMilliseconds(500); // 每500ms检查一次
|
||||||
_mousePositionTimer.Tick += OnMousePositionTimerTick;
|
_mousePositionTimer.Tick += OnMousePositionTimerTick;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -665,7 +665,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
if (newScreen != null && newScreen != _currentScreen)
|
if (newScreen != null && newScreen != _currentScreen)
|
||||||
{
|
{
|
||||||
_currentScreen = newScreen;
|
_currentScreen = newScreen;
|
||||||
|
|
||||||
// 重新注册热键以适应新屏幕
|
// 重新注册热键以适应新屏幕
|
||||||
RefreshHotkeysForCurrentScreen();
|
RefreshHotkeysForCurrentScreen();
|
||||||
}
|
}
|
||||||
@@ -691,7 +691,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
|
|
||||||
// 重新注册热键
|
// 重新注册热键
|
||||||
LoadHotkeysFromSettings();
|
LoadHotkeysFromSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -776,12 +776,12 @@ namespace Ink_Canvas.Helpers
|
|||||||
// 检查鼠标是否在当前窗口所在的屏幕上
|
// 检查鼠标是否在当前窗口所在的屏幕上
|
||||||
var mousePosition = Control.MousePosition;
|
var mousePosition = Control.MousePosition;
|
||||||
var currentScreen = Screen.FromPoint(mousePosition);
|
var currentScreen = Screen.FromPoint(mousePosition);
|
||||||
|
|
||||||
// 无论屏幕是否变化,都检查热键状态
|
// 无论屏幕是否变化,都检查热键状态
|
||||||
// 这样可以确保热键状态始终与当前上下文保持一致
|
// 这样可以确保热键状态始终与当前上下文保持一致
|
||||||
bool shouldEnableHotkeys = ShouldEnableHotkeysBasedOnContext();
|
bool shouldEnableHotkeys = ShouldEnableHotkeysBasedOnContext();
|
||||||
bool currentlyHasHotkeys = _registeredHotkeys.Count > 0;
|
bool currentlyHasHotkeys = _registeredHotkeys.Count > 0;
|
||||||
|
|
||||||
if (shouldEnableHotkeys && !currentlyHasHotkeys)
|
if (shouldEnableHotkeys && !currentlyHasHotkeys)
|
||||||
{
|
{
|
||||||
UpdateHotkeyStateBasedOnContext();
|
UpdateHotkeyStateBasedOnContext();
|
||||||
@@ -808,7 +808,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bool shouldEnableHotkeys = ShouldEnableHotkeysBasedOnContext();
|
bool shouldEnableHotkeys = ShouldEnableHotkeysBasedOnContext();
|
||||||
|
|
||||||
if (shouldEnableHotkeys)
|
if (shouldEnableHotkeys)
|
||||||
{
|
{
|
||||||
// 如果热键未注册,则注册
|
// 如果热键未注册,则注册
|
||||||
@@ -823,7 +823,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
if (_registeredHotkeys.Count > 0)
|
if (_registeredHotkeys.Count > 0)
|
||||||
{
|
{
|
||||||
UnregisterAllHotkeys();
|
UnregisterAllHotkeys();
|
||||||
|
|
||||||
// 注意:这里不设置 _hotkeysShouldBeRegistered = false
|
// 注意:这里不设置 _hotkeysShouldBeRegistered = false
|
||||||
// 因为我们需要保持热键系统的启用状态,只是暂时注销热键
|
// 因为我们需要保持热键系统的启用状态,只是暂时注销热键
|
||||||
// 这样当上下文变化时,热键可以重新注册
|
// 这样当上下文变化时,热键可以重新注册
|
||||||
@@ -882,7 +882,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
var mousePosition = Control.MousePosition;
|
var mousePosition = Control.MousePosition;
|
||||||
var mouseScreen = Screen.FromPoint(mousePosition);
|
var mouseScreen = Screen.FromPoint(mousePosition);
|
||||||
|
|
||||||
if (mouseScreen == _currentScreen)
|
if (mouseScreen == _currentScreen)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -1344,14 +1344,14 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
// 注销所有快捷键
|
// 注销所有快捷键
|
||||||
UnregisterAllHotkeys();
|
UnregisterAllHotkeys();
|
||||||
|
|
||||||
// 停止定时器
|
// 停止定时器
|
||||||
if (_mousePositionTimer != null)
|
if (_mousePositionTimer != null)
|
||||||
{
|
{
|
||||||
_mousePositionTimer.Stop();
|
_mousePositionTimer.Stop();
|
||||||
_mousePositionTimer = null;
|
_mousePositionTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除事件监听器
|
// 移除事件监听器
|
||||||
if (_mainWindow != null)
|
if (_mainWindow != null)
|
||||||
{
|
{
|
||||||
@@ -1359,7 +1359,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
_mainWindow.LocationChanged -= OnWindowLocationChanged;
|
_mainWindow.LocationChanged -= OnWindowLocationChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
_mainWindow.GotFocus -= OnWindowGotFocus;
|
_mainWindow.GotFocus -= OnWindowGotFocus;
|
||||||
_mainWindow.LostFocus -= OnWindowLostFocus;
|
_mainWindow.LostFocus -= OnWindowLostFocus;
|
||||||
_mainWindow.MouseEnter -= OnMouseEnterWindow;
|
_mainWindow.MouseEnter -= OnMouseEnterWindow;
|
||||||
|
|||||||
@@ -77,40 +77,40 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
// 保存用户设置的异步处理偏好
|
// 保存用户设置的异步处理偏好
|
||||||
bool userAsyncPreference = UseAsyncProcessing;
|
bool userAsyncPreference = UseAsyncProcessing;
|
||||||
|
|
||||||
switch (Quality)
|
switch (Quality)
|
||||||
{
|
{
|
||||||
case SmoothingQuality.Performance:
|
case SmoothingQuality.Performance:
|
||||||
SmoothingStrength = 0.15;
|
SmoothingStrength = 0.15;
|
||||||
ResampleInterval = 5.0;
|
ResampleInterval = 5.0;
|
||||||
InterpolationSteps = 4;
|
InterpolationSteps = 4;
|
||||||
UseAdaptiveInterpolation = false;
|
UseAdaptiveInterpolation = false;
|
||||||
CurveTension = 0.15;
|
CurveTension = 0.15;
|
||||||
MaxConcurrentTasks = Math.Max(1, Environment.ProcessorCount / 2);
|
MaxConcurrentTasks = Math.Max(1, Environment.ProcessorCount / 2);
|
||||||
UseHardwareAcceleration = true;
|
UseHardwareAcceleration = true;
|
||||||
UseAsyncProcessing = userAsyncPreference;
|
UseAsyncProcessing = userAsyncPreference;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmoothingQuality.Balanced:
|
case SmoothingQuality.Balanced:
|
||||||
SmoothingStrength = 0.3;
|
SmoothingStrength = 0.3;
|
||||||
ResampleInterval = 3.0;
|
ResampleInterval = 3.0;
|
||||||
InterpolationSteps = 8;
|
InterpolationSteps = 8;
|
||||||
UseAdaptiveInterpolation = true;
|
UseAdaptiveInterpolation = true;
|
||||||
CurveTension = 0.25;
|
CurveTension = 0.25;
|
||||||
MaxConcurrentTasks = Environment.ProcessorCount;
|
MaxConcurrentTasks = Environment.ProcessorCount;
|
||||||
UseHardwareAcceleration = true;
|
UseHardwareAcceleration = true;
|
||||||
UseAsyncProcessing = userAsyncPreference;
|
UseAsyncProcessing = userAsyncPreference;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmoothingQuality.Quality:
|
case SmoothingQuality.Quality:
|
||||||
SmoothingStrength = 0.5;
|
SmoothingStrength = 0.5;
|
||||||
ResampleInterval = 2.0;
|
ResampleInterval = 2.0;
|
||||||
InterpolationSteps = 15;
|
InterpolationSteps = 15;
|
||||||
UseAdaptiveInterpolation = true;
|
UseAdaptiveInterpolation = true;
|
||||||
CurveTension = 0.35;
|
CurveTension = 0.35;
|
||||||
MaxConcurrentTasks = Environment.ProcessorCount;
|
MaxConcurrentTasks = Environment.ProcessorCount;
|
||||||
UseHardwareAcceleration = true;
|
UseHardwareAcceleration = true;
|
||||||
UseAsyncProcessing = userAsyncPreference;
|
UseAsyncProcessing = userAsyncPreference;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
private readonly object _lockObject = new object();
|
private readonly object _lockObject = new object();
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
private string _currentActivePresentationId = "";
|
private string _currentActivePresentationId = "";
|
||||||
|
|
||||||
// 墨迹备份机制
|
// 墨迹备份机制
|
||||||
private readonly Dictionary<string, Dictionary<int, StrokeCollection>> _strokeBackups;
|
private readonly Dictionary<string, Dictionary<int, StrokeCollection>> _strokeBackups;
|
||||||
private DateTime _lastBackupTime = DateTime.MinValue;
|
private DateTime _lastBackupTime = DateTime.MinValue;
|
||||||
@@ -55,7 +55,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var presentationId = GeneratePresentationId(presentation);
|
var presentationId = GeneratePresentationId(presentation);
|
||||||
|
|
||||||
// 如果已存在该演示文稿的管理器,先清理
|
// 如果已存在该演示文稿的管理器,先清理
|
||||||
if (_presentationManagers.ContainsKey(presentationId))
|
if (_presentationManagers.ContainsKey(presentationId))
|
||||||
{
|
{
|
||||||
@@ -104,11 +104,11 @@ namespace Ink_Canvas.Helpers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var presentationId = GeneratePresentationId(presentation);
|
var presentationId = GeneratePresentationId(presentation);
|
||||||
|
|
||||||
if (_presentationManagers.ContainsKey(presentationId))
|
if (_presentationManagers.ContainsKey(presentationId))
|
||||||
{
|
{
|
||||||
// 如果切换的是不同的演示文稿,先保存当前活跃演示文稿的墨迹
|
// 如果切换的是不同的演示文稿,先保存当前活跃演示文稿的墨迹
|
||||||
if (!string.IsNullOrEmpty(_currentActivePresentationId) &&
|
if (!string.IsNullOrEmpty(_currentActivePresentationId) &&
|
||||||
_currentActivePresentationId != presentationId)
|
_currentActivePresentationId != presentationId)
|
||||||
{
|
{
|
||||||
var currentManager = GetCurrentManager();
|
var currentManager = GetCurrentManager();
|
||||||
@@ -132,7 +132,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
_currentActivePresentationId = presentationId;
|
_currentActivePresentationId = presentationId;
|
||||||
|
|
||||||
// 更新最后访问时间
|
// 更新最后访问时间
|
||||||
if (_presentationInfos.ContainsKey(presentationId))
|
if (_presentationInfos.ContainsKey(presentationId))
|
||||||
{
|
{
|
||||||
@@ -176,13 +176,13 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
// 保存到管理器
|
// 保存到管理器
|
||||||
manager.SaveCurrentSlideStrokes(slideIndex, strokes);
|
manager.SaveCurrentSlideStrokes(slideIndex, strokes);
|
||||||
|
|
||||||
// 只有在保存成功后才创建备份
|
// 只有在保存成功后才创建备份
|
||||||
if (!string.IsNullOrEmpty(_currentActivePresentationId))
|
if (!string.IsNullOrEmpty(_currentActivePresentationId))
|
||||||
{
|
{
|
||||||
CreateStrokeBackup(_currentActivePresentationId, slideIndex, strokes);
|
CreateStrokeBackup(_currentActivePresentationId, slideIndex, strokes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否需要执行定期备份
|
// 检查是否需要执行定期备份
|
||||||
CheckAndPerformBackup();
|
CheckAndPerformBackup();
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
if (manager != null)
|
if (manager != null)
|
||||||
{
|
{
|
||||||
var strokes = manager.LoadSlideStrokes(slideIndex);
|
var strokes = manager.LoadSlideStrokes(slideIndex);
|
||||||
|
|
||||||
// 如果从管理器加载失败,尝试从备份恢复
|
// 如果从管理器加载失败,尝试从备份恢复
|
||||||
if (strokes == null || strokes.Count == 0)
|
if (strokes == null || strokes.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -242,14 +242,14 @@ namespace Ink_Canvas.Helpers
|
|||||||
strokes = RestoreStrokeFromBackup(_currentActivePresentationId, slideIndex);
|
strokes = RestoreStrokeFromBackup(_currentActivePresentationId, slideIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strokes ?? new StrokeCollection();
|
return strokes ?? new StrokeCollection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"加载页面墨迹失败: {ex}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"加载页面墨迹失败: {ex}", LogHelper.LogType.Error);
|
||||||
|
|
||||||
// 尝试从备份恢复
|
// 尝试从备份恢复
|
||||||
if (!string.IsNullOrEmpty(_currentActivePresentationId))
|
if (!string.IsNullOrEmpty(_currentActivePresentationId))
|
||||||
{
|
{
|
||||||
@@ -464,12 +464,12 @@ namespace Ink_Canvas.Helpers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var presentationId = GeneratePresentationId(presentation);
|
var presentationId = GeneratePresentationId(presentation);
|
||||||
|
|
||||||
if (_presentationManagers.ContainsKey(presentationId))
|
if (_presentationManagers.ContainsKey(presentationId))
|
||||||
{
|
{
|
||||||
// 保存墨迹到文件
|
// 保存墨迹到文件
|
||||||
_presentationManagers[presentationId].SaveAllStrokesToFile(presentation);
|
_presentationManagers[presentationId].SaveAllStrokesToFile(presentation);
|
||||||
|
|
||||||
// 释放资源
|
// 释放资源
|
||||||
_presentationManagers[presentationId].Dispose();
|
_presentationManagers[presentationId].Dispose();
|
||||||
_presentationManagers.Remove(presentationId);
|
_presentationManagers.Remove(presentationId);
|
||||||
@@ -550,13 +550,13 @@ namespace Ink_Canvas.Helpers
|
|||||||
_presentationManagers.Remove(id);
|
_presentationManagers.Remove(id);
|
||||||
}
|
}
|
||||||
_presentationInfos.Remove(id);
|
_presentationInfos.Remove(id);
|
||||||
|
|
||||||
// 清理备份数据
|
// 清理备份数据
|
||||||
if (_strokeBackups.ContainsKey(id))
|
if (_strokeBackups.ContainsKey(id))
|
||||||
{
|
{
|
||||||
_strokeBackups.Remove(id);
|
_strokeBackups.Remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogHelper.WriteLogToFile($"已清理非活跃演示文稿: {id}", LogHelper.LogType.Trace);
|
LogHelper.WriteLogToFile($"已清理非活跃演示文稿: {id}", LogHelper.LogType.Trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -589,7 +589,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
|
|
||||||
// 创建新的备份
|
// 创建新的备份
|
||||||
_strokeBackups[presentationId][slideIndex] = strokes.Clone();
|
_strokeBackups[presentationId][slideIndex] = strokes.Clone();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -604,7 +604,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_strokeBackups.ContainsKey(presentationId) &&
|
if (_strokeBackups.ContainsKey(presentationId) &&
|
||||||
_strokeBackups[presentationId].ContainsKey(slideIndex))
|
_strokeBackups[presentationId].ContainsKey(slideIndex))
|
||||||
{
|
{
|
||||||
var backup = _strokeBackups[presentationId][slideIndex];
|
var backup = _strokeBackups[presentationId][slideIndex];
|
||||||
@@ -631,7 +631,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
|
|
||||||
// 检查是否需要执行备份
|
// 检查是否需要执行备份
|
||||||
if (now - _lastBackupTime < TimeSpan.FromMinutes(BackupIntervalMinutes))
|
if (now - _lastBackupTime < TimeSpan.FromMinutes(BackupIntervalMinutes))
|
||||||
{
|
{
|
||||||
@@ -639,7 +639,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 备份当前活跃演示文稿的所有墨迹
|
// 备份当前活跃演示文稿的所有墨迹
|
||||||
if (!string.IsNullOrEmpty(_currentActivePresentationId) &&
|
if (!string.IsNullOrEmpty(_currentActivePresentationId) &&
|
||||||
_presentationManagers.ContainsKey(_currentActivePresentationId))
|
_presentationManagers.ContainsKey(_currentActivePresentationId))
|
||||||
{
|
{
|
||||||
var manager = _presentationManagers[_currentActivePresentationId];
|
var manager = _presentationManagers[_currentActivePresentationId];
|
||||||
@@ -661,7 +661,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
#region Private Methods
|
#region Private Methods
|
||||||
private PPTInkManager GetCurrentManager()
|
private PPTInkManager GetCurrentManager()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_currentActivePresentationId) ||
|
if (string.IsNullOrEmpty(_currentActivePresentationId) ||
|
||||||
!_presentationManagers.ContainsKey(_currentActivePresentationId))
|
!_presentationManagers.ContainsKey(_currentActivePresentationId))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@@ -780,7 +780,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
}
|
}
|
||||||
_presentationManagers.Clear();
|
_presentationManagers.Clear();
|
||||||
_presentationInfos.Clear();
|
_presentationInfos.Clear();
|
||||||
|
|
||||||
// 清理备份数据
|
// 清理备份数据
|
||||||
foreach (var backupDict in _strokeBackups.Values)
|
foreach (var backupDict in _strokeBackups.Values)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
private bool _needsRedraw = true;
|
private bool _needsRedraw = true;
|
||||||
private int _lastPointCount = 0;
|
private int _lastPointCount = 0;
|
||||||
private const int REDRAW_THRESHOLD = 3;
|
private const int REDRAW_THRESHOLD = 3;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建显示笔迹的类
|
/// 创建显示笔迹的类
|
||||||
@@ -53,7 +53,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
public StrokeVisual(DrawingAttributes drawingAttributes)
|
public StrokeVisual(DrawingAttributes drawingAttributes)
|
||||||
{
|
{
|
||||||
_drawingAttributes = drawingAttributes;
|
_drawingAttributes = drawingAttributes;
|
||||||
|
|
||||||
// 启用硬件加速
|
// 启用硬件加速
|
||||||
RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality);
|
RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality);
|
||||||
RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
|
RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
|
||||||
@@ -82,7 +82,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
Stroke.StylusPoints.Add(point);
|
Stroke.StylusPoints.Add(point);
|
||||||
_lastPointCount++;
|
_lastPointCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 标记需要重绘
|
// 标记需要重绘
|
||||||
_needsRedraw = true;
|
_needsRedraw = true;
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
public void Redraw()
|
public void Redraw()
|
||||||
{
|
{
|
||||||
if (!_needsRedraw || Stroke == null) return;
|
if (!_needsRedraw || Stroke == null) return;
|
||||||
|
|
||||||
if (_lastPointCount % REDRAW_THRESHOLD != 0 && _lastPointCount > REDRAW_THRESHOLD)
|
if (_lastPointCount % REDRAW_THRESHOLD != 0 && _lastPointCount > REDRAW_THRESHOLD)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ namespace Ink_Canvas.Helpers
|
|||||||
private DateTime _inkLockUntil = DateTime.MinValue;
|
private DateTime _inkLockUntil = DateTime.MinValue;
|
||||||
private int _lockedSlideIndex = -1;
|
private int _lockedSlideIndex = -1;
|
||||||
private const int InkLockMilliseconds = 500;
|
private const int InkLockMilliseconds = 500;
|
||||||
|
|
||||||
// 添加快速切换保护机制
|
// 添加快速切换保护机制
|
||||||
private DateTime _lastSwitchTime = DateTime.MinValue;
|
private DateTime _lastSwitchTime = DateTime.MinValue;
|
||||||
private int _lastSwitchSlideIndex = -1;
|
private int _lastSwitchSlideIndex = -1;
|
||||||
private const int MinSwitchIntervalMs = 100; // 最小切换间隔100毫秒
|
private const int MinSwitchIntervalMs = 100; // 最小切换间隔100毫秒
|
||||||
|
|
||||||
// 内存管理相关字段
|
// 内存管理相关字段
|
||||||
private long _totalMemoryUsage = 0;
|
private long _totalMemoryUsage = 0;
|
||||||
private const long MaxMemoryUsageBytes = 100 * 1024 * 1024; // 100MB限制
|
private const long MaxMemoryUsageBytes = 100 * 1024 * 1024; // 100MB限制
|
||||||
@@ -90,7 +90,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
_memoryStreams = new MemoryStream[slideCount + 2];
|
_memoryStreams = new MemoryStream[slideCount + 2];
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
// 检查快速切换保护
|
// 检查快速切换保护
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
if (now - _lastSwitchTime < TimeSpan.FromMilliseconds(MinSwitchIntervalMs) &&
|
if (now - _lastSwitchTime < TimeSpan.FromMilliseconds(MinSwitchIntervalMs) &&
|
||||||
_lastSwitchSlideIndex == slideIndex)
|
_lastSwitchSlideIndex == slideIndex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"快速切换保护:忽略重复的页面切换请求 {slideIndex}", LogHelper.LogType.Warning);
|
LogHelper.WriteLogToFile($"快速切换保护:忽略重复的页面切换请求 {slideIndex}", LogHelper.LogType.Warning);
|
||||||
@@ -251,11 +251,11 @@ namespace Ink_Canvas.Helpers
|
|||||||
|
|
||||||
// 加载新页面的墨迹
|
// 加载新页面的墨迹
|
||||||
var newStrokes = LoadSlideStrokes(slideIndex);
|
var newStrokes = LoadSlideStrokes(slideIndex);
|
||||||
|
|
||||||
// 更新切换记录
|
// 更新切换记录
|
||||||
_lastSwitchTime = now;
|
_lastSwitchTime = now;
|
||||||
_lastSwitchSlideIndex = slideIndex;
|
_lastSwitchSlideIndex = slideIndex;
|
||||||
|
|
||||||
if (newStrokes.Count > 0)
|
if (newStrokes.Count > 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
// 保存所有页面的墨迹
|
// 保存所有页面的墨迹
|
||||||
int savedCount = 0;
|
int savedCount = 0;
|
||||||
int slideCount = 0;
|
int slideCount = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
slideCount = presentation.Slides.Count;
|
slideCount = presentation.Slides.Count;
|
||||||
@@ -308,13 +308,13 @@ namespace Ink_Canvas.Helpers
|
|||||||
catch (COMException comEx)
|
catch (COMException comEx)
|
||||||
{
|
{
|
||||||
var hr = (uint)comEx.HResult;
|
var hr = (uint)comEx.HResult;
|
||||||
if (hr == 0x80048010)
|
if (hr == 0x80048010)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i <= slideCount && i < _memoryStreams.Length; i++)
|
for (int i = 1; i <= slideCount && i < _memoryStreams.Length; i++)
|
||||||
{
|
{
|
||||||
if (_memoryStreams[i] != null)
|
if (_memoryStreams[i] != null)
|
||||||
@@ -430,7 +430,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
_memoryStreams[i] = null;
|
_memoryStreams[i] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新初始化数组
|
// 重新初始化数组
|
||||||
_memoryStreams = new MemoryStream[_maxSlides + 2];
|
_memoryStreams = new MemoryStream[_maxSlides + 2];
|
||||||
}
|
}
|
||||||
@@ -464,20 +464,20 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果当前页面与锁定页面相同,允许写入(用户在当前页面绘制)
|
// 如果当前页面与锁定页面相同,允许写入(用户在当前页面绘制)
|
||||||
if (currentSlideIndex == _lockedSlideIndex)
|
if (currentSlideIndex == _lockedSlideIndex)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果当前页面不是锁定页面,但锁定时间很短(小于50ms),允许写入
|
// 如果当前页面不是锁定页面,但锁定时间很短(小于50ms),允许写入
|
||||||
// 这样可以确保旧页面的墨迹能够及时保存
|
// 这样可以确保旧页面的墨迹能够及时保存
|
||||||
if (DateTime.Now - (_inkLockUntil.AddMilliseconds(-InkLockMilliseconds)) < TimeSpan.FromMilliseconds(50))
|
if (DateTime.Now - (_inkLockUntil.AddMilliseconds(-InkLockMilliseconds)) < TimeSpan.FromMilliseconds(50))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只有在快速切换且页面不同时才锁定
|
// 只有在快速切换且页面不同时才锁定
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -504,7 +504,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
|
|
||||||
// 检查是否需要执行内存清理
|
// 检查是否需要执行内存清理
|
||||||
if (now - _lastMemoryCleanup < TimeSpan.FromMinutes(MemoryCleanupIntervalMinutes))
|
if (now - _lastMemoryCleanup < TimeSpan.FromMinutes(MemoryCleanupIntervalMinutes))
|
||||||
{
|
{
|
||||||
@@ -530,10 +530,10 @@ namespace Ink_Canvas.Helpers
|
|||||||
if (currentMemoryUsage > MaxMemoryUsageBytes)
|
if (currentMemoryUsage > MaxMemoryUsageBytes)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"内存使用量超限 ({currentMemoryUsage / 1024 / 1024}MB),开始清理", LogHelper.LogType.Warning);
|
LogHelper.WriteLogToFile($"内存使用量超限 ({currentMemoryUsage / 1024 / 1024}MB),开始清理", LogHelper.LogType.Warning);
|
||||||
|
|
||||||
// 清理非当前页面的墨迹
|
// 清理非当前页面的墨迹
|
||||||
CleanupInactiveSlideStrokes();
|
CleanupInactiveSlideStrokes();
|
||||||
|
|
||||||
_lastMemoryCleanup = now;
|
_lastMemoryCleanup = now;
|
||||||
LogHelper.WriteLogToFile($"内存清理完成,当前使用量: {_totalMemoryUsage / 1024 / 1024}MB", LogHelper.LogType.Trace);
|
LogHelper.WriteLogToFile($"内存清理完成,当前使用量: {_totalMemoryUsage / 1024 / 1024}MB", LogHelper.LogType.Trace);
|
||||||
}
|
}
|
||||||
@@ -571,7 +571,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
if (_memoryStreams[i] != null)
|
if (_memoryStreams[i] != null)
|
||||||
{
|
{
|
||||||
long memorySize = _memoryStreams[i].Length;
|
long memorySize = _memoryStreams[i].Length;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_memoryStreams[i].Dispose();
|
_memoryStreams[i].Dispose();
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ namespace Ink_Canvas.Helpers
|
|||||||
_dispatcher.BeginInvoke(new Action(() =>
|
_dispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
MainWindow.MoveWindow(new WindowInteropHelper(_mainWindow).Handle, 0, 0,
|
MainWindow.MoveWindow(new WindowInteropHelper(_mainWindow).Handle, 0, 0,
|
||||||
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
|
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
|
||||||
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, true);
|
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, true);
|
||||||
}), DispatcherPriority.ApplicationIdle);
|
}), DispatcherPriority.ApplicationIdle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,12 +118,12 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
// 恢复为非画板模式,重新启用全屏限制
|
// 恢复为非画板模式,重新启用全屏限制
|
||||||
AvoidFullScreenHelper.SetBoardMode(false);
|
AvoidFullScreenHelper.SetBoardMode(false);
|
||||||
|
|
||||||
_dispatcher.BeginInvoke(new Action(() =>
|
_dispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
// 退出PPT放映模式,恢复到工作区域大小
|
// 退出PPT放映模式,恢复到工作区域大小
|
||||||
var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
|
var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
|
||||||
MainWindow.MoveWindow(new WindowInteropHelper(_mainWindow).Handle,
|
MainWindow.MoveWindow(new WindowInteropHelper(_mainWindow).Handle,
|
||||||
workingArea.X, workingArea.Y,
|
workingArea.X, workingArea.Y,
|
||||||
workingArea.Width, workingArea.Height, true);
|
workingArea.Width, workingArea.Height, true);
|
||||||
}), DispatcherPriority.ApplicationIdle);
|
}), DispatcherPriority.ApplicationIdle);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
|
|
||||||
// 获取窗口在屏幕上的位置
|
// 获取窗口在屏幕上的位置
|
||||||
var windowRect = GetWindowScreenBounds(window);
|
var windowRect = GetWindowScreenBounds(window);
|
||||||
|
|
||||||
// 查找与窗口重叠最多的屏幕
|
// 查找与窗口重叠最多的屏幕
|
||||||
Screen targetScreen = null;
|
Screen targetScreen = null;
|
||||||
double maxIntersection = 0;
|
double maxIntersection = 0;
|
||||||
@@ -66,10 +66,10 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
// 获取窗口左上角在屏幕上的位置
|
// 获取窗口左上角在屏幕上的位置
|
||||||
var topLeft = window.PointToScreen(new Point(0, 0));
|
var topLeft = window.PointToScreen(new Point(0, 0));
|
||||||
|
|
||||||
// 获取窗口右下角在屏幕上的位置
|
// 获取窗口右下角在屏幕上的位置
|
||||||
var bottomRight = window.PointToScreen(new Point(window.ActualWidth, window.ActualHeight));
|
var bottomRight = window.PointToScreen(new Point(window.ActualWidth, window.ActualHeight));
|
||||||
|
|
||||||
return new Rectangle(
|
return new Rectangle(
|
||||||
(int)topLeft.X,
|
(int)topLeft.X,
|
||||||
(int)topLeft.Y,
|
(int)topLeft.Y,
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ namespace Ink_Canvas
|
|||||||
//加载设置
|
//加载设置
|
||||||
LoadSettings(true);
|
LoadSettings(true);
|
||||||
AutoBackupManager.Initialize(Settings);
|
AutoBackupManager.Initialize(Settings);
|
||||||
|
|
||||||
// 检查保存路径是否可用,不可用则修正
|
// 检查保存路径是否可用,不可用则修正
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -549,7 +549,7 @@ namespace Ink_Canvas
|
|||||||
ApplyNoFocusMode();
|
ApplyNoFocusMode();
|
||||||
ToggleSwitchAlwaysOnTop.IsOn = Settings.Advanced.IsAlwaysOnTop;
|
ToggleSwitchAlwaysOnTop.IsOn = Settings.Advanced.IsAlwaysOnTop;
|
||||||
ApplyAlwaysOnTop();
|
ApplyAlwaysOnTop();
|
||||||
|
|
||||||
// 初始化剪贴板监控
|
// 初始化剪贴板监控
|
||||||
InitializeClipboardMonitoring();
|
InitializeClipboardMonitoring();
|
||||||
|
|
||||||
@@ -2696,7 +2696,7 @@ namespace Ink_Canvas
|
|||||||
if (toggle != null)
|
if (toggle != null)
|
||||||
{
|
{
|
||||||
Settings.ModeSettings.IsPPTOnlyMode = toggle.IsOn;
|
Settings.ModeSettings.IsPPTOnlyMode = toggle.IsOn;
|
||||||
|
|
||||||
// 保存设置到文件
|
// 保存设置到文件
|
||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
|
|
||||||
@@ -2788,20 +2788,20 @@ namespace Ink_Canvas
|
|||||||
private void ComboBoxTheme_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void ComboBoxTheme_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
System.Windows.Controls.ComboBox comboBox = sender as System.Windows.Controls.ComboBox;
|
System.Windows.Controls.ComboBox comboBox = sender as System.Windows.Controls.ComboBox;
|
||||||
if (comboBox != null)
|
if (comboBox != null)
|
||||||
{
|
{
|
||||||
Settings.Appearance.Theme = comboBox.SelectedIndex;
|
Settings.Appearance.Theme = comboBox.SelectedIndex;
|
||||||
|
|
||||||
// 应用新主题
|
// 应用新主题
|
||||||
ApplyTheme(comboBox.SelectedIndex);
|
ApplyTheme(comboBox.SelectedIndex);
|
||||||
|
|
||||||
// 保存设置
|
// 保存设置
|
||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
|
|
||||||
// 显示通知
|
// 显示通知
|
||||||
string themeName;
|
string themeName;
|
||||||
switch (comboBox.SelectedIndex)
|
switch (comboBox.SelectedIndex)
|
||||||
@@ -2819,7 +2819,7 @@ namespace Ink_Canvas
|
|||||||
themeName = "未知主题";
|
themeName = "未知主题";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowNotification($"已切换到{themeName}");
|
ShowNotification($"已切换到{themeName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2863,7 +2863,7 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 强制刷新通知框的颜色资源
|
// 强制刷新通知框的颜色资源
|
||||||
RefreshNotificationColors();
|
RefreshNotificationColors();
|
||||||
}
|
}
|
||||||
@@ -2872,7 +2872,7 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile($"应用主题时出错: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"应用主题时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 刷新通知框的颜色资源
|
/// 刷新通知框的颜色资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -2887,7 +2887,7 @@ namespace Ink_Canvas
|
|||||||
border.Background = (Brush)Application.Current.FindResource("SettingsPageBackground");
|
border.Background = (Brush)Application.Current.FindResource("SettingsPageBackground");
|
||||||
border.BorderBrush = new SolidColorBrush(Color.FromRgb(185, 28, 28)); // 保持红色边框
|
border.BorderBrush = new SolidColorBrush(Color.FromRgb(185, 28, 28)); // 保持红色边框
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBlockNotice.Foreground = (Brush)Application.Current.FindResource("SettingsPageForeground");
|
TextBlockNotice.Foreground = (Brush)Application.Current.FindResource("SettingsPageForeground");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ namespace Ink_Canvas
|
|||||||
var resourcesToRemove = new List<ResourceDictionary>();
|
var resourcesToRemove = new List<ResourceDictionary>();
|
||||||
foreach (var dict in Application.Current.Resources.MergedDictionaries)
|
foreach (var dict in Application.Current.Resources.MergedDictionaries)
|
||||||
{
|
{
|
||||||
if (dict.Source != null &&
|
if (dict.Source != null &&
|
||||||
(dict.Source.ToString().Contains("Light.xaml") ||
|
(dict.Source.ToString().Contains("Light.xaml") ||
|
||||||
dict.Source.ToString().Contains("Dark.xaml")))
|
dict.Source.ToString().Contains("Dark.xaml")))
|
||||||
{
|
{
|
||||||
resourcesToRemove.Add(dict);
|
resourcesToRemove.Add(dict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var dict in resourcesToRemove)
|
foreach (var dict in resourcesToRemove)
|
||||||
{
|
{
|
||||||
Application.Current.Resources.MergedDictionaries.Remove(dict);
|
Application.Current.Resources.MergedDictionaries.Remove(dict);
|
||||||
@@ -36,7 +36,7 @@ namespace Ink_Canvas
|
|||||||
var rd1 = new ResourceDictionary
|
var rd1 = new ResourceDictionary
|
||||||
{ Source = new Uri("Resources/Styles/Light.xaml", UriKind.Relative) };
|
{ Source = new Uri("Resources/Styles/Light.xaml", UriKind.Relative) };
|
||||||
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
||||||
|
|
||||||
// 在主题资源之后添加其他资源
|
// 在主题资源之后添加其他资源
|
||||||
var rd2 = new ResourceDictionary
|
var rd2 = new ResourceDictionary
|
||||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||||
@@ -53,10 +53,10 @@ namespace Ink_Canvas
|
|||||||
ThemeManager.SetRequestedTheme(window, ElementTheme.Light);
|
ThemeManager.SetRequestedTheme(window, ElementTheme.Light);
|
||||||
|
|
||||||
InitializeFloatBarForegroundColor();
|
InitializeFloatBarForegroundColor();
|
||||||
|
|
||||||
// 刷新快速面板图标
|
// 刷新快速面板图标
|
||||||
RefreshQuickPanelIcons();
|
RefreshQuickPanelIcons();
|
||||||
|
|
||||||
// 强制刷新UI
|
// 强制刷新UI
|
||||||
window.InvalidateVisual();
|
window.InvalidateVisual();
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
var rd1 = new ResourceDictionary { Source = new Uri("Resources/Styles/Dark.xaml", UriKind.Relative) };
|
var rd1 = new ResourceDictionary { Source = new Uri("Resources/Styles/Dark.xaml", UriKind.Relative) };
|
||||||
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
||||||
|
|
||||||
// 在主题资源之后添加其他资源
|
// 在主题资源之后添加其他资源
|
||||||
var rd2 = new ResourceDictionary
|
var rd2 = new ResourceDictionary
|
||||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||||
@@ -81,10 +81,10 @@ namespace Ink_Canvas
|
|||||||
ThemeManager.SetRequestedTheme(window, ElementTheme.Dark);
|
ThemeManager.SetRequestedTheme(window, ElementTheme.Dark);
|
||||||
|
|
||||||
InitializeFloatBarForegroundColor();
|
InitializeFloatBarForegroundColor();
|
||||||
|
|
||||||
// 刷新快速面板图标
|
// 刷新快速面板图标
|
||||||
RefreshQuickPanelIcons();
|
RefreshQuickPanelIcons();
|
||||||
|
|
||||||
// 强制刷新UI
|
// 强制刷新UI
|
||||||
window.InvalidateVisual();
|
window.InvalidateVisual();
|
||||||
}
|
}
|
||||||
@@ -98,17 +98,17 @@ namespace Ink_Canvas
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
FloatBarForegroundColor = (Color)Application.Current.FindResource("FloatBarForegroundColor");
|
FloatBarForegroundColor = (Color)Application.Current.FindResource("FloatBarForegroundColor");
|
||||||
|
|
||||||
// 强制刷新浮动工具栏按钮颜色
|
// 强制刷新浮动工具栏按钮颜色
|
||||||
RefreshFloatingBarButtonColors();
|
RefreshFloatingBarButtonColors();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// 如果无法从资源中加载,使用默认颜色
|
// 如果无法从资源中加载,使用默认颜色
|
||||||
FloatBarForegroundColor = Color.FromRgb(0, 0, 0);
|
FloatBarForegroundColor = Color.FromRgb(0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 刷新快速面板图标
|
/// 刷新快速面板图标
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -147,7 +147,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 选中状态的颜色(蓝底)
|
// 选中状态的颜色(蓝底)
|
||||||
var selectedColor = Color.FromRgb(30, 58, 138);
|
var selectedColor = Color.FromRgb(30, 58, 138);
|
||||||
|
|
||||||
// 根据当前模式设置按钮颜色
|
// 根据当前模式设置按钮颜色
|
||||||
switch (_currentToolMode)
|
switch (_currentToolMode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ namespace Ink_Canvas
|
|||||||
private StrokeCollection lastTouchDownStrokeCollection = new StrokeCollection();
|
private StrokeCollection lastTouchDownStrokeCollection = new StrokeCollection();
|
||||||
private int CurrentWhiteboardIndex = 1;
|
private int CurrentWhiteboardIndex = 1;
|
||||||
private int WhiteboardTotalCount = 1;
|
private int WhiteboardTotalCount = 1;
|
||||||
private TimeMachineHistory[][] TimeMachineHistories = new TimeMachineHistory[101][];
|
private TimeMachineHistory[][] TimeMachineHistories = new TimeMachineHistory[101][];
|
||||||
private bool[] savedMultiTouchModeStates = new bool[101];
|
private bool[] savedMultiTouchModeStates = new bool[101];
|
||||||
|
|
||||||
// 保存每页白板图片信息
|
// 保存每页白板图片信息
|
||||||
private void SaveStrokes(bool isBackupMain = false)
|
private void SaveStrokes(bool isBackupMain = false)
|
||||||
@@ -197,20 +197,20 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 恢复多指书写模式
|
// 恢复多指书写模式
|
||||||
EnterMultiTouchModeIfNeeded();
|
EnterMultiTouchModeIfNeeded();
|
||||||
|
|
||||||
// 更新UI状态
|
// 更新UI状态
|
||||||
if (ToggleSwitchEnableMultiTouchMode != null)
|
if (ToggleSwitchEnableMultiTouchMode != null)
|
||||||
{
|
{
|
||||||
ToggleSwitchEnableMultiTouchMode.IsOn = true;
|
ToggleSwitchEnableMultiTouchMode.IsOn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogHelper.WriteLogToFile($"恢复多指书写模式状态 - 页面索引: {pageIndex}", LogHelper.LogType.Info);
|
LogHelper.WriteLogToFile($"恢复多指书写模式状态 - 页面索引: {pageIndex}", LogHelper.LogType.Info);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 确保多指书写模式关闭
|
// 确保多指书写模式关闭
|
||||||
ExitMultiTouchModeIfNeeded();
|
ExitMultiTouchModeIfNeeded();
|
||||||
|
|
||||||
// 更新UI状态
|
// 更新UI状态
|
||||||
if (ToggleSwitchEnableMultiTouchMode != null)
|
if (ToggleSwitchEnableMultiTouchMode != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1585,7 +1585,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
isResizingImage = true;
|
isResizingImage = true;
|
||||||
imageResizeStartPoint = e.GetPosition(inkCanvas);
|
imageResizeStartPoint = e.GetPosition(inkCanvas);
|
||||||
|
|
||||||
// 确定是哪个控制点
|
// 确定是哪个控制点
|
||||||
activeResizeHandle = ellipse.Name;
|
activeResizeHandle = ellipse.Name;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Ink_Canvas.Helpers;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -46,29 +45,35 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 绑定事件处理
|
// 绑定事件处理
|
||||||
canvas.StylusDown += ((o, args) => {
|
canvas.StylusDown += ((o, args) =>
|
||||||
|
{
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
if (args.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) canvas.CaptureStylus();
|
if (args.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) canvas.CaptureStylus();
|
||||||
EraserOverlay_PointerDown(sender);
|
EraserOverlay_PointerDown(sender);
|
||||||
});
|
});
|
||||||
canvas.StylusUp += ((o, args) => {
|
canvas.StylusUp += ((o, args) =>
|
||||||
|
{
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
if (args.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) canvas.ReleaseStylusCapture();
|
if (args.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) canvas.ReleaseStylusCapture();
|
||||||
EraserOverlay_PointerUp(sender);
|
EraserOverlay_PointerUp(sender);
|
||||||
});
|
});
|
||||||
canvas.StylusMove += ((o, args) => {
|
canvas.StylusMove += ((o, args) =>
|
||||||
|
{
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
EraserOverlay_PointerMove(sender, args.GetPosition(inkCanvas));
|
EraserOverlay_PointerMove(sender, args.GetPosition(inkCanvas));
|
||||||
});
|
});
|
||||||
canvas.MouseDown += ((o, args) => {
|
canvas.MouseDown += ((o, args) =>
|
||||||
|
{
|
||||||
canvas.CaptureMouse();
|
canvas.CaptureMouse();
|
||||||
EraserOverlay_PointerDown(sender);
|
EraserOverlay_PointerDown(sender);
|
||||||
});
|
});
|
||||||
canvas.MouseUp += ((o, args) => {
|
canvas.MouseUp += ((o, args) =>
|
||||||
|
{
|
||||||
canvas.ReleaseMouseCapture();
|
canvas.ReleaseMouseCapture();
|
||||||
EraserOverlay_PointerUp(sender);
|
EraserOverlay_PointerUp(sender);
|
||||||
});
|
});
|
||||||
canvas.MouseMove += ((o, args) => {
|
canvas.MouseMove += ((o, args) =>
|
||||||
|
{
|
||||||
EraserOverlay_PointerMove(sender, args.GetPosition(inkCanvas));
|
EraserOverlay_PointerMove(sender, args.GetPosition(inkCanvas));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -86,7 +91,7 @@ namespace Ink_Canvas
|
|||||||
// 根据橡皮擦形状选择对应的图像资源
|
// 根据橡皮擦形状选择对应的图像资源
|
||||||
string resourceKey = isEraserCircleShape ? "EllipseEraserImageSource" : "RectangleEraserImageSource";
|
string resourceKey = isEraserCircleShape ? "EllipseEraserImageSource" : "RectangleEraserImageSource";
|
||||||
var imageSource = TryFindResource(resourceKey) as DrawingImage;
|
var imageSource = TryFindResource(resourceKey) as DrawingImage;
|
||||||
|
|
||||||
if (imageSource != null)
|
if (imageSource != null)
|
||||||
{
|
{
|
||||||
eraserFeedback.Source = imageSource;
|
eraserFeedback.Source = imageSource;
|
||||||
@@ -301,8 +306,8 @@ namespace Ink_Canvas
|
|||||||
if (isEraserCircleShape)
|
if (isEraserCircleShape)
|
||||||
{
|
{
|
||||||
eraserWidth = k * 90; // 圆形橡皮擦
|
eraserWidth = k * 90; // 圆形橡皮擦
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eraserWidth = k * 90 * 0.6; // 矩形橡皮擦宽度
|
eraserWidth = k * 90 * 0.6; // 矩形橡皮擦宽度
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,19 +86,19 @@ namespace Ink_Canvas
|
|||||||
// 根据主题设置颜色
|
// 根据主题设置颜色
|
||||||
if (Settings.Appearance.Theme == 1) // 深色主题
|
if (Settings.Appearance.Theme == 1) // 深色主题
|
||||||
{
|
{
|
||||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||||
BoardGestureGeometry2.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));
|
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||||
}
|
}
|
||||||
else // 浅色主题或跟随系统
|
else // 浅色主题或跟随系统
|
||||||
{
|
{
|
||||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||||
BoardGestureGeometry2.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));
|
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||||
}
|
}
|
||||||
BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.DisabledGestureIcon);
|
BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.DisabledGestureIcon);
|
||||||
BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z");
|
BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z");
|
||||||
@@ -111,10 +111,10 @@ namespace Ink_Canvas
|
|||||||
// 多指书写模式禁用时,根据实际手势功能状态显示
|
// 多指书写模式禁用时,根据实际手势功能状态显示
|
||||||
TwoFingerGestureSimpleStackPanel.Opacity = 1;
|
TwoFingerGestureSimpleStackPanel.Opacity = 1;
|
||||||
TwoFingerGestureSimpleStackPanel.IsHitTestVisible = true;
|
TwoFingerGestureSimpleStackPanel.IsHitTestVisible = true;
|
||||||
|
|
||||||
// 检查是否有任何手势功能启用
|
// 检查是否有任何手势功能启用
|
||||||
bool hasGestureEnabled = Settings.Gesture.IsEnableTwoFingerGesture;
|
bool hasGestureEnabled = Settings.Gesture.IsEnableTwoFingerGesture;
|
||||||
|
|
||||||
if (hasGestureEnabled)
|
if (hasGestureEnabled)
|
||||||
{
|
{
|
||||||
EnableTwoFingerGestureBtn.Source =
|
EnableTwoFingerGestureBtn.Source =
|
||||||
@@ -136,19 +136,19 @@ namespace Ink_Canvas
|
|||||||
// 根据主题设置颜色
|
// 根据主题设置颜色
|
||||||
if (Settings.Appearance.Theme == 1) // 深色主题
|
if (Settings.Appearance.Theme == 1) // 深色主题
|
||||||
{
|
{
|
||||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||||
BoardGestureGeometry2.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));
|
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||||
}
|
}
|
||||||
else // 浅色主题或跟随系统
|
else // 浅色主题或跟随系统
|
||||||
{
|
{
|
||||||
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||||
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||||
BoardGestureGeometry2.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));
|
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||||
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||||
}
|
}
|
||||||
BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.DisabledGestureIcon);
|
BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.DisabledGestureIcon);
|
||||||
BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z");
|
BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z");
|
||||||
@@ -443,33 +443,33 @@ namespace Ink_Canvas
|
|||||||
// 根据主题设置颜色
|
// 根据主题设置颜色
|
||||||
if (Settings.Appearance.Theme == 1) // 深色主题
|
if (Settings.Appearance.Theme == 1) // 深色主题
|
||||||
{
|
{
|
||||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
BoardPen.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||||
BoardSelect.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));
|
BoardEraser.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||||
BoardSelectGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
BoardSelectGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||||
BoardPenGeometry.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));
|
BoardEraserGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||||
BoardPenLabel.Foreground = 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));
|
BoardSelectLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||||
BoardEraserLabel.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));
|
BoardSelect.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||||
BoardEraser.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.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||||
}
|
}
|
||||||
else // 浅色主题或跟随系统
|
else // 浅色主题或跟随系统
|
||||||
{
|
{
|
||||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
BoardPen.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||||
BoardSelect.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));
|
BoardEraser.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||||
BoardSelectGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
BoardSelectGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||||
BoardPenGeometry.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));
|
BoardEraserGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||||
BoardPenLabel.Foreground = 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));
|
BoardSelectLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||||
BoardEraserLabel.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));
|
BoardSelect.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||||
BoardEraser.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.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||||
}
|
}
|
||||||
|
|
||||||
HideFloatingBarHighlight();
|
HideFloatingBarHighlight();
|
||||||
@@ -537,17 +537,17 @@ namespace Ink_Canvas
|
|||||||
// 根据主题设置颜色
|
// 根据主题设置颜色
|
||||||
if (Settings.Appearance.Theme == 1) // 深色主题
|
if (Settings.Appearance.Theme == 1) // 深色主题
|
||||||
{
|
{
|
||||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
BoardPen.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||||
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
|
||||||
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||||
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||||
}
|
}
|
||||||
else // 浅色主题或跟随系统
|
else // 浅色主题或跟随系统
|
||||||
{
|
{
|
||||||
BoardPen.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
BoardPen.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||||
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
|
||||||
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||||
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||||
}
|
}
|
||||||
|
|
||||||
SetFloatingBarHighlightPosition("cursor");
|
SetFloatingBarHighlightPosition("cursor");
|
||||||
@@ -1357,12 +1357,12 @@ namespace Ink_Canvas
|
|||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||||
inkCanvas.IsHitTestVisible = true;
|
inkCanvas.IsHitTestVisible = true;
|
||||||
inkCanvas.IsManipulationEnabled = true;
|
inkCanvas.IsManipulationEnabled = true;
|
||||||
|
|
||||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
|
if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
|
||||||
{
|
{
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetTouchStates();
|
ResetTouchStates();
|
||||||
});
|
});
|
||||||
}).Start();
|
}).Start();
|
||||||
@@ -1388,12 +1388,12 @@ namespace Ink_Canvas
|
|||||||
isStopInkReplay = true;
|
isStopInkReplay = true;
|
||||||
inkCanvas.IsHitTestVisible = true;
|
inkCanvas.IsHitTestVisible = true;
|
||||||
inkCanvas.IsManipulationEnabled = true;
|
inkCanvas.IsManipulationEnabled = true;
|
||||||
|
|
||||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
|
if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
|
||||||
{
|
{
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetTouchStates();
|
ResetTouchStates();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1975,7 +1975,7 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 禁用高级橡皮擦系统
|
// 禁用高级橡皮擦系统
|
||||||
DisableEraserOverlay();
|
DisableEraserOverlay();
|
||||||
|
|
||||||
ExitMultiTouchModeIfNeeded();
|
ExitMultiTouchModeIfNeeded();
|
||||||
|
|
||||||
@@ -2222,7 +2222,7 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 启用新的高级橡皮擦系统
|
// 启用新的高级橡皮擦系统
|
||||||
EnableEraserOverlay();
|
EnableEraserOverlay();
|
||||||
|
|
||||||
// 使用新的高级橡皮擦系统
|
// 使用新的高级橡皮擦系统
|
||||||
// 使用集中化的工具模式切换方法
|
// 使用集中化的工具模式切换方法
|
||||||
@@ -2234,7 +2234,7 @@ namespace Ink_Canvas
|
|||||||
ApplyAdvancedEraserShape(); // 使用新的橡皮擦形状应用方法
|
ApplyAdvancedEraserShape(); // 使用新的橡皮擦形状应用方法
|
||||||
SetCursorBasedOnEditingMode(inkCanvas);
|
SetCursorBasedOnEditingMode(inkCanvas);
|
||||||
HideSubPanels("eraser"); // 高亮橡皮按钮
|
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)
|
if (isAlreadyEraser)
|
||||||
{
|
{
|
||||||
@@ -2263,7 +2263,7 @@ namespace Ink_Canvas
|
|||||||
drawingShapeMode = 0;
|
drawingShapeMode = 0;
|
||||||
|
|
||||||
// 启用新的高级橡皮擦系统
|
// 启用新的高级橡皮擦系统
|
||||||
EnableEraserOverlay();
|
EnableEraserOverlay();
|
||||||
|
|
||||||
// 使用新的高级橡皮擦系统
|
// 使用新的高级橡皮擦系统
|
||||||
// 使用集中化的工具模式切换方法
|
// 使用集中化的工具模式切换方法
|
||||||
@@ -2578,7 +2578,7 @@ namespace Ink_Canvas
|
|||||||
private void SelectIcon_MouseUp(object sender, RoutedEventArgs e)
|
private void SelectIcon_MouseUp(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// 禁用高级橡皮擦系统
|
// 禁用高级橡皮擦系统
|
||||||
DisableEraserOverlay();
|
DisableEraserOverlay();
|
||||||
|
|
||||||
forceEraser = true;
|
forceEraser = true;
|
||||||
drawingShapeMode = 0;
|
drawingShapeMode = 0;
|
||||||
@@ -2687,12 +2687,12 @@ namespace Ink_Canvas
|
|||||||
if (!userChangedNoFocusModeInSettings && wasNoFocusModeBeforeSettings)
|
if (!userChangedNoFocusModeInSettings && wasNoFocusModeBeforeSettings)
|
||||||
{
|
{
|
||||||
Settings.Advanced.IsNoFocusMode = true;
|
Settings.Advanced.IsNoFocusMode = true;
|
||||||
ToggleSwitchNoFocusMode.IsOn = true;
|
ToggleSwitchNoFocusMode.IsOn = true;
|
||||||
ApplyNoFocusMode();
|
ApplyNoFocusMode();
|
||||||
}
|
}
|
||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
App.IsAppExitByUser = true;
|
App.IsAppExitByUser = true;
|
||||||
// 不设置 CloseIsFromButton = true,让它也经过确认流程
|
// 不设置 CloseIsFromButton = true,让它也经过确认流程
|
||||||
Close();
|
Close();
|
||||||
@@ -2706,12 +2706,12 @@ namespace Ink_Canvas
|
|||||||
if (!userChangedNoFocusModeInSettings && wasNoFocusModeBeforeSettings)
|
if (!userChangedNoFocusModeInSettings && wasNoFocusModeBeforeSettings)
|
||||||
{
|
{
|
||||||
Settings.Advanced.IsNoFocusMode = true;
|
Settings.Advanced.IsNoFocusMode = true;
|
||||||
ToggleSwitchNoFocusMode.IsOn = true;
|
ToggleSwitchNoFocusMode.IsOn = true;
|
||||||
ApplyNoFocusMode();
|
ApplyNoFocusMode();
|
||||||
}
|
}
|
||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m");
|
Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m");
|
||||||
App.IsAppExitByUser = true;
|
App.IsAppExitByUser = true;
|
||||||
// 不设置 CloseIsFromButton = true,让它也经过确认流程
|
// 不设置 CloseIsFromButton = true,让它也经过确认流程
|
||||||
@@ -2847,7 +2847,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 先关闭多指书写模式
|
// 先关闭多指书写模式
|
||||||
ToggleSwitchEnableMultiTouchMode.IsOn = false;
|
ToggleSwitchEnableMultiTouchMode.IsOn = false;
|
||||||
|
|
||||||
// 使用Dispatcher.BeginInvoke确保UI更新完成后再重新开启
|
// 使用Dispatcher.BeginInvoke确保UI更新完成后再重新开启
|
||||||
Dispatcher.BeginInvoke(new Action(() =>
|
Dispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
@@ -2873,7 +2873,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
ResetTouchStates();
|
ResetTouchStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重置所有触摸相关状态,
|
/// 重置所有触摸相关状态,
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -2883,8 +2883,8 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 清空触摸点计数器
|
// 清空触摸点计数器
|
||||||
dec.Clear();
|
dec.Clear();
|
||||||
|
|
||||||
|
|
||||||
// 重置单指拖动模式状态
|
// 重置单指拖动模式状态
|
||||||
if (isSingleFingerDragMode)
|
if (isSingleFingerDragMode)
|
||||||
{
|
{
|
||||||
@@ -2894,25 +2894,25 @@ namespace Ink_Canvas
|
|||||||
BtnFingerDragMode.Content = "单指\n拖动";
|
BtnFingerDragMode.Content = "单指\n拖动";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置手掌擦状态
|
// 重置手掌擦状态
|
||||||
if (isPalmEraserActive)
|
if (isPalmEraserActive)
|
||||||
{
|
{
|
||||||
isPalmEraserActive = false;
|
isPalmEraserActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确保触摸事件能正常响应
|
// 确保触摸事件能正常响应
|
||||||
inkCanvas.IsHitTestVisible = true;
|
inkCanvas.IsHitTestVisible = true;
|
||||||
inkCanvas.IsManipulationEnabled = true;
|
inkCanvas.IsManipulationEnabled = true;
|
||||||
|
|
||||||
// 释放所有触摸捕获
|
// 释放所有触摸捕获
|
||||||
inkCanvas.ReleaseAllTouchCaptures();
|
inkCanvas.ReleaseAllTouchCaptures();
|
||||||
|
|
||||||
// 恢复UI元素的触摸响应
|
// 恢复UI元素的触摸响应
|
||||||
ViewboxFloatingBar.IsHitTestVisible = true;
|
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -3007,7 +3007,7 @@ namespace Ink_Canvas
|
|||||||
// 使用异步延迟,等待浮动栏展开动画完成后再收纳
|
// 使用异步延迟,等待浮动栏展开动画完成后再收纳
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await Task.Delay(700);
|
await Task.Delay(700);
|
||||||
await Dispatcher.InvokeAsync(() =>
|
await Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
FoldFloatingBar_MouseUp(new object(), null);
|
FoldFloatingBar_MouseUp(new object(), null);
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ namespace Ink_Canvas
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_floatingWindowInterceptorManager = new FloatingWindowInterceptorManager();
|
_floatingWindowInterceptorManager = new FloatingWindowInterceptorManager();
|
||||||
|
|
||||||
// 订阅事件
|
// 订阅事件
|
||||||
_floatingWindowInterceptorManager.WindowIntercepted += OnFloatingWindowIntercepted;
|
_floatingWindowInterceptorManager.WindowIntercepted += OnFloatingWindowIntercepted;
|
||||||
_floatingWindowInterceptorManager.WindowRestored += OnFloatingWindowRestored;
|
_floatingWindowInterceptorManager.WindowRestored += OnFloatingWindowRestored;
|
||||||
|
|
||||||
// 初始化拦截器
|
// 初始化拦截器
|
||||||
_floatingWindowInterceptorManager.Initialize(Settings.Automation.FloatingWindowInterceptor);
|
_floatingWindowInterceptorManager.Initialize(Settings.Automation.FloatingWindowInterceptor);
|
||||||
|
|
||||||
// 加载UI状态
|
// 加载UI状态
|
||||||
LoadFloatingWindowInterceptorUI();
|
LoadFloatingWindowInterceptorUI();
|
||||||
|
|
||||||
LogHelper.WriteLogToFile("悬浮窗拦截管理器初始化完成", LogHelper.LogType.Event);
|
LogHelper.WriteLogToFile("悬浮窗拦截管理器初始化完成", LogHelper.LogType.Event);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -48,7 +48,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 设置主开关状态
|
// 设置主开关状态
|
||||||
ToggleSwitchFloatingWindowInterceptorEnabled.IsOn = Settings.Automation.FloatingWindowInterceptor.IsEnabled;
|
ToggleSwitchFloatingWindowInterceptorEnabled.IsOn = Settings.Automation.FloatingWindowInterceptor.IsEnabled;
|
||||||
|
|
||||||
// 设置各个拦截规则的状态
|
// 设置各个拦截规则的状态
|
||||||
foreach (var kvp in Settings.Automation.FloatingWindowInterceptor.InterceptRules)
|
foreach (var kvp in Settings.Automation.FloatingWindowInterceptor.InterceptRules)
|
||||||
{
|
{
|
||||||
@@ -59,7 +59,7 @@ namespace Ink_Canvas
|
|||||||
toggle.IsOn = kvp.Value;
|
toggle.IsOn = kvp.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新UI可见性
|
// 更新UI可见性
|
||||||
UpdateFloatingWindowInterceptorUI();
|
UpdateFloatingWindowInterceptorUI();
|
||||||
}
|
}
|
||||||
@@ -78,16 +78,16 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
var isEnabled = Settings.Automation.FloatingWindowInterceptor.IsEnabled;
|
var isEnabled = Settings.Automation.FloatingWindowInterceptor.IsEnabled;
|
||||||
FloatingWindowInterceptorGrid.Visibility = isEnabled ? Visibility.Visible : Visibility.Collapsed;
|
FloatingWindowInterceptorGrid.Visibility = isEnabled ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
|
||||||
// 计算启用的规则数量
|
// 计算启用的规则数量
|
||||||
var enabledRulesCount = Settings.Automation.FloatingWindowInterceptor.InterceptRules.Where(kvp => kvp.Value).Count();
|
var enabledRulesCount = Settings.Automation.FloatingWindowInterceptor.InterceptRules.Where(kvp => kvp.Value).Count();
|
||||||
var totalRulesCount = Settings.Automation.FloatingWindowInterceptor.InterceptRules.Count;
|
var totalRulesCount = Settings.Automation.FloatingWindowInterceptor.InterceptRules.Count;
|
||||||
|
|
||||||
// 更新状态文本
|
// 更新状态文本
|
||||||
if (_floatingWindowInterceptorManager != null)
|
if (_floatingWindowInterceptorManager != null)
|
||||||
{
|
{
|
||||||
var stats = _floatingWindowInterceptorManager.GetStatistics();
|
var stats = _floatingWindowInterceptorManager.GetStatistics();
|
||||||
TextBlockFloatingWindowInterceptorStatus.Text = stats.IsRunning
|
TextBlockFloatingWindowInterceptorStatus.Text = stats.IsRunning
|
||||||
? $"拦截器运行中 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则"
|
? $"拦截器运行中 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则"
|
||||||
: $"拦截器未启动 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则";
|
: $"拦截器未启动 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则";
|
||||||
}
|
}
|
||||||
@@ -150,11 +150,11 @@ namespace Ink_Canvas
|
|||||||
private void ToggleSwitchFloatingWindowInterceptorEnabled_Toggled(object sender, RoutedEventArgs e)
|
private void ToggleSwitchFloatingWindowInterceptorEnabled_Toggled(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Settings.Automation.FloatingWindowInterceptor.IsEnabled = ToggleSwitchFloatingWindowInterceptorEnabled.IsOn;
|
Settings.Automation.FloatingWindowInterceptor.IsEnabled = ToggleSwitchFloatingWindowInterceptorEnabled.IsOn;
|
||||||
|
|
||||||
if (_floatingWindowInterceptorManager != null)
|
if (_floatingWindowInterceptorManager != null)
|
||||||
{
|
{
|
||||||
if (Settings.Automation.FloatingWindowInterceptor.IsEnabled)
|
if (Settings.Automation.FloatingWindowInterceptor.IsEnabled)
|
||||||
@@ -166,7 +166,7 @@ namespace Ink_Canvas
|
|||||||
_floatingWindowInterceptorManager.Stop();
|
_floatingWindowInterceptorManager.Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateFloatingWindowInterceptorUI();
|
UpdateFloatingWindowInterceptorUI();
|
||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
_floatingWindowInterceptorManager.SetInterceptRule(type, enabled);
|
_floatingWindowInterceptorManager.SetInterceptRule(type, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新设置
|
// 更新设置
|
||||||
var ruleName = type.ToString();
|
var ruleName = type.ToString();
|
||||||
if (Settings.Automation.FloatingWindowInterceptor.InterceptRules.ContainsKey(ruleName))
|
if (Settings.Automation.FloatingWindowInterceptor.InterceptRules.ContainsKey(ruleName))
|
||||||
@@ -342,10 +342,10 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新UI显示
|
// 更新UI显示
|
||||||
UpdateFloatingWindowInterceptorUI();
|
UpdateFloatingWindowInterceptorUI();
|
||||||
|
|
||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 将Bitmap转换为WPF BitmapSource
|
// 将Bitmap转换为WPF BitmapSource
|
||||||
var bitmapSource = ConvertBitmapToBitmapSource(bitmap);
|
var bitmapSource = ConvertBitmapToBitmapSource(bitmap);
|
||||||
|
|
||||||
if (bitmapSource == null)
|
if (bitmapSource == null)
|
||||||
{
|
{
|
||||||
ShowNotification("转换截图失败");
|
ShowNotification("转换截图失败");
|
||||||
@@ -649,7 +649,7 @@ namespace Ink_Canvas
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"转换位图失败: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"转换位图失败: {ex.Message}", LogHelper.LogType.Error);
|
||||||
|
|
||||||
// 尝试使用备用方法:内存流转换
|
// 尝试使用备用方法:内存流转换
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -658,7 +658,7 @@ namespace Ink_Canvas
|
|||||||
catch (Exception fallbackEx)
|
catch (Exception fallbackEx)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"备用转换方法也失败: {fallbackEx.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"备用转换方法也失败: {fallbackEx.Message}", LogHelper.LogType.Error);
|
||||||
|
|
||||||
// 最后尝试:使用最简单的转换方法
|
// 最后尝试:使用最简单的转换方法
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -723,18 +723,18 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 使用最基础的方法:直接保存为PNG然后加载
|
// 使用最基础的方法:直接保存为PNG然后加载
|
||||||
var tempFile = Path.GetTempFileName() + ".png";
|
var tempFile = Path.GetTempFileName() + ".png";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bitmap.Save(tempFile, ImageFormat.Png);
|
bitmap.Save(tempFile, ImageFormat.Png);
|
||||||
|
|
||||||
var bitmapImage = new BitmapImage();
|
var bitmapImage = new BitmapImage();
|
||||||
bitmapImage.BeginInit();
|
bitmapImage.BeginInit();
|
||||||
bitmapImage.UriSource = new Uri(tempFile);
|
bitmapImage.UriSource = new Uri(tempFile);
|
||||||
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
bitmapImage.EndInit();
|
bitmapImage.EndInit();
|
||||||
bitmapImage.Freeze();
|
bitmapImage.Freeze();
|
||||||
|
|
||||||
return bitmapImage;
|
return bitmapImage;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -89,11 +89,11 @@ namespace Ink_Canvas
|
|||||||
// PowerPoint应用程序守护相关字段
|
// PowerPoint应用程序守护相关字段
|
||||||
private DispatcherTimer _powerPointProcessMonitorTimer;
|
private DispatcherTimer _powerPointProcessMonitorTimer;
|
||||||
private const int ProcessMonitorInterval = 1000; // 应用程序监控间隔(毫秒)
|
private const int ProcessMonitorInterval = 1000; // 应用程序监控间隔(毫秒)
|
||||||
|
|
||||||
// 上次播放位置相关字段
|
// 上次播放位置相关字段
|
||||||
private int _lastPlaybackPage = 0;
|
private int _lastPlaybackPage = 0;
|
||||||
private bool _shouldNavigateToLastPage = false;
|
private bool _shouldNavigateToLastPage = false;
|
||||||
|
|
||||||
// 页面切换防抖机制
|
// 页面切换防抖机制
|
||||||
private DateTime _lastSlideSwitchTime = DateTime.MinValue;
|
private DateTime _lastSlideSwitchTime = DateTime.MinValue;
|
||||||
private int _pendingSlideIndex = -1;
|
private int _pendingSlideIndex = -1;
|
||||||
@@ -800,7 +800,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
|
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
|
||||||
{
|
{
|
||||||
if (isFloatingBarFolded)
|
if (isFloatingBarFolded)
|
||||||
{
|
{
|
||||||
await UnFoldFloatingBar(new object());
|
await UnFoldFloatingBar(new object());
|
||||||
}
|
}
|
||||||
@@ -808,7 +808,7 @@ namespace Ink_Canvas
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 如果两个功能都关闭,确保浮动栏展开
|
// 如果两个功能都关闭,确保浮动栏展开
|
||||||
if (isFloatingBarFolded)
|
if (isFloatingBarFolded)
|
||||||
{
|
{
|
||||||
await UnFoldFloatingBar(new object());
|
await UnFoldFloatingBar(new object());
|
||||||
}
|
}
|
||||||
@@ -819,7 +819,7 @@ namespace Ink_Canvas
|
|||||||
isEnteredSlideShowEndEvent = true;
|
isEnteredSlideShowEndEvent = true;
|
||||||
|
|
||||||
// 保存所有墨迹
|
// 保存所有墨迹
|
||||||
_multiPPTInkManager?.SaveAllStrokesToFile(pres);
|
_multiPPTInkManager?.SaveAllStrokesToFile(pres);
|
||||||
|
|
||||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
@@ -1086,7 +1086,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 切换到对应的墨迹管理器
|
// 切换到对应的墨迹管理器
|
||||||
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
|
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
|
||||||
|
|
||||||
// 重置锁定状态
|
// 重置锁定状态
|
||||||
_multiPPTInkManager?.ResetCurrentPresentationLockState();
|
_multiPPTInkManager?.ResetCurrentPresentationLockState();
|
||||||
}
|
}
|
||||||
@@ -1106,21 +1106,21 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 重置进入PPT时的浮动栏收纳状态记录
|
// 重置进入PPT时的浮动栏收纳状态记录
|
||||||
wasFloatingBarFoldedWhenEnterSlideShow = false;
|
wasFloatingBarFoldedWhenEnterSlideShow = false;
|
||||||
|
|
||||||
// 重置PPT放映结束事件标志
|
// 重置PPT放映结束事件标志
|
||||||
isEnteredSlideShowEndEvent = false;
|
isEnteredSlideShowEndEvent = false;
|
||||||
|
|
||||||
// 重置演示文稿黑边状态
|
// 重置演示文稿黑边状态
|
||||||
isPresentationHaveBlackSpace = false;
|
isPresentationHaveBlackSpace = false;
|
||||||
|
|
||||||
// 重置上次播放位置相关字段
|
// 重置上次播放位置相关字段
|
||||||
_lastPlaybackPage = 0;
|
_lastPlaybackPage = 0;
|
||||||
_shouldNavigateToLastPage = false;
|
_shouldNavigateToLastPage = false;
|
||||||
|
|
||||||
// 重置页面切换防抖机制
|
// 重置页面切换防抖机制
|
||||||
_lastSlideSwitchTime = DateTime.MinValue;
|
_lastSlideSwitchTime = DateTime.MinValue;
|
||||||
_pendingSlideIndex = -1;
|
_pendingSlideIndex = -1;
|
||||||
|
|
||||||
LogHelper.WriteLogToFile("PPT状态变量已重置", LogHelper.LogType.Trace);
|
LogHelper.WriteLogToFile("PPT状态变量已重置", LogHelper.LogType.Trace);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1137,15 +1137,15 @@ namespace Ink_Canvas
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
|
|
||||||
// 如果距离上次切换时间太短,使用防抖机制
|
// 如果距离上次切换时间太短,使用防抖机制
|
||||||
if (now - _lastSlideSwitchTime < TimeSpan.FromMilliseconds(SlideSwitchDebounceMs))
|
if (now - _lastSlideSwitchTime < TimeSpan.FromMilliseconds(SlideSwitchDebounceMs))
|
||||||
{
|
{
|
||||||
_pendingSlideIndex = currentSlide;
|
_pendingSlideIndex = currentSlide;
|
||||||
|
|
||||||
// 停止之前的定时器
|
// 停止之前的定时器
|
||||||
_slideSwitchDebounceTimer?.Stop();
|
_slideSwitchDebounceTimer?.Stop();
|
||||||
|
|
||||||
// 创建新的定时器
|
// 创建新的定时器
|
||||||
_slideSwitchDebounceTimer = new System.Timers.Timer(SlideSwitchDebounceMs);
|
_slideSwitchDebounceTimer = new System.Timers.Timer(SlideSwitchDebounceMs);
|
||||||
_slideSwitchDebounceTimer.Elapsed += (sender, e) =>
|
_slideSwitchDebounceTimer.Elapsed += (sender, e) =>
|
||||||
@@ -1169,7 +1169,7 @@ namespace Ink_Canvas
|
|||||||
SwitchSlideInk(currentSlide);
|
SwitchSlideInk(currentSlide);
|
||||||
_pptUIManager?.UpdateCurrentSlideNumber(currentSlide, totalSlides);
|
_pptUIManager?.UpdateCurrentSlideNumber(currentSlide, totalSlides);
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastSlideSwitchTime = now;
|
_lastSlideSwitchTime = now;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1190,21 +1190,21 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 获取当前页面索引
|
// 获取当前页面索引
|
||||||
var currentSlideIndex = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
var currentSlideIndex = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
||||||
|
|
||||||
|
|
||||||
// 验证页面索引的有效性
|
// 验证页面索引的有效性
|
||||||
if (newSlideIndex <= 0)
|
if (newSlideIndex <= 0)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"无效的新页面索引: {newSlideIndex},跳过页面切换", LogHelper.LogType.Warning);
|
LogHelper.WriteLogToFile($"无效的新页面索引: {newSlideIndex},跳过页面切换", LogHelper.LogType.Warning);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果有当前墨迹且不是第一次切换,先保存到当前页面
|
// 如果有当前墨迹且不是第一次切换,先保存到当前页面
|
||||||
if (inkCanvas.Strokes.Count > 0 && currentSlideIndex > 0 && currentSlideIndex != newSlideIndex)
|
if (inkCanvas.Strokes.Count > 0 && currentSlideIndex > 0 && currentSlideIndex != newSlideIndex)
|
||||||
{
|
{
|
||||||
// 检查是否可以写入墨迹
|
// 检查是否可以写入墨迹
|
||||||
bool canWrite = _multiPPTInkManager?.CanWriteInk(currentSlideIndex) == true;
|
bool canWrite = _multiPPTInkManager?.CanWriteInk(currentSlideIndex) == true;
|
||||||
|
|
||||||
if (canWrite)
|
if (canWrite)
|
||||||
{
|
{
|
||||||
// 正常保存
|
// 正常保存
|
||||||
@@ -1219,7 +1219,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 无法获取当前页面索引时,不保存墨迹,直接清空
|
// 无法获取当前页面索引时,不保存墨迹,直接清空
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换到新页面并加载墨迹
|
// 切换到新页面并加载墨迹
|
||||||
var newStrokes = _multiPPTInkManager?.SwitchToSlide(newSlideIndex, null);
|
var newStrokes = _multiPPTInkManager?.SwitchToSlide(newSlideIndex, null);
|
||||||
if (newStrokes != null)
|
if (newStrokes != null)
|
||||||
@@ -1590,7 +1590,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
HideSubPanels("cursor");
|
HideSubPanels("cursor");
|
||||||
SetCurrentToolMode(InkCanvasEditingMode.None);
|
SetCurrentToolMode(InkCanvasEditingMode.None);
|
||||||
|
|
||||||
await Task.Delay(150);
|
await Task.Delay(150);
|
||||||
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow)
|
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow)
|
||||||
{
|
{
|
||||||
@@ -1628,7 +1628,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 异常情况下也手动处理收纳状态恢复
|
// 异常情况下也手动处理收纳状态恢复
|
||||||
await HandleManualSlideShowEnd();
|
await HandleManualSlideShowEnd();
|
||||||
|
|
||||||
// 异常情况下也要根据设置决定浮动栏边距
|
// 异常情况下也要根据设置决定浮动栏边距
|
||||||
await Task.Delay(150);
|
await Task.Delay(150);
|
||||||
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow)
|
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow)
|
||||||
@@ -1678,7 +1678,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
|
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
|
||||||
{
|
{
|
||||||
if (isFloatingBarFolded)
|
if (isFloatingBarFolded)
|
||||||
{
|
{
|
||||||
await UnFoldFloatingBar(new object());
|
await UnFoldFloatingBar(new object());
|
||||||
}
|
}
|
||||||
@@ -1686,7 +1686,7 @@ namespace Ink_Canvas
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 如果两个功能都关闭,确保浮动栏展开
|
// 如果两个功能都关闭,确保浮动栏展开
|
||||||
if (isFloatingBarFolded)
|
if (isFloatingBarFolded)
|
||||||
{
|
{
|
||||||
await UnFoldFloatingBar(new object());
|
await UnFoldFloatingBar(new object());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tarPos = transform.Transform(point);
|
var tarPos = transform.Transform(point);
|
||||||
scrollViewer.ScrollToVerticalOffset(tarPos.Y);
|
scrollViewer.ScrollToVerticalOffset(tarPos.Y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1029,41 +1029,41 @@ namespace Ink_Canvas
|
|||||||
// 获取当前屏幕的实际尺寸(考虑DPI缩放)
|
// 获取当前屏幕的实际尺寸(考虑DPI缩放)
|
||||||
var actualScreenWidth = SystemParameters.PrimaryScreenWidth;
|
var actualScreenWidth = SystemParameters.PrimaryScreenWidth;
|
||||||
var actualScreenHeight = SystemParameters.PrimaryScreenHeight;
|
var actualScreenHeight = SystemParameters.PrimaryScreenHeight;
|
||||||
|
|
||||||
// 预览区域固定尺寸
|
// 预览区域固定尺寸
|
||||||
const double previewWidth = 324.0;
|
const double previewWidth = 324.0;
|
||||||
const double previewHeight = 182.0;
|
const double previewHeight = 182.0;
|
||||||
|
|
||||||
// 计算缩放比例(预览区域与实际屏幕的比例)
|
// 计算缩放比例(预览区域与实际屏幕的比例)
|
||||||
double scaleX = previewWidth / actualScreenWidth;
|
double scaleX = previewWidth / actualScreenWidth;
|
||||||
double scaleY = previewHeight / actualScreenHeight;
|
double scaleY = previewHeight / actualScreenHeight;
|
||||||
|
|
||||||
// 获取按钮位置设置
|
// 获取按钮位置设置
|
||||||
double rsPosition = Settings.PowerPointSettings.PPTRSButtonPosition;
|
double rsPosition = Settings.PowerPointSettings.PPTRSButtonPosition;
|
||||||
double lsPosition = Settings.PowerPointSettings.PPTLSButtonPosition;
|
double lsPosition = Settings.PowerPointSettings.PPTLSButtonPosition;
|
||||||
double lbPosition = Settings.PowerPointSettings.PPTLBButtonPosition;
|
double lbPosition = Settings.PowerPointSettings.PPTLBButtonPosition;
|
||||||
double rbPosition = Settings.PowerPointSettings.PPTRBButtonPosition;
|
double rbPosition = Settings.PowerPointSettings.PPTRBButtonPosition;
|
||||||
|
|
||||||
bool showSidePageButton = sopt.Length >= 1 && sopt[0] == '2';
|
bool showSidePageButton = sopt.Length >= 1 && sopt[0] == '2';
|
||||||
bool showBottomPageButton = bopt.Length >= 1 && bopt[0] == '2';
|
bool showBottomPageButton = bopt.Length >= 1 && bopt[0] == '2';
|
||||||
|
|
||||||
// 页码按钮的实际尺寸
|
// 页码按钮的实际尺寸
|
||||||
const double pageButtonWidth = 50.0;
|
const double pageButtonWidth = 50.0;
|
||||||
const double pageButtonHeight = 50.0;
|
const double pageButtonHeight = 50.0;
|
||||||
|
|
||||||
// 计算侧边按钮位置(Y轴偏移)
|
// 计算侧边按钮位置(Y轴偏移)
|
||||||
double sideOffsetY = showSidePageButton ? pageButtonHeight * scaleY : 0;
|
double sideOffsetY = showSidePageButton ? pageButtonHeight * scaleY : 0;
|
||||||
PPTBtnPreviewRSTransform.Y = -(rsPosition * scaleY) - sideOffsetY;
|
PPTBtnPreviewRSTransform.Y = -(rsPosition * scaleY) - sideOffsetY;
|
||||||
PPTBtnPreviewLSTransform.Y = -(lsPosition * scaleY) - sideOffsetY;
|
PPTBtnPreviewLSTransform.Y = -(lsPosition * scaleY) - sideOffsetY;
|
||||||
|
|
||||||
// 计算底部按钮位置(X轴偏移)
|
// 计算底部按钮位置(X轴偏移)
|
||||||
const double bottomMarginOffset = 6.0;
|
const double bottomMarginOffset = 6.0;
|
||||||
double scaledMarginOffset = bottomMarginOffset * scaleX;
|
double scaledMarginOffset = bottomMarginOffset * scaleX;
|
||||||
|
|
||||||
double bottomOffsetX = showBottomPageButton ? pageButtonWidth * scaleX : 0;
|
double bottomOffsetX = showBottomPageButton ? pageButtonWidth * scaleX : 0;
|
||||||
PPTBtnPreviewLBTransform.X = scaledMarginOffset + (lbPosition * scaleX) + bottomOffsetX;
|
PPTBtnPreviewLBTransform.X = scaledMarginOffset + (lbPosition * scaleX) + bottomOffsetX;
|
||||||
PPTBtnPreviewRBTransform.X = -(scaledMarginOffset + (rbPosition * scaleX) + bottomOffsetX);
|
PPTBtnPreviewRBTransform.X = -(scaledMarginOffset + (rbPosition * scaleX) + bottomOffsetX);
|
||||||
|
|
||||||
// 计算工具栏尺寸
|
// 计算工具栏尺寸
|
||||||
var dpiScaleX = 1.0;
|
var dpiScaleX = 1.0;
|
||||||
var dpiScaleY = 1.0;
|
var dpiScaleY = 1.0;
|
||||||
@@ -1082,17 +1082,17 @@ namespace Ink_Canvas
|
|||||||
dpiScaleX = 1.0;
|
dpiScaleX = 1.0;
|
||||||
dpiScaleY = 1.0;
|
dpiScaleY = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算工具栏的实际尺寸
|
// 计算工具栏的实际尺寸
|
||||||
const double baseToolbarHeight = 24.0;
|
const double baseToolbarHeight = 24.0;
|
||||||
|
|
||||||
double actualToolbarHeight = baseToolbarHeight * dpiScaleY;
|
double actualToolbarHeight = baseToolbarHeight * dpiScaleY;
|
||||||
double scaledToolbarHeight = actualToolbarHeight * scaleY;
|
double scaledToolbarHeight = actualToolbarHeight * scaleY;
|
||||||
double scaledToolbarWidth = previewWidth;
|
double scaledToolbarWidth = previewWidth;
|
||||||
|
|
||||||
// 设置工具栏尺寸
|
// 设置工具栏尺寸
|
||||||
PPTBtnPreviewToolbar.Height = scaledToolbarHeight;
|
PPTBtnPreviewToolbar.Height = scaledToolbarHeight;
|
||||||
PPTBtnPreviewToolbar.Width = scaledToolbarWidth;
|
PPTBtnPreviewToolbar.Width = scaledToolbarWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleSwitchShowCursor_Toggled(object sender, RoutedEventArgs e)
|
private void ToggleSwitchShowCursor_Toggled(object sender, RoutedEventArgs e)
|
||||||
@@ -1495,18 +1495,18 @@ namespace Ink_Canvas
|
|||||||
private void ToggleSwitchAutoFoldInPPTSlideShow_Toggled(object sender, RoutedEventArgs e)
|
private void ToggleSwitchAutoFoldInPPTSlideShow_Toggled(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return;
|
||||||
|
|
||||||
// 记录设置变更前的状态
|
// 记录设置变更前的状态
|
||||||
bool previousState = Settings.Automation.IsAutoFoldInPPTSlideShow;
|
bool previousState = Settings.Automation.IsAutoFoldInPPTSlideShow;
|
||||||
Settings.Automation.IsAutoFoldInPPTSlideShow = ToggleSwitchAutoFoldInPPTSlideShow.IsOn;
|
Settings.Automation.IsAutoFoldInPPTSlideShow = ToggleSwitchAutoFoldInPPTSlideShow.IsOn;
|
||||||
|
|
||||||
// 如果设置状态发生变化,重置PPT相关状态变量
|
// 如果设置状态发生变化,重置PPT相关状态变量
|
||||||
if (previousState != Settings.Automation.IsAutoFoldInPPTSlideShow)
|
if (previousState != Settings.Automation.IsAutoFoldInPPTSlideShow)
|
||||||
{
|
{
|
||||||
ResetPPTStateVariables();
|
ResetPPTStateVariables();
|
||||||
LogHelper.WriteLogToFile($"PPT自动收纳设置已变更: {Settings.Automation.IsAutoFoldInPPTSlideShow}, 已重置相关状态变量", LogHelper.LogType.Trace);
|
LogHelper.WriteLogToFile($"PPT自动收纳设置已变更: {Settings.Automation.IsAutoFoldInPPTSlideShow}, 已重置相关状态变量", LogHelper.LogType.Trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
|
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
|
||||||
{
|
{
|
||||||
SettingsPPTInkingAndAutoFoldExplictBorder.Visibility = Visibility.Visible;
|
SettingsPPTInkingAndAutoFoldExplictBorder.Visibility = Visibility.Visible;
|
||||||
@@ -1887,7 +1887,7 @@ namespace Ink_Canvas
|
|||||||
private void ToggleSwitchEnableTwoFingerZoom_Toggled(object sender, RoutedEventArgs e)
|
private void ToggleSwitchEnableTwoFingerZoom_Toggled(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return;
|
||||||
|
|
||||||
// 如果多指书写模式启用,强制禁用双指手势
|
// 如果多指书写模式启用,强制禁用双指手势
|
||||||
if (ToggleSwitchEnableMultiTouchMode.IsOn)
|
if (ToggleSwitchEnableMultiTouchMode.IsOn)
|
||||||
{
|
{
|
||||||
@@ -1898,7 +1898,7 @@ namespace Ink_Canvas
|
|||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender == ToggleSwitchEnableTwoFingerZoom)
|
if (sender == ToggleSwitchEnableTwoFingerZoom)
|
||||||
BoardToggleSwitchEnableTwoFingerZoom.IsOn = ToggleSwitchEnableTwoFingerZoom.IsOn;
|
BoardToggleSwitchEnableTwoFingerZoom.IsOn = ToggleSwitchEnableTwoFingerZoom.IsOn;
|
||||||
else
|
else
|
||||||
@@ -1978,7 +1978,7 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
Settings.Gesture.IsEnableMultiTouchMode = ToggleSwitchEnableMultiTouchMode.IsOn;
|
Settings.Gesture.IsEnableMultiTouchMode = ToggleSwitchEnableMultiTouchMode.IsOn;
|
||||||
|
|
||||||
// 如果启用多指书写模式,强制禁用所有双指手势
|
// 如果启用多指书写模式,强制禁用所有双指手势
|
||||||
if (ToggleSwitchEnableMultiTouchMode.IsOn)
|
if (ToggleSwitchEnableMultiTouchMode.IsOn)
|
||||||
{
|
{
|
||||||
@@ -2003,7 +2003,7 @@ namespace Ink_Canvas
|
|||||||
if (BoardToggleSwitchEnableTwoFingerRotation != null)
|
if (BoardToggleSwitchEnableTwoFingerRotation != null)
|
||||||
BoardToggleSwitchEnableTwoFingerRotation.IsOn = false;
|
BoardToggleSwitchEnableTwoFingerRotation.IsOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckEnableTwoFingerGestureBtnColorPrompt();
|
CheckEnableTwoFingerGestureBtnColorPrompt();
|
||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
}
|
}
|
||||||
@@ -2011,7 +2011,7 @@ namespace Ink_Canvas
|
|||||||
private void ToggleSwitchEnableTwoFingerTranslate_Toggled(object sender, RoutedEventArgs e)
|
private void ToggleSwitchEnableTwoFingerTranslate_Toggled(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return;
|
||||||
|
|
||||||
// 如果多指书写模式启用,强制禁用双指手势
|
// 如果多指书写模式启用,强制禁用双指手势
|
||||||
if (ToggleSwitchEnableMultiTouchMode.IsOn)
|
if (ToggleSwitchEnableMultiTouchMode.IsOn)
|
||||||
{
|
{
|
||||||
@@ -2022,7 +2022,7 @@ namespace Ink_Canvas
|
|||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender == ToggleSwitchEnableTwoFingerTranslate)
|
if (sender == ToggleSwitchEnableTwoFingerTranslate)
|
||||||
BoardToggleSwitchEnableTwoFingerTranslate.IsOn = ToggleSwitchEnableTwoFingerTranslate.IsOn;
|
BoardToggleSwitchEnableTwoFingerTranslate.IsOn = ToggleSwitchEnableTwoFingerTranslate.IsOn;
|
||||||
else
|
else
|
||||||
@@ -3074,7 +3074,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
Directory.CreateDirectory(configsDir);
|
Directory.CreateDirectory(configsDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
File.WriteAllText(App.RootPath + settingsFileName, text);
|
File.WriteAllText(App.RootPath + settingsFileName, text);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using WinForms = System.Windows.Forms;
|
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
using OperatingSystem = OSVersionExtension.OperatingSystem;
|
using OperatingSystem = OSVersionExtension.OperatingSystem;
|
||||||
|
using WinForms = System.Windows.Forms;
|
||||||
|
|
||||||
namespace Ink_Canvas
|
namespace Ink_Canvas
|
||||||
{
|
{
|
||||||
@@ -30,7 +30,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
string text = File.ReadAllText(App.RootPath + settingsFileName);
|
string text = File.ReadAllText(App.RootPath + settingsFileName);
|
||||||
Settings = JsonConvert.DeserializeObject<Settings>(text);
|
Settings = JsonConvert.DeserializeObject<Settings>(text);
|
||||||
|
|
||||||
// 验证设置是否成功加载
|
// 验证设置是否成功加载
|
||||||
if (Settings == null)
|
if (Settings == null)
|
||||||
{
|
{
|
||||||
@@ -44,7 +44,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果仍然失败,使用默认设置
|
// 如果仍然失败,使用默认设置
|
||||||
if (Settings == null)
|
if (Settings == null)
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,7 @@ namespace Ink_Canvas
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"配置文件加载失败: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"配置文件加载失败: {ex.Message}", LogHelper.LogType.Error);
|
||||||
|
|
||||||
// 尝试从备份恢复
|
// 尝试从备份恢复
|
||||||
LogHelper.WriteLogToFile("尝试从备份恢复配置文件", LogHelper.LogType.Warning);
|
LogHelper.WriteLogToFile("尝试从备份恢复配置文件", LogHelper.LogType.Warning);
|
||||||
if (AutoBackupManager.TryRestoreFromBackup())
|
if (AutoBackupManager.TryRestoreFromBackup())
|
||||||
@@ -75,7 +75,7 @@ namespace Ink_Canvas
|
|||||||
BtnResetToSuggestion_Click(null, null);
|
BtnResetToSuggestion_Click(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果仍然失败,使用默认设置
|
// 如果仍然失败,使用默认设置
|
||||||
if (Settings == null)
|
if (Settings == null)
|
||||||
{
|
{
|
||||||
@@ -109,7 +109,7 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile("备份恢复失败,使用默认设置", LogHelper.LogType.Warning);
|
LogHelper.WriteLogToFile("备份恢复失败,使用默认设置", LogHelper.LogType.Warning);
|
||||||
BtnResetToSuggestion_Click(null, null);
|
BtnResetToSuggestion_Click(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果仍然失败,使用默认设置
|
// 如果仍然失败,使用默认设置
|
||||||
if (Settings == null)
|
if (Settings == null)
|
||||||
{
|
{
|
||||||
@@ -427,7 +427,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 应用浮动栏按钮可见性设置
|
// 应用浮动栏按钮可见性设置
|
||||||
UpdateFloatingBarButtonsVisibility();
|
UpdateFloatingBarButtonsVisibility();
|
||||||
|
|
||||||
// 更新浮动栏图标
|
// 更新浮动栏图标
|
||||||
UpdateFloatingBarIcons();
|
UpdateFloatingBarIcons();
|
||||||
|
|
||||||
@@ -806,7 +806,7 @@ namespace Ink_Canvas
|
|||||||
ToggleSwitchIsEnableAvoidFullScreenHelper.IsOn = Settings.Advanced.IsEnableAvoidFullScreenHelper;
|
ToggleSwitchIsEnableAvoidFullScreenHelper.IsOn = Settings.Advanced.IsEnableAvoidFullScreenHelper;
|
||||||
ToggleSwitchIsAutoBackupBeforeUpdate.IsOn = Settings.Advanced.IsAutoBackupBeforeUpdate;
|
ToggleSwitchIsAutoBackupBeforeUpdate.IsOn = Settings.Advanced.IsAutoBackupBeforeUpdate;
|
||||||
ToggleSwitchIsAutoBackupEnabled.IsOn = Settings.Advanced.IsAutoBackupEnabled;
|
ToggleSwitchIsAutoBackupEnabled.IsOn = Settings.Advanced.IsAutoBackupEnabled;
|
||||||
|
|
||||||
// 设置备份间隔下拉框
|
// 设置备份间隔下拉框
|
||||||
foreach (ComboBoxItem item in ComboBoxAutoBackupInterval.Items)
|
foreach (ComboBoxItem item in ComboBoxAutoBackupInterval.Items)
|
||||||
{
|
{
|
||||||
@@ -911,7 +911,7 @@ namespace Ink_Canvas
|
|||||||
if (Settings.ModeSettings != null)
|
if (Settings.ModeSettings != null)
|
||||||
{
|
{
|
||||||
ToggleSwitchMode.IsOn = Settings.ModeSettings.IsPPTOnlyMode;
|
ToggleSwitchMode.IsOn = Settings.ModeSettings.IsPPTOnlyMode;
|
||||||
|
|
||||||
// 根据加载的配置状态执行相应的窗口显示/隐藏逻辑
|
// 根据加载的配置状态执行相应的窗口显示/隐藏逻辑
|
||||||
if (isStartup && Settings.ModeSettings.IsPPTOnlyMode)
|
if (isStartup && Settings.ModeSettings.IsPPTOnlyMode)
|
||||||
{
|
{
|
||||||
@@ -1026,7 +1026,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 加载退出收纳模式自动切换至批注模式设置
|
// 加载退出收纳模式自动切换至批注模式设置
|
||||||
ToggleSwitchAutoEnterAnnotationModeWhenExitFoldMode.IsOn = Settings.Automation.IsAutoEnterAnnotationModeWhenExitFoldMode;
|
ToggleSwitchAutoEnterAnnotationModeWhenExitFoldMode.IsOn = Settings.Automation.IsAutoEnterAnnotationModeWhenExitFoldMode;
|
||||||
|
|
||||||
// 加载退出白板时自动收纳设置
|
// 加载退出白板时自动收纳设置
|
||||||
ToggleSwitchAutoFoldWhenExitWhiteboard.IsOn = Settings.Automation.IsAutoFoldWhenExitWhiteboard;
|
ToggleSwitchAutoFoldWhenExitWhiteboard.IsOn = Settings.Automation.IsAutoFoldWhenExitWhiteboard;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ namespace Ink_Canvas
|
|||||||
await CheckIsDrawingShapesInMultiTouchMode();
|
await CheckIsDrawingShapesInMultiTouchMode();
|
||||||
EnterShapeDrawingMode(3);
|
EnterShapeDrawingMode(3);
|
||||||
CancelSingleFingerDragMode();
|
CancelSingleFingerDragMode();
|
||||||
isLongPressSelected = false;
|
isLongPressSelected = false;
|
||||||
lastMouseDownSender = null;
|
lastMouseDownSender = null;
|
||||||
DrawShapePromptToPen();
|
DrawShapePromptToPen();
|
||||||
}
|
}
|
||||||
@@ -496,7 +496,7 @@ namespace Ink_Canvas
|
|||||||
if (!isTouchDown) return;
|
if (!isTouchDown) return;
|
||||||
|
|
||||||
if (isWaitUntilNextTouchDown && dec.Count > 1) return;
|
if (isWaitUntilNextTouchDown && dec.Count > 1) return;
|
||||||
|
|
||||||
// 对于多笔图形绘制,允许第二笔绘制,即使dec.Count > 1
|
// 对于多笔图形绘制,允许第二笔绘制,即使dec.Count > 1
|
||||||
if (dec.Count > 1 && !((drawingShapeMode == 24 || drawingShapeMode == 25) && drawMultiStepShapeCurrentStep == 1))
|
if (dec.Count > 1 && !((drawingShapeMode == 24 || drawingShapeMode == 25) && drawMultiStepShapeCurrentStep == 1))
|
||||||
{
|
{
|
||||||
@@ -512,7 +512,7 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 第二笔绘制双曲线时,只删除第二笔的临时笔画,保留第一笔的辅助线
|
// 第二笔绘制双曲线时,只删除第二笔的临时笔画,保留第一笔的辅助线
|
||||||
if ((drawingShapeMode == 24 || drawingShapeMode == 25) && drawMultiStepShapeCurrentStep == 1)
|
if ((drawingShapeMode == 24 || drawingShapeMode == 25) && drawMultiStepShapeCurrentStep == 1)
|
||||||
{
|
{
|
||||||
@@ -584,19 +584,19 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
UpdateTempStrokeSafely(stroke);
|
UpdateTempStrokeSafely(stroke);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
_currentCommitType = CommitReason.ShapeDrawing;
|
_currentCommitType = CommitReason.ShapeDrawing;
|
||||||
strokes.Add(GenerateDashedLineStrokeCollection(iniP, endP));
|
strokes.Add(GenerateDashedLineStrokeCollection(iniP, endP));
|
||||||
|
|
||||||
UpdateTempStrokeCollectionSafely(strokes);
|
UpdateTempStrokeCollectionSafely(strokes);
|
||||||
break;
|
break;
|
||||||
case 18:
|
case 18:
|
||||||
_currentCommitType = CommitReason.ShapeDrawing;
|
_currentCommitType = CommitReason.ShapeDrawing;
|
||||||
strokes.Add(GenerateDotLineStrokeCollection(iniP, endP));
|
strokes.Add(GenerateDotLineStrokeCollection(iniP, endP));
|
||||||
|
|
||||||
UpdateTempStrokeCollectionSafely(strokes);
|
UpdateTempStrokeCollectionSafely(strokes);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@@ -618,7 +618,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
// 优化:使用更安全的临时笔画更新方式,减少闪烁
|
// 优化:使用更安全的临时笔画更新方式,减少闪烁
|
||||||
UpdateTempStrokeSafely(stroke);
|
UpdateTempStrokeSafely(stroke);
|
||||||
break;
|
break;
|
||||||
@@ -1503,12 +1503,12 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 先添加新笔画,再删除旧笔画,减少视觉闪烁
|
// 先添加新笔画,再删除旧笔画,减少视觉闪烁
|
||||||
inkCanvas.Strokes.Add(newStroke);
|
inkCanvas.Strokes.Add(newStroke);
|
||||||
|
|
||||||
if (lastTempStroke != null && inkCanvas.Strokes.Contains(lastTempStroke))
|
if (lastTempStroke != null && inkCanvas.Strokes.Contains(lastTempStroke))
|
||||||
{
|
{
|
||||||
inkCanvas.Strokes.Remove(lastTempStroke);
|
inkCanvas.Strokes.Remove(lastTempStroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastTempStroke = newStroke;
|
lastTempStroke = newStroke;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1553,7 +1553,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 先添加新笔画集合,再删除旧笔画集合,减少视觉闪烁
|
// 先添加新笔画集合,再删除旧笔画集合,减少视觉闪烁
|
||||||
inkCanvas.Strokes.Add(newStrokeCollection);
|
inkCanvas.Strokes.Add(newStrokeCollection);
|
||||||
|
|
||||||
if (lastTempStrokeCollection != null && lastTempStrokeCollection.Count > 0)
|
if (lastTempStrokeCollection != null && lastTempStrokeCollection.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var stroke in lastTempStrokeCollection)
|
foreach (var stroke in lastTempStrokeCollection)
|
||||||
@@ -1564,7 +1564,7 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastTempStrokeCollection = newStrokeCollection;
|
lastTempStrokeCollection = newStrokeCollection;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -744,13 +744,13 @@ namespace Ink_Canvas
|
|||||||
// 应用高级贝塞尔曲线平滑(仅在未进行直线拉直时)
|
// 应用高级贝塞尔曲线平滑(仅在未进行直线拉直时)
|
||||||
Debug.WriteLine($"墨迹平滑检查: UseAdvancedBezierSmoothing={Settings.Canvas.UseAdvancedBezierSmoothing}, wasStraightened={wasStraightened}");
|
Debug.WriteLine($"墨迹平滑检查: UseAdvancedBezierSmoothing={Settings.Canvas.UseAdvancedBezierSmoothing}, wasStraightened={wasStraightened}");
|
||||||
Debug.WriteLine($"异步平滑设置: UseAsyncInkSmoothing={Settings.Canvas.UseAsyncInkSmoothing}, _inkSmoothingManager={_inkSmoothingManager != null}");
|
Debug.WriteLine($"异步平滑设置: UseAsyncInkSmoothing={Settings.Canvas.UseAsyncInkSmoothing}, _inkSmoothingManager={_inkSmoothingManager != null}");
|
||||||
|
|
||||||
if (Settings.Canvas.UseAdvancedBezierSmoothing && !wasStraightened)
|
if (Settings.Canvas.UseAdvancedBezierSmoothing && !wasStraightened)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"开始墨迹平滑处理: 原始点数={e.Stroke.StylusPoints.Count}, 直线拉直={wasStraightened}");
|
Debug.WriteLine($"开始墨迹平滑处理: 原始点数={e.Stroke.StylusPoints.Count}, 直线拉直={wasStraightened}");
|
||||||
|
|
||||||
// 检查原始笔画是否仍然存在于画布中
|
// 检查原始笔画是否仍然存在于画布中
|
||||||
if (inkCanvas.Strokes.Contains(e.Stroke))
|
if (inkCanvas.Strokes.Contains(e.Stroke))
|
||||||
{
|
{
|
||||||
@@ -807,7 +807,7 @@ namespace Ink_Canvas
|
|||||||
Debug.WriteLine($"异步平滑完成: 原始点数={original.StylusPoints.Count}, 平滑后点数={smoothed.StylusPoints.Count}");
|
Debug.WriteLine($"异步平滑完成: 原始点数={original.StylusPoints.Count}, 平滑后点数={smoothed.StylusPoints.Count}");
|
||||||
Debug.WriteLine($"墨迹比较: smoothed != original = {smoothed != original}");
|
Debug.WriteLine($"墨迹比较: smoothed != original = {smoothed != original}");
|
||||||
Debug.WriteLine($"画布包含原始墨迹: {inkCanvas.Strokes.Contains(original)}");
|
Debug.WriteLine($"画布包含原始墨迹: {inkCanvas.Strokes.Contains(original)}");
|
||||||
|
|
||||||
// 在UI线程上执行笔画替换
|
// 在UI线程上执行笔画替换
|
||||||
if (inkCanvas.Strokes.Contains(original) && smoothed != original)
|
if (inkCanvas.Strokes.Contains(original) && smoothed != original)
|
||||||
{
|
{
|
||||||
@@ -1424,7 +1424,7 @@ namespace Ink_Canvas
|
|||||||
// 修复灵敏度逻辑:灵敏度越大,容许的偏差越大,更容易将线条识别为直线
|
// 修复灵敏度逻辑:灵敏度越大,容许的偏差越大,更容易将线条识别为直线
|
||||||
// 将灵敏度转换为阈值:灵敏度0.05-1.0映射到阈值0.01-0.2
|
// 将灵敏度转换为阈值:灵敏度0.05-1.0映射到阈值0.01-0.2
|
||||||
double threshold = Math.Max(0.01, sensitivity * 0.2); // 确保最小阈值为0.01
|
double threshold = Math.Max(0.01, sensitivity * 0.2); // 确保最小阈值为0.01
|
||||||
|
|
||||||
if ((maxDeviation / lineLength) > threshold)
|
if ((maxDeviation / lineLength) > threshold)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"拒绝拉直:最大偏差过大 {maxDeviation / lineLength:F3} > {threshold:F3}");
|
Debug.WriteLine($"拒绝拉直:最大偏差过大 {maxDeviation / lineLength:F3} > {threshold:F3}");
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ namespace Ink_Canvas
|
|||||||
private TimeViewModel nowTimeVM = new TimeViewModel();
|
private TimeViewModel nowTimeVM = new TimeViewModel();
|
||||||
private DateTime cachedNetworkTime = DateTime.Now;
|
private DateTime cachedNetworkTime = DateTime.Now;
|
||||||
private DateTime lastNtpSyncTime = DateTime.MinValue;
|
private DateTime lastNtpSyncTime = DateTime.MinValue;
|
||||||
private string lastDisplayedTime = "";
|
private string lastDisplayedTime = "";
|
||||||
private bool useNetworkTime = false;
|
private bool useNetworkTime = false;
|
||||||
private TimeSpan networkTimeOffset = TimeSpan.Zero;
|
private TimeSpan networkTimeOffset = TimeSpan.Zero;
|
||||||
private DateTime lastLocalTime = DateTime.Now; // 记录上次的本地时间,用于检测时间跳跃
|
private DateTime lastLocalTime = DateTime.Now; // 记录上次的本地时间,用于检测时间跳跃
|
||||||
private bool isNtpSyncing = false; // 防止重复NTP同步的标志
|
private bool isNtpSyncing = false; // 防止重复NTP同步的标志
|
||||||
@@ -87,7 +87,7 @@ namespace Ink_Canvas
|
|||||||
var ipEndPoint = new IPEndPoint(addresses[0], 123);
|
var ipEndPoint = new IPEndPoint(addresses[0], 123);
|
||||||
using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
|
using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
|
||||||
{
|
{
|
||||||
socket.ReceiveTimeout = 5000;
|
socket.ReceiveTimeout = 5000;
|
||||||
socket.Connect(ipEndPoint);
|
socket.Connect(ipEndPoint);
|
||||||
await Task.Factory.FromAsync(socket.BeginSend(ntpData, 0, ntpData.Length, SocketFlags.None, null, socket), socket.EndSend);
|
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);
|
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();
|
timerKillProcess.Start();
|
||||||
nowTimeVM.nowDate = DateTime.Now.ToString("yyyy'年'MM'月'dd'日' dddd");
|
nowTimeVM.nowDate = DateTime.Now.ToString("yyyy'年'MM'月'dd'日' dddd");
|
||||||
nowTimeVM.nowTime = DateTime.Now.ToString("tt hh'时'mm'分'ss'秒'");
|
nowTimeVM.nowTime = DateTime.Now.ToString("tt hh'时'mm'分'ss'秒'");
|
||||||
|
|
||||||
// 程序启动时立即进行一次NTP同步
|
// 程序启动时立即进行一次NTP同步
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
@@ -151,17 +151,17 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 防止重复同步
|
// 防止重复同步
|
||||||
if (isNtpSyncing) return;
|
if (isNtpSyncing) return;
|
||||||
|
|
||||||
isNtpSyncing = true;
|
isNtpSyncing = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
// 添加超时机制,最多等待10秒
|
// 添加超时机制,最多等待10秒
|
||||||
var timeoutTask = Task.Delay(10000);
|
var timeoutTask = Task.Delay(10000);
|
||||||
var ntpTask = GetNetworkTimeAsync();
|
var ntpTask = GetNetworkTimeAsync();
|
||||||
|
|
||||||
var completedTask = await Task.WhenAny(ntpTask, timeoutTask);
|
var completedTask = await Task.WhenAny(ntpTask, timeoutTask);
|
||||||
|
|
||||||
if (completedTask == timeoutTask)
|
if (completedTask == timeoutTask)
|
||||||
{
|
{
|
||||||
cachedNetworkTime = DateTime.Now;
|
cachedNetworkTime = DateTime.Now;
|
||||||
@@ -170,20 +170,20 @@ namespace Ink_Canvas
|
|||||||
networkTimeOffset = TimeSpan.Zero;
|
networkTimeOffset = TimeSpan.Zero;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime networkTime = await ntpTask;
|
DateTime networkTime = await ntpTask;
|
||||||
DateTime localTime = DateTime.Now;
|
DateTime localTime = DateTime.Now;
|
||||||
|
|
||||||
cachedNetworkTime = networkTime;
|
cachedNetworkTime = networkTime;
|
||||||
lastNtpSyncTime = localTime;
|
lastNtpSyncTime = localTime;
|
||||||
|
|
||||||
// 计算网络时间与本地时间的偏移量
|
// 计算网络时间与本地时间的偏移量
|
||||||
networkTimeOffset = networkTime - localTime;
|
networkTimeOffset = networkTime - localTime;
|
||||||
|
|
||||||
// 如果时间差超过3分钟,则使用网络时间
|
// 如果时间差超过3分钟,则使用网络时间
|
||||||
useNetworkTime = Math.Abs(networkTimeOffset.TotalMinutes) > 3.0;
|
useNetworkTime = Math.Abs(networkTimeOffset.TotalMinutes) > 3.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// NTP同步失败时,保持使用本地时间
|
// NTP同步失败时,保持使用本地时间
|
||||||
@@ -191,7 +191,7 @@ namespace Ink_Canvas
|
|||||||
lastNtpSyncTime = DateTime.Now;
|
lastNtpSyncTime = DateTime.Now;
|
||||||
useNetworkTime = false;
|
useNetworkTime = false;
|
||||||
networkTimeOffset = TimeSpan.Zero;
|
networkTimeOffset = TimeSpan.Zero;
|
||||||
|
|
||||||
LogHelper.WriteLogToFile($"NTP同步失败: {ex.Message}", LogHelper.LogType.Warning);
|
LogHelper.WriteLogToFile($"NTP同步失败: {ex.Message}", LogHelper.LogType.Warning);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -209,7 +209,7 @@ namespace Ink_Canvas
|
|||||||
// 检测系统时间是否发生重大跳跃(超过2分钟)
|
// 检测系统时间是否发生重大跳跃(超过2分钟)
|
||||||
TimeSpan timeJump = localTime - lastLocalTime;
|
TimeSpan timeJump = localTime - lastLocalTime;
|
||||||
double timeJumpMinutes = Math.Abs(timeJump.TotalMinutes);
|
double timeJumpMinutes = Math.Abs(timeJump.TotalMinutes);
|
||||||
|
|
||||||
if (timeJumpMinutes > 3 && !isNtpSyncing)
|
if (timeJumpMinutes > 3 && !isNtpSyncing)
|
||||||
{
|
{
|
||||||
// 系统时间发生重大变化(超过3分钟),立即触发NTP同步
|
// 系统时间发生重大变化(超过3分钟),立即触发NTP同步
|
||||||
@@ -237,12 +237,12 @@ namespace Ink_Canvas
|
|||||||
// 格式化时间字符串
|
// 格式化时间字符串
|
||||||
string timeString = displayTime.ToString("tt hh'时'mm'分'ss'秒'");
|
string timeString = displayTime.ToString("tt hh'时'mm'分'ss'秒'");
|
||||||
|
|
||||||
|
|
||||||
// 只有当时间字符串发生变化时才更新UI,避免不必要的UI刷新
|
// 只有当时间字符串发生变化时才更新UI,避免不必要的UI刷新
|
||||||
if (timeString != lastDisplayedTime)
|
if (timeString != lastDisplayedTime)
|
||||||
{
|
{
|
||||||
lastDisplayedTime = timeString;
|
lastDisplayedTime = timeString;
|
||||||
|
|
||||||
// 使用BeginInvoke异步更新UI,避免阻塞
|
// 使用BeginInvoke异步更新UI,避免阻塞
|
||||||
Dispatcher.BeginInvoke(new Action(() =>
|
Dispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
@@ -477,7 +477,7 @@ namespace Ink_Canvas
|
|||||||
{ // EasiNote5
|
{ // EasiNote5
|
||||||
// 检查是否是桌面批注窗口
|
// 检查是否是桌面批注窗口
|
||||||
bool isAnnotationWindow = windowTitle.Length == 0 && ForegroundWindowInfo.WindowRect().Height < 500;
|
bool isAnnotationWindow = windowTitle.Length == 0 && ForegroundWindowInfo.WindowRect().Height < 500;
|
||||||
|
|
||||||
// 如果启用了忽略桌面批注窗口功能,且当前是批注窗口
|
// 如果启用了忽略桌面批注窗口功能,且当前是批注窗口
|
||||||
if (Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno && isAnnotationWindow)
|
if (Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno && isAnnotationWindow)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ namespace Ink_Canvas
|
|||||||
private Point centerPoint = new Point(0, 0);
|
private Point centerPoint = new Point(0, 0);
|
||||||
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 isMultiTouchTimerActive = false;
|
private bool isMultiTouchTimerActive = false;
|
||||||
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// 保存画布上的非笔画元素(如图片、媒体元素等)
|
/// 保存画布上的非笔画元素(如图片、媒体元素等)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -64,13 +64,13 @@ namespace Ink_Canvas
|
|||||||
if (originalElement is Image originalImage)
|
if (originalElement is Image originalImage)
|
||||||
{
|
{
|
||||||
var clonedImage = new Image();
|
var clonedImage = new Image();
|
||||||
|
|
||||||
// 复制图片源
|
// 复制图片源
|
||||||
if (originalImage.Source is BitmapSource bitmapSource)
|
if (originalImage.Source is BitmapSource bitmapSource)
|
||||||
{
|
{
|
||||||
clonedImage.Source = bitmapSource;
|
clonedImage.Source = bitmapSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 复制属性
|
// 复制属性
|
||||||
clonedImage.Width = originalImage.Width;
|
clonedImage.Width = originalImage.Width;
|
||||||
clonedImage.Height = originalImage.Height;
|
clonedImage.Height = originalImage.Height;
|
||||||
@@ -81,23 +81,23 @@ namespace Ink_Canvas
|
|||||||
clonedImage.Focusable = originalImage.Focusable;
|
clonedImage.Focusable = originalImage.Focusable;
|
||||||
clonedImage.Cursor = originalImage.Cursor;
|
clonedImage.Cursor = originalImage.Cursor;
|
||||||
clonedImage.IsManipulationEnabled = originalImage.IsManipulationEnabled;
|
clonedImage.IsManipulationEnabled = originalImage.IsManipulationEnabled;
|
||||||
|
|
||||||
// 复制位置
|
// 复制位置
|
||||||
InkCanvas.SetLeft(clonedImage, InkCanvas.GetLeft(originalImage));
|
InkCanvas.SetLeft(clonedImage, InkCanvas.GetLeft(originalImage));
|
||||||
InkCanvas.SetTop(clonedImage, InkCanvas.GetTop(originalImage));
|
InkCanvas.SetTop(clonedImage, InkCanvas.GetTop(originalImage));
|
||||||
|
|
||||||
// 复制变换
|
// 复制变换
|
||||||
if (originalImage.RenderTransform != null)
|
if (originalImage.RenderTransform != null)
|
||||||
{
|
{
|
||||||
clonedImage.RenderTransform = originalImage.RenderTransform.Clone();
|
clonedImage.RenderTransform = originalImage.RenderTransform.Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
return clonedImage;
|
return clonedImage;
|
||||||
}
|
}
|
||||||
else if (originalElement is MediaElement originalMedia)
|
else if (originalElement is MediaElement originalMedia)
|
||||||
{
|
{
|
||||||
var clonedMedia = new MediaElement();
|
var clonedMedia = new MediaElement();
|
||||||
|
|
||||||
// 复制媒体属性
|
// 复制媒体属性
|
||||||
clonedMedia.Source = originalMedia.Source;
|
clonedMedia.Source = originalMedia.Source;
|
||||||
clonedMedia.Width = originalMedia.Width;
|
clonedMedia.Width = originalMedia.Width;
|
||||||
@@ -105,23 +105,23 @@ namespace Ink_Canvas
|
|||||||
clonedMedia.Name = originalMedia.Name;
|
clonedMedia.Name = originalMedia.Name;
|
||||||
clonedMedia.IsHitTestVisible = originalMedia.IsHitTestVisible;
|
clonedMedia.IsHitTestVisible = originalMedia.IsHitTestVisible;
|
||||||
clonedMedia.Focusable = originalMedia.Focusable;
|
clonedMedia.Focusable = originalMedia.Focusable;
|
||||||
|
|
||||||
// 复制位置
|
// 复制位置
|
||||||
InkCanvas.SetLeft(clonedMedia, InkCanvas.GetLeft(originalMedia));
|
InkCanvas.SetLeft(clonedMedia, InkCanvas.GetLeft(originalMedia));
|
||||||
InkCanvas.SetTop(clonedMedia, InkCanvas.GetTop(originalMedia));
|
InkCanvas.SetTop(clonedMedia, InkCanvas.GetTop(originalMedia));
|
||||||
|
|
||||||
// 复制变换
|
// 复制变换
|
||||||
if (originalMedia.RenderTransform != null)
|
if (originalMedia.RenderTransform != null)
|
||||||
{
|
{
|
||||||
clonedMedia.RenderTransform = originalMedia.RenderTransform.Clone();
|
clonedMedia.RenderTransform = originalMedia.RenderTransform.Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
return clonedMedia;
|
return clonedMedia;
|
||||||
}
|
}
|
||||||
else if (originalElement is Border originalBorder)
|
else if (originalElement is Border originalBorder)
|
||||||
{
|
{
|
||||||
var clonedBorder = new Border();
|
var clonedBorder = new Border();
|
||||||
|
|
||||||
// 复制边框属性
|
// 复制边框属性
|
||||||
clonedBorder.Width = originalBorder.Width;
|
clonedBorder.Width = originalBorder.Width;
|
||||||
clonedBorder.Height = originalBorder.Height;
|
clonedBorder.Height = originalBorder.Height;
|
||||||
@@ -132,17 +132,17 @@ namespace Ink_Canvas
|
|||||||
clonedBorder.BorderBrush = originalBorder.BorderBrush;
|
clonedBorder.BorderBrush = originalBorder.BorderBrush;
|
||||||
clonedBorder.BorderThickness = originalBorder.BorderThickness;
|
clonedBorder.BorderThickness = originalBorder.BorderThickness;
|
||||||
clonedBorder.CornerRadius = originalBorder.CornerRadius;
|
clonedBorder.CornerRadius = originalBorder.CornerRadius;
|
||||||
|
|
||||||
// 复制位置
|
// 复制位置
|
||||||
InkCanvas.SetLeft(clonedBorder, InkCanvas.GetLeft(originalBorder));
|
InkCanvas.SetLeft(clonedBorder, InkCanvas.GetLeft(originalBorder));
|
||||||
InkCanvas.SetTop(clonedBorder, InkCanvas.GetTop(originalBorder));
|
InkCanvas.SetTop(clonedBorder, InkCanvas.GetTop(originalBorder));
|
||||||
|
|
||||||
// 复制变换
|
// 复制变换
|
||||||
if (originalBorder.RenderTransform != null)
|
if (originalBorder.RenderTransform != null)
|
||||||
{
|
{
|
||||||
clonedBorder.RenderTransform = originalBorder.RenderTransform.Clone();
|
clonedBorder.RenderTransform = originalBorder.RenderTransform.Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
return clonedBorder;
|
return clonedBorder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"克隆UI元素失败: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"克隆UI元素失败: {ex.Message}", LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,14 +246,14 @@ namespace Ink_Canvas
|
|||||||
if (drawingShapeMode != 0)
|
if (drawingShapeMode != 0)
|
||||||
{
|
{
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||||
|
|
||||||
isTouchDown = true;
|
isTouchDown = true;
|
||||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||||
|
|
||||||
// 设置起始点
|
// 设置起始点
|
||||||
if (NeedUpdateIniP()) iniP = e.GetTouchPoint(inkCanvas).Position;
|
if (NeedUpdateIniP()) iniP = e.GetTouchPoint(inkCanvas).Position;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,14 +292,14 @@ namespace Ink_Canvas
|
|||||||
if (drawingShapeMode != 0)
|
if (drawingShapeMode != 0)
|
||||||
{
|
{
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||||
|
|
||||||
isTouchDown = true;
|
isTouchDown = true;
|
||||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||||
|
|
||||||
// 设置起始点
|
// 设置起始点
|
||||||
if (NeedUpdateIniP()) iniP = e.GetPosition(inkCanvas);
|
if (NeedUpdateIniP()) iniP = e.GetPosition(inkCanvas);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke)
|
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke)
|
||||||
@@ -354,7 +354,7 @@ namespace Ink_Canvas
|
|||||||
isTouchDown = false;
|
isTouchDown = false;
|
||||||
ViewboxFloatingBar.IsHitTestVisible = true;
|
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||||
|
|
||||||
// 对于双曲线等需要多步绘制的图形,手写笔抬起时应该进入下一步
|
// 对于双曲线等需要多步绘制的图形,手写笔抬起时应该进入下一步
|
||||||
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
||||||
{
|
{
|
||||||
@@ -384,7 +384,7 @@ namespace Ink_Canvas
|
|||||||
};
|
};
|
||||||
inkCanvas_MouseUp(inkCanvas, mouseArgs);
|
inkCanvas_MouseUp(inkCanvas, mouseArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +393,7 @@ namespace Ink_Canvas
|
|||||||
var stroke = GetStrokeVisual(e.StylusDevice.Id).Stroke;
|
var stroke = GetStrokeVisual(e.StylusDevice.Id).Stroke;
|
||||||
|
|
||||||
inkCanvas.Strokes.Add(stroke);
|
inkCanvas.Strokes.Add(stroke);
|
||||||
await Task.Delay(5);
|
await Task.Delay(5);
|
||||||
inkCanvas.Children.Remove(GetVisualCanvas(e.StylusDevice.Id));
|
inkCanvas.Children.Remove(GetVisualCanvas(e.StylusDevice.Id));
|
||||||
|
|
||||||
inkCanvas_StrokeCollected(inkCanvas,
|
inkCanvas_StrokeCollected(inkCanvas,
|
||||||
@@ -464,7 +464,7 @@ namespace Ink_Canvas
|
|||||||
var strokeVisual = GetStrokeVisual(e.StylusDevice.Id);
|
var strokeVisual = GetStrokeVisual(e.StylusDevice.Id);
|
||||||
var stylusPointCollection = e.GetStylusPoints(this);
|
var stylusPointCollection = e.GetStylusPoints(this);
|
||||||
foreach (var stylusPoint in stylusPointCollection)
|
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();
|
strokeVisual.Redraw();
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
@@ -538,15 +538,15 @@ namespace Ink_Canvas
|
|||||||
if (drawingShapeMode != 0)
|
if (drawingShapeMode != 0)
|
||||||
{
|
{
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||||
|
|
||||||
// 设置触摸状态,类似鼠标事件处理
|
// 设置触摸状态,类似鼠标事件处理
|
||||||
isTouchDown = true;
|
isTouchDown = true;
|
||||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||||
|
|
||||||
// 设置起始点
|
// 设置起始点
|
||||||
if (NeedUpdateIniP()) iniP = e.GetTouchPoint(inkCanvas).Position;
|
if (NeedUpdateIniP()) iniP = e.GetTouchPoint(inkCanvas).Position;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
||||||
@@ -604,7 +604,7 @@ namespace Ink_Canvas
|
|||||||
inkCanvas.CaptureTouch(e.TouchDevice);
|
inkCanvas.CaptureTouch(e.TouchDevice);
|
||||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||||
|
|
||||||
isTouchDown = true;
|
isTouchDown = true;
|
||||||
|
|
||||||
if (dec.Count == 0)
|
if (dec.Count == 0)
|
||||||
@@ -646,7 +646,7 @@ namespace Ink_Canvas
|
|||||||
double boundWidth = GetTouchBoundWidth(e);
|
double boundWidth = GetTouchBoundWidth(e);
|
||||||
|
|
||||||
|
|
||||||
if ((Settings.Advanced.TouchMultiplier != 0 || !Settings.Advanced.IsSpecialScreen)
|
if ((Settings.Advanced.TouchMultiplier != 0 || !Settings.Advanced.IsSpecialScreen)
|
||||||
&& (boundWidth > BoundsWidth))
|
&& (boundWidth > BoundsWidth))
|
||||||
{
|
{
|
||||||
// 根据敏感度调整阈值倍数
|
// 根据敏感度调整阈值倍数
|
||||||
@@ -665,10 +665,10 @@ namespace Ink_Canvas
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
double EraserThresholdValue = Settings.Startup.IsEnableNibMode ?
|
double EraserThresholdValue = Settings.Startup.IsEnableNibMode ?
|
||||||
Settings.Advanced.NibModeBoundsWidthThresholdValue :
|
Settings.Advanced.NibModeBoundsWidthThresholdValue :
|
||||||
Settings.Advanced.FingerModeBoundsWidthThresholdValue;
|
Settings.Advanced.FingerModeBoundsWidthThresholdValue;
|
||||||
|
|
||||||
if (boundWidth > BoundsWidth * EraserThresholdValue * thresholdMultiplier)
|
if (boundWidth > BoundsWidth * EraserThresholdValue * thresholdMultiplier)
|
||||||
{
|
{
|
||||||
// 记录当前编辑模式和高光状态
|
// 记录当前编辑模式和高光状态
|
||||||
@@ -676,17 +676,17 @@ namespace Ink_Canvas
|
|||||||
palmEraserLastIsHighlighter = drawingAttributes.IsHighlighter;
|
palmEraserLastIsHighlighter = drawingAttributes.IsHighlighter;
|
||||||
|
|
||||||
// 动态调整橡皮大小
|
// 动态调整橡皮大小
|
||||||
boundWidth *= (Settings.Startup.IsEnableNibMode ?
|
boundWidth *= (Settings.Startup.IsEnableNibMode ?
|
||||||
Settings.Advanced.NibModeBoundsWidthEraserSize :
|
Settings.Advanced.NibModeBoundsWidthEraserSize :
|
||||||
Settings.Advanced.FingerModeBoundsWidthEraserSize);
|
Settings.Advanced.FingerModeBoundsWidthEraserSize);
|
||||||
|
|
||||||
if (Settings.Advanced.IsSpecialScreen)
|
if (Settings.Advanced.IsSpecialScreen)
|
||||||
boundWidth *= Settings.Advanced.TouchMultiplier;
|
boundWidth *= Settings.Advanced.TouchMultiplier;
|
||||||
|
|
||||||
inkCanvas.EraserShape = new EllipseStylusShape(boundWidth, boundWidth);
|
inkCanvas.EraserShape = new EllipseStylusShape(boundWidth, boundWidth);
|
||||||
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
|
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
|
||||||
isPalmEraserActive = true;
|
isPalmEraserActive = true;
|
||||||
|
|
||||||
// 启用橡皮擦覆盖层显示手掌擦样式
|
// 启用橡皮擦覆盖层显示手掌擦样式
|
||||||
EnableEraserOverlay();
|
EnableEraserOverlay();
|
||||||
// 更新橡皮擦大小以匹配手掌擦面积
|
// 更新橡皮擦大小以匹配手掌擦面积
|
||||||
@@ -746,7 +746,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
isMultiTouchTimerActive = true;
|
isMultiTouchTimerActive = true;
|
||||||
var remainingTime = MULTI_TOUCH_DELAY_MS - timeSinceLastTouch;
|
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(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
@@ -760,7 +760,7 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastInkCanvasEditingMode = inkCanvas.EditingMode;
|
lastInkCanvasEditingMode = inkCanvas.EditingMode;
|
||||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint
|
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint
|
||||||
&& inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke
|
&& inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke
|
||||||
@@ -773,7 +773,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
private void inkCanvas_PreviewTouchMove(object sender, TouchEventArgs e)
|
private void inkCanvas_PreviewTouchMove(object sender, TouchEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
// 如果手掌擦激活,更新橡皮擦反馈位置
|
// 如果手掌擦激活,更新橡皮擦反馈位置
|
||||||
if (isPalmEraserActive)
|
if (isPalmEraserActive)
|
||||||
{
|
{
|
||||||
@@ -795,13 +795,13 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// Palm Eraser 逻辑
|
// Palm Eraser 逻辑
|
||||||
dec.Remove(e.TouchDevice.Id);
|
dec.Remove(e.TouchDevice.Id);
|
||||||
|
|
||||||
// 重置多触控点定时器状态
|
// 重置多触控点定时器状态
|
||||||
if (dec.Count <= 1)
|
if (dec.Count <= 1)
|
||||||
{
|
{
|
||||||
isMultiTouchTimerActive = false;
|
isMultiTouchTimerActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 当手掌擦激活且所有触摸点都抬起时,恢复原编辑模式
|
// 当手掌擦激活且所有触摸点都抬起时,恢复原编辑模式
|
||||||
if (isPalmEraserActive && dec.Count == 0)
|
if (isPalmEraserActive && dec.Count == 0)
|
||||||
@@ -842,7 +842,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 重置手掌擦状态
|
// 重置手掌擦状态
|
||||||
isPalmEraserActive = false;
|
isPalmEraserActive = false;
|
||||||
|
|
||||||
// 禁用橡皮擦覆盖层
|
// 禁用橡皮擦覆盖层
|
||||||
DisableEraserOverlay();
|
DisableEraserOverlay();
|
||||||
if (Settings.Canvas.IsShowCursor)
|
if (Settings.Canvas.IsShowCursor)
|
||||||
@@ -859,7 +859,7 @@ namespace Ink_Canvas
|
|||||||
isTouchDown = false;
|
isTouchDown = false;
|
||||||
ViewboxFloatingBar.IsHitTestVisible = true;
|
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||||
|
|
||||||
// 对于双曲线等需要多步绘制的图形,触摸抬手时应该进入下一步
|
// 对于双曲线等需要多步绘制的图形,触摸抬手时应该进入下一步
|
||||||
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
if (drawingShapeMode == 24 || drawingShapeMode == 25)
|
||||||
{
|
{
|
||||||
@@ -917,7 +917,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");
|
||||||
|
|
||||||
@@ -1010,7 +1010,7 @@ 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))
|
||||||
{
|
{
|
||||||
ResetTouchStates();
|
ResetTouchStates();
|
||||||
@@ -1113,7 +1113,7 @@ namespace Ink_Canvas
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var stroke in inkCanvas.Strokes) stroke.Transform(m, false);
|
foreach (var stroke in inkCanvas.Strokes) stroke.Transform(m, false);
|
||||||
|
|
||||||
// 同时变换画布上的图片元素
|
// 同时变换画布上的图片元素
|
||||||
TransformCanvasImages(m);
|
TransformCanvasImages(m);
|
||||||
}
|
}
|
||||||
@@ -1144,7 +1144,7 @@ namespace Ink_Canvas
|
|||||||
for (int i = inkCanvas.Children.Count - 1; i >= 0; i--)
|
for (int i = inkCanvas.Children.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
var child = inkCanvas.Children[i];
|
var child = inkCanvas.Children[i];
|
||||||
|
|
||||||
if (child is Image image)
|
if (child is Image image)
|
||||||
{
|
{
|
||||||
// 应用矩阵变换到图片
|
// 应用矩阵变换到图片
|
||||||
|
|||||||
@@ -209,15 +209,15 @@ namespace Ink_Canvas
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 获取全局快捷键管理器
|
// 获取全局快捷键管理器
|
||||||
var hotkeyManagerField = typeof(MainWindow).GetField("_globalHotkeyManager",
|
var hotkeyManagerField = typeof(MainWindow).GetField("_globalHotkeyManager",
|
||||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||||
var hotkeyManager = hotkeyManagerField?.GetValue(mainWin) as GlobalHotkeyManager;
|
var hotkeyManager = hotkeyManagerField?.GetValue(mainWin) as GlobalHotkeyManager;
|
||||||
|
|
||||||
if (hotkeyManager != null)
|
if (hotkeyManager != null)
|
||||||
{
|
{
|
||||||
// 禁用所有快捷键
|
// 禁用所有快捷键
|
||||||
hotkeyManager.DisableHotkeyRegistration();
|
hotkeyManager.DisableHotkeyRegistration();
|
||||||
|
|
||||||
// 更新菜单项文本和状态
|
// 更新菜单项文本和状态
|
||||||
var menuItem = sender as MenuItem;
|
var menuItem = sender as MenuItem;
|
||||||
if (menuItem != null)
|
if (menuItem != null)
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 墨迹渐隐功能设置
|
// 墨迹渐隐功能设置
|
||||||
[JsonProperty("enableInkFade")]
|
[JsonProperty("enableInkFade")]
|
||||||
public bool EnableInkFade { get; set; } = false;
|
public bool EnableInkFade { get; set; } = false;
|
||||||
[JsonProperty("inkFadeTime")]
|
[JsonProperty("inkFadeTime")]
|
||||||
public int InkFadeTime { get; set; } = 3000; // 墨迹渐隐时间(毫秒)
|
public int InkFadeTime { get; set; } = 3000; // 墨迹渐隐时间(毫秒)
|
||||||
|
|
||||||
@@ -472,7 +472,7 @@ namespace Ink_Canvas
|
|||||||
public bool IsEnabled { get; set; } = false;
|
public bool IsEnabled { get; set; } = false;
|
||||||
|
|
||||||
[JsonProperty("scanIntervalMs")]
|
[JsonProperty("scanIntervalMs")]
|
||||||
public int ScanIntervalMs { get; set; } = 5000;
|
public int ScanIntervalMs { get; set; } = 5000;
|
||||||
|
|
||||||
[JsonProperty("autoStart")]
|
[JsonProperty("autoStart")]
|
||||||
public bool AutoStart { get; set; } = false;
|
public bool AutoStart { get; set; } = false;
|
||||||
@@ -624,7 +624,7 @@ namespace Ink_Canvas
|
|||||||
[JsonProperty("directCallCiRand")]
|
[JsonProperty("directCallCiRand")]
|
||||||
public bool DirectCallCiRand { get; set; }
|
public bool DirectCallCiRand { get; set; }
|
||||||
[JsonProperty("externalCallerType")]
|
[JsonProperty("externalCallerType")]
|
||||||
public int ExternalCallerType { get; set; } = 0;
|
public int ExternalCallerType { get; set; } = 0;
|
||||||
[JsonProperty("selectedBackgroundIndex")]
|
[JsonProperty("selectedBackgroundIndex")]
|
||||||
public int SelectedBackgroundIndex { get; set; }
|
public int SelectedBackgroundIndex { get; set; }
|
||||||
[JsonProperty("customPickNameBackgrounds")]
|
[JsonProperty("customPickNameBackgrounds")]
|
||||||
@@ -682,15 +682,15 @@ namespace Ink_Canvas
|
|||||||
public class CameraSettings
|
public class CameraSettings
|
||||||
{
|
{
|
||||||
[JsonProperty("rotationAngle")]
|
[JsonProperty("rotationAngle")]
|
||||||
public int RotationAngle { get; set; } = 0;
|
public int RotationAngle { get; set; } = 0;
|
||||||
|
|
||||||
[JsonProperty("resolutionWidth")]
|
[JsonProperty("resolutionWidth")]
|
||||||
public int ResolutionWidth { get; set; } = 1920;
|
public int ResolutionWidth { get; set; } = 1920;
|
||||||
|
|
||||||
[JsonProperty("resolutionHeight")]
|
[JsonProperty("resolutionHeight")]
|
||||||
public int ResolutionHeight { get; set; } = 1080;
|
public int ResolutionHeight { get; set; } = 1080;
|
||||||
|
|
||||||
[JsonProperty("selectedCameraIndex")]
|
[JsonProperty("selectedCameraIndex")]
|
||||||
public int SelectedCameraIndex { get; set; } = 0;
|
public int SelectedCameraIndex { get; set; } = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Ink_Canvas.Helpers;
|
using Ink_Canvas.Helpers;
|
||||||
using Ink_Canvas.Resources;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Media;
|
using System.Media;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
@@ -7,7 +6,6 @@ using System.Windows;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
|
|
||||||
namespace Ink_Canvas
|
namespace Ink_Canvas
|
||||||
{
|
{
|
||||||
@@ -362,12 +360,12 @@ namespace Ink_Canvas
|
|||||||
HourPlus1Text.Text = "+1";
|
HourPlus1Text.Text = "+1";
|
||||||
HourMinus1Text.Text = "-1";
|
HourMinus1Text.Text = "-1";
|
||||||
HourMinus5Text.Text = "-5";
|
HourMinus5Text.Text = "-5";
|
||||||
|
|
||||||
MinutePlus5Text.Text = "+5";
|
MinutePlus5Text.Text = "+5";
|
||||||
MinutePlus1Text.Text = "+1";
|
MinutePlus1Text.Text = "+1";
|
||||||
MinuteMinus1Text.Text = "-1";
|
MinuteMinus1Text.Text = "-1";
|
||||||
MinuteMinus5Text.Text = "-5";
|
MinuteMinus5Text.Text = "-5";
|
||||||
|
|
||||||
SecondPlus5Text.Text = "+5";
|
SecondPlus5Text.Text = "+5";
|
||||||
SecondPlus1Text.Text = "+1";
|
SecondPlus1Text.Text = "+1";
|
||||||
SecondMinus1Text.Text = "-1";
|
SecondMinus1Text.Text = "-1";
|
||||||
@@ -380,12 +378,12 @@ namespace Ink_Canvas
|
|||||||
HourPlus1Text.Text = "∧";
|
HourPlus1Text.Text = "∧";
|
||||||
HourMinus1Text.Text = "∨";
|
HourMinus1Text.Text = "∨";
|
||||||
HourMinus5Text.Text = "∨∨";
|
HourMinus5Text.Text = "∨∨";
|
||||||
|
|
||||||
MinutePlus5Text.Text = "∧∧";
|
MinutePlus5Text.Text = "∧∧";
|
||||||
MinutePlus1Text.Text = "∧";
|
MinutePlus1Text.Text = "∧";
|
||||||
MinuteMinus1Text.Text = "∨";
|
MinuteMinus1Text.Text = "∨";
|
||||||
MinuteMinus5Text.Text = "∨∨";
|
MinuteMinus5Text.Text = "∨∨";
|
||||||
|
|
||||||
SecondPlus5Text.Text = "∧∧";
|
SecondPlus5Text.Text = "∧∧";
|
||||||
SecondPlus1Text.Text = "∧";
|
SecondPlus1Text.Text = "∧";
|
||||||
SecondMinus1Text.Text = "∨";
|
SecondMinus1Text.Text = "∨";
|
||||||
@@ -399,8 +397,8 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
double volume = MainWindow.Settings.RandSettings?.TimerVolume ?? 1.0;
|
double volume = MainWindow.Settings.RandSettings?.TimerVolume ?? 1.0;
|
||||||
mediaPlayer.Volume = volume;
|
mediaPlayer.Volume = volume;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(MainWindow.Settings.RandSettings?.CustomTimerSoundPath) &&
|
if (!string.IsNullOrEmpty(MainWindow.Settings.RandSettings?.CustomTimerSoundPath) &&
|
||||||
System.IO.File.Exists(MainWindow.Settings.RandSettings.CustomTimerSoundPath))
|
System.IO.File.Exists(MainWindow.Settings.RandSettings.CustomTimerSoundPath))
|
||||||
{
|
{
|
||||||
// 播放自定义铃声
|
// 播放自定义铃声
|
||||||
@@ -419,7 +417,7 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
mediaPlayer.Open(new Uri(tempPath));
|
mediaPlayer.Open(new Uri(tempPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaPlayer.Play();
|
mediaPlayer.Play();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile($"应用主题时出错: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"应用主题时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新为浅色主题颜色
|
/// 更新为浅色主题颜色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -109,7 +109,7 @@ namespace Ink_Canvas
|
|||||||
Resources["UpdateWindowTextPrimaryBrush"] = new SolidColorBrush(Color.FromRgb(0x1f, 0x29, 0x37));
|
Resources["UpdateWindowTextPrimaryBrush"] = new SolidColorBrush(Color.FromRgb(0x1f, 0x29, 0x37));
|
||||||
Resources["UpdateWindowTextSecondaryBrush"] = new SolidColorBrush(Color.FromRgb(0x6b, 0x72, 0x80));
|
Resources["UpdateWindowTextSecondaryBrush"] = new SolidColorBrush(Color.FromRgb(0x6b, 0x72, 0x80));
|
||||||
Resources["UpdateWindowCloseButtonBrush"] = new SolidColorBrush(Color.FromRgb(0x66, 0x66, 0x66));
|
Resources["UpdateWindowCloseButtonBrush"] = new SolidColorBrush(Color.FromRgb(0x66, 0x66, 0x66));
|
||||||
|
|
||||||
// 更新渐变背景
|
// 更新渐变背景
|
||||||
var gradient = new LinearGradientBrush();
|
var gradient = new LinearGradientBrush();
|
||||||
gradient.StartPoint = new Point(0, 0);
|
gradient.StartPoint = new Point(0, 0);
|
||||||
@@ -123,7 +123,7 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile($"更新浅色主题颜色时出错: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"更新浅色主题颜色时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新为深色主题颜色
|
/// 更新为深色主题颜色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -140,7 +140,7 @@ namespace Ink_Canvas
|
|||||||
Resources["UpdateWindowTextPrimaryBrush"] = new SolidColorBrush(Color.FromRgb(0xf9, 0xfa, 0xfb));
|
Resources["UpdateWindowTextPrimaryBrush"] = new SolidColorBrush(Color.FromRgb(0xf9, 0xfa, 0xfb));
|
||||||
Resources["UpdateWindowTextSecondaryBrush"] = new SolidColorBrush(Color.FromRgb(0x9c, 0xa3, 0xaf));
|
Resources["UpdateWindowTextSecondaryBrush"] = new SolidColorBrush(Color.FromRgb(0x9c, 0xa3, 0xaf));
|
||||||
Resources["UpdateWindowCloseButtonBrush"] = new SolidColorBrush(Color.FromRgb(0x9c, 0xa3, 0xaf));
|
Resources["UpdateWindowCloseButtonBrush"] = new SolidColorBrush(Color.FromRgb(0x9c, 0xa3, 0xaf));
|
||||||
|
|
||||||
// 更新渐变背景
|
// 更新渐变背景
|
||||||
var gradient = new LinearGradientBrush();
|
var gradient = new LinearGradientBrush();
|
||||||
gradient.StartPoint = new Point(0, 0);
|
gradient.StartPoint = new Point(0, 0);
|
||||||
@@ -154,7 +154,7 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile($"更新深色主题颜色时出错: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"更新深色主题颜色时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查系统是否为浅色主题
|
/// 检查系统是否为浅色主题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -270,7 +270,7 @@ namespace Ink_Canvas
|
|||||||
UpdateLaterButton.IsEnabled = false;
|
UpdateLaterButton.IsEnabled = false;
|
||||||
SkipVersionButton.IsEnabled = false;
|
SkipVersionButton.IsEnabled = false;
|
||||||
DownloadProgressPanel.Visibility = Visibility.Visible;
|
DownloadProgressPanel.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
// 重置进度条
|
// 重置进度条
|
||||||
var progressFill = FindName("ProgressFill") as Border;
|
var progressFill = FindName("ProgressFill") as Border;
|
||||||
if (progressFill != null)
|
if (progressFill != null)
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
|
|
||||||
// 应用当前主题
|
// 应用当前主题
|
||||||
ApplyCurrentTheme();
|
ApplyCurrentTheme();
|
||||||
|
|
||||||
LoadVersions();
|
LoadVersions();
|
||||||
|
|
||||||
// 添加窗口拖动功能
|
// 添加窗口拖动功能
|
||||||
MouseDown += (sender, e) =>
|
MouseDown += (sender, e) =>
|
||||||
{
|
{
|
||||||
@@ -48,7 +48,7 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 应用当前主题设置
|
/// 应用当前主题设置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -86,7 +86,7 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile($"应用主题时出错: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"应用主题时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新为浅色主题颜色
|
/// 更新为浅色主题颜色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -104,7 +104,7 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile($"更新浅色主题颜色时出错: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"更新浅色主题颜色时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新为深色主题颜色
|
/// 更新为深色主题颜色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -122,7 +122,7 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile($"更新深色主题颜色时出错: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"更新深色主题颜色时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查系统是否为浅色主题
|
/// 检查系统是否为浅色主题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using Ink_Canvas.Helpers;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@@ -7,15 +9,13 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using System.Drawing;
|
|
||||||
using Ink_Canvas.Helpers;
|
|
||||||
using Brushes = System.Windows.Media.Brushes;
|
using Brushes = System.Windows.Media.Brushes;
|
||||||
using Color = System.Windows.Media.Color;
|
using Color = System.Windows.Media.Color;
|
||||||
using DrawingRectangle = System.Drawing.Rectangle;
|
using DrawingRectangle = System.Drawing.Rectangle;
|
||||||
using WpfPoint = System.Windows.Point;
|
|
||||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||||
using WpfCanvas = System.Windows.Controls.Canvas;
|
using WpfCanvas = System.Windows.Controls.Canvas;
|
||||||
|
using WpfPoint = System.Windows.Point;
|
||||||
|
|
||||||
namespace Ink_Canvas
|
namespace Ink_Canvas
|
||||||
{
|
{
|
||||||
@@ -115,7 +115,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 初始化摄像头选择下拉框
|
// 初始化摄像头选择下拉框
|
||||||
RefreshCameraComboBox();
|
RefreshCameraComboBox();
|
||||||
|
|
||||||
// 初始化旋转和分辨率显示
|
// 初始化旋转和分辨率显示
|
||||||
InitializeCameraControls();
|
InitializeCameraControls();
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 更新旋转角度显示
|
// 更新旋转角度显示
|
||||||
UpdateRotationDisplay();
|
UpdateRotationDisplay();
|
||||||
|
|
||||||
// 设置分辨率下拉框
|
// 设置分辨率下拉框
|
||||||
var currentResolution = $"{_cameraService.ResolutionWidth}x{_cameraService.ResolutionHeight}";
|
var currentResolution = $"{_cameraService.ResolutionWidth}x{_cameraService.ResolutionHeight}";
|
||||||
foreach (ComboBoxItem item in ResolutionComboBox.Items)
|
foreach (ComboBoxItem item in ResolutionComboBox.Items)
|
||||||
@@ -150,7 +150,7 @@ namespace Ink_Canvas
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
CameraSelectionComboBox.Items.Clear();
|
CameraSelectionComboBox.Items.Clear();
|
||||||
|
|
||||||
if (_cameraService.HasAvailableCameras())
|
if (_cameraService.HasAvailableCameras())
|
||||||
{
|
{
|
||||||
var cameraNames = _cameraService.GetCameraNames();
|
var cameraNames = _cameraService.GetCameraNames();
|
||||||
@@ -158,7 +158,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
CameraSelectionComboBox.Items.Add(name);
|
CameraSelectionComboBox.Items.Add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cameraNames.Count > 0)
|
if (cameraNames.Count > 0)
|
||||||
{
|
{
|
||||||
CameraSelectionComboBox.SelectedIndex = 0;
|
CameraSelectionComboBox.SelectedIndex = 0;
|
||||||
@@ -203,7 +203,7 @@ namespace Ink_Canvas
|
|||||||
CameraPreviewImage.Source = bitmapSource;
|
CameraPreviewImage.Source = bitmapSource;
|
||||||
CameraStatusText.Text = "摄像头已连接";
|
CameraStatusText.Text = "摄像头已连接";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 释放临时位图
|
// 释放临时位图
|
||||||
clonedFrame.Dispose();
|
clonedFrame.Dispose();
|
||||||
}
|
}
|
||||||
@@ -393,10 +393,10 @@ namespace Ink_Canvas
|
|||||||
RectangleModeButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
RectangleModeButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
||||||
FreehandModeButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
FreehandModeButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
||||||
CameraModeButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
CameraModeButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
||||||
|
|
||||||
// 隐藏摄像头预览
|
// 隐藏摄像头预览
|
||||||
CameraPreviewBorder.Visibility = Visibility.Collapsed;
|
CameraPreviewBorder.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
// 直接执行全屏截图
|
// 直接执行全屏截图
|
||||||
PerformFullScreenCapture();
|
PerformFullScreenCapture();
|
||||||
}
|
}
|
||||||
@@ -512,10 +512,10 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 保存BitmapSource而不是Bitmap
|
// 保存BitmapSource而不是Bitmap
|
||||||
CameraBitmapSource = bitmapSource;
|
CameraBitmapSource = bitmapSource;
|
||||||
|
|
||||||
// 停止摄像头预览
|
// 停止摄像头预览
|
||||||
_cameraService.StopPreview();
|
_cameraService.StopPreview();
|
||||||
|
|
||||||
// 设置结果并关闭窗口
|
// 设置结果并关闭窗口
|
||||||
DialogResult = true;
|
DialogResult = true;
|
||||||
Close();
|
Close();
|
||||||
@@ -1164,11 +1164,11 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 获取虚拟屏幕边界
|
// 获取虚拟屏幕边界
|
||||||
var virtualScreen = SystemInformation.VirtualScreen;
|
var virtualScreen = SystemInformation.VirtualScreen;
|
||||||
|
|
||||||
// 设置全屏截图区域
|
// 设置全屏截图区域
|
||||||
SelectedArea = new DrawingRectangle(virtualScreen.X, virtualScreen.Y, virtualScreen.Width, virtualScreen.Height);
|
SelectedArea = new DrawingRectangle(virtualScreen.X, virtualScreen.Y, virtualScreen.Width, virtualScreen.Height);
|
||||||
SelectedPath = null; // 全屏截图不需要路径
|
SelectedPath = null; // 全屏截图不需要路径
|
||||||
|
|
||||||
// 直接关闭窗口并返回结果
|
// 直接关闭窗口并返回结果
|
||||||
DialogResult = true;
|
DialogResult = true;
|
||||||
Close();
|
Close();
|
||||||
@@ -1271,8 +1271,8 @@ namespace Ink_Canvas
|
|||||||
if (!string.IsNullOrEmpty(resolution))
|
if (!string.IsNullOrEmpty(resolution))
|
||||||
{
|
{
|
||||||
var parts = resolution.Split(',');
|
var parts = resolution.Split(',');
|
||||||
if (parts.Length == 2 &&
|
if (parts.Length == 2 &&
|
||||||
int.TryParse(parts[0], out int width) &&
|
int.TryParse(parts[0], out int width) &&
|
||||||
int.TryParse(parts[1], out int height))
|
int.TryParse(parts[1], out int height))
|
||||||
{
|
{
|
||||||
_cameraService.ResolutionWidth = width;
|
_cameraService.ResolutionWidth = width;
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using System.IO;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Ink_Canvas.Windows
|
namespace Ink_Canvas.Windows
|
||||||
{
|
{
|
||||||
@@ -18,7 +17,7 @@ namespace Ink_Canvas.Windows
|
|||||||
{
|
{
|
||||||
private DispatcherTimer _timer;
|
private DispatcherTimer _timer;
|
||||||
private int _loadingStep = 0;
|
private int _loadingStep = 0;
|
||||||
private int _actualSplashStyle = 1;
|
private int _actualSplashStyle = 1;
|
||||||
private readonly string[] _loadingMessages = {
|
private readonly string[] _loadingMessages = {
|
||||||
"正在启动 Ink Canvas...",
|
"正在启动 Ink Canvas...",
|
||||||
"正在初始化组件...",
|
"正在初始化组件...",
|
||||||
@@ -37,13 +36,13 @@ namespace Ink_Canvas.Windows
|
|||||||
{
|
{
|
||||||
// 设置窗口居中
|
// 设置窗口居中
|
||||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
|
|
||||||
// 设置版本号
|
// 设置版本号
|
||||||
SetVersionText();
|
SetVersionText();
|
||||||
|
|
||||||
// 加载启动图片并获取实际样式
|
// 加载启动图片并获取实际样式
|
||||||
_actualSplashStyle = LoadSplashImageWithStyle();
|
_actualSplashStyle = LoadSplashImageWithStyle();
|
||||||
|
|
||||||
// 启动加载动画
|
// 启动加载动画
|
||||||
StartLoadingAnimation();
|
StartLoadingAnimation();
|
||||||
}
|
}
|
||||||
@@ -52,7 +51,7 @@ namespace Ink_Canvas.Windows
|
|||||||
{
|
{
|
||||||
_timer = new DispatcherTimer
|
_timer = new DispatcherTimer
|
||||||
{
|
{
|
||||||
Interval = TimeSpan.FromMilliseconds(1200)
|
Interval = TimeSpan.FromMilliseconds(1200)
|
||||||
};
|
};
|
||||||
_timer.Tick += Timer_Tick;
|
_timer.Tick += Timer_Tick;
|
||||||
_timer.Start();
|
_timer.Start();
|
||||||
@@ -83,7 +82,7 @@ namespace Ink_Canvas.Windows
|
|||||||
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseIn }
|
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseIn }
|
||||||
};
|
};
|
||||||
|
|
||||||
fadeOutAnimation.Completed += (s, e) =>
|
fadeOutAnimation.Completed += (s, e) =>
|
||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
};
|
};
|
||||||
@@ -101,7 +100,7 @@ namespace Ink_Canvas.Windows
|
|||||||
{
|
{
|
||||||
// 设置进度条颜色
|
// 设置进度条颜色
|
||||||
SetProgressBarColor();
|
SetProgressBarColor();
|
||||||
|
|
||||||
// 获取进度条容器的实际宽度
|
// 获取进度条容器的实际宽度
|
||||||
double containerWidth = ProgressBarBackground.ActualWidth;
|
double containerWidth = ProgressBarBackground.ActualWidth;
|
||||||
if (containerWidth <= 0)
|
if (containerWidth <= 0)
|
||||||
@@ -109,13 +108,13 @@ namespace Ink_Canvas.Windows
|
|||||||
// 如果ActualWidth为0,使用设计时宽度
|
// 如果ActualWidth为0,使用设计时宽度
|
||||||
containerWidth = 530;
|
containerWidth = 530;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算目标宽度
|
// 计算目标宽度
|
||||||
double targetWidth = containerWidth * (progress / 100.0);
|
double targetWidth = containerWidth * (progress / 100.0);
|
||||||
|
|
||||||
// 创建Storyboard动画
|
// 创建Storyboard动画
|
||||||
var storyboard = new Storyboard();
|
var storyboard = new Storyboard();
|
||||||
|
|
||||||
// 创建宽度动画
|
// 创建宽度动画
|
||||||
var widthAnimation = new DoubleAnimation
|
var widthAnimation = new DoubleAnimation
|
||||||
{
|
{
|
||||||
@@ -124,20 +123,20 @@ namespace Ink_Canvas.Windows
|
|||||||
Duration = TimeSpan.FromMilliseconds(300),
|
Duration = TimeSpan.FromMilliseconds(300),
|
||||||
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
|
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
|
||||||
};
|
};
|
||||||
|
|
||||||
// 设置动画目标
|
// 设置动画目标
|
||||||
Storyboard.SetTarget(widthAnimation, ProgressBarFill);
|
Storyboard.SetTarget(widthAnimation, ProgressBarFill);
|
||||||
Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(Border.WidthProperty));
|
Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(Border.WidthProperty));
|
||||||
|
|
||||||
// 添加动画到Storyboard
|
// 添加动画到Storyboard
|
||||||
storyboard.Children.Add(widthAnimation);
|
storyboard.Children.Add(widthAnimation);
|
||||||
|
|
||||||
// 添加动画完成事件
|
// 添加动画完成事件
|
||||||
storyboard.Completed += (s, e) =>
|
storyboard.Completed += (s, e) =>
|
||||||
{
|
{
|
||||||
// 确保最终值正确设置
|
// 确保最终值正确设置
|
||||||
ProgressBarFill.Width = targetWidth;
|
ProgressBarFill.Width = targetWidth;
|
||||||
|
|
||||||
// 根据进度调整圆角
|
// 根据进度调整圆角
|
||||||
if (progress >= 100)
|
if (progress >= 100)
|
||||||
{
|
{
|
||||||
@@ -150,7 +149,7 @@ namespace Ink_Canvas.Windows
|
|||||||
ProgressBarFill.CornerRadius = new CornerRadius(0, 0, 0, 7);
|
ProgressBarFill.CornerRadius = new CornerRadius(0, 0, 0, 7);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 开始动画
|
// 开始动画
|
||||||
storyboard.Begin();
|
storyboard.Begin();
|
||||||
});
|
});
|
||||||
@@ -171,7 +170,7 @@ namespace Ink_Canvas.Windows
|
|||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
LoadingText.Text = message;
|
LoadingText.Text = message;
|
||||||
|
|
||||||
// 根据实际启动动画样式调整加载文本样式
|
// 根据实际启动动画样式调整加载文本样式
|
||||||
if (actualSplashStyle == 6) // 马年限定
|
if (actualSplashStyle == 6) // 马年限定
|
||||||
{
|
{
|
||||||
@@ -180,7 +179,7 @@ namespace Ink_Canvas.Windows
|
|||||||
LoadingText.FontWeight = FontWeights.SemiBold;
|
LoadingText.FontWeight = FontWeights.SemiBold;
|
||||||
LoadingText.Foreground = Brushes.White;
|
LoadingText.Foreground = Brushes.White;
|
||||||
LoadingText.HorizontalAlignment = HorizontalAlignment.Center;
|
LoadingText.HorizontalAlignment = HorizontalAlignment.Center;
|
||||||
LoadingText.Margin = new Thickness(0,200,140,4);
|
LoadingText.Margin = new Thickness(0, 200, 140, 4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -189,7 +188,7 @@ namespace Ink_Canvas.Windows
|
|||||||
LoadingText.FontWeight = FontWeights.SemiBold;
|
LoadingText.FontWeight = FontWeights.SemiBold;
|
||||||
LoadingText.Foreground = Brushes.White;
|
LoadingText.Foreground = Brushes.White;
|
||||||
LoadingText.HorizontalAlignment = HorizontalAlignment.Center;
|
LoadingText.HorizontalAlignment = HorizontalAlignment.Center;
|
||||||
LoadingText.Margin = new Thickness(0,200,0,0);
|
LoadingText.Margin = new Thickness(0, 200, 0, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -282,7 +281,7 @@ namespace Ink_Canvas.Windows
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine($"加载启动图片失败: {ex.Message}");
|
System.Diagnostics.Debug.WriteLine($"加载启动图片失败: {ex.Message}");
|
||||||
return GetActualStyle(1);
|
return GetActualStyle(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +295,7 @@ namespace Ink_Canvas.Windows
|
|||||||
// 读取设置
|
// 读取设置
|
||||||
var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "Settings.json");
|
var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "Settings.json");
|
||||||
int splashStyle = 1; // 默认跟随四季
|
int splashStyle = 1; // 默认跟随四季
|
||||||
|
|
||||||
if (File.Exists(settingsPath))
|
if (File.Exists(settingsPath))
|
||||||
{
|
{
|
||||||
var json = File.ReadAllText(settingsPath);
|
var json = File.ReadAllText(settingsPath);
|
||||||
@@ -313,7 +312,7 @@ namespace Ink_Canvas.Windows
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
string imageName = GetImageNameByStyle(1);
|
string imageName = GetImageNameByStyle(1);
|
||||||
return $"pack://application:,,,/Resources/Startup-animation/{imageName}";
|
return $"pack://application:,,,/Resources/Startup-animation/{imageName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,7 +329,7 @@ namespace Ink_Canvas.Windows
|
|||||||
// 读取设置
|
// 读取设置
|
||||||
var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "Settings.json");
|
var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "Settings.json");
|
||||||
int splashStyle = 1; // 默认跟随四季
|
int splashStyle = 1; // 默认跟随四季
|
||||||
|
|
||||||
if (File.Exists(settingsPath))
|
if (File.Exists(settingsPath))
|
||||||
{
|
{
|
||||||
var json = File.ReadAllText(settingsPath);
|
var json = File.ReadAllText(settingsPath);
|
||||||
@@ -349,7 +348,7 @@ namespace Ink_Canvas.Windows
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
actualStyle = GetActualStyle(1);
|
actualStyle = GetActualStyle(1);
|
||||||
string imageName = GetImageNameByStyle(1);
|
string imageName = GetImageNameByStyle(1);
|
||||||
return $"pack://application:,,,/Resources/Startup-animation/{imageName}";
|
return $"pack://application:,,,/Resources/Startup-animation/{imageName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -367,16 +366,16 @@ namespace Ink_Canvas.Windows
|
|||||||
var random = new Random();
|
var random = new Random();
|
||||||
var randomStyles = new[] { 2, 3, 4, 5, 6 }; // 春季、夏季、秋季、冬季、马年限定
|
var randomStyles = new[] { 2, 3, 4, 5, 6 }; // 春季、夏季、秋季、冬季、马年限定
|
||||||
return randomStyles[random.Next(randomStyles.Length)];
|
return randomStyles[random.Next(randomStyles.Length)];
|
||||||
|
|
||||||
case 1: // 跟随四季
|
case 1: // 跟随四季
|
||||||
var month = DateTime.Now.Month;
|
var month = DateTime.Now.Month;
|
||||||
if (month >= 3 && month <= 5) return 2; // 春季
|
if (month >= 3 && month <= 5) return 2; // 春季
|
||||||
if (month >= 6 && month <= 8) return 3; // 夏季
|
if (month >= 6 && month <= 8) return 3; // 夏季
|
||||||
if (month >= 9 && month <= 11) return 4; // 秋季
|
if (month >= 9 && month <= 11) return 4; // 秋季
|
||||||
return 5; // 冬季
|
return 5; // 冬季
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,14 +390,14 @@ namespace Ink_Canvas.Windows
|
|||||||
var random = new Random();
|
var random = new Random();
|
||||||
var randomStyles = new[] { 2, 3, 4, 5, 6 }; // 春季、夏季、秋季、冬季、马年限定
|
var randomStyles = new[] { 2, 3, 4, 5, 6 }; // 春季、夏季、秋季、冬季、马年限定
|
||||||
return GetImageNameByStyle(randomStyles[random.Next(randomStyles.Length)]);
|
return GetImageNameByStyle(randomStyles[random.Next(randomStyles.Length)]);
|
||||||
|
|
||||||
case 1: // 跟随四季
|
case 1: // 跟随四季
|
||||||
var month = DateTime.Now.Month;
|
var month = DateTime.Now.Month;
|
||||||
if (month >= 3 && month <= 5) return GetImageNameByStyle(2); // 春季
|
if (month >= 3 && month <= 5) return GetImageNameByStyle(2); // 春季
|
||||||
if (month >= 6 && month <= 8) return GetImageNameByStyle(3); // 夏季
|
if (month >= 6 && month <= 8) return GetImageNameByStyle(3); // 夏季
|
||||||
if (month >= 9 && month <= 11) return GetImageNameByStyle(4); // 秋季
|
if (month >= 9 && month <= 11) return GetImageNameByStyle(4); // 秋季
|
||||||
return GetImageNameByStyle(5); // 冬季
|
return GetImageNameByStyle(5); // 冬季
|
||||||
|
|
||||||
case 2: // 春季
|
case 2: // 春季
|
||||||
return "ICC Spring.png";
|
return "ICC Spring.png";
|
||||||
case 3: // 夏季
|
case 3: // 夏季
|
||||||
@@ -410,7 +409,7 @@ namespace Ink_Canvas.Windows
|
|||||||
case 6: // 马年限定
|
case 6: // 马年限定
|
||||||
return "ICC Horse.png";
|
return "ICC Horse.png";
|
||||||
default:// 默认返回
|
default:// 默认返回
|
||||||
return "ICC Horse.png";
|
return "ICC Horse.png";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,7 +419,7 @@ namespace Ink_Canvas.Windows
|
|||||||
private void SetProgressBarColor()
|
private void SetProgressBarColor()
|
||||||
{
|
{
|
||||||
Color progressColor;
|
Color progressColor;
|
||||||
|
|
||||||
switch (_actualSplashStyle)
|
switch (_actualSplashStyle)
|
||||||
{
|
{
|
||||||
case 2: // 春季 - H=136, S=15, L=22
|
case 2: // 春季 - H=136, S=15, L=22
|
||||||
@@ -442,14 +441,14 @@ namespace Ink_Canvas.Windows
|
|||||||
progressColor = Colors.White;
|
progressColor = Colors.White;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建渐变画刷
|
// 创建渐变画刷
|
||||||
var gradientBrush = new LinearGradientBrush
|
var gradientBrush = new LinearGradientBrush
|
||||||
{
|
{
|
||||||
StartPoint = new System.Windows.Point(0, 0),
|
StartPoint = new System.Windows.Point(0, 0),
|
||||||
EndPoint = new System.Windows.Point(1, 0)
|
EndPoint = new System.Windows.Point(1, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
// 根据颜色类型设置渐变
|
// 根据颜色类型设置渐变
|
||||||
if (_actualSplashStyle == 6) // 马年限定使用白色渐变
|
if (_actualSplashStyle == 6) // 马年限定使用白色渐变
|
||||||
{
|
{
|
||||||
@@ -459,7 +458,7 @@ namespace Ink_Canvas.Windows
|
|||||||
}
|
}
|
||||||
else // 其他样式使用HSL颜色的渐变
|
else // 其他样式使用HSL颜色的渐变
|
||||||
{
|
{
|
||||||
var lighterColor = Color.FromArgb(255,
|
var lighterColor = Color.FromArgb(255,
|
||||||
(byte)Math.Min(255, progressColor.R + 30),
|
(byte)Math.Min(255, progressColor.R + 30),
|
||||||
(byte)Math.Min(255, progressColor.G + 30),
|
(byte)Math.Min(255, progressColor.G + 30),
|
||||||
(byte)Math.Min(255, progressColor.B + 30));
|
(byte)Math.Min(255, progressColor.B + 30));
|
||||||
@@ -467,12 +466,12 @@ namespace Ink_Canvas.Windows
|
|||||||
(byte)Math.Max(0, progressColor.R - 30),
|
(byte)Math.Max(0, progressColor.R - 30),
|
||||||
(byte)Math.Max(0, progressColor.G - 30),
|
(byte)Math.Max(0, progressColor.G - 30),
|
||||||
(byte)Math.Max(0, progressColor.B - 30));
|
(byte)Math.Max(0, progressColor.B - 30));
|
||||||
|
|
||||||
gradientBrush.GradientStops.Add(new GradientStop(lighterColor, 0));
|
gradientBrush.GradientStops.Add(new GradientStop(lighterColor, 0));
|
||||||
gradientBrush.GradientStops.Add(new GradientStop(progressColor, 0.5));
|
gradientBrush.GradientStops.Add(new GradientStop(progressColor, 0.5));
|
||||||
gradientBrush.GradientStops.Add(new GradientStop(darkerColor, 1));
|
gradientBrush.GradientStops.Add(new GradientStop(darkerColor, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressBarFill.Background = gradientBrush;
|
ProgressBarFill.Background = gradientBrush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user