优化代码
This commit is contained in:
+71
-65
@@ -1,19 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using Microsoft.Win32;
|
||||
using System.Security;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using Newtonsoft.Json;
|
||||
using Application = System.Windows.Application;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net;
|
||||
using Timer = System.Threading.Timer;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -22,17 +29,17 @@ namespace Ink_Canvas
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
System.Threading.Mutex mutex;
|
||||
Mutex mutex;
|
||||
|
||||
public static string[] StartArgs = null;
|
||||
public static string[] StartArgs;
|
||||
public static string RootPath = Environment.GetEnvironmentVariable("APPDATA") + "\\Ink Canvas\\";
|
||||
|
||||
// 新增:保存看门狗进程对象
|
||||
private static Process watchdogProcess = null;
|
||||
private static Process watchdogProcess;
|
||||
// 新增:标记是否为软件内主动退出
|
||||
public static bool IsAppExitByUser = false;
|
||||
public static bool IsAppExitByUser;
|
||||
// 新增:退出信号文件路径
|
||||
private static string watchdogExitSignalFile = Path.Combine(Path.GetTempPath(), "icc_watchdog_exit_" + System.Diagnostics.Process.GetCurrentProcess().Id + ".flag");
|
||||
private static string watchdogExitSignalFile = Path.Combine(Path.GetTempPath(), "icc_watchdog_exit_" + Process.GetCurrentProcess().Id + ".flag");
|
||||
// 新增:崩溃日志文件路径
|
||||
private static string crashLogFile = Path.Combine(Environment.GetEnvironmentVariable("APPDATA"), "Ink Canvas", "crash_logs");
|
||||
// 新增:进程ID
|
||||
@@ -42,7 +49,7 @@ namespace Ink_Canvas
|
||||
// 新增:最后一次错误信息
|
||||
private static string lastErrorMessage = string.Empty;
|
||||
// 新增:是否已初始化崩溃监听器
|
||||
private static bool crashListenersInitialized = false;
|
||||
private static bool crashListenersInitialized;
|
||||
|
||||
public App()
|
||||
{
|
||||
@@ -61,8 +68,8 @@ namespace Ink_Canvas
|
||||
// 启动时优先同步设置,确保CrashAction为最新
|
||||
SyncCrashActionFromSettings();
|
||||
|
||||
this.Startup += new StartupEventHandler(App_Startup);
|
||||
this.DispatcherUnhandledException += App_DispatcherUnhandledException;
|
||||
Startup += App_Startup;
|
||||
DispatcherUnhandledException += App_DispatcherUnhandledException;
|
||||
StartHeartbeatMonitor();
|
||||
|
||||
// 新增:初始化全局异常和进程结束处理
|
||||
@@ -73,7 +80,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
StartWatchdogIfNeeded();
|
||||
}
|
||||
this.Exit += App_Exit; // 注册退出事件
|
||||
Exit += App_Exit; // 注册退出事件
|
||||
}
|
||||
|
||||
// 新增:配置TLS协议以支持Windows 7
|
||||
@@ -87,7 +94,7 @@ namespace Ink_Canvas
|
||||
|
||||
if (isWindows7)
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到Windows 7系统,配置TLS协议支持", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("检测到Windows 7系统,配置TLS协议支持");
|
||||
|
||||
// 启用所有TLS版本以支持Windows 7
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
|
||||
@@ -97,12 +104,12 @@ namespace Ink_Canvas
|
||||
ServicePointManager.Expect100Continue = false;
|
||||
ServicePointManager.UseNagleAlgorithm = false;
|
||||
|
||||
LogHelper.WriteLogToFile("TLS协议配置完成,已启用TLS 1.2/1.1/1.0支持", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("TLS协议配置完成,已启用TLS 1.2/1.1/1.0支持");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 对于更新的Windows版本,不进行任何TLS配置,使用系统默认设置
|
||||
LogHelper.WriteLogToFile($"检测到Windows版本: {osVersion.VersionString},使用系统默认TLS配置", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"检测到Windows版本: {osVersion.VersionString},使用系统默认TLS配置");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -151,7 +158,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
crashListenersInitialized = true;
|
||||
LogHelper.WriteLogToFile("已初始化崩溃监听器", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("已初始化崩溃监听器");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -204,7 +211,7 @@ namespace Ink_Canvas
|
||||
var startMethod = watcherType.GetMethod("Start");
|
||||
startMethod.Invoke(watcher, null);
|
||||
|
||||
LogHelper.WriteLogToFile("已成功启动WMI进程监控", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("已成功启动WMI进程监控");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -346,7 +353,7 @@ namespace Ink_Canvas
|
||||
string logFileName = Path.Combine(crashLogFile, $"crash_{DateTime.Now:yyyyMMdd}.log");
|
||||
|
||||
// 收集系统状态信息
|
||||
string memoryUsage = (Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024)).ToString() + " MB";
|
||||
string memoryUsage = (Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024)) + " MB";
|
||||
string cpuTime = Process.GetCurrentProcess().TotalProcessorTime.ToString();
|
||||
string processUptime = (DateTime.Now - Process.GetCurrentProcess().StartTime).ToString();
|
||||
|
||||
@@ -377,7 +384,7 @@ namespace Ink_Canvas
|
||||
if (File.Exists(settingsPath))
|
||||
{
|
||||
var json = File.ReadAllText(settingsPath);
|
||||
dynamic obj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
|
||||
dynamic obj = JsonConvert.DeserializeObject(json);
|
||||
int crashAction = 0;
|
||||
try { crashAction = (int)(obj["startup"]["crashAction"] ?? 0); } catch { }
|
||||
CrashAction = (CrashActionType)crashAction;
|
||||
@@ -391,9 +398,9 @@ namespace Ink_Canvas
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
||||
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
Ink_Canvas.MainWindow.ShowNewMessage("抱歉,出现未预期的异常,可能导致 InkCanvasForClass 运行不稳定。\n建议保存墨迹后重启应用。", true);
|
||||
Ink_Canvas.MainWindow.ShowNewMessage("抱歉,出现未预期的异常,可能导致 InkCanvasForClass 运行不稳定。\n建议保存墨迹后重启应用。");
|
||||
LogHelper.NewLog(e.Exception.ToString());
|
||||
|
||||
// 新增:记录到崩溃日志
|
||||
@@ -415,8 +422,8 @@ namespace Ink_Canvas
|
||||
}
|
||||
try
|
||||
{
|
||||
string exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
|
||||
System.Diagnostics.Process.Start(exePath);
|
||||
string exePath = Process.GetCurrentProcess().MainModule.FileName;
|
||||
Process.Start(exePath);
|
||||
}
|
||||
catch { }
|
||||
Environment.Exit(1);
|
||||
@@ -430,7 +437,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
/*if (!StoreHelper.IsStoreApp) */RootPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
|
||||
|
||||
LogHelper.NewLog(string.Format("Ink Canvas Starting (Version: {0})", Assembly.GetExecutingAssembly().GetName().Version.ToString()));
|
||||
LogHelper.NewLog(string.Format("Ink Canvas Starting (Version: {0})", Assembly.GetExecutingAssembly().GetName().Version));
|
||||
|
||||
// 记录应用启动(设备标识符)
|
||||
DeviceIdentifier.RecordAppLaunch();
|
||||
@@ -439,7 +446,7 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile($"App | 更新优先级: {DeviceIdentifier.GetUpdatePriority()}");
|
||||
|
||||
bool ret;
|
||||
mutex = new System.Threading.Mutex(true, "InkCanvasForClass", out ret);
|
||||
mutex = new Mutex(true, "InkCanvasForClass", out ret);
|
||||
|
||||
if (!ret && !e.Args.Contains("-m")) //-m multiple
|
||||
{
|
||||
@@ -490,7 +497,7 @@ namespace Ink_Canvas
|
||||
|
||||
try
|
||||
{
|
||||
using (Microsoft.Win32.RegistryKey baseKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(regPath))
|
||||
using (RegistryKey baseKey = Registry.CurrentUser.OpenSubKey(regPath))
|
||||
{
|
||||
if (baseKey == null)
|
||||
{
|
||||
@@ -498,12 +505,12 @@ namespace Ink_Canvas
|
||||
// 尝试创建路径
|
||||
try
|
||||
{
|
||||
using (Microsoft.Win32.RegistryKey createKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(regPath, true))
|
||||
using (RegistryKey createKey = Registry.CurrentUser.CreateSubKey(regPath, true))
|
||||
{
|
||||
if (createKey != null)
|
||||
{
|
||||
createKey.SetValue("DisableProtectedView", 1, Microsoft.Win32.RegistryValueKind.DWord);
|
||||
LogHelper.WriteLogToFile($"创建并设置注册表路径: {regPath}", LogHelper.LogType.Info);
|
||||
createKey.SetValue("DisableProtectedView", 1, RegistryValueKind.DWord);
|
||||
LogHelper.WriteLogToFile($"创建并设置注册表路径: {regPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -528,11 +535,11 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile($"创建备份文件: {backupFile}");
|
||||
|
||||
// 使用UTF8编码写入注册表文件
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, System.Text.Encoding.UTF8))
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, Encoding.UTF8))
|
||||
{
|
||||
sw.WriteLine("Windows Registry Editor Version 5.00\n");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine($"[{Microsoft.Win32.Registry.CurrentUser.Name}\\{regPath}]");
|
||||
sw.WriteLine($"[{Registry.CurrentUser.Name}\\{regPath}]");
|
||||
|
||||
foreach (string valueName in baseKey.GetValueNames())
|
||||
{
|
||||
@@ -542,13 +549,13 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(regPath, true))
|
||||
using (RegistryKey key = Registry.CurrentUser.CreateSubKey(regPath, true))
|
||||
{
|
||||
// 仅在值不存在或不等于1时更新
|
||||
object currentValue = key.GetValue("DisableProtectedView");
|
||||
if (currentValue == null || (int)currentValue != 1)
|
||||
{
|
||||
key.SetValue("DisableProtectedView", 1, Microsoft.Win32.RegistryValueKind.DWord);
|
||||
key.SetValue("DisableProtectedView", 1, RegistryValueKind.DWord);
|
||||
LogHelper.WriteLogToFile($"Office {version} 注册表值已设置: DisableProtectedView = 1");
|
||||
}
|
||||
else
|
||||
@@ -561,7 +568,6 @@ namespace Ink_Canvas
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"处理Office版本 {version} 时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,21 +587,21 @@ namespace Ink_Canvas
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"未知错误: {ex.GetType().FullName} - {ex.Message}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile(ex.StackTrace, LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile(ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
|
||||
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (System.Windows.Forms.SystemInformation.MouseWheelScrollLines == -1)
|
||||
if (SystemInformation.MouseWheelScrollLines == -1)
|
||||
e.Handled = false;
|
||||
else
|
||||
try
|
||||
{
|
||||
ScrollViewerEx SenderScrollViewer = (ScrollViewerEx)sender;
|
||||
SenderScrollViewer.ScrollToVerticalOffset(SenderScrollViewer.VerticalOffset - e.Delta * 10 * System.Windows.Forms.SystemInformation.MouseWheelScrollLines / (double)120);
|
||||
SenderScrollViewer.ScrollToVerticalOffset(SenderScrollViewer.VerticalOffset - e.Delta * 10 * SystemInformation.MouseWheelScrollLines / (double)120);
|
||||
e.Handled = true;
|
||||
}
|
||||
catch { }
|
||||
@@ -758,60 +764,60 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 检查多个可能的注册表路径
|
||||
// 1. 检查传统的Office版本
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office"))
|
||||
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office"))
|
||||
{
|
||||
if (key != null && key.GetSubKeyNames().Any(name => name.Contains(".0")))
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到传统Office安装", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("检测到传统Office安装");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 检查64位注册表中的Office
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Office"))
|
||||
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Office"))
|
||||
{
|
||||
if (key != null && key.GetSubKeyNames().Any(name => name.Contains(".0")))
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到64位注册表中的Office安装", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("检测到64位注册表中的Office安装");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 检查Office 365/Click-to-Run安装
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\ClickToRun"))
|
||||
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\ClickToRun"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到Office 365 Click-to-Run", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("检测到Office 365 Click-to-Run");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 检查Office 365部署配置
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\15.0\\ClickToRun"))
|
||||
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\15.0\\ClickToRun"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到Office 365 (15.0)", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("检测到Office 365 (15.0)");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\16.0\\ClickToRun"))
|
||||
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\16.0\\ClickToRun"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到Office 365 (16.0)", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("检测到Office 365 (16.0)");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 检查Office 365零售订阅信息
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\ClickToRun\\Configuration"))
|
||||
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\ClickToRun\\Configuration"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到Office 365配置", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("检测到Office 365配置");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -833,7 +839,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
const string message = "需要管理员权限才能完成此操作\n请以管理员身份重新启动应用程序";
|
||||
LogHelper.WriteLogToFile(message, LogHelper.LogType.Error);
|
||||
System.Windows.MessageBox.Show(message, "权限错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show(message, "权限错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1058,11 +1064,11 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile($"创建Office 365 {app}备份文件: {backupFile}");
|
||||
|
||||
// 使用UTF8编码写入注册表文件
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, System.Text.Encoding.UTF8))
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, Encoding.UTF8))
|
||||
{
|
||||
sw.WriteLine("Windows Registry Editor Version 5.00\n");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine($"[{Microsoft.Win32.Registry.CurrentUser.Name}\\{regPath}]");
|
||||
sw.WriteLine($"[{Registry.CurrentUser.Name}\\{regPath}]");
|
||||
|
||||
foreach (string valueName in baseKey.GetValueNames())
|
||||
{
|
||||
@@ -1114,11 +1120,11 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile($"创建信任中心备份文件: {backupFile}");
|
||||
|
||||
// 使用UTF8编码写入注册表文件
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, System.Text.Encoding.UTF8))
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, Encoding.UTF8))
|
||||
{
|
||||
sw.WriteLine("Windows Registry Editor Version 5.00\n");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine($"[{Microsoft.Win32.Registry.CurrentUser.Name}\\{trustCenterPath}]");
|
||||
sw.WriteLine($"[{Registry.CurrentUser.Name}\\{trustCenterPath}]");
|
||||
|
||||
foreach (string valueName in baseKey.GetValueNames())
|
||||
{
|
||||
@@ -1158,11 +1164,11 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile($"创建策略备份文件: {backupFile}");
|
||||
|
||||
// 使用UTF8编码写入注册表文件
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, System.Text.Encoding.UTF8))
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, Encoding.UTF8))
|
||||
{
|
||||
sw.WriteLine("Windows Registry Editor Version 5.00\n");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine($"[{Microsoft.Win32.Registry.CurrentUser.Name}\\{policyPath}]");
|
||||
sw.WriteLine($"[{Registry.CurrentUser.Name}\\{policyPath}]");
|
||||
|
||||
foreach (string valueName in baseKey.GetValueNames())
|
||||
{
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Windows.Controls;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
@@ -21,7 +26,7 @@ namespace Ink_Canvas.Helpers
|
||||
// 定义超时时间为10秒
|
||||
private static readonly TimeSpan RequestTimeout = TimeSpan.FromSeconds(10);
|
||||
private static readonly string updatesFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate");
|
||||
private static string statusFilePath = null;
|
||||
private static string statusFilePath;
|
||||
|
||||
// 线路组结构体(包含版本、下载、日志地址)
|
||||
public class UpdateLineGroup
|
||||
@@ -209,7 +214,7 @@ namespace Ink_Canvas.Helpers
|
||||
if (zhiJiaoGroup != null)
|
||||
{
|
||||
orderedGroups.Insert(0, zhiJiaoGroup);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 智教联盟线路组已插入到首位");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 智教联盟线路组已插入到首位");
|
||||
}
|
||||
|
||||
// 将"inkeys"线路组插入到第二位(如果存在)
|
||||
@@ -217,7 +222,7 @@ namespace Ink_Canvas.Helpers
|
||||
if (inkeysGroup != null)
|
||||
{
|
||||
orderedGroups.Insert(1, inkeysGroup);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | inkeys线路组已插入到第二位");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | inkeys线路组已插入到第二位");
|
||||
}
|
||||
|
||||
if (orderedGroups.Count > 0)
|
||||
@@ -278,7 +283,7 @@ namespace Ink_Canvas.Helpers
|
||||
// 如果内容包含HTML(可能是GitHub页面而不是原始内容),尝试提取版本号
|
||||
if (content.Contains("<html") || content.Contains("<!DOCTYPE"))
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 收到HTML内容而不是原始版本号 - 尝试提取版本");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 收到HTML内容而不是原始版本号 - 尝试提取版本");
|
||||
int startPos = content.IndexOf("<table");
|
||||
if (startPos > 0)
|
||||
{
|
||||
@@ -286,7 +291,7 @@ namespace Ink_Canvas.Helpers
|
||||
if (endPos > startPos)
|
||||
{
|
||||
string tableContent = content.Substring(startPos, endPos - startPos);
|
||||
var match = System.Text.RegularExpressions.Regex.Match(tableContent, @"(\d+\.\d+\.\d+(\.\d+)?)");
|
||||
var match = Regex.Match(tableContent, @"(\d+\.\d+\.\d+(\.\d+)?)");
|
||||
if (match.Success)
|
||||
{
|
||||
content = match.Groups[1].Value;
|
||||
@@ -294,7 +299,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 无法从HTML内容提取版本");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 无法从HTML内容提取版本");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -321,77 +326,75 @@ namespace Ink_Canvas.Helpers
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 其他Windows版本使用标准配置
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
client.Timeout = RequestTimeout;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 发送HTTP请求到: {fileUrl}");
|
||||
|
||||
var downloadTask = client.GetAsync(fileUrl);
|
||||
var timeoutTask = Task.Delay(RequestTimeout);
|
||||
|
||||
var completedTask = await Task.WhenAny(downloadTask, timeoutTask);
|
||||
if (completedTask == timeoutTask)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 请求超时 ({RequestTimeout.TotalSeconds}秒)", LogHelper.LogType.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
HttpResponseMessage response = await downloadTask;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | HTTP响应状态: {response.StatusCode}");
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
content = content.Trim();
|
||||
// 其他Windows版本使用标准配置
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
client.Timeout = RequestTimeout;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 发送HTTP请求到: {fileUrl}");
|
||||
|
||||
// 如果内容包含HTML(可能是GitHub页面而不是原始内容),尝试提取版本号
|
||||
if (content.Contains("<html") || content.Contains("<!DOCTYPE"))
|
||||
var downloadTask = client.GetAsync(fileUrl);
|
||||
var timeoutTask = Task.Delay(RequestTimeout);
|
||||
|
||||
var completedTask = await Task.WhenAny(downloadTask, timeoutTask);
|
||||
if (completedTask == timeoutTask)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 请求超时 ({RequestTimeout.TotalSeconds}秒)", LogHelper.LogType.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
HttpResponseMessage response = await downloadTask;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | HTTP响应状态: {response.StatusCode}");
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
content = content.Trim();
|
||||
|
||||
// 如果内容包含HTML(可能是GitHub页面而不是原始内容),尝试提取版本号
|
||||
if (content.Contains("<html") || content.Contains("<!DOCTYPE"))
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 收到HTML内容而不是原始版本号 - 尝试提取版本");
|
||||
int startPos = content.IndexOf("<table");
|
||||
if (startPos > 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 收到HTML内容而不是原始版本号 - 尝试提取版本");
|
||||
int startPos = content.IndexOf("<table");
|
||||
if (startPos > 0)
|
||||
int endPos = content.IndexOf("</table>", startPos);
|
||||
if (endPos > startPos)
|
||||
{
|
||||
int endPos = content.IndexOf("</table>", startPos);
|
||||
if (endPos > startPos)
|
||||
string tableContent = content.Substring(startPos, endPos - startPos);
|
||||
var match = Regex.Match(tableContent, @"(\d+\.\d+\.\d+(\.\d+)?)");
|
||||
if (match.Success)
|
||||
{
|
||||
string tableContent = content.Substring(startPos, endPos - startPos);
|
||||
var match = System.Text.RegularExpressions.Regex.Match(tableContent, @"(\d+\.\d+\.\d+(\.\d+)?)");
|
||||
if (match.Success)
|
||||
{
|
||||
content = match.Groups[1].Value;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 从HTML提取版本: {content}");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 无法从HTML内容提取版本");
|
||||
return null;
|
||||
}
|
||||
content = match.Groups[1].Value;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 从HTML提取版本: {content}");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 无法从HTML内容提取版本");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 响应内容: {content}");
|
||||
return content;
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | HTTP请求错误: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 请求超时: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 错误: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
return null;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 响应内容: {content}");
|
||||
return content;
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | HTTP请求错误: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 请求超时: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 错误: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,7 +487,7 @@ namespace Ink_Canvas.Helpers
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 本地版本: {localVersion}");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 设备ID: {DeviceIdentifier.GetDeviceId()}");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 更新优先级: {DeviceIdentifier.GetUpdatePriority()}");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 优先通过GitHub Releases API检测...");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 优先通过GitHub Releases API检测...");
|
||||
|
||||
// 1. 优先通过GitHub Releases API获取
|
||||
var (apiVersion, _, apiReleaseNotes, apiReleaseTime) = await GetLatestGithubRelease(channel);
|
||||
@@ -518,7 +521,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 版本修复模式,跳过分级策略检查");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 版本修复模式,跳过分级策略检查");
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 根据用户优先级,推送更新 {apiVersion}");
|
||||
@@ -528,13 +531,13 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 当前版本已是最新 (GitHub Releases API)");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 当前版本已是最新 (GitHub Releases API)");
|
||||
var availableGroup = (await GetAvailableLineGroupsOrdered(channel)).FirstOrDefault();
|
||||
return (null, availableGroup, apiReleaseNotes);
|
||||
}
|
||||
}
|
||||
// 2. 回退到原有txt方案
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | GitHub Releases API获取失败,回退到txt方案...");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | GitHub Releases API获取失败,回退到txt方案...");
|
||||
var availableGroups = await GetAvailableLineGroupsOrdered(channel);
|
||||
if (availableGroups.Count == 0)
|
||||
{
|
||||
@@ -570,22 +573,18 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 版本修复模式,跳过分级策略检查");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 版本修复模式,跳过分级策略检查");
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 根据用户优先级,推送更新 {remoteVersion}");
|
||||
return (remoteVersion, group, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 当前版本已是最新");
|
||||
return (null, group, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 线路组 {group.GroupName} 获取版本失败,尝试下一个线路组", LogHelper.LogType.Warning);
|
||||
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 当前版本已是最新");
|
||||
return (null, group, null);
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 线路组 {group.GroupName} 获取版本失败,尝试下一个线路组", LogHelper.LogType.Warning);
|
||||
}
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 所有线路组均无法获取版本信息", LogHelper.LogType.Error);
|
||||
return (null, null, null);
|
||||
@@ -614,7 +613,7 @@ namespace Ink_Canvas.Helpers
|
||||
client.Timeout = RequestTimeout;
|
||||
var resp = await client.GetAsync(url);
|
||||
// 优先取Location头
|
||||
if (resp.StatusCode == System.Net.HttpStatusCode.Found || resp.StatusCode == System.Net.HttpStatusCode.Redirect || resp.StatusCode == System.Net.HttpStatusCode.MovedPermanently)
|
||||
if (resp.StatusCode == HttpStatusCode.Found || resp.StatusCode == HttpStatusCode.Redirect || resp.StatusCode == HttpStatusCode.MovedPermanently)
|
||||
{
|
||||
if (resp.Headers.Location != null)
|
||||
{
|
||||
@@ -675,12 +674,12 @@ namespace Ink_Canvas.Helpers
|
||||
if (zhiJiaoGroup != null)
|
||||
{
|
||||
priorityGroups.Add(zhiJiaoGroup);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 下载时优先尝试智教联盟线路组");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 下载时优先尝试智教联盟线路组");
|
||||
}
|
||||
if (inkeysGroup != null)
|
||||
{
|
||||
priorityGroups.Add(inkeysGroup);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 下载时优先尝试inkeys线路组");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 下载时优先尝试inkeys线路组");
|
||||
}
|
||||
groups = priorityGroups.Concat(groups.Where(g => g.GroupName != "智教联盟" && g.GroupName != "inkeys")).ToList();
|
||||
}
|
||||
@@ -696,7 +695,7 @@ namespace Ink_Canvas.Helpers
|
||||
var realUrl = await GetZhijiaoRealDownloadUrl(url);
|
||||
if (string.IsNullOrEmpty(realUrl))
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 智教联盟真实下载地址获取失败,跳过", LogHelper.LogType.Warning);
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 智教联盟真实下载地址获取失败,跳过", LogHelper.LogType.Warning);
|
||||
progressCallback?.Invoke(0, "智教联盟真实下载地址获取失败,跳过");
|
||||
continue;
|
||||
}
|
||||
@@ -719,10 +718,8 @@ namespace Ink_Canvas.Helpers
|
||||
progressCallback?.Invoke(100, "下载完成");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 线路组 {group.GroupName} 下载失败,尝试下一个线路组", LogHelper.LogType.Warning);
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 线路组 {group.GroupName} 下载失败,尝试下一个线路组", LogHelper.LogType.Warning);
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 所有线路组下载均失败", LogHelper.LogType.Error);
|
||||
@@ -749,7 +746,7 @@ namespace Ink_Canvas.Helpers
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 正在尝试多线程下载: {fileUrl}");
|
||||
int maxRetry = 3;
|
||||
// 降低并发数,减少网络压力
|
||||
int[] threadOptions = new int[] { 32, 16, 8, 4, 1 };
|
||||
int[] threadOptions = { 32, 16, 8, 4, 1 };
|
||||
|
||||
// 检查服务器是否支持Range分块下载
|
||||
bool supportRange = false;
|
||||
@@ -760,9 +757,9 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, fileUrl);
|
||||
req.Headers.Range = new System.Net.Http.Headers.RangeHeaderValue(0, 0);
|
||||
req.Headers.Range = new RangeHeaderValue(0, 0);
|
||||
var resp = await client.SendAsync(req);
|
||||
if (resp.StatusCode == System.Net.HttpStatusCode.PartialContent)
|
||||
if (resp.StatusCode == HttpStatusCode.PartialContent)
|
||||
{
|
||||
supportRange = true;
|
||||
if (resp.Content.Headers.ContentRange != null && resp.Content.Headers.ContentRange.Length.HasValue)
|
||||
@@ -774,7 +771,7 @@ namespace Ink_Canvas.Helpers
|
||||
totalSize = resp.Content.Headers.ContentLength.Value;
|
||||
}
|
||||
}
|
||||
else if (resp.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
else if (resp.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
supportRange = false;
|
||||
if (resp.Content.Headers.ContentLength.HasValue)
|
||||
@@ -791,7 +788,7 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
if (!supportRange)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 服务器不支持分块下载,自动降级为单线程下载");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 服务器不支持分块下载,自动降级为单线程下载");
|
||||
progressCallback?.Invoke(0, "服务器不支持分块下载,自动降级为单线程下载");
|
||||
return await DownloadSingleThread(fileUrl, destinationPath, totalSize, progressCallback);
|
||||
}
|
||||
@@ -818,8 +815,8 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 文件大小: {totalSize}, 分块数: {blockCount}, 分块大小: {blockSize}");
|
||||
|
||||
var blockQueue = new System.Collections.Concurrent.ConcurrentQueue<BlockTask>();
|
||||
var finishedBlocks = new System.Collections.Concurrent.ConcurrentDictionary<int, bool>();
|
||||
var blockQueue = new ConcurrentQueue<BlockTask>();
|
||||
var finishedBlocks = new ConcurrentDictionary<int, bool>();
|
||||
long[] blockDownloaded = new long[blockCount];
|
||||
|
||||
for (int i = 0; i < blockCount; i++)
|
||||
@@ -849,7 +846,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, fileUrl);
|
||||
req.Headers.Range = new System.Net.Http.Headers.RangeHeaderValue(block.Start, block.End);
|
||||
req.Headers.Range = new RangeHeaderValue(block.Start, block.End);
|
||||
|
||||
// 增加连接超时设置
|
||||
client.Timeout = TimeSpan.FromSeconds(30);
|
||||
@@ -967,16 +964,14 @@ namespace Ink_Canvas.Helpers
|
||||
if (threadCount == threadOptions.Last())
|
||||
{
|
||||
// 已经是最后一次尝试,降级为单线程
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 所有多线程尝试失败,降级为单线程下载");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 所有多线程尝试失败,降级为单线程下载");
|
||||
progressCallback?.Invoke(0, "所有多线程尝试失败,降级为单线程下载");
|
||||
return await DownloadSingleThread(fileUrl, destinationPath, totalSize, progressCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | {threadCount}线程下载失败,尝试降级为{threadOptions[Array.IndexOf(threadOptions, threadCount) + 1]}线程");
|
||||
progressCallback?.Invoke(0, $"{threadCount}线程下载失败,尝试降级为{threadOptions[Array.IndexOf(threadOptions, threadCount) + 1]}线程");
|
||||
continue;
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | {threadCount}线程下载失败,尝试降级为{threadOptions[Array.IndexOf(threadOptions, threadCount) + 1]}线程");
|
||||
progressCallback?.Invoke(0, $"{threadCount}线程下载失败,尝试降级为{threadOptions[Array.IndexOf(threadOptions, threadCount) + 1]}线程");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 合并所有块
|
||||
@@ -1018,7 +1013,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
System.IO.Compression.ZipFile.OpenRead(destinationPath).Dispose();
|
||||
ZipFile.OpenRead(destinationPath).Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -1086,7 +1081,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
|
||||
progressCallback?.Invoke(100, "单线程下载完成");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 单线程下载完成");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 单线程下载完成");
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1149,7 +1144,7 @@ namespace Ink_Canvas.Helpers
|
||||
if (!Directory.Exists(backupDir))
|
||||
{
|
||||
Directory.CreateDirectory(backupDir);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
|
||||
}
|
||||
|
||||
string backupFileName = $"Settings_BeforeUpdate_v{version}_{DateTime.Now:yyyyMMdd_HHmmss}.json";
|
||||
@@ -1158,11 +1153,11 @@ namespace Ink_Canvas.Helpers
|
||||
string settingsJson = JsonConvert.SerializeObject(MainWindow.Settings, Formatting.Indented);
|
||||
File.WriteAllText(backupPath, settingsJson);
|
||||
|
||||
LogHelper.WriteLogToFile($"更新前自动备份设置成功: {backupPath}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"更新前自动备份设置成功: {backupPath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("更新前自动备份功能已禁用,跳过备份", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("更新前自动备份功能已禁用,跳过备份");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1182,7 +1177,7 @@ namespace Ink_Canvas.Helpers
|
||||
FileInfo fileInfo = new FileInfo(zipFilePath);
|
||||
if (fileInfo.Length == 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | ZIP文件为空,无法继续", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile("AutoUpdate | ZIP文件为空,无法继续", LogHelper.LogType.Error);
|
||||
return;
|
||||
}
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | ZIP文件大小: {fileInfo.Length} 字节");
|
||||
@@ -1203,7 +1198,7 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
batchContent.AppendLine("echo Set objShell = CreateObject(\"WScript.Shell\") > \"%temp%\\hideme.vbs\"");
|
||||
batchContent.AppendLine("echo objShell.Run \"cmd /c \"\"\" ^& WScript.Arguments(0) ^& \"\"\"\", 0, True >> \"%temp%\\hideme.vbs\"");
|
||||
batchContent.AppendLine($"echo Wscript.Sleep 100 >> \"%temp%\\hideme.vbs\"");
|
||||
batchContent.AppendLine("echo Wscript.Sleep 100 >> \"%temp%\\hideme.vbs\"");
|
||||
|
||||
string updateBatPath = Path.Combine(Path.GetTempPath(), "ICCUpdate_" + Guid.NewGuid().ToString().Substring(0, 8) + ".bat");
|
||||
batchContent.AppendLine($"echo @echo off > \"{updateBatPath}\"");
|
||||
@@ -1283,7 +1278,7 @@ namespace Ink_Canvas.Helpers
|
||||
batchContent.AppendLine("exit");
|
||||
|
||||
File.WriteAllText(batchFilePath, batchContent.ToString());
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 创建更新批处理文件完成");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 创建更新批处理文件完成");
|
||||
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
@@ -1293,7 +1288,7 @@ namespace Ink_Canvas.Helpers
|
||||
WindowStyle = ProcessWindowStyle.Hidden
|
||||
});
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 启动更新批处理进程(隐藏窗口)");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 启动更新批处理进程(隐藏窗口)");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1356,43 +1351,41 @@ namespace Ink_Canvas.Helpers
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
// 其他Windows版本使用标准配置
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
// 其他Windows版本使用标准配置
|
||||
using (HttpClient client = new HttpClient())
|
||||
try
|
||||
{
|
||||
try
|
||||
client.Timeout = RequestTimeout;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 发送HTTP请求到: {fileUrl}");
|
||||
var downloadTask = client.GetAsync(fileUrl);
|
||||
var timeoutTask = Task.Delay(RequestTimeout);
|
||||
var completedTask = await Task.WhenAny(downloadTask, timeoutTask);
|
||||
if (completedTask == timeoutTask)
|
||||
{
|
||||
client.Timeout = RequestTimeout;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 发送HTTP请求到: {fileUrl}");
|
||||
var downloadTask = client.GetAsync(fileUrl);
|
||||
var timeoutTask = Task.Delay(RequestTimeout);
|
||||
var completedTask = await Task.WhenAny(downloadTask, timeoutTask);
|
||||
if (completedTask == timeoutTask)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 请求超时 ({RequestTimeout.TotalSeconds}秒)", LogHelper.LogType.Error);
|
||||
return null;
|
||||
}
|
||||
HttpResponseMessage response = await downloadTask;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | HTTP响应状态: {response.StatusCode}");
|
||||
response.EnsureSuccessStatusCode();
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
return content;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 请求超时 ({RequestTimeout.TotalSeconds}秒)", LogHelper.LogType.Error);
|
||||
return null;
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | HTTP请求错误: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 请求超时: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 错误: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
return null;
|
||||
HttpResponseMessage response = await downloadTask;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | HTTP响应状态: {response.StatusCode}");
|
||||
response.EnsureSuccessStatusCode();
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
return content;
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | HTTP请求错误: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 请求超时: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 错误: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1513,7 +1506,7 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
if (!isWindows7)
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 当前系统不是Windows 7,跳过TLS连接测试", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 当前系统不是Windows 7,跳过TLS连接测试");
|
||||
return true; // 非Windows 7系统直接返回成功
|
||||
}
|
||||
|
||||
@@ -1536,11 +1529,9 @@ namespace Ink_Canvas.Helpers
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Windows 7 TLS连接测试成功");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Windows 7 TLS连接测试失败,状态码: {response.StatusCode}", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Windows 7 TLS连接测试失败,状态码: {response.StatusCode}", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1632,11 +1623,8 @@ namespace Ink_Canvas.Helpers
|
||||
if (StartTime <= EndTime)
|
||||
{ // 单日时间段
|
||||
return currentTime >= StartTime && currentTime <= EndTime;
|
||||
}
|
||||
else
|
||||
{ // 跨越两天的时间段
|
||||
return currentTime >= StartTime || currentTime <= EndTime;
|
||||
}
|
||||
} // 跨越两天的时间段
|
||||
return currentTime >= StartTime || currentTime <= EndTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
@@ -8,7 +9,7 @@ namespace Ink_Canvas.Helpers
|
||||
/// <summary>
|
||||
/// 防止窗口进入全屏状态的辅助类
|
||||
/// </summary>
|
||||
public static partial class AvoidFullScreenHelper
|
||||
public static class AvoidFullScreenHelper
|
||||
{
|
||||
private static readonly DependencyProperty IsAvoidFullScreenEnabledProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
@@ -16,7 +17,7 @@ namespace Ink_Canvas.Helpers
|
||||
typeof(bool),
|
||||
typeof(AvoidFullScreenHelper));
|
||||
|
||||
private static bool _isBoardMode = false;
|
||||
private static bool _isBoardMode;
|
||||
public static void SetBoardMode(bool isBoardMode)
|
||||
{
|
||||
_isBoardMode = isBoardMode;
|
||||
@@ -120,10 +121,10 @@ namespace Ink_Canvas.Helpers
|
||||
private static Rect GetWorkingArea(Rect windowRect)
|
||||
{
|
||||
// 获取所有显示器
|
||||
var screens = System.Windows.Forms.Screen.AllScreens;
|
||||
var screens = Screen.AllScreens;
|
||||
|
||||
// 确定窗口主要位于哪个显示器上
|
||||
System.Windows.Forms.Screen targetScreen = null;
|
||||
Screen targetScreen = null;
|
||||
double maxIntersection = 0;
|
||||
|
||||
foreach (var screen in screens)
|
||||
@@ -144,7 +145,7 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
// 如果没找到,使用主显示器
|
||||
if (targetScreen == null)
|
||||
targetScreen = System.Windows.Forms.Screen.PrimaryScreen;
|
||||
targetScreen = Screen.PrimaryScreen;
|
||||
|
||||
return new Rect(
|
||||
targetScreen.WorkingArea.X,
|
||||
|
||||
@@ -9,125 +9,107 @@ namespace Ink_Canvas.Converter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if ((bool)value == true)
|
||||
if ((bool)value)
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if ((bool)value == true)
|
||||
if ((bool)value)
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
public class VisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
Visibility visibility = (Visibility)value;
|
||||
if (visibility == Visibility.Visible)
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
|
||||
return Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
Visibility visibility = (Visibility)value;
|
||||
if (visibility == Visibility.Visible)
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
|
||||
return Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
public class IntNumberToString : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if ((double)value == 0)
|
||||
{
|
||||
return "无限制";
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((double)value).ToString() + "人";
|
||||
}
|
||||
|
||||
return ((double)value) + "人";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if ((double)value == 0)
|
||||
{
|
||||
return "无限制";
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((double)value).ToString() + "人";
|
||||
}
|
||||
|
||||
return ((double)value) + "人";
|
||||
}
|
||||
}
|
||||
|
||||
public class IntNumberToString2 : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if ((double)value == 0)
|
||||
{
|
||||
return "自动截图";
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((double)value).ToString() + "条";
|
||||
}
|
||||
|
||||
return ((double)value) + "条";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if ((double)value == 0)
|
||||
{
|
||||
return "自动截图";
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((double)value).ToString() + "条";
|
||||
}
|
||||
|
||||
return ((double)value) + "条";
|
||||
}
|
||||
}
|
||||
|
||||
public class IsEnabledToOpacityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
bool isChecked = (bool)value;
|
||||
if (isChecked == true)
|
||||
if (isChecked)
|
||||
{
|
||||
return 1d;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.35;
|
||||
}
|
||||
|
||||
return 0.35;
|
||||
}
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); }
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,14 +26,14 @@ namespace Ink_Canvas.Helpers {
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile("DelAutoSavedFiles | 处理文件时出错: " + ex.ToString(), LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile("DelAutoSavedFiles | 处理文件时出错: " + ex, LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
try { // 递归删除空文件夹
|
||||
DeleteEmptyFolders(directoryPath);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile("DelAutoSavedFiles | 处理文件时出错: " + ex.ToString(), LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile("DelAutoSavedFiles | 处理文件时出错: " + ex, LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
{
|
||||
@@ -35,7 +36,7 @@ namespace Ink_Canvas.Helpers
|
||||
// 数据完整性验证密钥
|
||||
private static readonly string DataIntegrityKey = "ICC_DEVICE_INTEGRITY_2024";
|
||||
|
||||
private static readonly string DeviceId = null;
|
||||
private static readonly string DeviceId;
|
||||
private static readonly object fileLock = new object();
|
||||
|
||||
static DeviceIdentifier()
|
||||
@@ -132,7 +133,7 @@ namespace Ink_Canvas.Helpers
|
||||
try
|
||||
{
|
||||
// 尝试加载System.Management程序集
|
||||
var assembly = System.Reflection.Assembly.Load("System.Management");
|
||||
var assembly = Assembly.Load("System.Management");
|
||||
if (assembly != null)
|
||||
{
|
||||
// CPU信息
|
||||
@@ -239,7 +240,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
hardwareInfo.Append(Environment.MachineName);
|
||||
hardwareInfo.Append(Environment.UserName);
|
||||
hardwareInfo.Append(Environment.OSVersion.ToString());
|
||||
hardwareInfo.Append(Environment.OSVersion);
|
||||
}
|
||||
|
||||
// 生成哈希
|
||||
@@ -438,7 +439,7 @@ namespace Ink_Canvas.Helpers
|
||||
key?.SetValue("DeviceId", deviceId);
|
||||
key?.SetValue("LastUpdate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 设备ID已保存到注册表");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 设备ID已保存到注册表");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -675,7 +676,8 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
return $"{totalSeconds}秒";
|
||||
}
|
||||
else if (totalSeconds < 3600)
|
||||
|
||||
if (totalSeconds < 3600)
|
||||
{
|
||||
var minutes = totalSeconds / 60;
|
||||
var seconds = totalSeconds % 60;
|
||||
@@ -1015,13 +1017,13 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 所有数据源都不可用,检查是否有部分可恢复数据", LogHelper.LogType.Warning);
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 所有数据源都不可用,检查是否有部分可恢复数据", LogHelper.LogType.Warning);
|
||||
|
||||
// 如果没有完全可信的数据,尝试从部分损坏的数据中恢复
|
||||
var partiallyRecoveredData = AttemptPartialDataRecovery(allDataSources);
|
||||
if (partiallyRecoveredData != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 从部分损坏数据中恢复使用统计");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 从部分损坏数据中恢复使用统计");
|
||||
|
||||
// 执行数据迁移(如果需要)
|
||||
partiallyRecoveredData.MigrateToSecondsPrecision();
|
||||
@@ -1099,19 +1101,15 @@ namespace Ink_Canvas.Helpers
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 数据完整性验证通过: {filePath}");
|
||||
return stats;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 数据完整性验证失败,可能被篡改: {filePath}", LogHelper.LogType.Warning);
|
||||
return null; // 数据被篡改,不使用
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 旧版本数据,没有哈希值,更新哈希后返回
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 检测到旧版本数据,正在更新完整性哈希: {filePath}");
|
||||
stats.UpdateDataHash();
|
||||
return stats;
|
||||
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 数据完整性验证失败,可能被篡改: {filePath}", LogHelper.LogType.Warning);
|
||||
return null; // 数据被篡改,不使用
|
||||
}
|
||||
|
||||
// 旧版本数据,没有哈希值,更新哈希后返回
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 检测到旧版本数据,正在更新完整性哈希: {filePath}");
|
||||
stats.UpdateDataHash();
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1276,7 +1274,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
if (dataSources.Count == 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 没有可用数据源进行部分恢复");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 没有可用数据源进行部分恢复");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1626,11 +1624,8 @@ namespace Ink_Canvas.Helpers
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 从注册表位置恢复数据并验证完整性通过: {path}");
|
||||
return stats;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 注册表位置数据完整性验证失败: {path}", LogHelper.LogType.Warning);
|
||||
continue; // 尝试下一个位置
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 注册表位置数据完整性验证失败: {path}", LogHelper.LogType.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1720,7 +1715,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 开始保存使用统计到主注册表位置");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 开始保存使用统计到主注册表位置");
|
||||
|
||||
using (var key = Registry.CurrentUser.CreateSubKey(@"Software\ICC\DeviceInfo"))
|
||||
{
|
||||
@@ -1760,7 +1755,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 创建主注册表键失败", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 创建主注册表键失败", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1876,7 +1871,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
lock (fileLock)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 开始使用频率数据保护检查");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 开始使用频率数据保护检查");
|
||||
|
||||
var issues = new List<string>();
|
||||
var repaired = new List<string>();
|
||||
@@ -2323,7 +2318,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
lock (fileLock)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 开始数据完整性检查");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 开始数据完整性检查");
|
||||
|
||||
var issues = new List<string>();
|
||||
var repaired = new List<string>();
|
||||
@@ -2549,7 +2544,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
lock (fileLock)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 开始强制重建使用频率数据备份");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 开始强制重建使用频率数据备份");
|
||||
|
||||
var stats = LoadUsageStats();
|
||||
if (stats == null)
|
||||
@@ -2567,7 +2562,7 @@ namespace Ink_Canvas.Helpers
|
||||
UsageFrequency = UsageFrequency.Medium
|
||||
};
|
||||
stats.UpdateDataHash();
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 创建新的基础使用数据");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 创建新的基础使用数据");
|
||||
}
|
||||
|
||||
// 强制保存到所有位置
|
||||
@@ -2608,7 +2603,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
lock (fileLock)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 开始强制完整数据保存");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 开始强制完整数据保存");
|
||||
|
||||
// 保存设备ID到所有位置
|
||||
SaveDeviceIdToAllLocations(DeviceId);
|
||||
@@ -2624,14 +2619,12 @@ namespace Ink_Canvas.Helpers
|
||||
var verificationResult = VerifyRegistryData();
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 注册表数据验证结果: {verificationResult}");
|
||||
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 强制完整数据保存完成");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 强制完整数据保存完成");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 强制完整数据保存失败: 无法加载使用统计", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 强制完整数据保存失败: 无法加载使用统计", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -2663,7 +2656,7 @@ namespace Ink_Canvas.Helpers
|
||||
var totalMinutes = key.GetValue("TotalUsageMinutes");
|
||||
var lastUpdate = key.GetValue("LastUpdate") as string;
|
||||
|
||||
results.AppendLine($"✓ 主注册表位置存在");
|
||||
results.AppendLine("✓ 主注册表位置存在");
|
||||
results.AppendLine($" 设备ID: {deviceId ?? "未找到"}");
|
||||
results.AppendLine($" 启动次数: {launchCount ?? "未找到"}");
|
||||
results.AppendLine($" 使用时长: {totalMinutes ?? "未找到"}分钟");
|
||||
@@ -2732,7 +2725,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 开始保存并验证注册表数据");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 开始保存并验证注册表数据");
|
||||
|
||||
// 强制保存数据
|
||||
var saveSuccess = ForceCompleteDataSave();
|
||||
@@ -2742,7 +2735,7 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
var result = $"保存操作: {(saveSuccess ? "成功" : "失败")}\n\n{verificationResult}";
|
||||
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 保存并验证注册表数据完成");
|
||||
LogHelper.WriteLogToFile("DeviceIdentifier | 保存并验证注册表数据完成");
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
{
|
||||
@@ -70,7 +71,7 @@ namespace Ink_Canvas.Helpers
|
||||
[FieldOffset(8)]
|
||||
private DateTime date;
|
||||
[FieldOffset(8)]
|
||||
private System.Runtime.InteropServices.ComTypes.FILETIME filetime;
|
||||
private FILETIME filetime;
|
||||
|
||||
[FieldOffset(8)]
|
||||
private Blob blobVal;
|
||||
@@ -115,7 +116,7 @@ namespace Ink_Canvas.Helpers
|
||||
case VarEnum.VT_BLOB:
|
||||
return GetBlob();
|
||||
}
|
||||
throw new NotImplementedException("PropVariant " + ve.ToString());
|
||||
throw new NotImplementedException("PropVariant " + ve);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,17 +145,17 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
#region "Interfaces"
|
||||
|
||||
[ComImport(), Guid("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[ComImport, Guid("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
public interface IPropertyStore
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||
void GetCount([Out(), In()] ref uint cProps);
|
||||
void GetCount([Out, In] ref uint cProps);
|
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||
void GetAt([In()] uint iProp, ref PropertyKey pkey);
|
||||
void GetAt([In] uint iProp, ref PropertyKey pkey);
|
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||
void GetValue([In()] ref PropertyKey key, ref PropVariant pv);
|
||||
void GetValue([In] ref PropertyKey key, ref PropVariant pv);
|
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||
void SetValue([In()] ref PropertyKey key, [In()] ref PropVariant pv);
|
||||
void SetValue([In] ref PropertyKey key, [In] ref PropVariant pv);
|
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||
void Commit();
|
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
{
|
||||
@@ -94,7 +95,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
public static double GetTaskbarHeight(System.Windows.Forms.Screen screen, double dpiScaleY)
|
||||
public static double GetTaskbarHeight(Screen screen, double dpiScaleY)
|
||||
{
|
||||
// 获取工作区和屏幕高度的差值
|
||||
var workingArea = screen.WorkingArea;
|
||||
|
||||
@@ -264,8 +264,8 @@ namespace Ink_Canvas.Helpers
|
||||
/// </summary>
|
||||
public int Width
|
||||
{
|
||||
get { return unchecked((int) (Right - Left)); }
|
||||
set { Right = unchecked((int) (Left + value)); }
|
||||
get { return unchecked(Right - Left); }
|
||||
set { Right = unchecked(Left + value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -273,8 +273,8 @@ namespace Ink_Canvas.Helpers
|
||||
/// </summary>
|
||||
public int Height
|
||||
{
|
||||
get { return unchecked((int) (Bottom - Top)); }
|
||||
set { Bottom = unchecked((int) (Top + value)); }
|
||||
get { return unchecked(Bottom - Top); }
|
||||
set { Bottom = unchecked(Top + value); }
|
||||
}
|
||||
|
||||
public bool Equals(Rectangle other)
|
||||
@@ -296,10 +296,10 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hashCode = (int) Left;
|
||||
hashCode = (hashCode * 397) ^ (int) Top;
|
||||
hashCode = (hashCode * 397) ^ (int) Right;
|
||||
hashCode = (hashCode * 397) ^ (int) Bottom;
|
||||
var hashCode = Left;
|
||||
hashCode = (hashCode * 397) ^ Top;
|
||||
hashCode = (hashCode * 397) ^ Right;
|
||||
hashCode = (hashCode * 397) ^ Bottom;
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,10 +278,7 @@ namespace Ink_Canvas.Helpers
|
||||
window.Width = logicalSize.X;
|
||||
window.Height = logicalSize.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
//这个hwnd是前面从Window来的,如果现在他不是Window...... 你信么
|
||||
}
|
||||
//这个hwnd是前面从Window来的,如果现在他不是Window...... 你信么
|
||||
}
|
||||
|
||||
//将修改后的结构体拷贝回去
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
@@ -19,7 +17,7 @@ namespace Ink_Canvas.Helpers
|
||||
private readonly RenderTargetBitmap _renderTarget;
|
||||
private readonly DrawingVisual _drawingVisual;
|
||||
private readonly DrawingContext _drawingContext;
|
||||
private bool _isInitialized = false;
|
||||
private bool _isInitialized;
|
||||
|
||||
public HardwareAcceleratedInkProcessor(int width = 1920, int height = 1080)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
var analyzer = new InkAnalyzer();
|
||||
analyzer.AddStrokes(strokes);
|
||||
analyzer.SetStrokesType(strokes, System.Windows.Ink.StrokeType.Drawing);
|
||||
analyzer.SetStrokesType(strokes, StrokeType.Drawing);
|
||||
|
||||
AnalysisAlternate analysisAlternate = null;
|
||||
int strokesCount = strokes.Count;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
@@ -17,7 +18,7 @@ namespace Ink_Canvas.Helpers
|
||||
private readonly InkSmoothingPerformanceMonitor _performanceMonitor;
|
||||
private readonly InkSmoothingConfig _config;
|
||||
private readonly Dispatcher _uiDispatcher;
|
||||
private bool _disposed = false;
|
||||
private bool _disposed;
|
||||
|
||||
public InkSmoothingManager(Dispatcher uiDispatcher)
|
||||
{
|
||||
@@ -81,7 +82,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"墨迹平滑失败: {ex.Message}");
|
||||
Debug.WriteLine($"墨迹平滑失败: {ex.Message}");
|
||||
result = originalStroke;
|
||||
}
|
||||
finally
|
||||
@@ -122,7 +123,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"同步墨迹平滑失败: {ex.Message}");
|
||||
Debug.WriteLine($"同步墨迹平滑失败: {ex.Message}");
|
||||
result = originalStroke;
|
||||
}
|
||||
finally
|
||||
@@ -174,7 +175,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
return System.Windows.Media.RenderCapability.Tier >= 0x00020000;
|
||||
return RenderCapability.Tier >= 0x00020000;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Interop;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Interop;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Ink_Canvas.Helpers {
|
||||
internal class IsOutsideOfScreenHelper {
|
||||
@@ -13,16 +16,16 @@ namespace Ink_Canvas.Helpers {
|
||||
var hWnd = hwndSource.Handle;
|
||||
var targetBounds = GetPixelBoundsToScreen(target);
|
||||
|
||||
var screens = System.Windows.Forms.Screen.AllScreens;
|
||||
var screens = Screen.AllScreens;
|
||||
return !screens.Any(x => x.Bounds.IntersectsWith(targetBounds));
|
||||
|
||||
System.Drawing.Rectangle GetPixelBoundsToScreen(FrameworkElement visual) {
|
||||
Rectangle GetPixelBoundsToScreen(FrameworkElement visual) {
|
||||
var pixelBoundsToScreen = Rect.Empty;
|
||||
pixelBoundsToScreen.Union(visual.PointToScreen(new Point(0, 0)));
|
||||
pixelBoundsToScreen.Union(visual.PointToScreen(new Point(visual.ActualWidth, 0)));
|
||||
pixelBoundsToScreen.Union(visual.PointToScreen(new Point(0, visual.ActualHeight)));
|
||||
pixelBoundsToScreen.Union(visual.PointToScreen(new Point(visual.ActualWidth, visual.ActualHeight)));
|
||||
return new System.Drawing.Rectangle(
|
||||
return new Rectangle(
|
||||
(int)pixelBoundsToScreen.X, (int)pixelBoundsToScreen.Y,
|
||||
(int)pixelBoundsToScreen.Width, (int)pixelBoundsToScreen.Height);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
public static void NewLog(string str)
|
||||
{
|
||||
WriteLogToFile(str, LogType.Info);
|
||||
WriteLogToFile(str);
|
||||
}
|
||||
|
||||
public static void NewLog(Exception ex)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Ink_Canvas.Helpers
|
||||
/// <summary>
|
||||
/// 创建显示笔迹的类
|
||||
/// </summary>
|
||||
public StrokeVisual() : this(new DrawingAttributes()
|
||||
public StrokeVisual() : this(new DrawingAttributes
|
||||
{
|
||||
Color = Colors.Red,
|
||||
//FitToCurve = true,
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
try
|
||||
{
|
||||
_plugin = plugin;
|
||||
LogHelper.WriteLogToFile("开始创建启动台按钮", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("开始创建启动台按钮");
|
||||
|
||||
// 创建SimpleStackPanel
|
||||
_panel = new SimpleStackPanel
|
||||
@@ -49,7 +49,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
Background = Brushes.Transparent
|
||||
};
|
||||
|
||||
LogHelper.WriteLogToFile("创建SimpleStackPanel完成", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("创建SimpleStackPanel完成");
|
||||
|
||||
// 添加图标
|
||||
var image = CreateIconImage();
|
||||
@@ -77,7 +77,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
// 设置工具提示
|
||||
_panel.ToolTip = "启动台";
|
||||
|
||||
LogHelper.WriteLogToFile("启动台按钮创建完成", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("启动台按钮创建完成");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -112,8 +112,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
// 保存配置
|
||||
_plugin.SaveConfig();
|
||||
|
||||
LogHelper.WriteLogToFile($"通过右键菜单切换启动台按钮位置为: {_plugin.Config.ButtonPosition}",
|
||||
LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"通过右键菜单切换启动台按钮位置为: {_plugin.Config.ButtonPosition}");
|
||||
};
|
||||
menu.Items.Add(positionMenuItem);
|
||||
|
||||
@@ -133,7 +132,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
if (method != null)
|
||||
{
|
||||
method.Invoke(mainWindow, null);
|
||||
LogHelper.WriteLogToFile("已打开插件设置窗口", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("已打开插件设置窗口");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -218,7 +217,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
{
|
||||
// 提供反馈
|
||||
_panel.Background = new SolidColorBrush(Color.FromArgb(40, 0, 0, 0));
|
||||
LogHelper.WriteLogToFile("启动台按钮鼠标按下", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("启动台按钮鼠标按下");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -241,7 +240,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
|
||||
// 恢复背景
|
||||
_panel.Background = Brushes.Transparent;
|
||||
LogHelper.WriteLogToFile("启动台按钮鼠标抬起,准备显示启动台窗口", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("启动台按钮鼠标抬起,准备显示启动台窗口");
|
||||
|
||||
// 获取按钮在屏幕上的位置
|
||||
Point buttonPosition = _panel.PointToScreen(new Point(_panel.ActualWidth / 2, 0));
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
{
|
||||
@@ -75,13 +78,13 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
/// <summary>
|
||||
/// 图标缓存
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[JsonIgnore]
|
||||
private ImageSource _iconCache;
|
||||
|
||||
/// <summary>
|
||||
/// 获取应用程序图标
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[JsonIgnore]
|
||||
public ImageSource Icon
|
||||
{
|
||||
get
|
||||
@@ -241,28 +244,28 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
}
|
||||
|
||||
// 检查文件是否存在
|
||||
if (!System.IO.File.Exists(Path) && !Path.Contains(":\\"))
|
||||
if (!File.Exists(Path) && !Path.Contains(":\\"))
|
||||
{
|
||||
// 可能是系统命令,如explorer.exe
|
||||
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo
|
||||
ProcessStartInfo psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = Path,
|
||||
UseShellExecute = true
|
||||
};
|
||||
System.Diagnostics.Process.Start(psi);
|
||||
Process.Start(psi);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 使用Process.Start启动应用程序
|
||||
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo
|
||||
ProcessStartInfo psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = Path,
|
||||
UseShellExecute = true
|
||||
};
|
||||
System.Diagnostics.Process.Start(psi);
|
||||
Process.Start(psi);
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"已启动应用程序: {Path}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已启动应用程序: {Path}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -315,15 +318,15 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("Shell32.dll", EntryPoint = "ExtractIconEx")]
|
||||
[DllImport("Shell32.dll", EntryPoint = "ExtractIconEx")]
|
||||
private static extern int ExtractIconEx(
|
||||
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)] string lpszFile,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string lpszFile,
|
||||
int nIconIndex,
|
||||
out IntPtr phiconLarge,
|
||||
out IntPtr phiconSmall,
|
||||
int nIcons);
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("User32.dll")]
|
||||
[DllImport("User32.dll")]
|
||||
private static extern int DestroyIcon(IntPtr hIcon);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Ink_Canvas.Windows;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
{
|
||||
@@ -77,7 +78,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
// 保存配置
|
||||
_plugin.SaveConfig();
|
||||
|
||||
LogHelper.WriteLogToFile($"启动台按钮位置已更改为: {_plugin.Config.ButtonPosition}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"启动台按钮位置已更改为: {_plugin.Config.ButtonPosition}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -283,9 +284,9 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
pathTextBox.Text = dialog.FileName;
|
||||
|
||||
// 如果选择的是.exe文件,自动获取文件名填入名称字段
|
||||
if (System.IO.Path.GetExtension(dialog.FileName).ToLower() == ".exe")
|
||||
if (Path.GetExtension(dialog.FileName).ToLower() == ".exe")
|
||||
{
|
||||
string fileName = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName);
|
||||
string fileName = Path.GetFileNameWithoutExtension(dialog.FileName);
|
||||
// 只有在名称字段为空或者是新建项目时才自动填入
|
||||
if (string.IsNullOrWhiteSpace(nameTextBox.Text) || isNew)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
{
|
||||
@@ -21,7 +27,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
/// <summary>
|
||||
/// 是否处于固定模式
|
||||
/// </summary>
|
||||
private bool _isFixMode = false;
|
||||
private bool _isFixMode;
|
||||
|
||||
/// <summary>
|
||||
/// 应用项按钮列表
|
||||
@@ -51,11 +57,11 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
LoadLauncherItems();
|
||||
|
||||
// 添加鼠标按下事件(用于拖动窗口)
|
||||
this.MouseDown += (s, e) =>
|
||||
MouseDown += (s, e) =>
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left && e.ButtonState == MouseButtonState.Pressed)
|
||||
{
|
||||
this.DragMove();
|
||||
DragMove();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -145,18 +151,18 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
string appPath = item.Path;
|
||||
string appName = item.Name;
|
||||
|
||||
LogHelper.WriteLogToFile($"点击启动应用: {appName}, 路径: {appPath}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"点击启动应用: {appName}, 路径: {appPath}");
|
||||
|
||||
// 首先标记窗口正在关闭
|
||||
IsClosing = true;
|
||||
|
||||
// 创建一个应用启动任务
|
||||
var launchTask = new System.Threading.Tasks.Task(() =>
|
||||
var launchTask = new Task(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// 等待一段时间,确保窗口关闭流程已经开始
|
||||
System.Threading.Thread.Sleep(200);
|
||||
Thread.Sleep(200);
|
||||
|
||||
// 使用UI线程启动应用
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
@@ -164,18 +170,18 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
try
|
||||
{
|
||||
// 检查应用路径是否存在
|
||||
if (System.IO.File.Exists(appPath) || !appPath.Contains(":\\"))
|
||||
if (File.Exists(appPath) || !appPath.Contains(":\\"))
|
||||
{
|
||||
// 创建进程启动信息
|
||||
var psi = new System.Diagnostics.ProcessStartInfo
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = appPath,
|
||||
UseShellExecute = true,
|
||||
};
|
||||
|
||||
// 启动应用程序
|
||||
var process = System.Diagnostics.Process.Start(psi);
|
||||
LogHelper.WriteLogToFile($"应用程序 {appName} 已启动", LogHelper.LogType.Info);
|
||||
var process = Process.Start(psi);
|
||||
LogHelper.WriteLogToFile($"应用程序 {appName} 已启动");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -205,7 +211,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
|
||||
// 启动应用程序任务
|
||||
launchTask.Start();
|
||||
}), System.Windows.Threading.DispatcherPriority.Background);
|
||||
}), DispatcherPriority.Background);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -406,7 +412,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
{
|
||||
LogHelper.WriteLogToFile($"延迟关闭窗口时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}), System.Windows.Threading.DispatcherPriority.Background);
|
||||
}), DispatcherPriority.Background);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -418,12 +424,12 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
|
||||
/// <summary>
|
||||
/// 窗口是否正在关闭
|
||||
/// </summary>
|
||||
private bool IsClosing { get; set; } = false;
|
||||
private bool IsClosing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 重写OnClosing方法,标记窗口正在关闭
|
||||
/// </summary>
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
IsClosing = true;
|
||||
base.OnClosing(e);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -7,6 +5,8 @@ using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
/// <summary>
|
||||
/// 标记是否已添加到浮动栏
|
||||
/// </summary>
|
||||
private bool _isAddedToFloatingBar = false;
|
||||
private bool _isAddedToFloatingBar;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
// 加载配置
|
||||
LoadConfig();
|
||||
|
||||
LogHelper.WriteLogToFile("超级启动台插件已初始化", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("超级启动台插件已初始化");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -100,7 +100,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
if (_launcherButton == null)
|
||||
{
|
||||
_launcherButton = new LauncherButton(this);
|
||||
LogHelper.WriteLogToFile("超级启动台按钮已创建", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("超级启动台按钮已创建");
|
||||
}
|
||||
|
||||
// 添加启动台按钮到浮动栏
|
||||
@@ -112,7 +112,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
// 保存插件配置
|
||||
SavePluginSettings();
|
||||
|
||||
LogHelper.WriteLogToFile("超级启动台插件已启用", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("超级启动台插件已启用");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -143,7 +143,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
// 保存插件配置
|
||||
SavePluginSettings();
|
||||
|
||||
LogHelper.WriteLogToFile("超级启动台插件已禁用", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("超级启动台插件已禁用");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -193,7 +193,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
// 保存配置
|
||||
SaveConfig();
|
||||
|
||||
LogHelper.WriteLogToFile($"超级启动台插件设置已保存", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("超级启动台插件设置已保存");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -250,7 +250,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
string json = JsonConvert.SerializeObject(Config, Formatting.Indented);
|
||||
File.WriteAllText(_configPath, json);
|
||||
|
||||
LogHelper.WriteLogToFile("超级启动台配置已保存", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("超级启动台配置已保存");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -332,12 +332,12 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
if (Config.ButtonPosition == LauncherButtonPosition.Left)
|
||||
{
|
||||
floatingBar.Children.Insert(0, buttonElement);
|
||||
LogHelper.WriteLogToFile("启动台按钮已添加到浮动栏左侧", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("启动台按钮已添加到浮动栏左侧");
|
||||
}
|
||||
else
|
||||
{
|
||||
floatingBar.Children.Add(buttonElement);
|
||||
LogHelper.WriteLogToFile("启动台按钮已添加到浮动栏右侧", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("启动台按钮已添加到浮动栏右侧");
|
||||
}
|
||||
|
||||
_isAddedToFloatingBar = true;
|
||||
@@ -424,7 +424,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
if (floatingBar.Children.Contains(buttonElement))
|
||||
{
|
||||
floatingBar.Children.Remove(buttonElement);
|
||||
LogHelper.WriteLogToFile("启动台按钮已从浮动栏移除", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("启动台按钮已从浮动栏移除");
|
||||
}
|
||||
|
||||
_isAddedToFloatingBar = false;
|
||||
@@ -448,7 +448,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn
|
||||
{
|
||||
RemoveLauncherButtonFromFloatingBar();
|
||||
AddLauncherButtonToFloatingBar();
|
||||
LogHelper.WriteLogToFile($"启动台按钮位置已更新为: {Config.ButtonPosition}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"启动台按钮位置已更新为: {Config.ButtonPosition}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
private readonly string _pluginPath;
|
||||
private readonly string _pluginName;
|
||||
private readonly Version _pluginVersion;
|
||||
private bool _isInitialized = false;
|
||||
private bool _isInitialized;
|
||||
|
||||
/// <summary>
|
||||
/// 创建 ICCPP 插件适配器
|
||||
@@ -104,7 +104,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 这里可以添加 .iccpp 插件的初始化逻辑
|
||||
// 例如,根据文件格式加载特定资源
|
||||
|
||||
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已初始化", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已初始化");
|
||||
_isInitialized = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -126,7 +126,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 例如,加载动态库、注册事件等
|
||||
|
||||
base.Enable(); // 设置启用状态并触发事件
|
||||
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已启用", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已启用");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -147,7 +147,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 例如,卸载动态库、注销事件等
|
||||
|
||||
base.Disable(); // 设置禁用状态并触发事件
|
||||
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已禁用", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已禁用");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -165,7 +165,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 这里可以添加 .iccpp 插件的清理逻辑
|
||||
// 例如,释放资源等
|
||||
|
||||
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已清理资源", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已清理资源");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
/// <summary>
|
||||
/// 插件状态(私有字段)
|
||||
/// </summary>
|
||||
private bool _isEnabled = false;
|
||||
private bool _isEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// 插件状态(公共属性)
|
||||
@@ -80,7 +80,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
try
|
||||
{
|
||||
string name = Name;
|
||||
LogHelper.WriteLogToFile($"初始化插件: ID={Id}, 名称={name ?? "未命名"}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"初始化插件: ID={Id}, 名称={name ?? "未命名"}");
|
||||
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
@@ -92,7 +92,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
LogHelper.WriteLogToFile($"获取插件名称时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已初始化", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已初始化");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -103,7 +103,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (!IsEnabled)
|
||||
{
|
||||
IsEnabled = true;
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已启用", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已启用");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (IsEnabled)
|
||||
{
|
||||
IsEnabled = false;
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已禁用", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已禁用");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
/// </summary>
|
||||
public virtual void Cleanup()
|
||||
{
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已卸载", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已卸载");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,6 +8,9 @@ using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Ink_Canvas.Windows;
|
||||
using Newtonsoft.Json;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
@@ -51,12 +54,12 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
/// <summary>
|
||||
/// 配置是否已更改但未保存
|
||||
/// </summary>
|
||||
private bool _configDirty = false;
|
||||
private bool _configDirty;
|
||||
|
||||
/// <summary>
|
||||
/// 配置自动保存计时器
|
||||
/// </summary>
|
||||
private System.Timers.Timer _autoSaveTimer;
|
||||
private Timer _autoSaveTimer;
|
||||
|
||||
/// <summary>
|
||||
/// 加载的程序集缓存
|
||||
@@ -80,7 +83,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
LoadConfig();
|
||||
|
||||
// 初始化自动保存计时器(3秒)
|
||||
_autoSaveTimer = new System.Timers.Timer(3000);
|
||||
_autoSaveTimer = new Timer(3000);
|
||||
_autoSaveTimer.Elapsed += (s, e) =>
|
||||
{
|
||||
if (_configDirty)
|
||||
@@ -108,22 +111,22 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile("开始初始化插件系统", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("开始初始化插件系统");
|
||||
|
||||
// 加载配置
|
||||
LoadConfig();
|
||||
LogHelper.WriteLogToFile($"已从配置文件加载 {PluginStates.Count} 个插件状态记录", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已从配置文件加载 {PluginStates.Count} 个插件状态记录");
|
||||
|
||||
// 加载内置插件
|
||||
LogHelper.WriteLogToFile("正在加载内置插件...", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("正在加载内置插件...");
|
||||
LoadBuiltInPlugins();
|
||||
|
||||
// 加载外部插件
|
||||
LogHelper.WriteLogToFile("正在加载外部插件...", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("正在加载外部插件...");
|
||||
LoadExternalPlugins();
|
||||
|
||||
// 启用已配置为启用的插件
|
||||
LogHelper.WriteLogToFile("正在应用配置的插件状态...", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("正在应用配置的插件状态...");
|
||||
EnableConfiguredPlugins();
|
||||
|
||||
// 设置定期检查热重载
|
||||
@@ -132,7 +135,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 保存初始化后的配置(可能有新插件)
|
||||
SaveConfig();
|
||||
|
||||
LogHelper.WriteLogToFile($"插件系统初始化完成,共加载 {Plugins.Count} 个插件", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件系统初始化完成,共加载 {Plugins.Count} 个插件");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -166,7 +169,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
plugin.Initialize();
|
||||
Plugins.Add(plugin);
|
||||
LogHelper.WriteLogToFile($"已加载内置插件: {plugin.Name} v{plugin.Version}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已加载内置插件: {plugin.Name} v{plugin.Version}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -200,7 +203,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
.Concat(Directory.GetFiles(PluginsDirectory, "*.dll", SearchOption.TopDirectoryOnly))
|
||||
.ToArray();
|
||||
|
||||
LogHelper.WriteLogToFile($"发现 {pluginFiles.Length} 个外部插件文件", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"发现 {pluginFiles.Length} 个外部插件文件");
|
||||
|
||||
foreach (var pluginFile in pluginFiles)
|
||||
{
|
||||
@@ -258,8 +261,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
plugin.Initialize();
|
||||
Plugins.Add(plugin);
|
||||
|
||||
LogHelper.WriteLogToFile($"已加载外部插件: {plugin.Name} v{plugin.Version} 来自 {Path.GetFileName(pluginPath)}",
|
||||
LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已加载外部插件: {plugin.Name} v{plugin.Version} 来自 {Path.GetFileName(pluginPath)}");
|
||||
|
||||
return plugin;
|
||||
}
|
||||
@@ -297,8 +299,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 添加到插件列表
|
||||
Plugins.Add(pluginAdapter);
|
||||
|
||||
LogHelper.WriteLogToFile($"已创建 ICCPP 插件适配器: {pluginAdapter.Name} 来自 {Path.GetFileName(pluginPath)}",
|
||||
LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已创建 ICCPP 插件适配器: {pluginAdapter.Name} 来自 {Path.GetFileName(pluginPath)}");
|
||||
|
||||
return pluginAdapter;
|
||||
}
|
||||
@@ -371,13 +372,13 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
plugin.Enable();
|
||||
enabledCount++;
|
||||
LogHelper.WriteLogToFile($"根据配置启用插件: {plugin.Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"根据配置启用插件: {plugin.Name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.Disable();
|
||||
disabledCount++;
|
||||
LogHelper.WriteLogToFile($"根据配置禁用插件: {plugin.Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"根据配置禁用插件: {plugin.Name}");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -406,7 +407,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
plugin.Disable();
|
||||
disabledCount++;
|
||||
LogHelper.WriteLogToFile($"插件不在配置中,默认禁用: {plugin.Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件不在配置中,默认禁用: {plugin.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,7 +424,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
TriggerAutoSave();
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"已应用插件配置: 启用 {enabledCount} 个,禁用 {disabledCount} 个,错误 {errorCount} 个", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已应用插件配置: 启用 {enabledCount} 个,禁用 {disabledCount} 个,错误 {errorCount} 个");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -443,11 +444,11 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
PluginStates[pluginTypeName] = isEnabled;
|
||||
_configDirty = true;
|
||||
|
||||
LogHelper.WriteLogToFile($"插件状态变更: {plugin.Name} = {(isEnabled ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件状态变更: {plugin.Name} = {(isEnabled ? "启用" : "禁用")}");
|
||||
|
||||
// 立即同步保存配置(不再使用延迟自动保存)
|
||||
SaveConfig();
|
||||
LogHelper.WriteLogToFile($"插件 {plugin.Name} 状态已立即保存到配置文件", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {plugin.Name} 状态已立即保存到配置文件");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -534,14 +535,14 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
return;
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"开始热重载插件: {plugin.Name} ({Path.GetFileName(pluginPath)})", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"开始热重载插件: {plugin.Name} ({Path.GetFileName(pluginPath)})");
|
||||
|
||||
// 保存插件的当前状态
|
||||
bool wasEnabled = plugin.IsEnabled;
|
||||
string pluginTypeName = plugin.GetType().FullName;
|
||||
|
||||
// 卸载插件
|
||||
UnloadPlugin(plugin, false);
|
||||
UnloadPlugin(plugin);
|
||||
|
||||
// 从加载缓存中移除
|
||||
if (_loadedAssemblies.ContainsKey(pluginPath))
|
||||
@@ -575,7 +576,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {newPlugin.Name} v{newPlugin.Version} 热重载成功", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {newPlugin.Name} v{newPlugin.Version} 热重载成功");
|
||||
|
||||
// 通知UI刷新
|
||||
NotifyUIRefresh();
|
||||
@@ -626,7 +627,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"已卸载插件: {pluginName}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已卸载插件: {pluginName}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -677,7 +678,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 保存配置
|
||||
SaveConfig();
|
||||
|
||||
LogHelper.WriteLogToFile($"已删除插件: {pluginName}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已删除插件: {pluginName}");
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -701,7 +702,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (currentState == enable)
|
||||
{
|
||||
// 已经是目标状态,无需操作
|
||||
LogHelper.WriteLogToFile($"插件 {plugin.Name} 已经是 {(enable ? "启用" : "禁用")} 状态,无需切换", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {plugin.Name} 已经是 {(enable ? "启用" : "禁用")} 状态,无需切换");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -709,7 +710,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
string pluginName = plugin.Name;
|
||||
string pluginTypeName = plugin.GetType().FullName;
|
||||
|
||||
LogHelper.WriteLogToFile($"开始切换插件 {pluginName} 状态为: {(enable ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"开始切换插件 {pluginName} 状态为: {(enable ? "启用" : "禁用")}");
|
||||
|
||||
// 首先更新配置状态
|
||||
PluginStates[pluginTypeName] = enable;
|
||||
@@ -731,13 +732,13 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (enable)
|
||||
{
|
||||
plugin.Enable();
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 已启用", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 已启用");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 禁用前先记录是否为内置插件
|
||||
bool isBuiltIn = plugin.IsBuiltIn;
|
||||
LogHelper.WriteLogToFile($"尝试禁用{(isBuiltIn ? "内置" : "外部")}插件 {pluginName}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"尝试禁用{(isBuiltIn ? "内置" : "外部")}插件 {pluginName}");
|
||||
|
||||
// 禁用插件
|
||||
plugin.Disable();
|
||||
@@ -762,13 +763,13 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (enabledProperty != null)
|
||||
{
|
||||
enabledProperty.SetValue(pb4, false);
|
||||
LogHelper.WriteLogToFile($"已通过反射强制设置插件 {pluginName} 为禁用状态", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已通过反射强制设置插件 {pluginName} 为禁用状态");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 已禁用", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 已禁用");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -785,7 +786,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 对于内置插件,执行专门的处理
|
||||
if (pluginInstance.IsBuiltIn)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"处理内置插件 {pluginName} 状态变更", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"处理内置插件 {pluginName} 状态变更");
|
||||
|
||||
// 对于内置插件,我们需要确保状态正确应用
|
||||
bool finalState = pluginInstance.IsEnabled;
|
||||
@@ -811,7 +812,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (enabledProperty != null)
|
||||
{
|
||||
enabledProperty.SetValue(pluginInstance, expectedState);
|
||||
LogHelper.WriteLogToFile($"已通过反射强制设置内置插件 {pluginName} 状态为 {(expectedState ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已通过反射强制设置内置插件 {pluginName} 状态为 {(expectedState ? "启用" : "禁用")}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -827,7 +828,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
if (!string.IsNullOrEmpty(pluginInstance.PluginPath) && File.Exists(pluginInstance.PluginPath))
|
||||
{
|
||||
LogHelper.WriteLogToFile($"开始重载外部插件 {pluginName}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"开始重载外部插件 {pluginName}");
|
||||
|
||||
// 使用调度器确保在UI线程执行热重载
|
||||
if (Application.Current != null && Application.Current.Dispatcher != null)
|
||||
@@ -835,14 +836,14 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
ReloadPlugin(pluginInstance);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 已重载以应用{(enable ? "启用" : "禁用")}状态", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 已重载以应用{(enable ? "启用" : "禁用")}状态");
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 当前不在UI线程,直接重载
|
||||
ReloadPlugin(pluginInstance);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 已重载以应用{(enable ? "启用" : "禁用")}状态", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 已重载以应用{(enable ? "启用" : "禁用")}状态");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -865,7 +866,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
NotifyUIRefresh();
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 状态切换完成", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 状态切换完成");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -889,12 +890,12 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (enable)
|
||||
{
|
||||
plugin.Enable();
|
||||
LogHelper.WriteLogToFile($"实时应用: 已启用插件 {plugin.Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"实时应用: 已启用插件 {plugin.Name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.Disable();
|
||||
LogHelper.WriteLogToFile($"实时应用: 已禁用插件 {plugin.Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"实时应用: 已禁用插件 {plugin.Name}");
|
||||
}
|
||||
|
||||
// 同步状态到插件自身的配置
|
||||
@@ -904,7 +905,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
// 保存插件设置(与启用状态无关)
|
||||
pluginSettings.SavePluginSettings();
|
||||
LogHelper.WriteLogToFile($"实时应用: 已保存插件 {plugin.Name} 设置", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"实时应用: 已保存插件 {plugin.Name} 设置");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -940,7 +941,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
|
||||
// 执行热重载
|
||||
ReloadPlugin(externalPlugin);
|
||||
LogHelper.WriteLogToFile($"插件 {plugin.Name} 已成功热重载以应用实时状态", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {plugin.Name} 已成功热重载以应用实时状态");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -964,7 +965,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {plugin.Name} 实时状态已应用: {(enable ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {plugin.Name} 实时状态已应用: {(enable ? "启用" : "禁用")}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -986,7 +987,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 通知任何可能打开的插件设置窗口刷新
|
||||
foreach (Window window in Application.Current.Windows)
|
||||
{
|
||||
if (window is Windows.PluginSettingsWindow pluginWindow)
|
||||
if (window is PluginSettingsWindow pluginWindow)
|
||||
{
|
||||
pluginWindow.RefreshPluginList();
|
||||
break;
|
||||
@@ -1009,7 +1010,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
const int maxRetries = 3; // 最大重试次数
|
||||
const int retryDelayMs = 300; // 重试延迟时间(毫秒)
|
||||
|
||||
LogHelper.WriteLogToFile($"开始从配置文件加载插件状态: {PluginConfigFile}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"开始从配置文件加载插件状态: {PluginConfigFile}");
|
||||
|
||||
// 确保至少有一个默认配置
|
||||
Dictionary<string, bool> defaultConfig = new Dictionary<string, bool>();
|
||||
@@ -1033,14 +1034,13 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
json = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
var loadedStates = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, bool>>(json);
|
||||
var loadedStates = JsonConvert.DeserializeObject<Dictionary<string, bool>>(json);
|
||||
|
||||
if (loadedStates != null && loadedStates.Count > 0)
|
||||
{
|
||||
PluginStates = loadedStates;
|
||||
_configDirty = false; // 重置脏标记
|
||||
LogHelper.WriteLogToFile($"成功从配置文件加载了 {PluginStates.Count} 个插件状态", LogHelper.LogType.Info);
|
||||
return; // 成功加载,提前退出
|
||||
LogHelper.WriteLogToFile($"成功从配置文件加载了 {PluginStates.Count} 个插件状态");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1051,13 +1051,13 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
try
|
||||
{
|
||||
string backupJson = File.ReadAllText(PluginConfigBackupFile);
|
||||
var backupStates = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, bool>>(backupJson);
|
||||
var backupStates = JsonConvert.DeserializeObject<Dictionary<string, bool>>(backupJson);
|
||||
|
||||
if (backupStates != null && backupStates.Count > 0)
|
||||
{
|
||||
PluginStates = backupStates;
|
||||
_configDirty = true; // 从备份加载,需要重新保存主配置
|
||||
LogHelper.WriteLogToFile($"已从备份恢复 {PluginStates.Count} 个插件状态", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已从备份恢复 {PluginStates.Count} 个插件状态");
|
||||
return; // 成功从备份加载,提前退出
|
||||
}
|
||||
}
|
||||
@@ -1082,13 +1082,13 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
try
|
||||
{
|
||||
string backupJson = File.ReadAllText(PluginConfigBackupFile);
|
||||
var backupStates = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, bool>>(backupJson);
|
||||
var backupStates = JsonConvert.DeserializeObject<Dictionary<string, bool>>(backupJson);
|
||||
|
||||
if (backupStates != null && backupStates.Count > 0)
|
||||
{
|
||||
PluginStates = backupStates;
|
||||
_configDirty = true; // 从备份加载,需要重新保存主配置
|
||||
LogHelper.WriteLogToFile($"已从备份恢复 {PluginStates.Count} 个插件状态", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已从备份恢复 {PluginStates.Count} 个插件状态");
|
||||
return; // 成功从备份加载,提前退出
|
||||
}
|
||||
}
|
||||
@@ -1111,7 +1111,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (attempt < maxRetries)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"加载配置失败 (尝试 {attempt}/{maxRetries}): {ex.Message},将在 {retryDelayMs}ms 后重试", LogHelper.LogType.Warning);
|
||||
System.Threading.Thread.Sleep(retryDelayMs);
|
||||
Thread.Sleep(retryDelayMs);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1178,10 +1178,10 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile($"开始保存插件配置到: {PluginConfigFile}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"开始保存插件配置到: {PluginConfigFile}");
|
||||
|
||||
// 生成JSON数据
|
||||
string json = Newtonsoft.Json.JsonConvert.SerializeObject(PluginStates, Newtonsoft.Json.Formatting.Indented);
|
||||
string json = JsonConvert.SerializeObject(PluginStates, Formatting.Indented);
|
||||
string tempFile = PluginConfigFile + ".temp"; // 临时文件路径
|
||||
|
||||
// 确保目录存在
|
||||
@@ -1189,7 +1189,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (!Directory.Exists(configDir))
|
||||
{
|
||||
Directory.CreateDirectory(configDir);
|
||||
LogHelper.WriteLogToFile($"创建配置目录: {configDir}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"创建配置目录: {configDir}");
|
||||
}
|
||||
|
||||
// 先备份当前配置
|
||||
@@ -1217,7 +1217,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
// 重置脏标记
|
||||
_configDirty = false;
|
||||
LogHelper.WriteLogToFile($"插件配置已成功保存到磁盘: {PluginConfigFile}, 共 {PluginStates.Count} 个插件状态", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件配置已成功保存到磁盘: {PluginConfigFile}, 共 {PluginStates.Count} 个插件状态");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1226,7 +1226,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (attempt < maxRetries)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"保存配置失败 (尝试 {attempt}/{maxRetries}): {ex.Message},将在 {retryDelayMs}ms 后重试", LogHelper.LogType.Warning);
|
||||
System.Threading.Thread.Sleep(retryDelayMs);
|
||||
Thread.Sleep(retryDelayMs);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1255,7 +1255,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
|
||||
// 重置脏标记
|
||||
_configDirty = false;
|
||||
LogHelper.WriteLogToFile($"使用临时文件方式成功保存配置: {PluginConfigFile}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"使用临时文件方式成功保存配置: {PluginConfigFile}");
|
||||
return;
|
||||
}
|
||||
catch (Exception fallbackEx)
|
||||
@@ -1302,7 +1302,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile("开始从配置文件重新加载插件状态", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("开始从配置文件重新加载插件状态");
|
||||
|
||||
// 保存当前配置状态,以便在加载失败时回滚
|
||||
Dictionary<string, bool> previousStates = new Dictionary<string, bool>(PluginStates);
|
||||
@@ -1318,7 +1318,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
return;
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"已加载 {PluginStates.Count} 个插件状态,开始应用...", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已加载 {PluginStates.Count} 个插件状态,开始应用...");
|
||||
|
||||
// 对比配置,查找变更的插件
|
||||
foreach (var plugin in Plugins.ToList()) // 创建副本进行遍历,避免集合修改异常
|
||||
@@ -1333,7 +1333,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 如果状态需要变更
|
||||
if (currentlyEnabled != shouldBeEnabled)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"应用插件 {plugin.Name} 的配置状态: {(shouldBeEnabled ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"应用插件 {plugin.Name} 的配置状态: {(shouldBeEnabled ? "启用" : "禁用")}");
|
||||
|
||||
if (shouldBeEnabled)
|
||||
{
|
||||
@@ -1352,7 +1352,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
// 记录禁用信息,特别是内置插件
|
||||
bool isBuiltIn = plugin.IsBuiltIn;
|
||||
LogHelper.WriteLogToFile($"尝试禁用{(isBuiltIn ? "内置" : "外部")}插件 {plugin.Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"尝试禁用{(isBuiltIn ? "内置" : "外部")}插件 {plugin.Name}");
|
||||
|
||||
// 禁用插件
|
||||
plugin.Disable();
|
||||
@@ -1368,7 +1368,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (enabledProperty != null)
|
||||
{
|
||||
enabledProperty.SetValue(builtInPluginBase, false);
|
||||
LogHelper.WriteLogToFile($"已通过反射强制禁用内置插件 {plugin.Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已通过反射强制禁用内置插件 {plugin.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1397,7 +1397,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
{
|
||||
// 插件不在配置中,将其添加为禁用状态
|
||||
PluginStates[pluginTypeName] = false;
|
||||
LogHelper.WriteLogToFile($"插件 {plugin.Name} 不在配置中,默认设置为禁用状态", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {plugin.Name} 不在配置中,默认设置为禁用状态");
|
||||
|
||||
// 如果当前是启用状态,则禁用它
|
||||
if (plugin is PluginBase pluginBase && pluginBase.IsEnabled)
|
||||
@@ -1405,7 +1405,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
try
|
||||
{
|
||||
bool isBuiltIn = plugin.IsBuiltIn;
|
||||
LogHelper.WriteLogToFile($"尝试禁用未配置的{(isBuiltIn ? "内置" : "外部")}插件 {plugin.Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"尝试禁用未配置的{(isBuiltIn ? "内置" : "外部")}插件 {plugin.Name}");
|
||||
|
||||
plugin.Disable();
|
||||
|
||||
@@ -1418,7 +1418,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
if (enabledProperty != null)
|
||||
{
|
||||
enabledProperty.SetValue(pluginBase, false);
|
||||
LogHelper.WriteLogToFile($"已通过反射强制禁用未配置的内置插件 {plugin.Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已通过反射强制禁用未配置的内置插件 {plugin.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1440,7 +1440,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 通知任何可能打开的插件设置窗口刷新
|
||||
foreach (Window window in Application.Current.Windows)
|
||||
{
|
||||
if (window is Windows.PluginSettingsWindow pluginWindow)
|
||||
if (window is PluginSettingsWindow pluginWindow)
|
||||
{
|
||||
pluginWindow.RefreshPluginList();
|
||||
}
|
||||
@@ -1448,7 +1448,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
});
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile("插件状态已从配置文件重新加载完成", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("插件状态已从配置文件重新加载完成");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// TODO: 在这里进行插件初始化工作
|
||||
|
||||
// 示例:记录初始化信息
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 开始初始化", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 开始初始化");
|
||||
|
||||
// 示例:加载配置
|
||||
LoadConfig();
|
||||
@@ -61,7 +61,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
// 示例:注册自定义事件
|
||||
// MainWindow.Instance.SomeEvent += OnSomeEvent;
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 初始化完成", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 初始化完成");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -75,7 +75,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
|
||||
// TODO: 在这里启用插件功能
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已启用", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已启用");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -89,7 +89,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
|
||||
// TODO: 在这里禁用插件功能
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已禁用", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {Name} 已禁用");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -270,7 +270,7 @@ namespace Ink_Canvas.Helpers.Plugins
|
||||
panel.Children.Add(button);
|
||||
|
||||
// 设置控件内容
|
||||
this.Content = panel;
|
||||
Content = panel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
{
|
||||
@@ -27,10 +28,7 @@ namespace Ink_Canvas.Helpers
|
||||
//MessageBox.Show("启动失败: " + ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine(softwareName + " 未找到可执行文件路径。");
|
||||
}
|
||||
//Console.WriteLine(softwareName + " 未找到可执行文件路径。");
|
||||
}
|
||||
|
||||
private static string FindEasiCameraExecutablePath(string softwareName)
|
||||
@@ -51,7 +49,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
if (!string.IsNullOrEmpty(installLocation))
|
||||
{
|
||||
executablePath = System.IO.Path.Combine(installLocation, "sweclauncher.exe");
|
||||
executablePath = Path.Combine(installLocation, "sweclauncher.exe");
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(uninstallString))
|
||||
{
|
||||
@@ -59,7 +57,7 @@ namespace Ink_Canvas.Helpers
|
||||
if (lastSlashIndex >= 0)
|
||||
{
|
||||
string folderPath = uninstallString.Substring(0, lastSlashIndex);
|
||||
executablePath = System.IO.Path.Combine(folderPath, "sweclauncher", "sweclauncher.exe");
|
||||
executablePath = Path.Combine(folderPath, "sweclauncher", "sweclauncher.exe");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows; // Added for UIElement
|
||||
|
||||
// Added for UIElement
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
{
|
||||
@@ -133,7 +135,7 @@ namespace Ink_Canvas.Helpers
|
||||
public class TimeMachineHistory
|
||||
{
|
||||
public TimeMachineHistoryType CommitType;
|
||||
public bool StrokeHasBeenCleared = false;
|
||||
public bool StrokeHasBeenCleared;
|
||||
public StrokeCollection CurrentStroke;
|
||||
public StrokeCollection ReplacedStroke;
|
||||
//这里说一下 Tuple的 Value1 是初始值 ; Value 2 是改变值
|
||||
|
||||
@@ -1,33 +1,44 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Media;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using File = System.IO.File;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Interop;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Reflection;
|
||||
using Brushes = System.Windows.Media.Brushes;
|
||||
using Point = System.Windows.Point;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Ink_Canvas.Helpers.Plugins;
|
||||
using Ink_Canvas.Windows;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Microsoft.Win32;
|
||||
using Application = System.Windows.Application;
|
||||
using File = System.IO.File;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Brushes = System.Windows.Media.Brushes;
|
||||
using Button = System.Windows.Controls.Button;
|
||||
using Cursor = System.Windows.Input.Cursor;
|
||||
using Cursors = System.Windows.Input.Cursors;
|
||||
using DpiChangedEventArgs = System.Windows.DpiChangedEventArgs;
|
||||
using GroupBox = System.Windows.Controls.GroupBox;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
// 新增:每一页一个Canvas对象
|
||||
private List<System.Windows.Controls.Canvas> whiteboardPages = new List<System.Windows.Controls.Canvas>();
|
||||
private int currentPageIndex = 0;
|
||||
private System.Windows.Controls.Canvas currentCanvas = null;
|
||||
private AutoUpdateHelper.UpdateLineGroup AvailableLatestLineGroup = null;
|
||||
private int currentPageIndex;
|
||||
private System.Windows.Controls.Canvas currentCanvas;
|
||||
private AutoUpdateHelper.UpdateLineGroup AvailableLatestLineGroup;
|
||||
|
||||
|
||||
|
||||
@@ -58,7 +69,7 @@ namespace Ink_Canvas {
|
||||
|
||||
ViewBoxStackPanelMain.Visibility = Visibility.Collapsed;
|
||||
ViewBoxStackPanelShapes.Visibility = Visibility.Collapsed;
|
||||
var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
|
||||
var workingArea = Screen.PrimaryScreen.WorkingArea;
|
||||
ViewboxFloatingBar.Margin = new Thickness(
|
||||
(workingArea.Width - 284) / 2,
|
||||
workingArea.Bottom - 60 - workingArea.Top,
|
||||
@@ -81,7 +92,7 @@ namespace Ink_Canvas {
|
||||
File.Delete("Log.txt");
|
||||
LogHelper.WriteLogToFile(
|
||||
"The Log.txt file has been successfully deleted. Original file size: " + fileSizeInKB +
|
||||
" KB", LogHelper.LogType.Info);
|
||||
" KB");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile(
|
||||
@@ -99,7 +110,7 @@ namespace Ink_Canvas {
|
||||
timeMachine.OnUndoStateChanged += TimeMachine_OnUndoStateChanged;
|
||||
inkCanvas.Strokes.StrokesChanged += StrokesOnStrokesChanged;
|
||||
|
||||
Microsoft.Win32.SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
|
||||
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
|
||||
try {
|
||||
if (File.Exists("SpecialVersion.ini")) SpecialVersionResetToSuggestion_Click();
|
||||
}
|
||||
@@ -111,7 +122,7 @@ namespace Ink_Canvas {
|
||||
CheckPenTypeUIState();
|
||||
|
||||
// 初始化墨迹平滑管理器
|
||||
_inkSmoothingManager = new Helpers.InkSmoothingManager(Dispatcher);
|
||||
_inkSmoothingManager = new InkSmoothingManager(Dispatcher);
|
||||
|
||||
// 注册输入事件
|
||||
inkCanvas.PreviewMouseDown += inkCanvas_PreviewMouseDown;
|
||||
@@ -182,10 +193,10 @@ namespace Ink_Canvas {
|
||||
|
||||
#region Ink Canvas Functions
|
||||
|
||||
private System.Windows.Media.Color Ink_DefaultColor = Colors.Red;
|
||||
private Color Ink_DefaultColor = Colors.Red;
|
||||
|
||||
private DrawingAttributes drawingAttributes;
|
||||
private Helpers.InkSmoothingManager _inkSmoothingManager;
|
||||
private InkSmoothingManager _inkSmoothingManager;
|
||||
|
||||
private void loadPenCanvas() {
|
||||
try {
|
||||
@@ -256,7 +267,7 @@ namespace Ink_Canvas {
|
||||
if (inkCanvas1.EditingMode == InkCanvasEditingMode.Ink) forcePointEraser = !forcePointEraser;
|
||||
|
||||
// 处理高级橡皮擦覆盖层的启用/禁用
|
||||
var eraserOverlay = this.FindName("AdvancedEraserOverlay") as Border;
|
||||
var eraserOverlay = FindName("AdvancedEraserOverlay") as Border;
|
||||
if (eraserOverlay != null) {
|
||||
if (inkCanvas1.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
// 橡皮擦模式下启用覆盖层
|
||||
@@ -278,8 +289,8 @@ namespace Ink_Canvas {
|
||||
|
||||
public static Settings Settings = new Settings();
|
||||
public static string settingsFileName = "Settings.json";
|
||||
private bool isLoaded = false;
|
||||
private bool forcePointEraser = false;
|
||||
private bool isLoaded;
|
||||
private bool forcePointEraser;
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
loadPenCanvas();
|
||||
@@ -290,7 +301,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
string savePath = Settings.Automation.AutoSavedStrokesLocation;
|
||||
bool needFix = false;
|
||||
if (string.IsNullOrWhiteSpace(savePath) || !System.IO.Directory.Exists(savePath))
|
||||
if (string.IsNullOrWhiteSpace(savePath) || !Directory.Exists(savePath))
|
||||
{
|
||||
needFix = true;
|
||||
}
|
||||
@@ -299,9 +310,9 @@ namespace Ink_Canvas {
|
||||
// 检查是否可写
|
||||
try
|
||||
{
|
||||
string testFile = System.IO.Path.Combine(savePath, "test.tmp");
|
||||
System.IO.File.WriteAllText(testFile, "test");
|
||||
System.IO.File.Delete(testFile);
|
||||
string testFile = Path.Combine(savePath, "test.tmp");
|
||||
File.WriteAllText(testFile, "test");
|
||||
File.Delete(testFile);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -310,10 +321,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
if (needFix)
|
||||
{
|
||||
string newPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "saves");
|
||||
string newPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "saves");
|
||||
Settings.Automation.AutoSavedStrokesLocation = newPath;
|
||||
if (!System.IO.Directory.Exists(newPath))
|
||||
System.IO.Directory.CreateDirectory(newPath);
|
||||
if (!Directory.Exists(newPath))
|
||||
Directory.CreateDirectory(newPath);
|
||||
SaveSettingsToFile();
|
||||
LogHelper.WriteLogToFile($"自动修正保存路径为: {newPath}");
|
||||
}
|
||||
@@ -347,10 +358,10 @@ namespace Ink_Canvas {
|
||||
BlackBoardRightSidePageListView.ItemsSource = blackBoardSidePageListViewObservableCollection;
|
||||
|
||||
BtnLeftWhiteBoardSwitchPreviousGeometry.Brush =
|
||||
new SolidColorBrush(System.Windows.Media.Color.FromArgb(127, 24, 24, 27));
|
||||
new SolidColorBrush(Color.FromArgb(127, 24, 24, 27));
|
||||
BtnLeftWhiteBoardSwitchPreviousLabel.Opacity = 0.5;
|
||||
BtnRightWhiteBoardSwitchPreviousGeometry.Brush =
|
||||
new SolidColorBrush(System.Windows.Media.Color.FromArgb(127, 24, 24, 27));
|
||||
new SolidColorBrush(Color.FromArgb(127, 24, 24, 27));
|
||||
BtnRightWhiteBoardSwitchPreviousLabel.Opacity = 0.5;
|
||||
|
||||
// 应用颜色主题,这将考虑自定义背景色
|
||||
@@ -396,7 +407,7 @@ namespace Ink_Canvas {
|
||||
|
||||
// 确保背景颜色正确设置为黑板颜色
|
||||
CheckColorTheme(true);
|
||||
}), System.Windows.Threading.DispatcherPriority.Loaded);
|
||||
}), DispatcherPriority.Loaded);
|
||||
}
|
||||
|
||||
// 初始化插件系统
|
||||
@@ -411,7 +422,7 @@ namespace Ink_Canvas {
|
||||
|
||||
private void SystemEventsOnDisplaySettingsChanged(object sender, EventArgs e) {
|
||||
if (!Settings.Advanced.IsEnableResolutionChangeDetection) return;
|
||||
ShowNotification($"检测到显示器信息变化,变为{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height})");
|
||||
ShowNotification($"检测到显示器信息变化,变为{Screen.PrimaryScreen.Bounds.Width}x{Screen.PrimaryScreen.Bounds.Height})");
|
||||
new Thread(() => {
|
||||
var isFloatingBarOutsideScreen = false;
|
||||
var isInPPTPresentationMode = false;
|
||||
@@ -455,7 +466,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||
private void Window_Closing(object sender, CancelEventArgs e) {
|
||||
LogHelper.WriteLogToFile("Ink Canvas closing", LogHelper.LogType.Event);
|
||||
if (!CloseIsFromButton && Settings.Advanced.IsSecondConfirmWhenShutdownApp) {
|
||||
e.Cancel = true;
|
||||
@@ -477,11 +488,11 @@ namespace Ink_Canvas {
|
||||
private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e) {
|
||||
if (Settings.Advanced.IsEnableForceFullScreen) {
|
||||
if (isLoaded) ShowNotification(
|
||||
$"检测到窗口大小变化,已自动恢复到全屏:{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height}(缩放比例为{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / SystemParameters.PrimaryScreenHeight})");
|
||||
$"检测到窗口大小变化,已自动恢复到全屏:{Screen.PrimaryScreen.Bounds.Width}x{Screen.PrimaryScreen.Bounds.Height}(缩放比例为{Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth}x{Screen.PrimaryScreen.Bounds.Height / SystemParameters.PrimaryScreenHeight})");
|
||||
WindowState = WindowState.Maximized;
|
||||
MoveWindow(new WindowInteropHelper(this).Handle, 0, 0,
|
||||
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
|
||||
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, true);
|
||||
Screen.PrimaryScreen.Bounds.Width,
|
||||
Screen.PrimaryScreen.Bounds.Height, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1004,7 +1015,7 @@ namespace Ink_Canvas {
|
||||
BorderSettings.Visibility = Visibility.Visible;
|
||||
// 设置蒙版为可点击,并添加半透明背景
|
||||
BorderSettingsMask.IsHitTestVisible = true;
|
||||
BorderSettingsMask.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(1, 0, 0, 0));
|
||||
BorderSettingsMask.Background = new SolidColorBrush(Color.FromArgb(1, 0, 0, 0));
|
||||
|
||||
// 获取SettingsPanelScrollViewer中的所有GroupBox
|
||||
var stackPanel = SettingsPanelScrollViewer.Content as StackPanel;
|
||||
@@ -1020,7 +1031,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 确保UI完全更新
|
||||
await Dispatcher.InvokeAsync(() => {}, System.Windows.Threading.DispatcherPriority.Render);
|
||||
await Dispatcher.InvokeAsync(() => {}, DispatcherPriority.Render);
|
||||
|
||||
// 根据传入的sectionTag滚动到相应的设置部分
|
||||
GroupBox targetGroupBox = null;
|
||||
@@ -1153,7 +1164,7 @@ namespace Ink_Canvas {
|
||||
// 重新启用滚动事件处理
|
||||
SettingsPanelScrollViewer.ScrollChanged += SettingsPanelScrollViewer_ScrollChanged;
|
||||
}
|
||||
}, System.Windows.Threading.DispatcherPriority.Render);
|
||||
}, DispatcherPriority.Render);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -1163,7 +1174,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 滚动条变化事件处理
|
||||
private void SettingsPanelScrollViewer_ScrollChanged(object sender, System.Windows.Controls.ScrollChangedEventArgs e)
|
||||
private void SettingsPanelScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||
{
|
||||
// 可以在这里添加滚动事件的处理逻辑,如果需要的话
|
||||
}
|
||||
@@ -1308,8 +1319,8 @@ namespace Ink_Canvas {
|
||||
try
|
||||
{
|
||||
// 初始化插件管理器
|
||||
Helpers.Plugins.PluginManager.Instance.Initialize();
|
||||
LogHelper.WriteLogToFile("插件系统已初始化", LogHelper.LogType.Info);
|
||||
PluginManager.Instance.Initialize();
|
||||
LogHelper.WriteLogToFile("插件系统已初始化");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1333,7 +1344,7 @@ namespace Ink_Canvas {
|
||||
BorderSettingsMask.Visibility = Visibility.Hidden;
|
||||
|
||||
// 创建并显示插件设置窗口
|
||||
Windows.PluginSettingsWindow pluginSettingsWindow = new Windows.PluginSettingsWindow();
|
||||
PluginSettingsWindow pluginSettingsWindow = new PluginSettingsWindow();
|
||||
|
||||
// 设置窗口关闭事件,用于在插件管理窗口关闭后恢复设置面板
|
||||
pluginSettingsWindow.Closed += (s, args) =>
|
||||
@@ -1393,7 +1404,7 @@ namespace Ink_Canvas {
|
||||
// 只切换可见性
|
||||
for (int i = 0; i < whiteboardPages.Count; i++)
|
||||
{
|
||||
whiteboardPages[i].Visibility = (i == index) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
|
||||
whiteboardPages[i].Visibility = (i == index) ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
currentCanvas = whiteboardPages[index];
|
||||
currentPageIndex = index;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -8,11 +6,13 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
public bool isFloatingBarFolded = false;
|
||||
private bool isFloatingBarChangingHideMode = false;
|
||||
public bool isFloatingBarFolded;
|
||||
private bool isFloatingBarChangingHideMode;
|
||||
|
||||
private void CloseWhiteboardImmediately() {
|
||||
if (isDisplayingOrHidingBlackboard) return;
|
||||
@@ -28,10 +28,10 @@ namespace Ink_Canvas {
|
||||
BtnSwitch_Click(BtnSwitch, null);
|
||||
BtnExit.Foreground = Brushes.White;
|
||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(200);
|
||||
Application.Current.Dispatcher.Invoke(() => { isDisplayingOrHidingBlackboard = false; });
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
|
||||
public async void FoldFloatingBar_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
@@ -98,7 +98,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private async void LeftUnFoldButtonDisplayQuickPanel_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (Settings.Appearance.IsShowQuickPanel == true) {
|
||||
if (Settings.Appearance.IsShowQuickPanel) {
|
||||
HideRightQuickPanel();
|
||||
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Visible;
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
@@ -122,7 +122,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private async void RightUnFoldButtonDisplayQuickPanel_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (Settings.Appearance.IsShowQuickPanel == true) {
|
||||
if (Settings.Appearance.IsShowQuickPanel) {
|
||||
HideLeftQuickPanel();
|
||||
RightUnFoldButtonQuickPanel.Visibility = Visibility.Visible;
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
@@ -249,13 +249,13 @@ namespace Ink_Canvas {
|
||||
if (MarginFromEdge == -10) LeftSidePanel.Visibility = Visibility.Visible;
|
||||
|
||||
var LeftSidePanelmarginAnimation = new ThicknessAnimation {
|
||||
Duration = isNoAnimation == true ? TimeSpan.FromSeconds(0) : TimeSpan.FromSeconds(0.175),
|
||||
Duration = isNoAnimation ? TimeSpan.FromSeconds(0) : TimeSpan.FromSeconds(0.175),
|
||||
From = LeftSidePanel.Margin,
|
||||
To = new Thickness(MarginFromEdge, 0, 0, -150)
|
||||
};
|
||||
LeftSidePanelmarginAnimation.EasingFunction = new CubicEase();
|
||||
var RightSidePanelmarginAnimation = new ThicknessAnimation {
|
||||
Duration = isNoAnimation == true ? TimeSpan.FromSeconds(0) : TimeSpan.FromSeconds(0.175),
|
||||
Duration = isNoAnimation ? TimeSpan.FromSeconds(0) : TimeSpan.FromSeconds(0.175),
|
||||
From = RightSidePanel.Margin,
|
||||
To = new Thickness(0, 0, MarginFromEdge, -150)
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using IWshRuntimeLibrary;
|
||||
using Application = System.Windows.Forms.Application;
|
||||
using File = System.IO.File;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -10,7 +12,7 @@ namespace Ink_Canvas {
|
||||
var shortcut = (IWshShortcut)shell.CreateShortcut(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName + ".lnk");
|
||||
//设置快捷方式的目标所在的位置(源程序完整路径)
|
||||
shortcut.TargetPath = System.Windows.Forms.Application.ExecutablePath;
|
||||
shortcut.TargetPath = Application.ExecutablePath;
|
||||
//应用程序的工作目录
|
||||
//当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
|
||||
shortcut.WorkingDirectory = Environment.CurrentDirectory;
|
||||
@@ -30,8 +32,8 @@ namespace Ink_Canvas {
|
||||
|
||||
public static bool StartAutomaticallyDel(string exeName) {
|
||||
try {
|
||||
System.IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName +
|
||||
".lnk");
|
||||
File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName +
|
||||
".lnk");
|
||||
return true;
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Microsoft.Win32;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using System;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using Microsoft.Win32;
|
||||
using Application = System.Windows.Application;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
@@ -11,19 +11,19 @@ namespace Ink_Canvas {
|
||||
|
||||
private void SetTheme(string theme) {
|
||||
if (theme == "Light") {
|
||||
var rd1 = new ResourceDictionary()
|
||||
var rd1 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/Styles/Light.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
||||
|
||||
var rd2 = new ResourceDictionary()
|
||||
var rd2 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd2);
|
||||
|
||||
var rd3 = new ResourceDictionary()
|
||||
var rd3 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/SeewoImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd3);
|
||||
|
||||
var rd4 = new ResourceDictionary()
|
||||
var rd4 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/IconImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd4);
|
||||
|
||||
@@ -32,18 +32,18 @@ namespace Ink_Canvas {
|
||||
FloatBarForegroundColor = (Color)Application.Current.FindResource("FloatBarForegroundColor");
|
||||
}
|
||||
else if (theme == "Dark") {
|
||||
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);
|
||||
|
||||
var rd2 = new ResourceDictionary()
|
||||
var rd2 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd2);
|
||||
|
||||
var rd3 = new ResourceDictionary()
|
||||
var rd3 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/SeewoImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd3);
|
||||
|
||||
var rd4 = new ResourceDictionary()
|
||||
var rd4 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/IconImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd4);
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -138,7 +139,7 @@ namespace Ink_Canvas {
|
||||
};
|
||||
|
||||
// 确保面板显示在顶层
|
||||
System.Windows.Controls.Panel.SetZIndex(BackgroundPalette, 1000);
|
||||
Panel.SetZIndex(BackgroundPalette, 1000);
|
||||
|
||||
// 创建面板内容
|
||||
var stackPanel = new StackPanel();
|
||||
@@ -169,9 +170,9 @@ namespace Ink_Canvas {
|
||||
titleCanvas.Children.Add(titleText);
|
||||
|
||||
// 关闭按钮
|
||||
var closeImage = new System.Windows.Controls.Image
|
||||
var closeImage = new Image
|
||||
{
|
||||
Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Resources/new-icons/close-white.png", UriKind.Relative)),
|
||||
Source = new BitmapImage(new Uri("/Resources/new-icons/close-white.png", UriKind.Relative)),
|
||||
Height = 16,
|
||||
Width = 16
|
||||
};
|
||||
@@ -370,7 +371,7 @@ namespace Ink_Canvas {
|
||||
// R滑块和文本框
|
||||
var rPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(10, 0, 10, 5) };
|
||||
var rLabel = new TextBlock { Text = "R:", Width = 20, VerticalAlignment = VerticalAlignment.Center };
|
||||
var rSlider = new System.Windows.Controls.Slider
|
||||
var rSlider = new Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
@@ -390,7 +391,7 @@ namespace Ink_Canvas {
|
||||
// G滑块和文本框
|
||||
var gPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(10, 0, 10, 5) };
|
||||
var gLabel = new TextBlock { Text = "G:", Width = 20, VerticalAlignment = VerticalAlignment.Center };
|
||||
var gSlider = new System.Windows.Controls.Slider
|
||||
var gSlider = new Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
@@ -410,7 +411,7 @@ namespace Ink_Canvas {
|
||||
// B滑块和文本框
|
||||
var bPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(10, 0, 10, 5) };
|
||||
var bLabel = new TextBlock { Text = "B:", Width = 20, VerticalAlignment = VerticalAlignment.Center };
|
||||
var bSlider = new System.Windows.Controls.Slider
|
||||
var bSlider = new Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
@@ -575,7 +576,7 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 更新颜色预览框的颜色
|
||||
/// </summary>
|
||||
private void UpdateColorPreview(Border colorPreview, System.Windows.Controls.Slider rSlider, System.Windows.Controls.Slider gSlider, System.Windows.Controls.Slider bSlider)
|
||||
private void UpdateColorPreview(Border colorPreview, Slider rSlider, Slider gSlider, Slider bSlider)
|
||||
{
|
||||
Color previewColor = Color.FromRgb(
|
||||
(byte)rSlider.Value,
|
||||
@@ -720,17 +721,17 @@ namespace Ink_Canvas {
|
||||
// 根据设置决定是否清空图片
|
||||
if (Settings.Canvas.ClearCanvasAlsoClearImages) {
|
||||
// 如果设置为清空图片,则直接清空所有子元素
|
||||
System.Diagnostics.Debug.WriteLine("BoardSymbolIconDelete: Clearing all children including images");
|
||||
Debug.WriteLine("BoardSymbolIconDelete: Clearing all children including images");
|
||||
inkCanvas.Children.Clear();
|
||||
} else {
|
||||
// 保存非笔画元素(如图片)
|
||||
System.Diagnostics.Debug.WriteLine("BoardSymbolIconDelete: Preserving non-stroke elements (images)");
|
||||
Debug.WriteLine("BoardSymbolIconDelete: Preserving non-stroke elements (images)");
|
||||
var preservedElements = PreserveNonStrokeElements();
|
||||
System.Diagnostics.Debug.WriteLine($"BoardSymbolIconDelete: Preserved elements count: {preservedElements.Count}");
|
||||
Debug.WriteLine($"BoardSymbolIconDelete: Preserved elements count: {preservedElements.Count}");
|
||||
inkCanvas.Children.Clear();
|
||||
// 恢复非笔画元素
|
||||
RestoreNonStrokeElements(preservedElements);
|
||||
System.Diagnostics.Debug.WriteLine($"BoardSymbolIconDelete: inkCanvas.Children.Count after restore: {inkCanvas.Children.Count}");
|
||||
Debug.WriteLine($"BoardSymbolIconDelete: inkCanvas.Children.Count after restore: {inkCanvas.Children.Count}");
|
||||
}
|
||||
}
|
||||
private void BoardSymbolIconDeleteInkAndHistories_MouseUp(object sender, RoutedEventArgs e)
|
||||
@@ -742,17 +743,17 @@ namespace Ink_Canvas {
|
||||
// 根据设置决定是否清空图片
|
||||
if (Settings.Canvas.ClearCanvasAlsoClearImages) {
|
||||
// 如果设置为清空图片,则直接清空所有子元素
|
||||
System.Diagnostics.Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Clearing all children including images");
|
||||
Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Clearing all children including images");
|
||||
inkCanvas.Children.Clear();
|
||||
} else {
|
||||
// 保存非笔画元素(如图片)
|
||||
System.Diagnostics.Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Preserving non-stroke elements (images)");
|
||||
Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Preserving non-stroke elements (images)");
|
||||
var preservedElements = PreserveNonStrokeElements();
|
||||
System.Diagnostics.Debug.WriteLine($"BoardSymbolIconDeleteInkAndHistories: Preserved elements count: {preservedElements.Count}");
|
||||
Debug.WriteLine($"BoardSymbolIconDeleteInkAndHistories: Preserved elements count: {preservedElements.Count}");
|
||||
inkCanvas.Children.Clear();
|
||||
// 恢复非笔画元素
|
||||
RestoreNonStrokeElements(preservedElements);
|
||||
System.Diagnostics.Debug.WriteLine($"BoardSymbolIconDeleteInkAndHistories: inkCanvas.Children.Count after restore: {inkCanvas.Children.Count}");
|
||||
Debug.WriteLine($"BoardSymbolIconDeleteInkAndHistories: inkCanvas.Children.Count after restore: {inkCanvas.Children.Count}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -777,9 +778,9 @@ namespace Ink_Canvas {
|
||||
if (stackPanel.Children.Count > 1 && stackPanel.Children[1] is StackPanel contentPanel)
|
||||
{
|
||||
// 查找RGB滑块
|
||||
System.Windows.Controls.Slider rSlider = null;
|
||||
System.Windows.Controls.Slider gSlider = null;
|
||||
System.Windows.Controls.Slider bSlider = null;
|
||||
Slider rSlider = null;
|
||||
Slider gSlider = null;
|
||||
Slider bSlider = null;
|
||||
|
||||
// 遍历面板查找RGB滑块
|
||||
foreach (var child in contentPanel.Children)
|
||||
@@ -788,7 +789,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
foreach (var panelChild in panel.Children)
|
||||
{
|
||||
if (panelChild is System.Windows.Controls.Slider slider)
|
||||
if (panelChild is Slider slider)
|
||||
{
|
||||
if (panel.Children.Count > 0 && panel.Children[0] is TextBlock label)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Media;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -59,8 +58,8 @@ namespace Ink_Canvas {
|
||||
isLongPressSelected = false;
|
||||
}
|
||||
|
||||
private bool isUselightThemeColor = false, isDesktopUselightThemeColor = false;
|
||||
private int penType = 0; // 0是签字笔,1是荧光笔
|
||||
private bool isUselightThemeColor, isDesktopUselightThemeColor;
|
||||
private int penType; // 0是签字笔,1是荧光笔
|
||||
private int lastDesktopInkColor = 1, lastBoardInkColor = 5;
|
||||
private int highlighterColor = 102;
|
||||
|
||||
@@ -388,7 +387,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void CheckLastColor(int inkColor, bool isHighlighter = false) {
|
||||
if (isHighlighter == true) {
|
||||
if (isHighlighter) {
|
||||
highlighterColor = inkColor;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Ink_Canvas
|
||||
|
||||
@@ -12,18 +12,18 @@ namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
|
||||
// 新橡皮擦系统的核心变量
|
||||
public bool isUsingAdvancedEraser = false;
|
||||
private IncrementalStrokeHitTester advancedHitTester = null;
|
||||
public bool isUsingAdvancedEraser;
|
||||
private IncrementalStrokeHitTester advancedHitTester;
|
||||
|
||||
// 橡皮擦配置
|
||||
public double currentEraserSize = 64;
|
||||
public bool isCurrentEraserCircle = false;
|
||||
public bool isUsingStrokeEraser = false;
|
||||
public bool isCurrentEraserCircle;
|
||||
public bool isUsingStrokeEraser;
|
||||
|
||||
// 视觉反馈相关
|
||||
private Matrix eraserTransformMatrix = new Matrix();
|
||||
private Point lastEraserPosition = new Point();
|
||||
private bool isEraserVisible = false;
|
||||
private Matrix eraserTransformMatrix;
|
||||
private Point lastEraserPosition;
|
||||
private bool isEraserVisible;
|
||||
|
||||
// 性能优化相关
|
||||
private DateTime lastEraserUpdate = DateTime.Now;
|
||||
@@ -35,7 +35,7 @@ namespace Ink_Canvas {
|
||||
// 橡皮擦视觉反馈控件
|
||||
private DrawingVisual eraserVisual = new DrawingVisual();
|
||||
private VisualCanvas eraserOverlayCanvas = null;
|
||||
private Border eraserVisualBorder = null; // 用于显示橡皮擦视觉反馈的Border
|
||||
private Border eraserVisualBorder; // 用于显示橡皮擦视觉反馈的Border
|
||||
|
||||
// 兼容性属性:模拟原有的EraserOverlay_DrawingVisual
|
||||
private VisualCanvas EraserOverlay_DrawingVisual => eraserOverlayCanvas;
|
||||
@@ -102,7 +102,7 @@ namespace Ink_Canvas {
|
||||
UpdateEraserSize();
|
||||
|
||||
// 获取inkCanvas引用
|
||||
var inkCanvas = this.FindName("inkCanvas") as InkCanvas;
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
// 根据橡皮擦形状创建碰撞检测器
|
||||
@@ -117,13 +117,14 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 创建橡皮擦形状
|
||||
/// </summary>
|
||||
private StylusShape CreateEraserShape() {
|
||||
private StylusShape CreateEraserShape()
|
||||
{
|
||||
if (isCurrentEraserCircle) {
|
||||
return new EllipseStylusShape(currentEraserSize, currentEraserSize);
|
||||
} else {
|
||||
// 矩形橡皮擦,使用与原来相同的逻辑
|
||||
return new RectangleStylusShape(currentEraserSize, currentEraserSize / 0.6);
|
||||
}
|
||||
|
||||
// 矩形橡皮擦,使用与原来相同的逻辑
|
||||
return new RectangleStylusShape(currentEraserSize, currentEraserSize / 0.6);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -231,7 +232,7 @@ namespace Ink_Canvas {
|
||||
/// </summary>
|
||||
private void OnAdvancedEraserStrokeHit(object sender, StrokeHitEventArgs args) {
|
||||
try {
|
||||
var inkCanvas = this.FindName("inkCanvas") as InkCanvas;
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
var eraseResult = args.GetPointEraseResults();
|
||||
@@ -296,7 +297,7 @@ namespace Ink_Canvas {
|
||||
/// </summary>
|
||||
private void ProcessStrokeEraserAtPosition(Point position) {
|
||||
try {
|
||||
var inkCanvas = this.FindName("inkCanvas") as InkCanvas;
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
var hitStrokes = inkCanvas.Strokes.HitTest(position)
|
||||
@@ -343,7 +344,7 @@ namespace Ink_Canvas {
|
||||
Panel.SetZIndex(eraserVisualBorder, 1001);
|
||||
|
||||
// 将Border添加到InkCanvasGridForInkReplay中
|
||||
var inkCanvasGrid = this.FindName("InkCanvasGridForInkReplay") as Grid;
|
||||
var inkCanvasGrid = FindName("InkCanvasGridForInkReplay") as Grid;
|
||||
if (inkCanvasGrid != null) {
|
||||
inkCanvasGrid.Children.Add(eraserVisualBorder);
|
||||
Trace.WriteLine("Advanced Eraser: Visual feedback border added to grid");
|
||||
@@ -401,7 +402,7 @@ namespace Ink_Canvas {
|
||||
string resourceKey = isCurrentEraserCircle ? "EraserCircleDrawingGroup" : "EraserDrawingGroup";
|
||||
|
||||
// 尝试从资源字典中获取DrawingGroup
|
||||
var drawingGroup = this.TryFindResource(resourceKey) as DrawingGroup;
|
||||
var drawingGroup = TryFindResource(resourceKey) as DrawingGroup;
|
||||
if (drawingGroup == null) {
|
||||
// 如果找不到资源,创建默认的橡皮擦图像
|
||||
return CreateDefaultEraserImage();
|
||||
@@ -525,7 +526,7 @@ namespace Ink_Canvas {
|
||||
/// 获取当前橡皮擦状态信息(用于调试)
|
||||
/// </summary>
|
||||
public string GetEraserStatusInfo() {
|
||||
return $"Advanced Eraser Status:\n" +
|
||||
return "Advanced Eraser Status:\n" +
|
||||
$"- Active: {isUsingAdvancedEraser}\n" +
|
||||
$"- Size: {currentEraserSize:F1}\n" +
|
||||
$"- Shape: {(isCurrentEraserCircle ? "Circle" : "Rectangle")}\n" +
|
||||
@@ -551,7 +552,7 @@ namespace Ink_Canvas {
|
||||
|
||||
// 清理视觉反馈Border
|
||||
if (eraserVisualBorder != null) {
|
||||
var inkCanvasGrid = this.FindName("InkCanvasGridForInkReplay") as Grid;
|
||||
var inkCanvasGrid = FindName("InkCanvasGridForInkReplay") as Grid;
|
||||
if (inkCanvasGrid != null) {
|
||||
inkCanvasGrid.Children.Remove(eraserVisualBorder);
|
||||
}
|
||||
@@ -564,7 +565,7 @@ namespace Ink_Canvas {
|
||||
/// </summary>
|
||||
public void ApplyAdvancedEraserShape() {
|
||||
try {
|
||||
var inkCanvas = this.FindName("inkCanvas") as InkCanvas;
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
// 更新橡皮擦尺寸和形状
|
||||
@@ -595,7 +596,7 @@ namespace Ink_Canvas {
|
||||
public void EnableAdvancedEraserSystem() {
|
||||
try {
|
||||
// 获取橡皮擦覆盖层
|
||||
var eraserOverlay = this.FindName("AdvancedEraserOverlay") as Border;
|
||||
var eraserOverlay = FindName("AdvancedEraserOverlay") as Border;
|
||||
if (eraserOverlay != null) {
|
||||
// 启用覆盖层的交互
|
||||
eraserOverlay.IsHitTestVisible = true;
|
||||
@@ -607,7 +608,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 设置覆盖层的大小以覆盖整个InkCanvas
|
||||
var inkCanvasControl = this.FindName("inkCanvas") as InkCanvas;
|
||||
var inkCanvasControl = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvasControl != null) {
|
||||
eraserOverlay.Width = inkCanvasControl.ActualWidth;
|
||||
eraserOverlay.Height = inkCanvasControl.ActualHeight;
|
||||
@@ -649,7 +650,7 @@ namespace Ink_Canvas {
|
||||
|
||||
overlay.MouseMove += (sender, e) => {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
var position = e.GetPosition((UIElement)this.FindName("inkCanvas"));
|
||||
var position = e.GetPosition((UIElement)FindName("inkCanvas"));
|
||||
Trace.WriteLine($"Advanced Eraser: Mouse move event triggered at ({position.X:F1}, {position.Y:F1})");
|
||||
UpdateAdvancedEraserPosition(sender, position);
|
||||
} else {
|
||||
@@ -681,7 +682,7 @@ namespace Ink_Canvas {
|
||||
overlay.StylusMove += (sender, e) => {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
e.Handled = true;
|
||||
var position = e.GetPosition((UIElement)this.FindName("inkCanvas"));
|
||||
var position = e.GetPosition((UIElement)FindName("inkCanvas"));
|
||||
UpdateAdvancedEraserPosition(sender, position);
|
||||
Trace.WriteLine($"Advanced Eraser: Stylus move at ({position.X:F1}, {position.Y:F1})");
|
||||
}
|
||||
@@ -702,7 +703,7 @@ namespace Ink_Canvas {
|
||||
ResetEraserState();
|
||||
|
||||
// 获取橡皮擦覆盖层并禁用
|
||||
var eraserOverlay = this.FindName("AdvancedEraserOverlay") as Border;
|
||||
var eraserOverlay = FindName("AdvancedEraserOverlay") as Border;
|
||||
if (eraserOverlay != null) {
|
||||
eraserOverlay.IsHitTestVisible = false;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using System.Threading;
|
||||
using Application = System.Windows.Application;
|
||||
using Button = System.Windows.Controls.Button;
|
||||
using HorizontalAlignment = System.Windows.HorizontalAlignment;
|
||||
using Point = System.Windows.Point;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Linq;
|
||||
using Image = System.Windows.Controls.Image;
|
||||
using MessageBox = iNKORE.UI.WPF.Modern.Controls.MessageBox;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||
using Panel = System.Windows.Controls.Panel;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -113,7 +117,7 @@ namespace Ink_Canvas {
|
||||
|| BorderFloatingBarMainControls.Visibility != Visibility.Visible) {
|
||||
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (isVisible == true) {
|
||||
else if (isVisible) {
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
|
||||
else EnableTwoFingerGestureBorder.Visibility = Visibility.Visible;
|
||||
@@ -127,9 +131,9 @@ namespace Ink_Canvas {
|
||||
|
||||
#region 浮動工具欄的拖動實現
|
||||
|
||||
private bool isDragDropInEffect = false;
|
||||
private Point pos = new Point();
|
||||
private Point downPos = new Point();
|
||||
private bool isDragDropInEffect;
|
||||
private Point pos;
|
||||
private Point downPos;
|
||||
private Point pointDesktop = new Point(-1, -1); //用于记录上次在桌面时的坐标
|
||||
private Point pointPPT = new Point(-1, -1); //用于记录上次在PPT中的坐标
|
||||
|
||||
@@ -295,7 +299,7 @@ namespace Ink_Canvas {
|
||||
To = BorderSettings.RenderTransform.Value.OffsetX - 440,
|
||||
Duration = TimeSpan.FromSeconds(0.6)
|
||||
};
|
||||
slideAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
|
||||
slideAnimation.EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut };
|
||||
Storyboard.SetTargetProperty(slideAnimation,
|
||||
new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
|
||||
|
||||
@@ -310,7 +314,7 @@ namespace Ink_Canvas {
|
||||
BorderSettings.RenderTransform = new TranslateTransform();
|
||||
|
||||
isOpeningOrHidingSettingsPane = true;
|
||||
sb.Begin((FrameworkElement)BorderSettings);
|
||||
sb.Begin(BorderSettings);
|
||||
}
|
||||
|
||||
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
|
||||
@@ -420,7 +424,7 @@ namespace Ink_Canvas {
|
||||
await Task.Delay(50);
|
||||
ViewboxFloatingBarMarginAnimation(60);
|
||||
}
|
||||
else if (Topmost == true) //非黑板
|
||||
else if (Topmost) //非黑板
|
||||
{
|
||||
await Task.Delay(50);
|
||||
ViewboxFloatingBarMarginAnimation(100, true);
|
||||
@@ -469,7 +473,7 @@ namespace Ink_Canvas {
|
||||
#region 白板按鈕和退出白板模式按鈕
|
||||
|
||||
//private bool Not_Enter_Blackboard_fir_Mouse_Click = true;
|
||||
private bool isDisplayingOrHidingBlackboard = false;
|
||||
private bool isDisplayingOrHidingBlackboard;
|
||||
|
||||
private void ImageBlackboard_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
@@ -504,10 +508,10 @@ namespace Ink_Canvas {
|
||||
Not_Enter_Blackboard_fir_Mouse_Click = false;
|
||||
}
|
||||
*/
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(100);
|
||||
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(60); });
|
||||
})).Start();
|
||||
}).Start();
|
||||
|
||||
HideSubPanels();
|
||||
|
||||
@@ -531,7 +535,7 @@ namespace Ink_Canvas {
|
||||
if (isInMultiTouchMode) ToggleSwitchEnableMultiTouchMode.IsOn = false;
|
||||
}
|
||||
|
||||
if (Settings.Appearance.EnableTimeDisplayInWhiteboardMode == true)
|
||||
if (Settings.Appearance.EnableTimeDisplayInWhiteboardMode)
|
||||
{
|
||||
WaterMarkTime.Visibility = Visibility.Visible;
|
||||
WaterMarkDate.Visibility = Visibility.Visible;
|
||||
@@ -540,7 +544,7 @@ namespace Ink_Canvas {
|
||||
WaterMarkDate.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
if (Settings.Appearance.EnableChickenSoupInWhiteboardMode == true)
|
||||
if (Settings.Appearance.EnableChickenSoupInWhiteboardMode)
|
||||
{
|
||||
BlackBoardWaterMark.Visibility = Visibility.Visible;
|
||||
} else {
|
||||
@@ -597,15 +601,15 @@ namespace Ink_Canvas {
|
||||
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenShot(true);
|
||||
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Collapsed)
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(300);
|
||||
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(100, true); });
|
||||
})).Start();
|
||||
}).Start();
|
||||
else
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(300);
|
||||
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(60); });
|
||||
})).Start();
|
||||
}).Start();
|
||||
|
||||
if (System.Windows.Controls.Canvas.GetLeft(FloatingbarSelectionBG)!=28) PenIcon_Click(null, null);
|
||||
|
||||
@@ -628,10 +632,10 @@ namespace Ink_Canvas {
|
||||
BtnExit.Foreground = Brushes.White;
|
||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
|
||||
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(200);
|
||||
Application.Current.Dispatcher.Invoke(() => { isDisplayingOrHidingBlackboard = false; });
|
||||
})).Start();
|
||||
}).Start();
|
||||
|
||||
SwitchToDefaultPen(null, null);
|
||||
CheckColorTheme(true);
|
||||
@@ -715,7 +719,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void SymbolIconSettings_Click(object sender, RoutedEventArgs e) {
|
||||
if (isOpeningOrHidingSettingsPane != false) return;
|
||||
if (isOpeningOrHidingSettingsPane) return;
|
||||
HideSubPanels();
|
||||
BtnSettings_Click(null, null);
|
||||
}
|
||||
@@ -827,7 +831,7 @@ namespace Ink_Canvas {
|
||||
// 检查是否启用了直接调用ClassIsland点名功能
|
||||
if (Settings.RandSettings.DirectCallCiRand) {
|
||||
try {
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo {
|
||||
Process.Start(new ProcessStartInfo {
|
||||
FileName = "classisland://plugins/IslandCaller/Run",
|
||||
UseShellExecute = true
|
||||
});
|
||||
@@ -961,9 +965,9 @@ namespace Ink_Canvas {
|
||||
}).Start();
|
||||
}
|
||||
|
||||
private bool isStopInkReplay = false;
|
||||
private bool isPauseInkReplay = false;
|
||||
private bool isRestartInkReplay = false;
|
||||
private bool isStopInkReplay;
|
||||
private bool isPauseInkReplay;
|
||||
private bool isRestartInkReplay;
|
||||
private double inkReplaySpeed = 1;
|
||||
|
||||
private void InkCanvasForInkReplay_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
@@ -1078,7 +1082,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private bool isViewboxFloatingBarMarginAnimationRunning = false;
|
||||
private bool isViewboxFloatingBarMarginAnimationRunning;
|
||||
|
||||
public async void ViewboxFloatingBarMarginAnimation(int MarginFromEdge,
|
||||
bool PosXCaculatedWithTaskbarHeight = false) {
|
||||
@@ -1098,7 +1102,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
var windowHandle = new WindowInteropHelper(this).Handle;
|
||||
var screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
var screen = Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
|
||||
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
|
||||
@@ -1110,21 +1114,21 @@ namespace Ink_Canvas {
|
||||
if (toolbarHeight == 0)
|
||||
{
|
||||
pos.Y = screenHeight - MarginFromEdge * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定边距: {MarginFromEdge}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定边距: {MarginFromEdge}");
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.Y = screenHeight - MarginFromEdge * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
}
|
||||
}
|
||||
else if (PosXCaculatedWithTaskbarHeight == true)
|
||||
else if (PosXCaculatedWithTaskbarHeight)
|
||||
{
|
||||
// 如果任务栏高度为0(隐藏状态),则使用固定高度
|
||||
if (toolbarHeight == 0)
|
||||
{
|
||||
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
|
||||
3 * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1184,7 +1188,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
var windowHandle = new WindowInteropHelper(this).Handle;
|
||||
var screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
var screen = Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
|
||||
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
|
||||
@@ -1195,7 +1199,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
|
||||
3 * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1237,7 +1241,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
var windowHandle = new WindowInteropHelper(this).Handle;
|
||||
var screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
var screen = Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
|
||||
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
|
||||
@@ -1565,7 +1569,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void DrawShapePromptToPen() {
|
||||
if (isLongPressSelected == true) {
|
||||
if (isLongPressSelected) {
|
||||
// 如果是长按选中的状态,只隐藏面板,不切换到笔模式
|
||||
HideSubPanels("shape");
|
||||
}
|
||||
@@ -1629,7 +1633,7 @@ namespace Ink_Canvas {
|
||||
|
||||
#region Right Side Panel
|
||||
|
||||
public static bool CloseIsFromButton = false;
|
||||
public static bool CloseIsFromButton;
|
||||
|
||||
public void BtnExit_Click(object sender, RoutedEventArgs e) {
|
||||
App.IsAppExitByUser = true;
|
||||
@@ -1646,7 +1650,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void SettingsOverlayClick(object sender, MouseButtonEventArgs e) {
|
||||
if (isOpeningOrHidingSettingsPane == true) return;
|
||||
if (isOpeningOrHidingSettingsPane) return;
|
||||
|
||||
// 获取点击的位置
|
||||
Point clickPoint = e.GetPosition(BorderSettingsMask);
|
||||
@@ -1666,7 +1670,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private bool isOpeningOrHidingSettingsPane = false;
|
||||
private bool isOpeningOrHidingSettingsPane;
|
||||
|
||||
private void BtnSettings_Click(object sender, RoutedEventArgs e) {
|
||||
if (BorderSettings.Visibility == Visibility.Visible) {
|
||||
@@ -1685,7 +1689,7 @@ namespace Ink_Canvas {
|
||||
To = 0,
|
||||
Duration = TimeSpan.FromSeconds(0.6)
|
||||
};
|
||||
slideAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
|
||||
slideAnimation.EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut };
|
||||
Storyboard.SetTargetProperty(slideAnimation,
|
||||
new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
|
||||
|
||||
@@ -1697,13 +1701,13 @@ namespace Ink_Canvas {
|
||||
BorderSettings.RenderTransform = new TranslateTransform();
|
||||
|
||||
isOpeningOrHidingSettingsPane = true;
|
||||
sb.Begin((FrameworkElement)BorderSettings);
|
||||
sb.Begin(BorderSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnThickness_Click(object sender, RoutedEventArgs e) { }
|
||||
|
||||
private bool forceEraser = false;
|
||||
private bool forceEraser;
|
||||
|
||||
|
||||
private void BtnClear_Click(object sender, RoutedEventArgs e) {
|
||||
@@ -1737,7 +1741,7 @@ namespace Ink_Canvas {
|
||||
if (Settings.Canvas.ClearCanvasAndClearTimeMachine) timeMachine.ClearStrokeHistory();
|
||||
}
|
||||
|
||||
private bool lastIsInMultiTouchMode = false;
|
||||
private bool lastIsInMultiTouchMode;
|
||||
|
||||
private void CancelSingleFingerDragMode() {
|
||||
if (ToggleSwitchDrawShapeBorderAutoHide.IsOn) CollapseBorderDrawShape();
|
||||
@@ -1755,7 +1759,7 @@ namespace Ink_Canvas {
|
||||
StackPanelControl.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private int currentMode = 0;
|
||||
private int currentMode;
|
||||
|
||||
private void BtnSwitch_Click(object sender, RoutedEventArgs e) {
|
||||
if (GridTransparencyFakeBackground.Background == Brushes.Transparent) {
|
||||
@@ -1995,7 +1999,7 @@ namespace Ink_Canvas {
|
||||
|
||||
private async void InsertImage_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var dialog = new Microsoft.Win32.OpenFileDialog
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp;*.gif"
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
private int lastNotificationShowTime = 0;
|
||||
private int lastNotificationShowTime;
|
||||
private int notificationShowTime = 2500;
|
||||
|
||||
public static void ShowNewMessage(string notice, bool isShowImmediately = true) {
|
||||
@@ -21,13 +21,13 @@ namespace Ink_Canvas {
|
||||
TextBlockNotice.Text = notice;
|
||||
AnimationsHelper.ShowWithSlideFromBottomAndFade(GridNotifications);
|
||||
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(notificationShowTime + 300);
|
||||
if (Environment.TickCount - lastNotificationShowTime >= notificationShowTime)
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
AnimationsHelper.HideWithSlideAndFade(GridNotifications);
|
||||
});
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
+107
-103
@@ -1,25 +1,31 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Microsoft.Office.Interop.PowerPoint;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using Microsoft.Office.Core;
|
||||
using Microsoft.Office.Interop.PowerPoint;
|
||||
using Application = System.Windows.Application;
|
||||
using File = System.IO.File;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using Microsoft.Office.Core;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using Point = System.Drawing.Point;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -30,7 +36,7 @@ namespace Ink_Canvas {
|
||||
private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder lpString, int nMaxCount);
|
||||
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId, out uint lpdwThreadId);
|
||||
@@ -60,7 +66,7 @@ namespace Ink_Canvas {
|
||||
private static extern bool GetWindowRect(IntPtr hWnd, out ForegroundWindowInfo.RECT lpRect);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern int GetClassName(IntPtr hWnd, System.Text.StringBuilder lpClassName, int nMaxCount);
|
||||
private static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||
|
||||
private const int GWL_STYLE = -16;
|
||||
private const int WS_VISIBLE = 0x10000000;
|
||||
@@ -72,14 +78,14 @@ namespace Ink_Canvas {
|
||||
|
||||
private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||
|
||||
public static Microsoft.Office.Interop.PowerPoint.Application pptApplication = null;
|
||||
public static Presentation presentation = null;
|
||||
public static Slides slides = null;
|
||||
public static Slide slide = null;
|
||||
public static int slidescount = 0;
|
||||
public static Microsoft.Office.Interop.PowerPoint.Application pptApplication;
|
||||
public static Presentation presentation;
|
||||
public static Slides slides;
|
||||
public static Slide slide;
|
||||
public static int slidescount;
|
||||
|
||||
// 在类中添加字段
|
||||
private bool wasFloatingBarFoldedWhenEnterSlideShow = false;
|
||||
private bool wasFloatingBarFoldedWhenEnterSlideShow;
|
||||
|
||||
// 新增:用于控制WPS强制关闭提示只弹一次
|
||||
private static bool hasShownWpsForceCloseWarning = false;
|
||||
@@ -115,7 +121,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"获取当前幻灯片失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取当前幻灯片失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +131,7 @@ namespace Ink_Canvas {
|
||||
StackPanelPPTControls.Visibility = Visibility.Visible;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"检查PPT应用程序失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查PPT应用程序失败: {ex}", LogHelper.LogType.Error);
|
||||
//BtnCheckPPT.Visibility = Visibility.Visible;
|
||||
StackPanelPPTControls.Visibility = Visibility.Collapsed;
|
||||
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
@@ -145,16 +151,16 @@ namespace Ink_Canvas {
|
||||
|
||||
private static bool isWPSSupportOn => Settings.PowerPointSettings.IsSupportWPS;
|
||||
|
||||
public static bool IsShowingRestoreHiddenSlidesWindow = false;
|
||||
private static bool IsShowingAutoplaySlidesWindow = false;
|
||||
public static bool IsShowingRestoreHiddenSlidesWindow;
|
||||
private static bool IsShowingAutoplaySlidesWindow;
|
||||
|
||||
// WPP 相关变量
|
||||
private static Process wppProcess = null;
|
||||
private static bool hasWppProcessID = false;
|
||||
private static System.Timers.Timer wppProcessCheckTimer = null;
|
||||
private static Process wppProcess;
|
||||
private static bool hasWppProcessID;
|
||||
private static Timer wppProcessCheckTimer;
|
||||
private static DateTime wppProcessRecordTime = DateTime.MinValue; // 记录进程时间
|
||||
private static int wppProcessCheckCount = 0; // 检查次数计数器
|
||||
private static WpsWindowInfo lastForegroundWpsWindow = null; // 记录上次检测到的前台WPS窗口
|
||||
private static int wppProcessCheckCount; // 检查次数计数器
|
||||
private static WpsWindowInfo lastForegroundWpsWindow; // 记录上次检测到的前台WPS窗口
|
||||
private static DateTime lastWindowCheckTime = DateTime.MinValue; // 记录上次窗口检查时间
|
||||
|
||||
|
||||
@@ -191,7 +197,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"获取当前幻灯片失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取当前幻灯片失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,14 +221,14 @@ namespace Ink_Canvas {
|
||||
PptApplication_SlideShowBegin(pptApplication.SlideShowWindows[1]);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"启动幻灯片放映失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"启动幻灯片放映失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 忽略常见的COM对象失效错误
|
||||
if (ex is System.Runtime.InteropServices.COMException comEx)
|
||||
if (ex is COMException comEx)
|
||||
{
|
||||
uint hr = (uint)comEx.HResult;
|
||||
// 0x800401E3: 操作无法使用
|
||||
@@ -237,7 +243,7 @@ namespace Ink_Canvas {
|
||||
return;
|
||||
}
|
||||
}
|
||||
LogHelper.WriteLogToFile($"检查PPT状态失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查PPT状态失败: {ex}", LogHelper.LogType.Error);
|
||||
Application.Current.Dispatcher.Invoke(() => { BtnPPTSlideShow.Visibility = Visibility.Collapsed; });
|
||||
timerCheckPPT.Start();
|
||||
}
|
||||
@@ -262,7 +268,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"跳转到首页失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"跳转到首页失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}), DispatcherPriority.Normal);
|
||||
}
|
||||
@@ -295,16 +301,16 @@ namespace Ink_Canvas {
|
||||
presentation.Windows[1].View.GotoSlide(page);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"跳转到指定页面失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"跳转到指定页面失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}).ShowDialog();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"读取上次播放位置失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"读取上次播放位置失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"处理上次播放页跳转失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"处理上次播放页跳转失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}), DispatcherPriority.Normal);
|
||||
|
||||
@@ -316,7 +322,7 @@ namespace Ink_Canvas {
|
||||
if (slides != null)
|
||||
{
|
||||
foreach (Slide slide in slides)
|
||||
if (slide.SlideShowTransition.Hidden == Microsoft.Office.Core.MsoTriState.msoTrue) {
|
||||
if (slide.SlideShowTransition.Hidden == MsoTriState.msoTrue) {
|
||||
isHaveHiddenSlide = true;
|
||||
break;
|
||||
}
|
||||
@@ -332,13 +338,13 @@ namespace Ink_Canvas {
|
||||
{
|
||||
foreach (Slide slide in slides)
|
||||
if (slide.SlideShowTransition.Hidden ==
|
||||
Microsoft.Office.Core.MsoTriState.msoTrue)
|
||||
MsoTriState.msoTrue)
|
||||
slide.SlideShowTransition.Hidden =
|
||||
Microsoft.Office.Core.MsoTriState.msoFalse;
|
||||
MsoTriState.msoFalse;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"取消隐藏幻灯片失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"取消隐藏幻灯片失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
finally {
|
||||
IsShowingRestoreHiddenSlidesWindow = false;
|
||||
@@ -351,7 +357,7 @@ namespace Ink_Canvas {
|
||||
}), DispatcherPriority.Normal);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"检查隐藏幻灯片失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查隐藏幻灯片失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +392,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"设置手动播放模式失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"设置手动播放模式失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
finally {
|
||||
IsShowingAutoplaySlidesWindow = false;
|
||||
@@ -402,12 +408,12 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"设置演示文稿播放模式失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"设置演示文稿播放模式失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"检查自动播放设置失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查自动播放设置失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -433,8 +439,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private bool isPresentationHaveBlackSpace = false;
|
||||
private string pptName = null;
|
||||
private bool isPresentationHaveBlackSpace;
|
||||
private string pptName;
|
||||
|
||||
private void UpdatePPTBtnStyleSettingsStatus() {
|
||||
try {
|
||||
@@ -600,7 +606,7 @@ namespace Ink_Canvas {
|
||||
else RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"更新PPT按钮显示状态失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"更新PPT按钮显示状态失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,7 +636,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"放映开始时跳转首页失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"放映开始时跳转首页失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,9 +650,8 @@ namespace Ink_Canvas {
|
||||
//Light
|
||||
BtnExit.Foreground = Brushes.White;
|
||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
|
||||
} else {
|
||||
//Dark
|
||||
}
|
||||
//Dark
|
||||
}
|
||||
} else if (screenRatio == -256 / 135) { }
|
||||
|
||||
@@ -658,7 +663,7 @@ namespace Ink_Canvas {
|
||||
|
||||
pptName = Wn.Presentation.Name;
|
||||
LogHelper.NewLog("Name: " + Wn.Presentation.Name);
|
||||
LogHelper.NewLog("Slides Count: " + slidescount.ToString());
|
||||
LogHelper.NewLog("Slides Count: " + slidescount);
|
||||
|
||||
//检查是否有已有墨迹,并加载
|
||||
if (Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint)
|
||||
@@ -685,7 +690,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile(
|
||||
$"Failed to load strokes on Slide {i}\n{ex.ToString()}",
|
||||
$"Failed to load strokes on Slide {i}\n{ex}",
|
||||
LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
@@ -743,16 +748,16 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"加载当前页墨迹失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"加载当前页墨迹失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
if (!isFloatingBarFolded) {
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(100);
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
ViewboxFloatingBarMarginAnimation(60);
|
||||
});
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
});
|
||||
await Application.Current.Dispatcher.InvokeAsync(() => {
|
||||
@@ -763,12 +768,12 @@ namespace Ink_Canvas {
|
||||
});
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile("PowerPoint Application Slide Show Begin Error: " + ex.ToString(), LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile("PowerPoint Application Slide Show Begin Error: " + ex, LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private bool isEnteredSlideShowEndEvent = false; //防止重复调用本函数导致墨迹保存失效
|
||||
private bool isEnteredSlideShowEndEvent; //防止重复调用本函数导致墨迹保存失效
|
||||
|
||||
private async void PptApplication_SlideShowEnd(Presentation Pres) {
|
||||
try {
|
||||
@@ -834,11 +839,11 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"记录WPS进程失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"记录WPS进程失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile(string.Format("PowerPoint Slide Show End"), LogHelper.LogType.Event);
|
||||
LogHelper.WriteLogToFile("PowerPoint Slide Show End", LogHelper.LogType.Event);
|
||||
if (isEnteredSlideShowEndEvent) {
|
||||
LogHelper.WriteLogToFile("Detected previous entrance, returning");
|
||||
return;
|
||||
@@ -878,7 +883,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile(
|
||||
$"Failed to save strokes for Slide {i}\n{ex.ToString()}",
|
||||
$"Failed to save strokes for Slide {i}\n{ex}",
|
||||
LogHelper.LogType.Error);
|
||||
if (File.Exists(folderPath + @"\" + i.ToString("0000") + ".icstk"))
|
||||
File.Delete(folderPath + @"\" + i.ToString("0000") + ".icstk");
|
||||
@@ -893,10 +898,9 @@ namespace Ink_Canvas {
|
||||
//Light
|
||||
BtnExit.Foreground = Brushes.Black;
|
||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
|
||||
} else {
|
||||
//Dark
|
||||
}
|
||||
|
||||
//Dark
|
||||
BtnPPTSlideShow.Visibility = Visibility.Visible;
|
||||
BtnPPTSlideShowEnd.Visibility = Visibility.Collapsed;
|
||||
StackPanelPPTControls.Visibility = Visibility.Collapsed;
|
||||
@@ -941,11 +945,11 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private int previousSlideID = 0;
|
||||
private int previousSlideID;
|
||||
private MemoryStream[] memoryStreams = new MemoryStream[50];
|
||||
|
||||
private DateTime inkLockUntil = DateTime.MinValue;
|
||||
private int lockedSlideIndex = 0;
|
||||
private int lockedSlideIndex;
|
||||
private const int InkLockMilliseconds = 500;
|
||||
|
||||
private void PptApplication_SlideShowNextSlide(SlideShowWindow Wn) {
|
||||
@@ -980,11 +984,11 @@ namespace Ink_Canvas {
|
||||
});
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"幻灯片切换事件处理失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"幻灯片切换事件处理失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isPptClickingBtnTurned = false;
|
||||
private bool _isPptClickingBtnTurned;
|
||||
|
||||
private void BtnPPTSlidesUp_Click(object sender, RoutedEventArgs e) {
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
@@ -1023,7 +1027,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"PPT上一页操作异常: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"PPT上一页操作异常: {ex}", LogHelper.LogType.Error);
|
||||
StackPanelPPTControls.Visibility = Visibility.Collapsed;
|
||||
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
@@ -1070,7 +1074,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"PPT下一页操作异常: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"PPT下一页操作异常: {ex}", LogHelper.LogType.Error);
|
||||
StackPanelPPTControls.Visibility = Visibility.Collapsed;
|
||||
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
@@ -1177,7 +1181,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"设置PPT导航可见性失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"设置PPT导航可见性失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
// 控制居中
|
||||
@@ -1188,17 +1192,17 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"PPT翻页控件操作失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"PPT翻页控件操作失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnPPTSlideShow_Click(object sender, RoutedEventArgs e) {
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
try {
|
||||
presentation.SlideShowSettings.Run();
|
||||
}
|
||||
catch { }
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
|
||||
private async void BtnPPTSlideShowEnd_Click(object sender, RoutedEventArgs e) {
|
||||
@@ -1240,11 +1244,11 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
});
|
||||
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
try {
|
||||
// 安全访问SlideShowWindows[1]
|
||||
if (pptApplication.SlideShowWindows.Count >= 1)
|
||||
@@ -1257,9 +1261,9 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"退出PPT放映失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"退出PPT放映失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
})).Start();
|
||||
}).Start();
|
||||
|
||||
HideSubPanels("cursor");
|
||||
await Task.Delay(150);
|
||||
@@ -1267,7 +1271,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"结束PPT放映操作异常: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"结束PPT放映操作异常: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
await Application.Current.Dispatcher.InvokeAsync(() => {
|
||||
// 隐藏侧边栏退出按钮
|
||||
@@ -1289,7 +1293,7 @@ namespace Ink_Canvas {
|
||||
LogHelper.WriteLogToFile("手动隐藏所有放映模式按钮", LogHelper.LogType.Trace);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"手动隐藏放映模式按钮失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"手动隐藏放映模式按钮失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1411,13 +1415,13 @@ namespace Ink_Canvas {
|
||||
wppProcessCheckTimer.Dispose();
|
||||
}
|
||||
|
||||
wppProcessCheckTimer = new System.Timers.Timer(500); // 改为500ms检查一次,提高响应速度
|
||||
wppProcessCheckTimer = new Timer(500); // 改为500ms检查一次,提高响应速度
|
||||
wppProcessCheckTimer.Elapsed += WppProcessCheckTimer_Elapsed;
|
||||
wppProcessCheckTimer.Start();
|
||||
LogHelper.WriteLogToFile("启动 WPP 进程检测定时器(前台窗口监控模式)", LogHelper.LogType.Trace);
|
||||
}
|
||||
|
||||
private void WppProcessCheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
private void WppProcessCheckTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
// 新增:WPS联动未启用时不查杀wpp进程
|
||||
if (!Settings.PowerPointSettings.IsSupportWPS)
|
||||
@@ -1487,7 +1491,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查WPS文档保存状态失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查WPS文档保存状态失败: {ex}", LogHelper.LogType.Error);
|
||||
allSaved = false; // 出错时默认不安全
|
||||
}
|
||||
|
||||
@@ -1515,7 +1519,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"结束WPP进程失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"结束WPP进程失败: {ex}", LogHelper.LogType.Error);
|
||||
|
||||
// 如果常规方法失败,尝试强制结束
|
||||
try
|
||||
@@ -1533,7 +1537,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception forceKillEx)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"强制结束WPP进程也失败: {forceKillEx.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"强制结束WPP进程也失败: {forceKillEx}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -1543,7 +1547,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"WPP 进程检测失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"WPP 进程检测失败: {ex}", LogHelper.LogType.Error);
|
||||
StopWppProcessCheckTimer();
|
||||
}
|
||||
}
|
||||
@@ -1568,7 +1572,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查WPP窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查WPP窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
return false; // 出错时,默认允许Kill
|
||||
}
|
||||
@@ -1619,14 +1623,14 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"枚举窗口时出错: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"枚举窗口时出错: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
return true;
|
||||
}, IntPtr.Zero);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取WPS窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取WPS窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
return wpsWindows;
|
||||
@@ -1646,12 +1650,12 @@ namespace Ink_Canvas {
|
||||
};
|
||||
|
||||
// 获取窗口标题
|
||||
var windowTitle = new System.Text.StringBuilder(256);
|
||||
var windowTitle = new StringBuilder(256);
|
||||
GetWindowText(hWnd, windowTitle, 256);
|
||||
windowInfo.Title = windowTitle.ToString().Trim();
|
||||
|
||||
// 获取窗口类名
|
||||
var className = new System.Text.StringBuilder(256);
|
||||
var className = new StringBuilder(256);
|
||||
GetClassName(hWnd, className, 256);
|
||||
windowInfo.ClassName = className.ToString().Trim();
|
||||
|
||||
@@ -1668,7 +1672,7 @@ namespace Ink_Canvas {
|
||||
windowInfo.ProcessName = "";
|
||||
try
|
||||
{
|
||||
var proc = System.Diagnostics.Process.GetProcessById((int)processId);
|
||||
var proc = Process.GetProcessById((int)processId);
|
||||
windowInfo.ProcessName = proc.ProcessName.ToLower();
|
||||
}
|
||||
catch { }
|
||||
@@ -1730,7 +1734,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取前台WPS窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取前台WPS窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1805,7 +1809,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查前台WPS窗口状态失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查前台WPS窗口状态失败: {ex}", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1837,9 +1841,9 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 按窗口位置排序,优先选择屏幕中央的窗口
|
||||
var screenCenter = new System.Drawing.Point(
|
||||
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / 2,
|
||||
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / 2
|
||||
var screenCenter = new Point(
|
||||
Screen.PrimaryScreen.Bounds.Width / 2,
|
||||
Screen.PrimaryScreen.Bounds.Height / 2
|
||||
);
|
||||
|
||||
var sortedWindows = allWpsWindows
|
||||
@@ -1854,7 +1858,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取顶级WPS窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取顶级WPS窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
return topLevelWindows;
|
||||
@@ -1915,7 +1919,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"第{attempt}次尝试检查活跃WPS窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"第{attempt}次尝试检查活跃WPS窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
|
||||
// 如果还有重试机会,等待一小段时间再重试
|
||||
if (attempt < maxRetries)
|
||||
@@ -1959,13 +1963,13 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查进程{process.ProcessName}失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查进程{process.ProcessName}失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取WPS进程失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取WPS进程失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
return wpsProcesses;
|
||||
}
|
||||
@@ -1995,7 +1999,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"调试窗口时出错: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"调试窗口时出错: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
return true;
|
||||
}, IntPtr.Zero);
|
||||
@@ -2004,7 +2008,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"调试窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"调试窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2015,7 +2019,7 @@ namespace Ink_Canvas {
|
||||
var wpsWindowCount = 0;
|
||||
var currentProcessId = wppProcess?.Id ?? 0;
|
||||
|
||||
EnumWindows((IntPtr hWnd, IntPtr lParam) =>
|
||||
EnumWindows((hWnd, lParam) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2025,7 +2029,7 @@ namespace Ink_Canvas {
|
||||
// 检查是否是WPP进程的窗口
|
||||
if (windowProcessId == currentProcessId)
|
||||
{
|
||||
var windowTitle = new System.Text.StringBuilder(256);
|
||||
var windowTitle = new StringBuilder(256);
|
||||
GetWindowText(hWnd, windowTitle, 256);
|
||||
var title = windowTitle.ToString().Trim();
|
||||
|
||||
@@ -2040,7 +2044,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"枚举窗口时出错: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"枚举窗口时出错: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
return true; // 继续枚举
|
||||
@@ -2056,7 +2060,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"通过枚举检查WPS窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"通过枚举检查WPS窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2092,15 +2096,15 @@ namespace Ink_Canvas {
|
||||
return "unknown";
|
||||
|
||||
// 使用文件路径的哈希值作为唯一标识符
|
||||
using (var md5 = System.Security.Cryptography.MD5.Create())
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
byte[] hashBytes = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(filePath));
|
||||
byte[] hashBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(filePath));
|
||||
return BitConverter.ToString(hashBytes).Replace("-", "").Substring(0, 8);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"计算文件哈希值失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"计算文件哈希值失败: {ex}", LogHelper.LogType.Error);
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
@@ -2130,7 +2134,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
var st = ApplyHistoriesToNewStrokeCollection(TimeMachineHistories[index]);
|
||||
st.Clip(new Rect(0, 0, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight));
|
||||
var pitem = new PageListViewItem()
|
||||
var pitem = new PageListViewItem
|
||||
{
|
||||
Index = index,
|
||||
Strokes = st,
|
||||
@@ -40,7 +40,7 @@ namespace Ink_Canvas
|
||||
foreach (int index in Enumerable.Range(1, WhiteboardTotalCount)) {
|
||||
var st = ApplyHistoriesToNewStrokeCollection(TimeMachineHistories[index]);
|
||||
st.Clip(new Rect(0,0, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight));
|
||||
var pitem = new PageListViewItem()
|
||||
var pitem = new PageListViewItem
|
||||
{
|
||||
Index = index,
|
||||
Strokes = st,
|
||||
@@ -51,7 +51,7 @@ namespace Ink_Canvas
|
||||
|
||||
var _st = inkCanvas.Strokes.Clone();
|
||||
_st.Clip(new Rect(0, 0, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight));
|
||||
var _pitem = new PageListViewItem()
|
||||
var _pitem = new PageListViewItem
|
||||
{
|
||||
Index = CurrentWhiteboardIndex,
|
||||
Strokes = _st,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -13,7 +15,7 @@ namespace Ink_Canvas {
|
||||
CaptureAndSaveScreenshot(savePath, isHideNotification);
|
||||
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
|
||||
SaveInkCanvasStrokes(false, false);
|
||||
SaveInkCanvasStrokes(false);
|
||||
}
|
||||
|
||||
private void SaveScreenShotToDesktop() {
|
||||
@@ -24,16 +26,16 @@ namespace Ink_Canvas {
|
||||
CaptureAndSaveScreenshot(desktopPath, false);
|
||||
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
|
||||
SaveInkCanvasStrokes(false, false);
|
||||
SaveInkCanvasStrokes(false);
|
||||
}
|
||||
|
||||
// 提取公共的截图和保存逻辑
|
||||
private void CaptureAndSaveScreenshot(string savePath, bool isHideNotification) {
|
||||
var rc = System.Windows.Forms.SystemInformation.VirtualScreen;
|
||||
var rc = SystemInformation.VirtualScreen;
|
||||
|
||||
using (var bitmap = new System.Drawing.Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb))
|
||||
using (var memoryGraphics = System.Drawing.Graphics.FromImage(bitmap)) {
|
||||
memoryGraphics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, System.Drawing.CopyPixelOperation.SourceCopy);
|
||||
using (var bitmap = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb))
|
||||
using (var memoryGraphics = Graphics.FromImage(bitmap)) {
|
||||
memoryGraphics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, CopyPixelOperation.SourceCopy);
|
||||
|
||||
// 确保目录存在
|
||||
var directory = Path.GetDirectoryName(savePath);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
@@ -7,6 +6,7 @@ using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
@@ -26,7 +26,7 @@ namespace Ink_Canvas {
|
||||
lastBorderMouseDownObject = sender;
|
||||
}
|
||||
|
||||
private bool isStrokeSelectionCloneOn = false;
|
||||
private bool isStrokeSelectionCloneOn;
|
||||
|
||||
private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
@@ -229,7 +229,7 @@ namespace Ink_Canvas {
|
||||
|
||||
#endregion
|
||||
|
||||
private bool isGridInkCanvasSelectionCoverMouseDown = false;
|
||||
private bool isGridInkCanvasSelectionCoverMouseDown;
|
||||
private StrokeCollection StrokesSelectionClone = new StrokeCollection();
|
||||
|
||||
private void GridInkCanvasSelectionCover_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
@@ -267,7 +267,7 @@ namespace Ink_Canvas {
|
||||
|
||||
private double BorderStrokeSelectionControlWidth = 490.0;
|
||||
private double BorderStrokeSelectionControlHeight = 80.0;
|
||||
private bool isProgramChangeStrokeSelection = false;
|
||||
private bool isProgramChangeStrokeSelection;
|
||||
|
||||
private void inkCanvas_SelectionChanged(object sender, EventArgs e) {
|
||||
if (isProgramChangeStrokeSelection) return;
|
||||
@@ -459,10 +459,10 @@ namespace Ink_Canvas {
|
||||
|
||||
#region UIElement Selection and Resize
|
||||
|
||||
private UIElement selectedUIElement = null;
|
||||
private System.Windows.Controls.Canvas resizeHandlesCanvas = null;
|
||||
private UIElement selectedUIElement;
|
||||
private System.Windows.Controls.Canvas resizeHandlesCanvas;
|
||||
private readonly List<Rectangle> resizeHandles = new List<Rectangle>();
|
||||
private bool isResizing = false;
|
||||
private bool isResizing;
|
||||
private ResizeDirection currentResizeDirection = ResizeDirection.None;
|
||||
private Point resizeStartPoint;
|
||||
private Rect originalElementBounds;
|
||||
@@ -817,7 +817,7 @@ namespace Ink_Canvas {
|
||||
if (element != null)
|
||||
{
|
||||
// 切换到选择模式并选择这个元素
|
||||
inkCanvas.Select(new UIElement[] { element });
|
||||
inkCanvas.Select(new[] { element });
|
||||
SelectUIElement(element);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using File = System.IO.File;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Interop;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using OSVersionExtension;
|
||||
using Microsoft.Win32;
|
||||
using System.IO;
|
||||
using Application = System.Windows.Application;
|
||||
using CheckBox = System.Windows.Controls.CheckBox;
|
||||
using ComboBox = System.Windows.Controls.ComboBox;
|
||||
using File = System.IO.File;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||
using OperatingSystem = OSVersionExtension.OperatingSystem;
|
||||
using RadioButton = System.Windows.Controls.RadioButton;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -312,7 +319,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
ComboBoxItem item = new ComboBoxItem();
|
||||
item.Content = customIcon.Name;
|
||||
item.FontFamily = new System.Windows.Media.FontFamily("Microsoft YaHei UI");
|
||||
item.FontFamily = new FontFamily("Microsoft YaHei UI");
|
||||
ComboBoxFloatingBarImg.Items.Add(item);
|
||||
}
|
||||
}
|
||||
@@ -834,7 +841,7 @@ namespace Ink_Canvas {
|
||||
Settings.InkToShape.LineStraightenSensitivity = e.NewValue;
|
||||
|
||||
// 输出调试信息,观察值变化
|
||||
System.Diagnostics.Debug.WriteLine($"LineStraightenSensitivity changed: {oldValue} -> {e.NewValue}");
|
||||
Debug.WriteLine($"LineStraightenSensitivity changed: {oldValue} -> {e.NewValue}");
|
||||
|
||||
// 立即保存设置到文件,确保设置不会丢失
|
||||
SaveSettingsToFile();
|
||||
@@ -844,7 +851,7 @@ namespace Ink_Canvas {
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.Canvas.HighPrecisionLineStraighten = ToggleSwitchHighPrecisionLineStraighten.IsOn;
|
||||
System.Diagnostics.Debug.WriteLine($"HighPrecisionLineStraighten changed: {Settings.Canvas.HighPrecisionLineStraighten}");
|
||||
Debug.WriteLine($"HighPrecisionLineStraighten changed: {Settings.Canvas.HighPrecisionLineStraighten}");
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
@@ -1399,7 +1406,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void AutoSavedStrokesLocationButton_Click(object sender, RoutedEventArgs e) {
|
||||
var folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
|
||||
var folderBrowser = new FolderBrowserDialog();
|
||||
folderBrowser.ShowDialog();
|
||||
if (folderBrowser.SelectedPath.Length > 0) AutoSavedStrokesLocation.Text = folderBrowser.SelectedPath;
|
||||
SaveSettingsToFile();
|
||||
@@ -1821,7 +1828,7 @@ namespace Ink_Canvas {
|
||||
private void ToggleSwitchIsEnableEdgeGestureUtil_Toggled(object sender, RoutedEventArgs e) {
|
||||
if (!isLoaded) return;
|
||||
Settings.Advanced.IsEnableEdgeGestureUtil = ToggleSwitchIsEnableEdgeGestureUtil.IsOn;
|
||||
if (OSVersion.GetOperatingSystem() >= OSVersionExtension.OperatingSystem.Windows10) EdgeGestureUtil.DisableEdgeGestures(new WindowInteropHelper(this).Handle, ToggleSwitchIsEnableEdgeGestureUtil.IsOn);
|
||||
if (OSVersion.GetOperatingSystem() >= OperatingSystem.Windows10) EdgeGestureUtil.DisableEdgeGestures(new WindowInteropHelper(this).Handle, ToggleSwitchIsEnableEdgeGestureUtil.IsOn);
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
@@ -1913,7 +1920,7 @@ namespace Ink_Canvas {
|
||||
string backupDir = Path.Combine(App.RootPath, "Backups");
|
||||
if (!Directory.Exists(backupDir)) {
|
||||
Directory.CreateDirectory(backupDir);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
|
||||
}
|
||||
|
||||
// 创建备份文件名(使用当前日期时间)
|
||||
@@ -1924,7 +1931,7 @@ namespace Ink_Canvas {
|
||||
string settingsJson = JsonConvert.SerializeObject(Settings, Formatting.Indented);
|
||||
File.WriteAllText(backupPath, settingsJson);
|
||||
|
||||
LogHelper.WriteLogToFile($"成功创建设置备份: {backupPath}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"成功创建设置备份: {backupPath}");
|
||||
MessageBox.Show($"设置已成功备份到:\n{backupPath}", "备份成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@@ -1941,7 +1948,7 @@ namespace Ink_Canvas {
|
||||
string backupDir = Path.Combine(App.RootPath, "Backups");
|
||||
if (!Directory.Exists(backupDir)) {
|
||||
Directory.CreateDirectory(backupDir);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
|
||||
MessageBox.Show("没有找到备份文件,请先创建备份", "还原失败", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
@@ -1978,7 +1985,7 @@ namespace Ink_Canvas {
|
||||
// 重新加载设置到UI
|
||||
LoadSettings();
|
||||
|
||||
LogHelper.WriteLogToFile($"成功从备份还原设置: {dlg.FileName}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"成功从备份还原设置: {dlg.FileName}");
|
||||
MessageBox.Show("设置已成功还原,部分设置可能需要重启软件后生效。", "还原成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
@@ -2073,7 +2080,7 @@ namespace Ink_Canvas {
|
||||
|
||||
private async void UpdateChannelSelector_Checked(object sender, RoutedEventArgs e) {
|
||||
if (!isLoaded) return;
|
||||
var radioButton = sender as System.Windows.Controls.RadioButton;
|
||||
var radioButton = sender as RadioButton;
|
||||
if (radioButton != null) {
|
||||
string channel = radioButton.Tag.ToString();
|
||||
UpdateChannel newChannel = channel == "Beta" ? UpdateChannel.Beta : UpdateChannel.Release;
|
||||
@@ -2172,7 +2179,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
ComboBoxItem item = new ComboBoxItem();
|
||||
item.Content = background.Name;
|
||||
item.FontFamily = new System.Windows.Media.FontFamily("Microsoft YaHei UI");
|
||||
item.FontFamily = new FontFamily("Microsoft YaHei UI");
|
||||
ComboBoxPickNameBackground.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using OSVersionExtension;
|
||||
using System;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -10,11 +6,15 @@ using System.Windows.Ink;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using OSVersionExtension;
|
||||
using File = System.IO.File;
|
||||
using OperatingSystem = OSVersionExtension.OperatingSystem;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : System.Windows.Window {
|
||||
public partial class MainWindow : Window {
|
||||
private void LoadSettings(bool isStartup = false) {
|
||||
AppVersionTextBlock.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
try {
|
||||
@@ -92,7 +92,7 @@ namespace Ink_Canvas {
|
||||
|
||||
// 初始化更新通道选择
|
||||
foreach (var radioButton in UpdateChannelSelector.Items) {
|
||||
if (radioButton is System.Windows.Controls.RadioButton rb) {
|
||||
if (radioButton is RadioButton rb) {
|
||||
if (rb.Tag.ToString() == Settings.Startup.UpdateChannel.ToString()) {
|
||||
rb.IsChecked = true;
|
||||
break;
|
||||
@@ -465,7 +465,7 @@ namespace Ink_Canvas {
|
||||
BoardComboBoxEraserSize.SelectedIndex = Settings.Canvas.EraserSize;
|
||||
|
||||
ToggleSwitchClearCanvasAndClearTimeMachine.IsOn =
|
||||
Settings.Canvas.ClearCanvasAndClearTimeMachine == true;
|
||||
Settings.Canvas.ClearCanvasAndClearTimeMachine;
|
||||
ToggleSwitchClearCanvasAlsoClearImages.IsOn = Settings.Canvas.ClearCanvasAlsoClearImages;
|
||||
|
||||
switch (Settings.Canvas.EraserShapeType) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,6 +8,8 @@ using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
@@ -55,8 +56,8 @@ namespace Ink_Canvas {
|
||||
|
||||
#endregion Floating Bar Control
|
||||
|
||||
private int drawingShapeMode = 0;
|
||||
private bool isLongPressSelected = false; // 用于存是否是"选中"状态,便于后期抬笔后不做切换到笔的处理
|
||||
private int drawingShapeMode;
|
||||
private bool isLongPressSelected; // 用于存是否是"选中"状态,便于后期抬笔后不做切换到笔的处理
|
||||
|
||||
#region Buttons
|
||||
|
||||
@@ -66,12 +67,12 @@ namespace Ink_Canvas {
|
||||
ToggleSwitchDrawShapeBorderAutoHide.IsOn = !ToggleSwitchDrawShapeBorderAutoHide.IsOn;
|
||||
|
||||
if (ToggleSwitchDrawShapeBorderAutoHide.IsOn)
|
||||
((iNKORE.UI.WPF.Modern.Controls.SymbolIcon)sender).Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Pin;
|
||||
((SymbolIcon)sender).Symbol = Symbol.Pin;
|
||||
else
|
||||
((iNKORE.UI.WPF.Modern.Controls.SymbolIcon)sender).Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.UnPin;
|
||||
((SymbolIcon)sender).Symbol = Symbol.UnPin;
|
||||
}
|
||||
|
||||
private object lastMouseDownSender = null;
|
||||
private object lastMouseDownSender;
|
||||
private DateTime lastMouseDownTime = DateTime.MinValue;
|
||||
|
||||
private async void Image_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
@@ -402,23 +403,22 @@ namespace Ink_Canvas {
|
||||
inkCanvas.EditingMode == InkCanvasEditingMode.Select ||
|
||||
inkCanvas.EditingMode == InkCanvasEditingMode.Ink) {
|
||||
// 允许正常橡皮、套索、批注
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private int drawMultiStepShapeCurrentStep = 0; //多笔完成的图形 当前所处在的笔画
|
||||
private int drawMultiStepShapeCurrentStep; //多笔完成的图形 当前所处在的笔画
|
||||
|
||||
private StrokeCollection drawMultiStepShapeSpecialStrokeCollection = new StrokeCollection(); //多笔完成的图形 当前所处在的笔画
|
||||
|
||||
//double drawMultiStepShapeSpecialParameter1 = 0.0; //多笔完成的图形 特殊参数 通常用于表示a
|
||||
//double drawMultiStepShapeSpecialParameter2 = 0.0; //多笔完成的图形 特殊参数 通常用于表示b
|
||||
private double drawMultiStepShapeSpecialParameter3 = 0.0; //多笔完成的图形 特殊参数 通常用于表示k
|
||||
private double drawMultiStepShapeSpecialParameter3; //多笔完成的图形 特殊参数 通常用于表示k
|
||||
|
||||
#region 形状绘制主函数
|
||||
|
||||
private void MouseTouchMove(Point endP) {
|
||||
// 禁用原有的FitToCurve,使用新的高级贝塞尔曲线平滑
|
||||
if (Settings.Canvas.FitToCurve == true) drawingAttributes.FitToCurve = false;
|
||||
if (Settings.Canvas.FitToCurve) drawingAttributes.FitToCurve = false;
|
||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||
List<Point> pointList;
|
||||
@@ -1041,7 +1041,7 @@ namespace Ink_Canvas {
|
||||
strokes.Add(stroke.Clone());
|
||||
//底部椭圆
|
||||
pointList = GenerateEllipseGeometry(new Point(newIniP.X, endP.Y - topB / 2),
|
||||
new Point(endP.X, endP.Y + topB / 2), false, true);
|
||||
new Point(endP.X, endP.Y + topB / 2), false);
|
||||
point = new StylusPointCollection(pointList);
|
||||
stroke = new Stroke(point) {
|
||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||
@@ -1090,7 +1090,7 @@ namespace Ink_Canvas {
|
||||
var bottomB = bottomA / 2.646;
|
||||
//底部椭圆
|
||||
pointList = GenerateEllipseGeometry(new Point(newIniP.X, endP.Y - bottomB / 2),
|
||||
new Point(endP.X, endP.Y + bottomB / 2), false, true);
|
||||
new Point(endP.X, endP.Y + bottomB / 2), false);
|
||||
point = new StylusPointCollection(pointList);
|
||||
stroke = new Stroke(point) {
|
||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||
@@ -1221,13 +1221,13 @@ namespace Ink_Canvas {
|
||||
#endregion
|
||||
|
||||
private bool isFirstTouchCuboid = true;
|
||||
private Point CuboidFrontRectIniP = new Point();
|
||||
private Point CuboidFrontRectEndP = new Point();
|
||||
private Point CuboidFrontRectIniP;
|
||||
private Point CuboidFrontRectEndP;
|
||||
|
||||
private Stroke lastTempStroke = null;
|
||||
private Stroke lastTempStroke;
|
||||
private StrokeCollection lastTempStrokeCollection = new StrokeCollection();
|
||||
|
||||
private bool isWaitUntilNextTouchDown = false;
|
||||
private bool isWaitUntilNextTouchDown;
|
||||
|
||||
private List<Point> GenerateEllipseGeometry(Point st, Point ed, bool isDrawTop = true,
|
||||
bool isDrawBottom = true) {
|
||||
@@ -1377,7 +1377,7 @@ namespace Ink_Canvas {
|
||||
return strokes;
|
||||
}
|
||||
|
||||
private bool isMouseDown = false;
|
||||
private bool isMouseDown;
|
||||
|
||||
private void inkCanvas_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
inkCanvas.CaptureMouse();
|
||||
@@ -1547,7 +1547,7 @@ namespace Ink_Canvas {
|
||||
StrokeCollection collection = null;
|
||||
if (lastTempStrokeCollection != null && lastTempStrokeCollection.Count > 0)
|
||||
collection = lastTempStrokeCollection;
|
||||
else if (lastTempStroke != null) collection = new StrokeCollection() { lastTempStroke };
|
||||
else if (lastTempStroke != null) collection = new StrokeCollection { lastTempStroke };
|
||||
if (collection != null) timeMachine.CommitStrokeUserInputHistory(collection);
|
||||
}
|
||||
|
||||
@@ -1593,10 +1593,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"形状绘制高级贝塞尔曲线平滑失败: {ex.Message}");
|
||||
Debug.WriteLine($"形状绘制高级贝塞尔曲线平滑失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
else if (Settings.Canvas.FitToCurve == true)
|
||||
else if (Settings.Canvas.FitToCurve)
|
||||
{
|
||||
drawingAttributes.FitToCurve = true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -8,6 +8,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
@@ -21,7 +22,7 @@ namespace Ink_Canvas {
|
||||
bool wasStraightened = false;
|
||||
|
||||
// 禁用原有的FitToCurve,使用新的高级贝塞尔曲线平滑
|
||||
if (Settings.Canvas.FitToCurve == true) drawingAttributes.FitToCurve = false;
|
||||
if (Settings.Canvas.FitToCurve) drawingAttributes.FitToCurve = false;
|
||||
|
||||
try {
|
||||
inkCanvas.Opacity = 1;
|
||||
@@ -134,13 +135,13 @@ namespace Ink_Canvas {
|
||||
// 先完成所有直线判定,再考虑端点吸附
|
||||
// 读取实际的灵敏度设置值
|
||||
double sensitivity = Settings.InkToShape.LineStraightenSensitivity;
|
||||
System.Diagnostics.Debug.WriteLine($"当前灵敏度值: {sensitivity}");
|
||||
Debug.WriteLine($"当前灵敏度值: {sensitivity}");
|
||||
|
||||
// 判断是否应该拉直线条
|
||||
bool shouldStraighten = ShouldStraightenLine(e.Stroke);
|
||||
|
||||
// 输出一些调试信息,帮助理解灵敏度设置的效果
|
||||
System.Diagnostics.Debug.WriteLine($"LineStraightenSensitivity: {Settings.InkToShape.LineStraightenSensitivity}, ShouldStraighten: {shouldStraighten}");
|
||||
Debug.WriteLine($"LineStraightenSensitivity: {Settings.InkToShape.LineStraightenSensitivity}, ShouldStraighten: {shouldStraighten}");
|
||||
|
||||
// 只有当确定要拉直线条时,才检查端点吸附
|
||||
if (shouldStraighten && Settings.Canvas.LineEndpointSnapping) {
|
||||
@@ -208,7 +209,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
if (result.InkDrawingNode.GetShapeName() == "Circle" &&
|
||||
Settings.InkToShape.IsInkToShapeRounded == true) {
|
||||
Settings.InkToShape.IsInkToShapeRounded) {
|
||||
var shape = result.InkDrawingNode.GetShape();
|
||||
if (shape.Width > 75) {
|
||||
foreach (var circle in circles)
|
||||
@@ -264,7 +265,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
else if (result.InkDrawingNode.GetShapeName().Contains("Ellipse") &&
|
||||
Settings.InkToShape.IsInkToShapeRounded == true) {
|
||||
Settings.InkToShape.IsInkToShapeRounded) {
|
||||
var shape = result.InkDrawingNode.GetShape();
|
||||
//var shape1 = result.InkDrawingNode.GetShape();
|
||||
//shape1.Fill = Brushes.Gray;
|
||||
@@ -334,14 +335,14 @@ namespace Ink_Canvas {
|
||||
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
|
||||
newStrokes = new StrokeCollection();
|
||||
|
||||
var _pointList = GenerateEllipseGeometry(iniP, endP, false, true);
|
||||
var _pointList = GenerateEllipseGeometry(iniP, endP, false);
|
||||
var _point = new StylusPointCollection(_pointList);
|
||||
var _stroke = new Stroke(_point) {
|
||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||
};
|
||||
var _dashedLineStroke =
|
||||
GenerateDashedLineEllipseStrokeCollection(iniP, endP, true, false);
|
||||
var strokes = new StrokeCollection() {
|
||||
var strokes = new StrokeCollection {
|
||||
_stroke,
|
||||
_dashedLineStroke
|
||||
};
|
||||
@@ -398,7 +399,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
else if (result.InkDrawingNode.GetShapeName().Contains("Triangle") &&
|
||||
Settings.InkToShape.IsInkToShapeTriangle == true) {
|
||||
Settings.InkToShape.IsInkToShapeTriangle) {
|
||||
var shape = result.InkDrawingNode.GetShape();
|
||||
var p = result.InkDrawingNode.HotPoints;
|
||||
if ((Math.Max(Math.Max(p[0].X, p[1].X), p[2].X) -
|
||||
@@ -437,7 +438,7 @@ namespace Ink_Canvas {
|
||||
result.InkDrawingNode.GetShapeName().Contains("Parallelogram") ||
|
||||
result.InkDrawingNode.GetShapeName().Contains("Square") ||
|
||||
result.InkDrawingNode.GetShapeName().Contains("Trapezoid")) &&
|
||||
Settings.InkToShape.IsInkToShapeRectangle == true) {
|
||||
Settings.InkToShape.IsInkToShapeRectangle) {
|
||||
var shape = result.InkDrawingNode.GetShape();
|
||||
var p = result.InkDrawingNode.HotPoints;
|
||||
if ((Math.Max(Math.Max(Math.Max(p[0].X, p[1].X), p[2].X), p[3].X) -
|
||||
@@ -514,7 +515,7 @@ namespace Ink_Canvas {
|
||||
var speed = GetPointSpeed(e.Stroke.StylusPoints[Math.Max(i - 1, 0)].ToPoint(),
|
||||
e.Stroke.StylusPoints[i].ToPoint(),
|
||||
e.Stroke.StylusPoints[Math.Min(i + 1, n)].ToPoint());
|
||||
s += speed.ToString() + "\t";
|
||||
s += speed + "\t";
|
||||
var point = new StylusPoint();
|
||||
if (speed >= 0.25)
|
||||
point.PressureFactor = (float)(0.5 - 0.3 * (Math.Min(speed, 1.5) - 0.3) / 1.2);
|
||||
@@ -614,10 +615,10 @@ namespace Ink_Canvas {
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 如果高级平滑失败,回退到原始笔画
|
||||
System.Diagnostics.Debug.WriteLine($"高级贝塞尔曲线平滑失败: {ex.Message}");
|
||||
Debug.WriteLine($"高级贝塞尔曲线平滑失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
else if (Settings.Canvas.FitToCurve == true && !wasStraightened)
|
||||
else if (Settings.Canvas.FitToCurve && !wasStraightened)
|
||||
{
|
||||
drawingAttributes.FitToCurve = true;
|
||||
}
|
||||
@@ -645,7 +646,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"异步墨迹平滑失败: {ex.Message}");
|
||||
Debug.WriteLine($"异步墨迹平滑失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,7 +669,7 @@ namespace Ink_Canvas {
|
||||
double sensitivity = Settings.InkToShape.LineStraightenSensitivity;
|
||||
|
||||
// 输出当前灵敏度值(调试用)
|
||||
System.Diagnostics.Debug.WriteLine($"IsPotentialStraightLine - sensitivity: {sensitivity}, length: {lineLength}");
|
||||
Debug.WriteLine($"IsPotentialStraightLine - sensitivity: {sensitivity}, length: {lineLength}");
|
||||
|
||||
// 根据灵敏度调整快速检查阈值
|
||||
double quickThreshold;
|
||||
@@ -682,7 +683,7 @@ namespace Ink_Canvas {
|
||||
quickThreshold = Math.Min(sensitivity * 1.5, 0.20);
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"使用快速检查阈值: {quickThreshold}");
|
||||
Debug.WriteLine($"使用快速检查阈值: {quickThreshold}");
|
||||
|
||||
// 快速检查:计算几个关键点与直线的距离
|
||||
if (stroke.StylusPoints.Count >= 10) {
|
||||
@@ -703,7 +704,7 @@ namespace Ink_Canvas {
|
||||
double quickRelativeThreshold = lineLength * quickThreshold;
|
||||
|
||||
// 记录检测到的偏差(调试用)
|
||||
System.Diagnostics.Debug.WriteLine($"Deviations: q={quarterDeviation}, m={midDeviation}, tq={threeQuarterDeviation}, threshold={quickRelativeThreshold}");
|
||||
Debug.WriteLine($"Deviations: q={quarterDeviation}, m={midDeviation}, tq={threeQuarterDeviation}, threshold={quickRelativeThreshold}");
|
||||
|
||||
// 如果灵敏度超过1.5,则即使有一个点满足条件也认为可能是直线
|
||||
if (sensitivity > 1.5) {
|
||||
@@ -745,7 +746,7 @@ namespace Ink_Canvas {
|
||||
double sensitivity = Settings.InkToShape.LineStraightenSensitivity;
|
||||
|
||||
// 输出详细的调试信息
|
||||
System.Diagnostics.Debug.WriteLine($"ShouldStraightenLine - sensitivity: {sensitivity}, length: {lineLength}");
|
||||
Debug.WriteLine($"ShouldStraightenLine - sensitivity: {sensitivity}, length: {lineLength}");
|
||||
|
||||
// 临时:显示调试消息框
|
||||
// MessageBox.Show($"灵敏度值: {sensitivity}", "调试信息");
|
||||
@@ -758,7 +759,7 @@ namespace Ink_Canvas {
|
||||
bool useHighPrecision = Settings.Canvas.HighPrecisionLineStraighten;
|
||||
|
||||
if (useHighPrecision) {
|
||||
System.Diagnostics.Debug.WriteLine("使用高精度直线拉直模式");
|
||||
Debug.WriteLine("使用高精度直线拉直模式");
|
||||
|
||||
// 高精度模式:每隔10像素取一个计数点
|
||||
double strokeLength = 0;
|
||||
@@ -844,7 +845,7 @@ namespace Ink_Canvas {
|
||||
double avgDeviation = totalDeviation / pointCount;
|
||||
|
||||
// 更详细的调试信息
|
||||
System.Diagnostics.Debug.WriteLine($"Max deviation: {maxDeviation}, Avg: {avgDeviation}, Threshold: {sensitivity * lineLength}, Points: {pointCount}");
|
||||
Debug.WriteLine($"Max deviation: {maxDeviation}, Avg: {avgDeviation}, Threshold: {sensitivity * lineLength}, Points: {pointCount}");
|
||||
|
||||
// 支持更广泛的灵敏度范围 (0.05-2.0)
|
||||
|
||||
@@ -855,129 +856,128 @@ namespace Ink_Canvas {
|
||||
|
||||
// 只判断平均偏差和相对偏差
|
||||
if (maxDeviation / lineLength < adjustedSensitivity && avgDeviation < lineLength * 0.1 * adjustedSensitivity) {
|
||||
System.Diagnostics.Debug.WriteLine("接受拉直 (高灵敏度模式)");
|
||||
Debug.WriteLine("接受拉直 (高灵敏度模式)");
|
||||
return true;
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("拒绝拉直 (高灵敏度模式)");
|
||||
Debug.WriteLine("拒绝拉直 (高灵敏度模式)");
|
||||
return false;
|
||||
}
|
||||
// 否则使用常规判断标准
|
||||
else {
|
||||
// 检查点分布的一致性 - 如果有些点偏离很大而其他点很接近直线,表明线条有明显弯曲
|
||||
double deviationVariance = 0;
|
||||
|
||||
// 检查点分布的一致性 - 如果有些点偏离很大而其他点很接近直线,表明线条有明显弯曲
|
||||
double deviationVariance = 0;
|
||||
|
||||
// 使用相同的高精度/原始模式来计算方差
|
||||
if (useHighPrecision) {
|
||||
// 高精度模式:重新采样计算方差
|
||||
double strokeLength = 0;
|
||||
double sampleInterval = 10.0; // 10像素间隔
|
||||
// 使用相同的高精度/原始模式来计算方差
|
||||
if (useHighPrecision) {
|
||||
// 高精度模式:重新采样计算方差
|
||||
double strokeLength = 0;
|
||||
double sampleInterval = 10.0; // 10像素间隔
|
||||
|
||||
// 计算笔画的总长度,用于后续采样
|
||||
for (int i = 1; i < stroke.StylusPoints.Count; i++) {
|
||||
Point p1 = stroke.StylusPoints[i-1].ToPoint();
|
||||
Point p2 = stroke.StylusPoints[i].ToPoint();
|
||||
strokeLength += GetDistance(p1, p2);
|
||||
}
|
||||
// 计算笔画的总长度,用于后续采样
|
||||
for (int i = 1; i < stroke.StylusPoints.Count; i++) {
|
||||
Point p1 = stroke.StylusPoints[i-1].ToPoint();
|
||||
Point p2 = stroke.StylusPoints[i].ToPoint();
|
||||
strokeLength += GetDistance(p1, p2);
|
||||
}
|
||||
|
||||
// 如果笔画太短,直接使用所有点
|
||||
if (strokeLength < sampleInterval * 5) {
|
||||
foreach (StylusPoint sp in stroke.StylusPoints) {
|
||||
Point p = sp.ToPoint();
|
||||
double deviation = DistanceFromLineToPoint(start, end, p);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
} else {
|
||||
// 使用等距采样点
|
||||
double currentLength = 0;
|
||||
double nextSampleAt = 0;
|
||||
Point lastPoint = start;
|
||||
|
||||
// 起点方差
|
||||
double deviation = DistanceFromLineToPoint(start, end, lastPoint);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
|
||||
// 采样中间点
|
||||
for (int i = 1; i < stroke.StylusPoints.Count; i++) {
|
||||
Point currentPoint = stroke.StylusPoints[i].ToPoint();
|
||||
double segmentLength = GetDistance(lastPoint, currentPoint);
|
||||
|
||||
// 如果这段线段跨越了下一个采样点
|
||||
while (currentLength + segmentLength >= nextSampleAt) {
|
||||
// 计算采样点在线段上的位置
|
||||
double t = (nextSampleAt - currentLength) / segmentLength;
|
||||
Point samplePoint = new Point(
|
||||
lastPoint.X + t * (currentPoint.X - lastPoint.X),
|
||||
lastPoint.Y + t * (currentPoint.Y - lastPoint.Y)
|
||||
);
|
||||
|
||||
// 计算采样点的方差
|
||||
deviation = DistanceFromLineToPoint(start, end, samplePoint);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
|
||||
// 设置下一个采样点位置
|
||||
nextSampleAt += sampleInterval;
|
||||
|
||||
// 防止无限循环
|
||||
if (nextSampleAt > strokeLength) break;
|
||||
}
|
||||
|
||||
currentLength += segmentLength;
|
||||
lastPoint = currentPoint;
|
||||
}
|
||||
|
||||
// 终点方差
|
||||
deviation = DistanceFromLineToPoint(start, end, end);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
} else {
|
||||
// 原始模式:使用所有点计算方差
|
||||
// 如果笔画太短,直接使用所有点
|
||||
if (strokeLength < sampleInterval * 5) {
|
||||
foreach (StylusPoint sp in stroke.StylusPoints) {
|
||||
Point p = sp.ToPoint();
|
||||
double deviation = DistanceFromLineToPoint(start, end, p);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
}
|
||||
|
||||
deviationVariance /= pointCount;
|
||||
|
||||
// 输出更多调试信息
|
||||
System.Diagnostics.Debug.WriteLine($"Deviation variance: {deviationVariance}, Threshold: {sensitivity * lineLength * 0.05}");
|
||||
|
||||
// 如果最大偏差超过线长的阈值比例,或者偏差方差较大(表示不均匀弯曲),则不拉直
|
||||
// 灵敏度越大,容许的偏差越大,更容易将线条识别为直线
|
||||
if ((maxDeviation / lineLength) > sensitivity) {
|
||||
System.Diagnostics.Debug.WriteLine("拒绝拉直:最大偏差过大");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 如果偏差方差大,说明线条弯曲不均匀
|
||||
// 灵敏度越大,容许的偏差方差越大
|
||||
if (deviationVariance > (sensitivity * lineLength * 0.05)) {
|
||||
System.Diagnostics.Debug.WriteLine("拒绝拉直:偏差方差过大");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查中点偏离情况 - 针对弧形线条特别有效
|
||||
if (stroke.StylusPoints.Count > 10) {
|
||||
int midIndex = stroke.StylusPoints.Count / 2;
|
||||
Point midPoint = stroke.StylusPoints[midIndex].ToPoint();
|
||||
double midDeviation = DistanceFromLineToPoint(start, end, midPoint);
|
||||
|
||||
// 输出中点偏差信息
|
||||
System.Diagnostics.Debug.WriteLine($"Mid deviation: {midDeviation}, Threshold: {lineLength * sensitivity * 0.8}");
|
||||
|
||||
// 如果中点偏离过大,不拉直
|
||||
// 使用灵敏度作为判断基准,灵敏度越大,容许的中点偏离越大
|
||||
if (midDeviation > (lineLength * sensitivity * 0.8)) {
|
||||
System.Diagnostics.Debug.WriteLine("拒绝拉直:中点偏差过大");
|
||||
return false;
|
||||
} else {
|
||||
// 使用等距采样点
|
||||
double currentLength = 0;
|
||||
double nextSampleAt = 0;
|
||||
Point lastPoint = start;
|
||||
|
||||
// 起点方差
|
||||
double deviation = DistanceFromLineToPoint(start, end, lastPoint);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
|
||||
// 采样中间点
|
||||
for (int i = 1; i < stroke.StylusPoints.Count; i++) {
|
||||
Point currentPoint = stroke.StylusPoints[i].ToPoint();
|
||||
double segmentLength = GetDistance(lastPoint, currentPoint);
|
||||
|
||||
// 如果这段线段跨越了下一个采样点
|
||||
while (currentLength + segmentLength >= nextSampleAt) {
|
||||
// 计算采样点在线段上的位置
|
||||
double t = (nextSampleAt - currentLength) / segmentLength;
|
||||
Point samplePoint = new Point(
|
||||
lastPoint.X + t * (currentPoint.X - lastPoint.X),
|
||||
lastPoint.Y + t * (currentPoint.Y - lastPoint.Y)
|
||||
);
|
||||
|
||||
// 计算采样点的方差
|
||||
deviation = DistanceFromLineToPoint(start, end, samplePoint);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
|
||||
// 设置下一个采样点位置
|
||||
nextSampleAt += sampleInterval;
|
||||
|
||||
// 防止无限循环
|
||||
if (nextSampleAt > strokeLength) break;
|
||||
}
|
||||
|
||||
currentLength += segmentLength;
|
||||
lastPoint = currentPoint;
|
||||
}
|
||||
|
||||
// 终点方差
|
||||
deviation = DistanceFromLineToPoint(start, end, end);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
} else {
|
||||
// 原始模式:使用所有点计算方差
|
||||
foreach (StylusPoint sp in stroke.StylusPoints) {
|
||||
Point p = sp.ToPoint();
|
||||
double deviation = DistanceFromLineToPoint(start, end, p);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("接受拉直");
|
||||
return true;
|
||||
}
|
||||
|
||||
deviationVariance /= pointCount;
|
||||
|
||||
// 输出更多调试信息
|
||||
Debug.WriteLine($"Deviation variance: {deviationVariance}, Threshold: {sensitivity * lineLength * 0.05}");
|
||||
|
||||
// 如果最大偏差超过线长的阈值比例,或者偏差方差较大(表示不均匀弯曲),则不拉直
|
||||
// 灵敏度越大,容许的偏差越大,更容易将线条识别为直线
|
||||
if ((maxDeviation / lineLength) > sensitivity) {
|
||||
Debug.WriteLine("拒绝拉直:最大偏差过大");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 如果偏差方差大,说明线条弯曲不均匀
|
||||
// 灵敏度越大,容许的偏差方差越大
|
||||
if (deviationVariance > (sensitivity * lineLength * 0.05)) {
|
||||
Debug.WriteLine("拒绝拉直:偏差方差过大");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查中点偏离情况 - 针对弧形线条特别有效
|
||||
if (stroke.StylusPoints.Count > 10) {
|
||||
int midIndex = stroke.StylusPoints.Count / 2;
|
||||
Point midPoint = stroke.StylusPoints[midIndex].ToPoint();
|
||||
double midDeviation = DistanceFromLineToPoint(start, end, midPoint);
|
||||
|
||||
// 输出中点偏差信息
|
||||
Debug.WriteLine($"Mid deviation: {midDeviation}, Threshold: {lineLength * sensitivity * 0.8}");
|
||||
|
||||
// 如果中点偏离过大,不拉直
|
||||
// 使用灵敏度作为判断基准,灵敏度越大,容许的中点偏离越大
|
||||
if (midDeviation > (lineLength * sensitivity * 0.8)) {
|
||||
Debug.WriteLine("拒绝拉直:中点偏差过大");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.WriteLine("接受拉直");
|
||||
return true;
|
||||
}
|
||||
|
||||
// New method: Creates a straight line stroke between two points
|
||||
@@ -987,7 +987,7 @@ namespace Ink_Canvas {
|
||||
// 根据是否启用压感触屏模式决定如何设置压感
|
||||
// 如果未启用压感触屏模式,则使用均匀粗细
|
||||
if (!Settings.Canvas.EnablePressureTouchMode || Settings.Canvas.DisablePressure ||
|
||||
Settings.InkToShape.IsInkToShapeNoFakePressureRectangle == true || penType == 1) {
|
||||
Settings.InkToShape.IsInkToShapeNoFakePressureRectangle || penType == 1) {
|
||||
// 使用均匀粗细(所有点压感值都是0.5f)
|
||||
points.Add(new StylusPoint(start.X, start.Y, 0.5f));
|
||||
|
||||
@@ -1083,7 +1083,7 @@ namespace Ink_Canvas {
|
||||
|
||||
// Return snapped points if any snapping occurred
|
||||
if (startSnapped || endSnapped) {
|
||||
return new Point[] { snappedStart, snappedEnd };
|
||||
return new[] { snappedStart, snappedEnd };
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -1140,7 +1140,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
public StylusPointCollection GenerateFakePressureTriangle(StylusPointCollection points) {
|
||||
if (Settings.InkToShape.IsInkToShapeNoFakePressureTriangle == true || penType == 1) {
|
||||
if (Settings.InkToShape.IsInkToShapeNoFakePressureTriangle || penType == 1) {
|
||||
var newPoint = new StylusPointCollection();
|
||||
newPoint.Add(new StylusPoint(points[0].X, points[0].Y));
|
||||
var cPoint = GetCenterPoint(points[0], points[1]);
|
||||
@@ -1174,30 +1174,30 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
public StylusPointCollection GenerateFakePressureRectangle(StylusPointCollection points) {
|
||||
if (Settings.InkToShape.IsInkToShapeNoFakePressureRectangle == true || penType == 1) {
|
||||
public StylusPointCollection GenerateFakePressureRectangle(StylusPointCollection points)
|
||||
{
|
||||
if (Settings.InkToShape.IsInkToShapeNoFakePressureRectangle || penType == 1) {
|
||||
return points;
|
||||
}
|
||||
else {
|
||||
var newPoint = new StylusPointCollection();
|
||||
newPoint.Add(new StylusPoint(points[0].X, points[0].Y, (float)0.4));
|
||||
var cPoint = GetCenterPoint(points[0], points[1]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[1].X, points[1].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[1].X, points[1].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[1], points[2]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[2].X, points[2].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[2].X, points[2].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[2], points[3]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[3].X, points[3].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[3].X, points[3].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[3], points[0]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[0].X, points[0].Y, (float)0.4));
|
||||
return newPoint;
|
||||
}
|
||||
|
||||
var newPoint = new StylusPointCollection();
|
||||
newPoint.Add(new StylusPoint(points[0].X, points[0].Y, (float)0.4));
|
||||
var cPoint = GetCenterPoint(points[0], points[1]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[1].X, points[1].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[1].X, points[1].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[1], points[2]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[2].X, points[2].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[2].X, points[2].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[2], points[3]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[3].X, points[3].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[3].X, points[3].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[3], points[0]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[0].X, points[0].Y, (float)0.4));
|
||||
return newPoint;
|
||||
}
|
||||
|
||||
public Point GetCenterPoint(Point point1, Point point2) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Diagnostics;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -32,7 +32,7 @@ namespace Ink_Canvas {
|
||||
private Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>> DrawingAttributesHistory =
|
||||
new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
|
||||
|
||||
private Dictionary<Guid, List<Stroke>> DrawingAttributesHistoryFlag = new Dictionary<Guid, List<Stroke>>() {
|
||||
private Dictionary<Guid, List<Stroke>> DrawingAttributesHistoryFlag = new Dictionary<Guid, List<Stroke>> {
|
||||
{ DrawingAttributeIds.Color, new List<Stroke>() },
|
||||
{ DrawingAttributeIds.DrawingFlags, new List<Stroke>() },
|
||||
{ DrawingAttributeIds.IsHighlighter, new List<Stroke>() },
|
||||
@@ -145,7 +145,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private StrokeCollection ApplyHistoriesToNewStrokeCollection(TimeMachineHistory[] items) {
|
||||
InkCanvas fakeInkCanv = new InkCanvas() {
|
||||
InkCanvas fakeInkCanv = new InkCanvas {
|
||||
Width = inkCanvas.ActualWidth,
|
||||
Height = inkCanvas.ActualHeight,
|
||||
EditingMode = InkCanvasEditingMode.None,
|
||||
@@ -202,24 +202,23 @@ namespace Ink_Canvas {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Added.Count != 0) {
|
||||
if (e.Added.Count != 0)
|
||||
{
|
||||
if (_currentCommitType == CommitReason.ShapeRecognition) {
|
||||
timeMachine.CommitStrokeShapeHistory(ReplacedStroke, e.Added);
|
||||
ReplacedStroke = null;
|
||||
return;
|
||||
} else {
|
||||
timeMachine.CommitStrokeUserInputHistory(e.Added);
|
||||
return;
|
||||
}
|
||||
|
||||
timeMachine.CommitStrokeUserInputHistory(e.Added);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Removed.Count != 0) {
|
||||
if (_currentCommitType == CommitReason.ShapeRecognition) {
|
||||
ReplacedStroke = e.Removed;
|
||||
return;
|
||||
} else if (!IsEraseByPoint || _currentCommitType == CommitReason.ClearingCanvas) {
|
||||
timeMachine.CommitStrokeEraseHistory(e.Removed);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public class TimeViewModel : INotifyPropertyChanged {
|
||||
@@ -49,9 +49,9 @@ namespace Ink_Canvas {
|
||||
private Timer timerCheckPPT = new Timer();
|
||||
private Timer timerKillProcess = new Timer();
|
||||
private Timer timerCheckAutoFold = new Timer();
|
||||
private string AvailableLatestVersion = null;
|
||||
private string AvailableLatestVersion;
|
||||
private Timer timerCheckAutoUpdateWithSilence = new Timer();
|
||||
private bool isHidingSubPanelsWhenInking = false; // 避免书写时触发二次关闭二级菜单导致动画不连续
|
||||
private bool isHidingSubPanelsWhenInking; // 避免书写时触发二次关闭二级菜单导致动画不连续
|
||||
|
||||
private Timer timerDisplayTime = new Timer();
|
||||
private Timer timerDisplayDate = new Timer();
|
||||
@@ -232,8 +232,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
|
||||
private bool foldFloatingBarByUser = false, // 保持收纳操作不受自动收纳的控制
|
||||
unfoldFloatingBarByUser = false; // 允许用户在希沃软件内进行展开操作
|
||||
private bool foldFloatingBarByUser, // 保持收纳操作不受自动收纳的控制
|
||||
unfoldFloatingBarByUser; // 允许用户在希沃软件内进行展开操作
|
||||
|
||||
private void timerCheckAutoFold_Elapsed(object sender, ElapsedEventArgs e) {
|
||||
if (isFloatingBarChangingHideMode) return;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -8,16 +7,16 @@ using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Point = System.Windows.Point;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
#region Multi-Touch
|
||||
|
||||
private bool isInMultiTouchMode = false;
|
||||
private bool isInMultiTouchMode;
|
||||
private List<int> dec = new List<int>();
|
||||
private bool isSingleFingerDragMode = false;
|
||||
private bool isSingleFingerDragMode;
|
||||
private Point centerPoint = new Point(0, 0);
|
||||
private InkCanvasEditingMode lastInkCanvasEditingMode = InkCanvasEditingMode.Ink;
|
||||
|
||||
@@ -273,10 +272,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 手掌擦相关变量
|
||||
private bool isPalmEraserActive = false;
|
||||
private bool isPalmEraserActive;
|
||||
private InkCanvasEditingMode palmEraserLastEditingMode = InkCanvasEditingMode.Ink;
|
||||
private bool palmEraserLastIsHighlighter = false;
|
||||
private bool palmEraserWasEnabledBeforeMultiTouch = false;
|
||||
private bool palmEraserLastIsHighlighter;
|
||||
private bool palmEraserWasEnabledBeforeMultiTouch;
|
||||
|
||||
private void inkCanvas_PreviewTouchDown(object sender, TouchEventArgs e) {
|
||||
// 橡皮状态下不做任何切换,直接return,保证橡皮可持续
|
||||
@@ -358,7 +357,7 @@ namespace Ink_Canvas {
|
||||
if (drawingShapeMode != 0) {
|
||||
var mouseArgs = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left)
|
||||
{
|
||||
RoutedEvent = UIElement.MouseLeftButtonUpEvent,
|
||||
RoutedEvent = MouseLeftButtonUpEvent,
|
||||
Source = inkCanvas
|
||||
};
|
||||
inkCanvas_MouseUp(inkCanvas, mouseArgs);
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Interop;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Application = System.Windows.Application;
|
||||
using ContextMenu = System.Windows.Controls.ContextMenu;
|
||||
using MenuItem = System.Windows.Controls.MenuItem;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -21,7 +25,7 @@ namespace Ink_Canvas
|
||||
(TextBlock)((SimpleStackPanel)((MenuItem)s.Items[s.Items.Count - 5]).Header).Children[0];
|
||||
var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4];
|
||||
var HideICCMainWindowTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 9];
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
// 判斷是否在收納模式中
|
||||
if (mainWin.isFloatingBarFolded) {
|
||||
@@ -46,18 +50,18 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
private void CloseAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
App.IsAppExitByUser = true;
|
||||
Application.Current.Shutdown();
|
||||
IsAppExitByUser = true;
|
||||
Current.Shutdown();
|
||||
// mainWin.BtnExit_Click(null,null);
|
||||
}
|
||||
}
|
||||
|
||||
private void RestartAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
App.IsAppExitByUser = true;
|
||||
IsAppExitByUser = true;
|
||||
|
||||
try {
|
||||
// 启动新实例
|
||||
@@ -73,22 +77,22 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
// 退出当前实例
|
||||
Application.Current.Shutdown();
|
||||
Current.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void ForceFullScreenTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
Ink_Canvas.MainWindow.MoveWindow(new WindowInteropHelper(mainWin).Handle, 0, 0,
|
||||
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, true);
|
||||
Ink_Canvas.MainWindow.ShowNewMessage($"已强制全屏化:{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height}(缩放比例为{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / SystemParameters.PrimaryScreenHeight})");
|
||||
Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, true);
|
||||
Ink_Canvas.MainWindow.ShowNewMessage($"已强制全屏化:{Screen.PrimaryScreen.Bounds.Width}x{Screen.PrimaryScreen.Bounds.Height}(缩放比例为{Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth}x{Screen.PrimaryScreen.Bounds.Height / SystemParameters.PrimaryScreenHeight})");
|
||||
}
|
||||
}
|
||||
|
||||
private void FoldFloatingBarTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded)
|
||||
if (mainWin.isFloatingBarFolded) mainWin.UnFoldFloatingBar_MouseUp(new object(),null);
|
||||
else mainWin.FoldFloatingBar_MouseUp(new object(),null);
|
||||
@@ -96,7 +100,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void ResetFloatingBarPositionTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
var isInPPTPresentationMode = false;
|
||||
Dispatcher.Invoke(() => {
|
||||
@@ -111,10 +115,10 @@ namespace Ink_Canvas
|
||||
|
||||
private void HideICCMainWindowTrayIconMenuItem_Checked(object sender, RoutedEventArgs e) {
|
||||
var mi = (MenuItem)sender;
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
mainWin.Hide();
|
||||
var s = ((TaskbarIcon)Application.Current.Resources["TaskbarTrayIcon"]).ContextMenu;
|
||||
var s = ((TaskbarIcon)Current.Resources["TaskbarTrayIcon"]).ContextMenu;
|
||||
var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4];
|
||||
var FoldFloatingBarTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 5];
|
||||
var ForceFullScreenTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 6];
|
||||
@@ -132,10 +136,10 @@ namespace Ink_Canvas
|
||||
|
||||
private void HideICCMainWindowTrayIconMenuItem_UnChecked(object sender, RoutedEventArgs e) {
|
||||
var mi = (MenuItem)sender;
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
mainWin.Show();
|
||||
var s = ((TaskbarIcon)Application.Current.Resources["TaskbarTrayIcon"]).ContextMenu;
|
||||
var s = ((TaskbarIcon)Current.Resources["TaskbarTrayIcon"]).ContextMenu;
|
||||
var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4];
|
||||
var FoldFloatingBarTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 5];
|
||||
var ForceFullScreenTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 6];
|
||||
|
||||
+22
-16
@@ -8,10 +8,16 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.CodeDom.Compiler;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ink_Canvas.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
@@ -19,27 +25,27 @@ namespace Ink_Canvas.Properties {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[DebuggerNonUserCode()]
|
||||
[CompilerGenerated()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
private static ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
private static CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ink_Canvas.Properties.Resources", typeof(Resources).Assembly);
|
||||
if (ReferenceEquals(resourceMan, null)) {
|
||||
ResourceManager temp = new ResourceManager("Ink_Canvas.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
@@ -50,8 +56,8 @@ namespace Ink_Canvas.Properties {
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
@@ -63,7 +69,7 @@ namespace Ink_Canvas.Properties {
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream.
|
||||
/// </summary>
|
||||
internal static System.IO.UnmanagedMemoryStream TimerDownNotice {
|
||||
internal static UnmanagedMemoryStream TimerDownNotice {
|
||||
get {
|
||||
return ResourceManager.GetStream("TimerDownNotice", resourceCulture);
|
||||
}
|
||||
|
||||
+8
-4
@@ -8,14 +8,18 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Configuration;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ink_Canvas.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
[CompilerGenerated()]
|
||||
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")]
|
||||
internal sealed partial class Settings : ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
private static Settings defaultInstance = ((Settings)(Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public static class ChickenSoup {
|
||||
public static string[] OSUPlayerYuLu = new string[] {
|
||||
public static string[] OSUPlayerYuLu = {
|
||||
"澳洲原神,启动!",
|
||||
"一眼丁真,鉴定为玩osu!玩的",
|
||||
"喊MimosaM给我炒两菜",
|
||||
@@ -32,7 +32,7 @@
|
||||
"又有人2000了"
|
||||
};
|
||||
|
||||
public static string[] MingYanJingJu = new string[] {
|
||||
public static string[] MingYanJingJu = {
|
||||
"老骥伏枥,志在千里;烈士暮年,壮心不已",
|
||||
"有志者,事竟成",
|
||||
"有志者自有千方百计,无志者只感千难万难",
|
||||
@@ -98,7 +98,7 @@
|
||||
"有志不在年高,无志空活百岁",
|
||||
};
|
||||
|
||||
public static string[] GaoKaoPhrases = new string[] {
|
||||
public static string[] GaoKaoPhrases = {
|
||||
"以梦为马,不负韶华。祝你高考顺利,未来可期!",
|
||||
"高考顺利,愿你乘风破浪,前程似锦!",
|
||||
"愿你高考顺利,不负韶华,梦想成真!",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -35,19 +36,19 @@ namespace Ink_Canvas
|
||||
[JsonProperty("inkAlpha")]
|
||||
public double InkAlpha { get; set; } = 255;
|
||||
[JsonProperty("isShowCursor")]
|
||||
public bool IsShowCursor { get; set; } = false;
|
||||
public bool IsShowCursor { get; set; }
|
||||
[JsonProperty("inkStyle")]
|
||||
public int InkStyle { get; set; } = 0;
|
||||
public int InkStyle { get; set; }
|
||||
[JsonProperty("eraserSize")]
|
||||
public int EraserSize { get; set; } = 2;
|
||||
[JsonProperty("eraserType")]
|
||||
public int EraserType { get; set; } = 0; // 0 - 图标切换模式 1 - 面积擦 2 - 线条擦
|
||||
public int EraserType { get; set; } // 0 - 图标切换模式 1 - 面积擦 2 - 线条擦
|
||||
[JsonProperty("eraserShapeType")]
|
||||
public int EraserShapeType { get; set; } = 0; // 0 - 圆形擦 1 - 黑板擦
|
||||
public int EraserShapeType { get; set; } // 0 - 圆形擦 1 - 黑板擦
|
||||
[JsonProperty("hideStrokeWhenSelecting")]
|
||||
public bool HideStrokeWhenSelecting { get; set; } = true;
|
||||
[JsonProperty("fitToCurve")]
|
||||
public bool FitToCurve { get; set; } = false; // 默认关闭原来的贝塞尔平滑
|
||||
public bool FitToCurve { get; set; } // 默认关闭原来的贝塞尔平滑
|
||||
[JsonProperty("useAdvancedBezierSmoothing")]
|
||||
public bool UseAdvancedBezierSmoothing { get; set; } = true; // 默认启用高级贝塞尔曲线平滑
|
||||
[JsonProperty("useAsyncInkSmoothing")]
|
||||
@@ -57,13 +58,13 @@ namespace Ink_Canvas
|
||||
[JsonProperty("inkSmoothingQuality")]
|
||||
public int InkSmoothingQuality { get; set; } = 1; // 0-低质量高性能, 1-平衡, 2-高质量低性能
|
||||
[JsonProperty("maxConcurrentSmoothingTasks")]
|
||||
public int MaxConcurrentSmoothingTasks { get; set; } = 0; // 0表示自动检测CPU核心数
|
||||
public int MaxConcurrentSmoothingTasks { get; set; } // 0表示自动检测CPU核心数
|
||||
[JsonProperty("clearCanvasAndClearTimeMachine")]
|
||||
public bool ClearCanvasAndClearTimeMachine { get; set; } = false;
|
||||
public bool ClearCanvasAndClearTimeMachine { get; set; }
|
||||
[JsonProperty("enablePressureTouchMode")]
|
||||
public bool EnablePressureTouchMode { get; set; } = false; // 是否启用压感触屏模式
|
||||
public bool EnablePressureTouchMode { get; set; } // 是否启用压感触屏模式
|
||||
[JsonProperty("disablePressure")]
|
||||
public bool DisablePressure { get; set; } = false; // 是否屏蔽压感
|
||||
public bool DisablePressure { get; set; } // 是否屏蔽压感
|
||||
[JsonProperty("autoStraightenLine")]
|
||||
public bool AutoStraightenLine { get; set; } = true; // 是否启用直线自动拉直
|
||||
[JsonProperty("autoStraightenLineThreshold")]
|
||||
@@ -76,7 +77,7 @@ namespace Ink_Canvas
|
||||
public int LineEndpointSnappingThreshold { get; set; } = 15; // 直线端点吸附的距离阈值(像素)
|
||||
|
||||
[JsonProperty("usingWhiteboard")]
|
||||
public bool UsingWhiteboard { get; set; } = false;
|
||||
public bool UsingWhiteboard { get; set; }
|
||||
|
||||
[JsonProperty("customBackgroundColor")]
|
||||
public string CustomBackgroundColor { get; set; } = "#162924";
|
||||
@@ -84,7 +85,7 @@ namespace Ink_Canvas
|
||||
[JsonProperty("hyperbolaAsymptoteOption")]
|
||||
public OptionalOperation HyperbolaAsymptoteOption { get; set; } = OptionalOperation.Ask;
|
||||
[JsonProperty("isCompressPicturesUploaded")]
|
||||
public bool IsCompressPicturesUploaded { get; set; } = false;
|
||||
public bool IsCompressPicturesUploaded { get; set; }
|
||||
[JsonProperty("enablePalmEraser")]
|
||||
public bool EnablePalmEraser { get; set; } = true;
|
||||
[JsonProperty("clearCanvasAlsoClearImages")]
|
||||
@@ -113,9 +114,9 @@ namespace Ink_Canvas
|
||||
[JsonProperty("AutoSwitchTwoFingerGesture")]
|
||||
public bool AutoSwitchTwoFingerGesture { get; set; } = true;
|
||||
[JsonProperty("isEnableTwoFingerRotation")]
|
||||
public bool IsEnableTwoFingerRotation { get; set; } = false;
|
||||
public bool IsEnableTwoFingerRotation { get; set; }
|
||||
[JsonProperty("isEnableTwoFingerRotationOnSelection")]
|
||||
public bool IsEnableTwoFingerRotationOnSelection { get; set; } = false;
|
||||
public bool IsEnableTwoFingerRotationOnSelection { get; set; }
|
||||
}
|
||||
|
||||
// 更新通道枚举
|
||||
@@ -130,7 +131,7 @@ namespace Ink_Canvas
|
||||
[JsonProperty("isAutoUpdate")]
|
||||
public bool IsAutoUpdate { get; set; } = true;
|
||||
[JsonProperty("isAutoUpdateWithSilence")]
|
||||
public bool IsAutoUpdateWithSilence { get; set; } = false;
|
||||
public bool IsAutoUpdateWithSilence { get; set; }
|
||||
[JsonProperty("isAutoUpdateWithSilenceStartTime")]
|
||||
public string AutoUpdateWithSilenceStartTime { get; set; } = "06:00";
|
||||
[JsonProperty("isAutoUpdateWithSilenceEndTime")]
|
||||
@@ -140,11 +141,11 @@ namespace Ink_Canvas
|
||||
[JsonProperty("skippedVersion")]
|
||||
public string SkippedVersion { get; set; } = "";
|
||||
[JsonProperty("isEnableNibMode")]
|
||||
public bool IsEnableNibMode { get; set; } = false;
|
||||
public bool IsEnableNibMode { get; set; }
|
||||
[JsonProperty("isFoldAtStartup")]
|
||||
public bool IsFoldAtStartup { get; set; } = false;
|
||||
public bool IsFoldAtStartup { get; set; }
|
||||
[JsonProperty("crashAction")]
|
||||
public int CrashAction { get; set; } = 0;
|
||||
public int CrashAction { get; set; }
|
||||
}
|
||||
|
||||
public class Appearance
|
||||
@@ -152,13 +153,13 @@ namespace Ink_Canvas
|
||||
[JsonProperty("isEnableDisPlayNibModeToggler")]
|
||||
public bool IsEnableDisPlayNibModeToggler { get; set; } = true;
|
||||
[JsonProperty("isColorfulViewboxFloatingBar")]
|
||||
public bool IsColorfulViewboxFloatingBar { get; set; } = false;
|
||||
public bool IsColorfulViewboxFloatingBar { get; set; }
|
||||
// [JsonProperty("enableViewboxFloatingBarScaleTransform")]
|
||||
// public bool EnableViewboxFloatingBarScaleTransform { get; set; } = false;
|
||||
[JsonProperty("viewboxFloatingBarScaleTransformValue")]
|
||||
public double ViewboxFloatingBarScaleTransformValue { get; set; } = 1.0;
|
||||
[JsonProperty("floatingBarImg")]
|
||||
public int FloatingBarImg { get; set; } = 0;
|
||||
public int FloatingBarImg { get; set; }
|
||||
[JsonProperty("customFloatingBarImgs")]
|
||||
public List<CustomFloatingBarIcon> CustomFloatingBarImgs { get; set; } = new List<CustomFloatingBarIcon>();
|
||||
[JsonProperty("viewboxFloatingBarOpacityValue")]
|
||||
@@ -168,7 +169,7 @@ namespace Ink_Canvas
|
||||
[JsonProperty("viewboxFloatingBarOpacityInPPTValue")]
|
||||
public double ViewboxFloatingBarOpacityInPPTValue { get; set; } = 0.5;
|
||||
[JsonProperty("enableViewboxBlackBoardScaleTransform")]
|
||||
public bool EnableViewboxBlackBoardScaleTransform { get; set; } = false;
|
||||
public bool EnableViewboxBlackBoardScaleTransform { get; set; }
|
||||
[JsonProperty("isTransparentButtonBackground")]
|
||||
public bool IsTransparentButtonBackground { get; set; } = true;
|
||||
[JsonProperty("isShowExitButton")]
|
||||
@@ -180,11 +181,11 @@ namespace Ink_Canvas
|
||||
[JsonProperty("enableChickenSoupInWhiteboardMode")]
|
||||
public bool EnableChickenSoupInWhiteboardMode { get; set; } = true;
|
||||
[JsonProperty("isShowHideControlButton")]
|
||||
public bool IsShowHideControlButton { get; set; } = false;
|
||||
public bool IsShowHideControlButton { get; set; }
|
||||
[JsonProperty("unFoldButtonImageType")]
|
||||
public int UnFoldButtonImageType { get; set; } = 0;
|
||||
public int UnFoldButtonImageType { get; set; }
|
||||
[JsonProperty("isShowLRSwitchButton")]
|
||||
public bool IsShowLRSwitchButton { get; set; } = false;
|
||||
public bool IsShowLRSwitchButton { get; set; }
|
||||
[JsonProperty("isShowQuickPanel")]
|
||||
public bool IsShowQuickPanel { get; set; } = true;
|
||||
[JsonProperty("chickenSoupSource")]
|
||||
@@ -192,7 +193,7 @@ namespace Ink_Canvas
|
||||
[JsonProperty("isShowModeFingerToggleSwitch")]
|
||||
public bool IsShowModeFingerToggleSwitch { get; set; } = true;
|
||||
[JsonProperty("theme")]
|
||||
public int Theme { get; set; } = 0;
|
||||
public int Theme { get; set; }
|
||||
}
|
||||
|
||||
public class PowerPointSettings
|
||||
@@ -208,11 +209,11 @@ namespace Ink_Canvas
|
||||
|
||||
// 0居中,+就是往上,-就是往下
|
||||
[JsonProperty("pptLSButtonPosition")]
|
||||
public int PPTLSButtonPosition { get; set; } = 0;
|
||||
public int PPTLSButtonPosition { get; set; }
|
||||
|
||||
// 0居中,+就是往上,-就是往下
|
||||
[JsonProperty("pptRSButtonPosition")]
|
||||
public int PPTRSButtonPosition { get; set; } = 0;
|
||||
public int PPTRSButtonPosition { get; set; }
|
||||
|
||||
[JsonProperty("pptSButtonsOption")]
|
||||
public int PPTSButtonsOption { get; set; } = 221;
|
||||
@@ -232,27 +233,27 @@ namespace Ink_Canvas
|
||||
[JsonProperty("isNoClearStrokeOnSelectWhenInPowerPoint")]
|
||||
public bool IsNoClearStrokeOnSelectWhenInPowerPoint { get; set; } = true;
|
||||
[JsonProperty("isShowStrokeOnSelectInPowerPoint")]
|
||||
public bool IsShowStrokeOnSelectInPowerPoint { get; set; } = false;
|
||||
public bool IsShowStrokeOnSelectInPowerPoint { get; set; }
|
||||
[JsonProperty("isAutoSaveStrokesInPowerPoint")]
|
||||
public bool IsAutoSaveStrokesInPowerPoint { get; set; } = true;
|
||||
[JsonProperty("isAutoSaveScreenShotInPowerPoint")]
|
||||
public bool IsAutoSaveScreenShotInPowerPoint { get; set; } = false;
|
||||
public bool IsAutoSaveScreenShotInPowerPoint { get; set; }
|
||||
[JsonProperty("isNotifyPreviousPage")]
|
||||
public bool IsNotifyPreviousPage { get; set; } = false;
|
||||
public bool IsNotifyPreviousPage { get; set; }
|
||||
[JsonProperty("isNotifyHiddenPage")]
|
||||
public bool IsNotifyHiddenPage { get; set; } = true;
|
||||
[JsonProperty("isNotifyAutoPlayPresentation")]
|
||||
public bool IsNotifyAutoPlayPresentation { get; set; } = true;
|
||||
[JsonProperty("isEnableTwoFingerGestureInPresentationMode")]
|
||||
public bool IsEnableTwoFingerGestureInPresentationMode { get; set; } = false;
|
||||
public bool IsEnableTwoFingerGestureInPresentationMode { get; set; }
|
||||
[JsonProperty("isEnableFingerGestureSlideShowControl")]
|
||||
public bool IsEnableFingerGestureSlideShowControl { get; set; } = true;
|
||||
[JsonProperty("isSupportWPS")]
|
||||
public bool IsSupportWPS { get; set; } = false;
|
||||
public bool IsSupportWPS { get; set; }
|
||||
[JsonProperty("enableWppProcessKill")]
|
||||
public bool EnableWppProcessKill { get; set; } = true;
|
||||
[JsonProperty("isAlwaysGoToFirstPageOnReenter")]
|
||||
public bool IsAlwaysGoToFirstPageOnReenter { get; set; } = false;
|
||||
public bool IsAlwaysGoToFirstPageOnReenter { get; set; }
|
||||
}
|
||||
|
||||
public class Automation
|
||||
@@ -277,131 +278,131 @@ namespace Ink_Canvas
|
||||
|| IsAutoFoldInMaxHubWhiteboard;
|
||||
|
||||
[JsonProperty("isAutoEnterAnnotationModeWhenExitFoldMode")]
|
||||
public bool IsAutoEnterAnnotationModeWhenExitFoldMode { get; set; } = false;
|
||||
public bool IsAutoEnterAnnotationModeWhenExitFoldMode { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInEasiNote")]
|
||||
public bool IsAutoFoldInEasiNote { get; set; } = false;
|
||||
public bool IsAutoFoldInEasiNote { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInEasiNoteIgnoreDesktopAnno")]
|
||||
public bool IsAutoFoldInEasiNoteIgnoreDesktopAnno { get; set; } = false;
|
||||
public bool IsAutoFoldInEasiNoteIgnoreDesktopAnno { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInEasiCamera")]
|
||||
public bool IsAutoFoldInEasiCamera { get; set; } = false;
|
||||
public bool IsAutoFoldInEasiCamera { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInEasiNote3")]
|
||||
public bool IsAutoFoldInEasiNote3 { get; set; } = false;
|
||||
public bool IsAutoFoldInEasiNote3 { get; set; }
|
||||
[JsonProperty("isAutoFoldInEasiNote3C")]
|
||||
public bool IsAutoFoldInEasiNote3C { get; set; } = false;
|
||||
public bool IsAutoFoldInEasiNote3C { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInEasiNote5C")]
|
||||
public bool IsAutoFoldInEasiNote5C { get; set; } = false;
|
||||
public bool IsAutoFoldInEasiNote5C { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInSeewoPincoTeacher")]
|
||||
public bool IsAutoFoldInSeewoPincoTeacher { get; set; } = false;
|
||||
public bool IsAutoFoldInSeewoPincoTeacher { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInHiteTouchPro")]
|
||||
public bool IsAutoFoldInHiteTouchPro { get; set; } = false;
|
||||
public bool IsAutoFoldInHiteTouchPro { get; set; }
|
||||
[JsonProperty("isAutoFoldInHiteLightBoard")]
|
||||
public bool IsAutoFoldInHiteLightBoard { get; set; } = false;
|
||||
public bool IsAutoFoldInHiteLightBoard { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInHiteCamera")]
|
||||
public bool IsAutoFoldInHiteCamera { get; set; } = false;
|
||||
public bool IsAutoFoldInHiteCamera { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInWxBoardMain")]
|
||||
public bool IsAutoFoldInWxBoardMain { get; set; } = false;
|
||||
public bool IsAutoFoldInWxBoardMain { get; set; }
|
||||
/*
|
||||
[JsonProperty("isAutoFoldInZySmartBoard")]
|
||||
public bool IsAutoFoldInZySmartBoard { get; set; } = false;
|
||||
*/
|
||||
[JsonProperty("isAutoFoldInOldZyBoard")]
|
||||
public bool IsAutoFoldInOldZyBoard { get; set; } = false;
|
||||
public bool IsAutoFoldInOldZyBoard { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInMSWhiteboard")]
|
||||
public bool IsAutoFoldInMSWhiteboard { get; set; } = false;
|
||||
public bool IsAutoFoldInMSWhiteboard { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInAdmoxWhiteboard")]
|
||||
public bool IsAutoFoldInAdmoxWhiteboard { get; set; } = false;
|
||||
public bool IsAutoFoldInAdmoxWhiteboard { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInAdmoxBooth")]
|
||||
public bool IsAutoFoldInAdmoxBooth { get; set; } = false;
|
||||
public bool IsAutoFoldInAdmoxBooth { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInQPoint")]
|
||||
public bool IsAutoFoldInQPoint { get; set; } = false;
|
||||
public bool IsAutoFoldInQPoint { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInYiYunVisualPresenter")]
|
||||
public bool IsAutoFoldInYiYunVisualPresenter { get; set; } = false;
|
||||
public bool IsAutoFoldInYiYunVisualPresenter { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInMaxHubWhiteboard")]
|
||||
public bool IsAutoFoldInMaxHubWhiteboard { get; set; } = false;
|
||||
public bool IsAutoFoldInMaxHubWhiteboard { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldInPPTSlideShow")]
|
||||
public bool IsAutoFoldInPPTSlideShow { get; set; } = false;
|
||||
public bool IsAutoFoldInPPTSlideShow { get; set; }
|
||||
|
||||
[JsonProperty("isAutoFoldAfterPPTSlideShow")]
|
||||
public bool IsAutoFoldAfterPPTSlideShow { get; set; } = false;
|
||||
public bool IsAutoFoldAfterPPTSlideShow { get; set; }
|
||||
|
||||
[JsonProperty("isAutoKillPptService")]
|
||||
public bool IsAutoKillPptService { get; set; } = false;
|
||||
public bool IsAutoKillPptService { get; set; }
|
||||
|
||||
[JsonProperty("isAutoKillEasiNote")]
|
||||
public bool IsAutoKillEasiNote { get; set; } = false;
|
||||
public bool IsAutoKillEasiNote { get; set; }
|
||||
|
||||
[JsonProperty("isAutoKillHiteAnnotation")]
|
||||
public bool IsAutoKillHiteAnnotation { get; set; } = false;
|
||||
public bool IsAutoKillHiteAnnotation { get; set; }
|
||||
|
||||
[JsonProperty("isAutoKillVComYouJiao")]
|
||||
public bool IsAutoKillVComYouJiao { get; set; } = false;
|
||||
public bool IsAutoKillVComYouJiao { get; set; }
|
||||
|
||||
[JsonProperty("isAutoKillSeewoLauncher2DesktopAnnotation")]
|
||||
public bool IsAutoKillSeewoLauncher2DesktopAnnotation { get; set; } = false;
|
||||
public bool IsAutoKillSeewoLauncher2DesktopAnnotation { get; set; }
|
||||
|
||||
[JsonProperty("isAutoKillInkCanvas")]
|
||||
public bool IsAutoKillInkCanvas { get; set; } = false;
|
||||
public bool IsAutoKillInkCanvas { get; set; }
|
||||
|
||||
[JsonProperty("isAutoKillICA")]
|
||||
public bool IsAutoKillICA { get; set; } = false;
|
||||
public bool IsAutoKillICA { get; set; }
|
||||
|
||||
[JsonProperty("isAutoKillIDT")]
|
||||
public bool IsAutoKillIDT { get; set; } = false;
|
||||
public bool IsAutoKillIDT { get; set; }
|
||||
|
||||
[JsonProperty("isSaveScreenshotsInDateFolders")]
|
||||
public bool IsSaveScreenshotsInDateFolders { get; set; } = false;
|
||||
public bool IsSaveScreenshotsInDateFolders { get; set; }
|
||||
|
||||
[JsonProperty("isAutoSaveStrokesAtScreenshot")]
|
||||
public bool IsAutoSaveStrokesAtScreenshot { get; set; } = false;
|
||||
public bool IsAutoSaveStrokesAtScreenshot { get; set; }
|
||||
|
||||
[JsonProperty("isAutoSaveStrokesAtClear")]
|
||||
public bool IsAutoSaveStrokesAtClear { get; set; } = false;
|
||||
public bool IsAutoSaveStrokesAtClear { get; set; }
|
||||
|
||||
[JsonProperty("isAutoClearWhenExitingWritingMode")]
|
||||
public bool IsAutoClearWhenExitingWritingMode { get; set; } = false;
|
||||
public bool IsAutoClearWhenExitingWritingMode { get; set; }
|
||||
|
||||
[JsonProperty("minimumAutomationStrokeNumber")]
|
||||
public int MinimumAutomationStrokeNumber { get; set; } = 0;
|
||||
public int MinimumAutomationStrokeNumber { get; set; }
|
||||
|
||||
[JsonProperty("autoSavedStrokesLocation")]
|
||||
public string AutoSavedStrokesLocation = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "saves");
|
||||
public string AutoSavedStrokesLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "saves");
|
||||
|
||||
[JsonProperty("autoDelSavedFiles")]
|
||||
public bool AutoDelSavedFiles = false;
|
||||
public bool AutoDelSavedFiles;
|
||||
|
||||
[JsonProperty("autoDelSavedFilesDaysThreshold")]
|
||||
public int AutoDelSavedFilesDaysThreshold = 15;
|
||||
|
||||
[JsonProperty("isSaveFullPageStrokes")]
|
||||
public bool IsSaveFullPageStrokes = false;
|
||||
public bool IsSaveFullPageStrokes;
|
||||
|
||||
[JsonProperty("isAutoEnterAnnotationAfterKillHite")]
|
||||
public bool IsAutoEnterAnnotationAfterKillHite { get; set; } = false;
|
||||
public bool IsAutoEnterAnnotationAfterKillHite { get; set; }
|
||||
}
|
||||
|
||||
public class Advanced
|
||||
{
|
||||
[JsonProperty("isSpecialScreen")]
|
||||
public bool IsSpecialScreen { get; set; } = false;
|
||||
public bool IsSpecialScreen { get; set; }
|
||||
|
||||
[JsonProperty("isQuadIR")]
|
||||
public bool IsQuadIR { get; set; } = false;
|
||||
public bool IsQuadIR { get; set; }
|
||||
|
||||
[JsonProperty("touchMultiplier")]
|
||||
public double TouchMultiplier { get; set; } = 0.25;
|
||||
@@ -413,7 +414,7 @@ namespace Ink_Canvas
|
||||
public int FingerModeBoundsWidth { get; set; } = 30;
|
||||
|
||||
[JsonProperty("eraserBindTouchMultiplier")]
|
||||
public bool EraserBindTouchMultiplier { get; set; } = false;
|
||||
public bool EraserBindTouchMultiplier { get; set; }
|
||||
|
||||
[JsonProperty("isLogEnabled")]
|
||||
public bool IsLogEnabled { get; set; } = true;
|
||||
@@ -422,28 +423,28 @@ namespace Ink_Canvas
|
||||
public bool IsSaveLogByDate { get; set; } = true;
|
||||
|
||||
[JsonProperty("isEnableFullScreenHelper")]
|
||||
public bool IsEnableFullScreenHelper { get; set; } = false;
|
||||
public bool IsEnableFullScreenHelper { get; set; }
|
||||
|
||||
[JsonProperty("isEnableEdgeGestureUtil")]
|
||||
public bool IsEnableEdgeGestureUtil { get; set; } = false;
|
||||
public bool IsEnableEdgeGestureUtil { get; set; }
|
||||
|
||||
[JsonProperty("edgeGestureUtilOnlyAffectBlackboardMode")]
|
||||
public bool EdgeGestureUtilOnlyAffectBlackboardMode { get; set; } = false;
|
||||
public bool EdgeGestureUtilOnlyAffectBlackboardMode { get; set; }
|
||||
|
||||
[JsonProperty("isEnableForceFullScreen")]
|
||||
public bool IsEnableForceFullScreen { get; set; } = false;
|
||||
public bool IsEnableForceFullScreen { get; set; }
|
||||
|
||||
[JsonProperty("isEnableResolutionChangeDetection")]
|
||||
public bool IsEnableResolutionChangeDetection { get; set; } = false;
|
||||
public bool IsEnableResolutionChangeDetection { get; set; }
|
||||
|
||||
[JsonProperty("isEnableDPIChangeDetection")]
|
||||
public bool IsEnableDPIChangeDetection { get; set; } = false;
|
||||
public bool IsEnableDPIChangeDetection { get; set; }
|
||||
|
||||
[JsonProperty("isSecondConfirmWhenShutdownApp")]
|
||||
public bool IsSecondConfirmWhenShutdownApp { get; set; } = false;
|
||||
public bool IsSecondConfirmWhenShutdownApp { get; set; }
|
||||
|
||||
[JsonProperty("isEnableAvoidFullScreenHelper")]
|
||||
public bool IsEnableAvoidFullScreenHelper { get; set; } = false;
|
||||
public bool IsEnableAvoidFullScreenHelper { get; set; }
|
||||
|
||||
[JsonProperty("isAutoBackupBeforeUpdate")]
|
||||
public bool IsAutoBackupBeforeUpdate { get; set; } = true;
|
||||
@@ -457,9 +458,9 @@ namespace Ink_Canvas
|
||||
[JsonProperty("isInkToShapeEnabled")]
|
||||
public bool IsInkToShapeEnabled { get; set; } = true;
|
||||
[JsonProperty("isInkToShapeNoFakePressureRectangle")]
|
||||
public bool IsInkToShapeNoFakePressureRectangle { get; set; } = false;
|
||||
public bool IsInkToShapeNoFakePressureRectangle { get; set; }
|
||||
[JsonProperty("isInkToShapeNoFakePressureTriangle")]
|
||||
public bool IsInkToShapeNoFakePressureTriangle { get; set; } = false;
|
||||
public bool IsInkToShapeNoFakePressureTriangle { get; set; }
|
||||
[JsonProperty("isInkToShapeTriangle")]
|
||||
public bool IsInkToShapeTriangle { get; set; } = true;
|
||||
[JsonProperty("isInkToShapeRectangle")]
|
||||
@@ -472,7 +473,7 @@ namespace Ink_Canvas
|
||||
|
||||
public class RandSettings {
|
||||
[JsonProperty("displayRandWindowNamesInputBtn")]
|
||||
public bool DisplayRandWindowNamesInputBtn { get; set; } = false;
|
||||
public bool DisplayRandWindowNamesInputBtn { get; set; }
|
||||
[JsonProperty("randWindowOnceCloseLatency")]
|
||||
public double RandWindowOnceCloseLatency { get; set; } = 2.5;
|
||||
[JsonProperty("randWindowOnceMaxStudents")]
|
||||
@@ -480,9 +481,9 @@ namespace Ink_Canvas
|
||||
[JsonProperty("showRandomAndSingleDraw")]
|
||||
public bool ShowRandomAndSingleDraw { get; set; } = true;
|
||||
[JsonProperty("directCallCiRand")]
|
||||
public bool DirectCallCiRand { get; set; } = false;
|
||||
public bool DirectCallCiRand { get; set; }
|
||||
[JsonProperty("selectedBackgroundIndex")]
|
||||
public int SelectedBackgroundIndex { get; set; } = 0;
|
||||
public int SelectedBackgroundIndex { get; set; }
|
||||
[JsonProperty("customPickNameBackgrounds")]
|
||||
public List<CustomPickNameBackground> CustomPickNameBackgrounds { get; set; } = new List<CustomPickNameBackground>();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
@@ -109,7 +109,7 @@ namespace Ink_Canvas
|
||||
MainWindow.SaveSettingsToFile();
|
||||
|
||||
IsSuccess = true;
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
@@ -110,7 +110,7 @@ namespace Ink_Canvas
|
||||
MainWindow.SaveSettingsToFile();
|
||||
|
||||
IsSuccess = true;
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Media;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Application = System.Windows.Application;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -51,7 +57,7 @@ namespace Ink_Canvas
|
||||
TextBlockSecond.Text = "00";
|
||||
timer.Stop();
|
||||
isTimerRunning = false;
|
||||
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play;
|
||||
SymbolIconStart.Symbol = Symbol.Play;
|
||||
BtnStartCover.Visibility = Visibility.Visible;
|
||||
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
|
||||
BorderStopTime.Visibility = Visibility.Collapsed;
|
||||
@@ -70,16 +76,16 @@ namespace Ink_Canvas
|
||||
|
||||
SoundPlayer player = new SoundPlayer();
|
||||
|
||||
int hour = 0;
|
||||
int hour;
|
||||
int minute = 1;
|
||||
int second = 0;
|
||||
int second;
|
||||
int totalSeconds = 60;
|
||||
|
||||
DateTime startTime = DateTime.Now;
|
||||
DateTime pauseTime = DateTime.Now;
|
||||
|
||||
bool isTimerRunning = false;
|
||||
bool isPaused = false;
|
||||
bool isTimerRunning;
|
||||
bool isPaused;
|
||||
|
||||
Timer timer = new Timer();
|
||||
|
||||
@@ -202,12 +208,12 @@ namespace Ink_Canvas
|
||||
if (WindowState == WindowState.Normal)
|
||||
{
|
||||
WindowState = WindowState.Maximized;
|
||||
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.BackToWindow;
|
||||
SymbolIconFullscreen.Symbol = Symbol.BackToWindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = WindowState.Normal;
|
||||
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.FullScreen;
|
||||
SymbolIconFullscreen.Symbol = Symbol.FullScreen;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +228,6 @@ namespace Ink_Canvas
|
||||
BtnStartCover.Visibility = Visibility.Collapsed;
|
||||
BorderStopTime.Visibility = Visibility.Collapsed;
|
||||
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
|
||||
return;
|
||||
}
|
||||
else if (isTimerRunning && isPaused)
|
||||
{
|
||||
@@ -233,7 +238,7 @@ namespace Ink_Canvas
|
||||
BtnStartCover.Visibility = Visibility.Collapsed;
|
||||
BorderStopTime.Visibility = Visibility.Collapsed;
|
||||
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
|
||||
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play;
|
||||
SymbolIconStart.Symbol = Symbol.Play;
|
||||
isTimerRunning = false;
|
||||
timer.Stop();
|
||||
isPaused = false;
|
||||
@@ -283,7 +288,7 @@ namespace Ink_Canvas
|
||||
startTime += DateTime.Now - pauseTime;
|
||||
ProcessBarTime.IsPaused = false;
|
||||
TextBlockHour.Foreground = Brushes.Black;
|
||||
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Pause;
|
||||
SymbolIconStart.Symbol = Symbol.Pause;
|
||||
isPaused = false;
|
||||
timer.Start();
|
||||
UpdateStopTime();
|
||||
@@ -295,7 +300,7 @@ namespace Ink_Canvas
|
||||
pauseTime = DateTime.Now;
|
||||
ProcessBarTime.IsPaused = true;
|
||||
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
|
||||
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play;
|
||||
SymbolIconStart.Symbol = Symbol.Play;
|
||||
BorderStopTime.Visibility = Visibility.Collapsed;
|
||||
isPaused = true;
|
||||
timer.Stop();
|
||||
@@ -307,7 +312,7 @@ namespace Ink_Canvas
|
||||
totalSeconds = ((hour * 60) + minute) * 60 + second;
|
||||
ProcessBarTime.IsPaused = false;
|
||||
TextBlockHour.Foreground = Brushes.Black;
|
||||
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Pause;
|
||||
SymbolIconStart.Symbol = Symbol.Pause;
|
||||
BtnResetCover.Visibility = Visibility.Collapsed;
|
||||
|
||||
if (totalSeconds <= 10)
|
||||
@@ -335,7 +340,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
isTimerRunning = false;
|
||||
}
|
||||
@@ -345,7 +350,7 @@ namespace Ink_Canvas
|
||||
Close();
|
||||
}
|
||||
|
||||
private bool _isInCompact = false;
|
||||
private bool _isInCompact;
|
||||
|
||||
private void BtnMinimal_OnMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
@@ -364,7 +369,7 @@ namespace Ink_Canvas
|
||||
dpiScaleY = source.CompositionTarget.TransformToDevice.M22;
|
||||
}
|
||||
IntPtr windowHandle = new WindowInteropHelper(this).Handle;
|
||||
System.Windows.Forms.Screen screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
Screen screen = Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
Left = (screenWidth / 2) - (Width / 2);
|
||||
Top = (screenHeight / 2) - (Height / 2);
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ namespace Ink_Canvas.ProcessBars
|
||||
//达到100%则闭合整个
|
||||
if (angel == 360)
|
||||
{
|
||||
myCycleProcessBar.Data = Geometry.Parse(myCycleProcessBar.Data.ToString() + " z");
|
||||
myCycleProcessBar.Data = Geometry.Parse(myCycleProcessBar.Data + " z");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using MdXaml;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -98,7 +101,7 @@ namespace Ink_Canvas
|
||||
UseImmersiveDarkMode(new WindowInteropHelper(this).Handle, true);
|
||||
|
||||
// 窗口加载完成后再次确保按钮可见
|
||||
this.Loaded += HasNewUpdateWindow_Loaded;
|
||||
Loaded += HasNewUpdateWindow_Loaded;
|
||||
}
|
||||
|
||||
private void HasNewUpdateWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
@@ -231,35 +234,35 @@ namespace Ink_Canvas
|
||||
bool needsAdjustment = false;
|
||||
|
||||
// 如果窗口高度超过最大允许高度,调整窗口高度
|
||||
if (this.Height > maxHeight)
|
||||
if (Height > maxHeight)
|
||||
{
|
||||
this.Height = maxHeight;
|
||||
Height = maxHeight;
|
||||
needsAdjustment = true;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window height to: {this.Height}");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window height to: {Height}");
|
||||
}
|
||||
|
||||
// 如果窗口宽度超过最大允许宽度,调整窗口宽度
|
||||
if (this.Width > maxWidth)
|
||||
if (Width > maxWidth)
|
||||
{
|
||||
this.Width = maxWidth;
|
||||
Width = maxWidth;
|
||||
needsAdjustment = true;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window width to: {this.Width}");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window width to: {Width}");
|
||||
}
|
||||
|
||||
// 如果屏幕分辨率较低,调整更多UI元素
|
||||
if (screenHeight < 768 || screenWidth < 1024 || needsAdjustment)
|
||||
{
|
||||
// 查找相关控件并调整大小
|
||||
var markdownViewer = this.FindName("markdownContent") as MdXaml.MarkdownScrollViewer;
|
||||
var updateNowButton = this.FindName("UpdateNowButton") as Button;
|
||||
var updateLaterButton = this.FindName("UpdateLaterButton") as Button;
|
||||
var skipVersionButton = this.FindName("SkipVersionButton") as Button;
|
||||
var markdownViewer = FindName("markdownContent") as MarkdownScrollViewer;
|
||||
var updateNowButton = FindName("UpdateNowButton") as Button;
|
||||
var updateLaterButton = FindName("UpdateLaterButton") as Button;
|
||||
var skipVersionButton = FindName("SkipVersionButton") as Button;
|
||||
|
||||
// 查找包含ScrollViewer的边框控件,减小其高度
|
||||
var contentBorders = this.FindVisualChildren<Border>().ToList();
|
||||
var contentBorders = FindVisualChildren<Border>().ToList();
|
||||
foreach (var border in contentBorders)
|
||||
{
|
||||
if (border.Child is ScrollViewer || border.Child is iNKORE.UI.WPF.Modern.Controls.ScrollViewerEx)
|
||||
if (border.Child is ScrollViewer || border.Child is ScrollViewerEx)
|
||||
{
|
||||
// 减小内容显示区域的高度
|
||||
if (border.Height > 180)
|
||||
@@ -267,7 +270,7 @@ namespace Ink_Canvas
|
||||
border.Height = 160;
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Reduced content area height");
|
||||
}
|
||||
else if (border.Child is iNKORE.UI.WPF.Modern.Controls.ScrollViewerEx scrollViewer && scrollViewer.Height > 160)
|
||||
else if (border.Child is ScrollViewerEx scrollViewer && scrollViewer.Height > 160)
|
||||
{
|
||||
scrollViewer.Height = 160;
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Reduced scroll viewer height");
|
||||
@@ -289,12 +292,12 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
// 确保窗口在屏幕范围内
|
||||
if (this.Left < 0) this.Left = 0;
|
||||
if (this.Top < 0) this.Top = 0;
|
||||
if (this.Left + this.Width > screenWidth) this.Left = screenWidth - this.Width;
|
||||
if (this.Top + this.Height > screenHeight) this.Top = screenHeight - this.Height;
|
||||
if (Left < 0) Left = 0;
|
||||
if (Top < 0) Top = 0;
|
||||
if (Left + Width > screenWidth) Left = screenWidth - Width;
|
||||
if (Top + Height > screenHeight) Top = screenHeight - Height;
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Final window size: {this.Width}x{this.Height}");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Final window size: {Width}x{Height}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -332,7 +335,7 @@ namespace Ink_Canvas
|
||||
if (string.IsNullOrEmpty(downloadUrl))
|
||||
{
|
||||
// 自动更新场景下,downloadUrl为null,直接用主下载目录
|
||||
string updatesFolderPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "AutoUpdate");
|
||||
string updatesFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate");
|
||||
downloadUrl = Path.Combine(updatesFolderPath, $"InkCanvasForClass.CE.{version}.zip");
|
||||
}
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 开始安装版本: {version}");
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Linq; // Added for OrderByDescending
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using Ink_Canvas.Helpers;
|
||||
// Added for OrderByDescending
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -22,7 +22,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
private List<VersionItem> versionList = new List<VersionItem>();
|
||||
private VersionItem selectedItem = null;
|
||||
private VersionItem selectedItem;
|
||||
private UpdateChannel channel = UpdateChannel.Release;
|
||||
private CancellationTokenSource downloadCts = null;
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Ink_Canvas
|
||||
else
|
||||
{
|
||||
ReleaseNotesViewer.Markdown = "未获取到历史版本信息。";
|
||||
LogHelper.WriteLogToFile($"HistoryRollback | 未获取到历史版本信息", LogHelper.LogType.Warning);
|
||||
LogHelper.WriteLogToFile("HistoryRollback | 未获取到历史版本信息", LogHelper.LogType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,8 +122,8 @@ namespace Ink_Canvas
|
||||
DownloadProgressBar.Value = 100;
|
||||
DownloadProgressText.Text = "下载完成,准备安装...";
|
||||
await Task.Delay(800);
|
||||
this.DialogResult = true;
|
||||
this.Close();
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (originText != TextBoxNames.Text)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -28,10 +29,10 @@ namespace Ink_Canvas
|
||||
private void BtnFullscreen_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (WindowState == WindowState.Normal) {
|
||||
WindowState = WindowState.Maximized;
|
||||
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.BackToWindow;
|
||||
SymbolIconFullscreen.Symbol = Symbol.BackToWindow;
|
||||
} else {
|
||||
WindowState = WindowState.Normal;
|
||||
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.FullScreen;
|
||||
SymbolIconFullscreen.Symbol = Symbol.FullScreen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
using Ink_Canvas.Helpers.Plugins;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Threading;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System.Linq;
|
||||
using Ink_Canvas.Helpers.Plugins;
|
||||
using Ink_Canvas.Helpers.Plugins.BuiltIn;
|
||||
using Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Microsoft.Win32;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
namespace Ink_Canvas.Windows
|
||||
{
|
||||
@@ -36,7 +41,7 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
|
||||
OnPropertyChanged(nameof(SelectedPlugin));
|
||||
LogHelper.WriteLogToFile("插件列表已刷新", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("插件列表已刷新");
|
||||
}
|
||||
|
||||
private IPlugin _selectedPlugin;
|
||||
@@ -90,20 +95,20 @@ namespace Ink_Canvas.Windows
|
||||
LoadPlugins();
|
||||
|
||||
// 注册窗口关闭事件
|
||||
this.Closing += PluginSettingsWindow_Closing;
|
||||
Closing += PluginSettingsWindow_Closing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口关闭事件处理
|
||||
/// </summary>
|
||||
private void PluginSettingsWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
private void PluginSettingsWindow_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 保存插件配置
|
||||
LogHelper.WriteLogToFile("插件管理窗口关闭,保存插件配置...", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("插件管理窗口关闭,保存插件配置...");
|
||||
PluginManager.Instance.SaveConfig();
|
||||
LogHelper.WriteLogToFile("插件配置已保存", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("插件配置已保存");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -118,7 +123,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
Plugins.Clear();
|
||||
|
||||
LogHelper.WriteLogToFile($"开始加载插件列表到UI,插件总数: {PluginManager.Instance.Plugins.Count}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"开始加载插件列表到UI,插件总数: {PluginManager.Instance.Plugins.Count}");
|
||||
|
||||
// 添加所有已加载的插件
|
||||
foreach (var plugin in PluginManager.Instance.Plugins)
|
||||
@@ -132,8 +137,7 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
|
||||
// 记录插件详细信息
|
||||
LogHelper.WriteLogToFile($"正在加载插件到UI: 类型={plugin.GetType().FullName}, 名称={plugin.Name ?? "未命名"}, 状态={isEnabled}",
|
||||
LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"正在加载插件到UI: 类型={plugin.GetType().FullName}, 名称={plugin.Name ?? "未命名"}, 状态={isEnabled}");
|
||||
|
||||
// 创建视图模型并添加到集合
|
||||
var viewModel = new PluginViewModel(plugin)
|
||||
@@ -142,17 +146,17 @@ namespace Ink_Canvas.Windows
|
||||
};
|
||||
Plugins.Add(viewModel);
|
||||
|
||||
LogHelper.WriteLogToFile($"已加载插件到UI列表: {plugin.Name},状态: {(isEnabled ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已加载插件到UI列表: {plugin.Name},状态: {(isEnabled ? "启用" : "禁用")}");
|
||||
}
|
||||
|
||||
// 绑定到ListView
|
||||
LogHelper.WriteLogToFile($"绑定 {Plugins.Count} 个插件到ListView", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"绑定 {Plugins.Count} 个插件到ListView");
|
||||
PluginListView.ItemsSource = Plugins;
|
||||
|
||||
// 如果有插件,选择第一个
|
||||
if (Plugins.Count > 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"选择第一个插件: {Plugins[0].Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"选择第一个插件: {Plugins[0].Name}");
|
||||
PluginListView.SelectedIndex = 0;
|
||||
}
|
||||
else
|
||||
@@ -389,7 +393,7 @@ namespace Ink_Canvas.Windows
|
||||
File.Copy(pluginPath, targetPath, true);
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {SelectedPlugin.Name} 已成功导出到: {targetPath}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {SelectedPlugin.Name} 已成功导出到: {targetPath}");
|
||||
MessageBox.Show($"插件 {SelectedPlugin.Name} 已成功导出!", "成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
@@ -407,7 +411,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sender is iNKORE.UI.WPF.Modern.Controls.ToggleSwitch toggleSwitch &&
|
||||
if (sender is ToggleSwitch toggleSwitch &&
|
||||
toggleSwitch.Tag is IPlugin plugin)
|
||||
{
|
||||
// 记录当前开关状态
|
||||
@@ -418,14 +422,14 @@ namespace Ink_Canvas.Windows
|
||||
string pluginName = plugin.Name;
|
||||
bool wasBuiltIn = plugin.IsBuiltIn;
|
||||
|
||||
LogHelper.WriteLogToFile($"UI开关切换: {pluginName}, 目标状态: {(targetState ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"UI开关切换: {pluginName}, 目标状态: {(targetState ? "启用" : "禁用")}");
|
||||
|
||||
// 切换插件状态
|
||||
PluginManager.Instance.TogglePlugin(plugin, targetState);
|
||||
|
||||
// 立即同步保存配置到文件(确保状态被立即持久化)
|
||||
PluginManager.Instance.SaveConfig();
|
||||
LogHelper.WriteLogToFile($"插件状态已立即保存到配置文件", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("插件状态已立即保存到配置文件");
|
||||
|
||||
// 延迟一下再检查状态,确保变更已应用
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
@@ -451,7 +455,7 @@ namespace Ink_Canvas.Windows
|
||||
|
||||
// 检查实际状态
|
||||
bool actualState = currentPlugin is PluginBase pb && pb.IsEnabled;
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 实际状态: {(actualState ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 实际状态: {(actualState ? "启用" : "禁用")}");
|
||||
|
||||
// 更新视图模型
|
||||
PluginViewModel viewModel = null;
|
||||
@@ -469,14 +473,14 @@ namespace Ink_Canvas.Windows
|
||||
// 确保视图模型状态与实际状态一致
|
||||
if (viewModel.IsEnabled != actualState)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"同步视图模型状态: {(actualState ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"同步视图模型状态: {(actualState ? "启用" : "禁用")}");
|
||||
viewModel.IsEnabled = actualState;
|
||||
}
|
||||
|
||||
// 确保UI开关状态与实际状态一致
|
||||
if (toggleSwitch.IsOn != actualState)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"同步UI开关状态: {(actualState ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"同步UI开关状态: {(actualState ? "启用" : "禁用")}");
|
||||
toggleSwitch.IsOn = actualState;
|
||||
}
|
||||
}
|
||||
@@ -491,21 +495,21 @@ namespace Ink_Canvas.Windows
|
||||
if (wasBuiltIn)
|
||||
{
|
||||
// 特殊插件刷新逻辑,如果是超级启动台插件,立即刷新UI
|
||||
if (currentPlugin is Helpers.Plugins.BuiltIn.SuperLauncherPlugin &&
|
||||
PluginSettingsContainer.Content is Helpers.Plugins.BuiltIn.SuperLauncher.LauncherSettingsControl)
|
||||
if (currentPlugin is SuperLauncherPlugin &&
|
||||
PluginSettingsContainer.Content is LauncherSettingsControl)
|
||||
{
|
||||
// 重新获取设置界面
|
||||
PluginSettingsContainer.Content = currentPlugin.GetSettingsView();
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} UI状态同步完成", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} UI状态同步完成");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"同步UI状态时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}), System.Windows.Threading.DispatcherPriority.Background);
|
||||
}), DispatcherPriority.Background);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -567,7 +571,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
// 应用界面的状态到插件
|
||||
PluginManager.Instance.TogglePlugin(actualPlugin, uiState);
|
||||
LogHelper.WriteLogToFile($"手动保存:同步插件 {actualPlugin.Name} 状态 {pluginState} -> {uiState}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"手动保存:同步插件 {actualPlugin.Name} 状态 {pluginState} -> {uiState}");
|
||||
syncCount++;
|
||||
}
|
||||
|
||||
@@ -575,7 +579,7 @@ namespace Ink_Canvas.Windows
|
||||
if (PluginManager.Instance.PluginStates.TryGetValue(pluginTypeName, out bool configState) && configState != uiState)
|
||||
{
|
||||
PluginManager.Instance.PluginStates[pluginTypeName] = uiState;
|
||||
LogHelper.WriteLogToFile($"手动保存:更新配置中插件 {actualPlugin.Name} 状态 {configState} -> {uiState}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"手动保存:更新配置中插件 {actualPlugin.Name} 状态 {configState} -> {uiState}");
|
||||
syncCount++;
|
||||
}
|
||||
}
|
||||
@@ -591,7 +595,7 @@ namespace Ink_Canvas.Windows
|
||||
PluginManager.Instance.SaveConfig();
|
||||
|
||||
// 记录日志
|
||||
LogHelper.WriteLogToFile($"用户手动保存插件状态配置,同步了 {syncCount} 个状态变更", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"用户手动保存插件状态配置,同步了 {syncCount} 个状态变更");
|
||||
|
||||
// 刷新插件列表,确保UI与最新状态同步
|
||||
RefreshPluginList();
|
||||
@@ -642,7 +646,7 @@ namespace Ink_Canvas.Windows
|
||||
get
|
||||
{
|
||||
string name = Plugin?.Name ?? "未命名插件";
|
||||
LogHelper.WriteLogToFile($"获取插件名称: {name},类型: {Plugin?.GetType().FullName ?? "未知"}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"获取插件名称: {name},类型: {Plugin?.GetType().FullName ?? "未知"}");
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -672,7 +676,7 @@ namespace Ink_Canvas.Windows
|
||||
_isEnabled = plugin is PluginBase pluginBase && pluginBase.IsEnabled;
|
||||
|
||||
// 记录日志
|
||||
LogHelper.WriteLogToFile($"创建插件视图模型: {plugin?.GetType().FullName ?? "未知"}, 名称: {plugin?.Name ?? "未命名"}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"创建插件视图模型: {plugin?.GetType().FullName ?? "未知"}, 名称: {plugin?.Name ?? "未命名"}");
|
||||
|
||||
// 注册插件状态变更事件
|
||||
if (plugin is PluginBase pb)
|
||||
@@ -694,9 +698,9 @@ namespace Ink_Canvas.Windows
|
||||
// 确保配置立即保存
|
||||
if (sender is IPlugin plugin)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"视图模型捕获到插件 {plugin.Name} 状态变更: {(isEnabled ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
Helpers.Plugins.PluginManager.Instance.SaveConfig();
|
||||
LogHelper.WriteLogToFile($"视图模型已触发配置保存", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"视图模型捕获到插件 {plugin.Name} 状态变更: {(isEnabled ? "启用" : "禁用")}");
|
||||
PluginManager.Instance.SaveConfig();
|
||||
LogHelper.WriteLogToFile("视图模型已触发配置保存");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Microsoft.VisualBasic;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Microsoft.VisualBasic;
|
||||
using MessageBox = iNKORE.UI.WPF.Modern.Controls.MessageBox;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
@@ -35,7 +38,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
// 默认背景(无背景)
|
||||
BackgroundImage.ImageSource = null;
|
||||
MainBorder.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(240, 243, 249));
|
||||
MainBorder.Background = new SolidColorBrush(Color.FromRgb(240, 243, 249));
|
||||
}
|
||||
else if (selectedIndex <= settings.RandSettings.CustomPickNameBackgrounds.Count)
|
||||
{
|
||||
@@ -43,7 +46,7 @@ namespace Ink_Canvas {
|
||||
var customBackground = settings.RandSettings.CustomPickNameBackgrounds[selectedIndex - 1];
|
||||
if (File.Exists(customBackground.FilePath))
|
||||
{
|
||||
var bitmap = new System.Windows.Media.Imaging.BitmapImage();
|
||||
var bitmap = new BitmapImage();
|
||||
bitmap.BeginInit();
|
||||
bitmap.UriSource = new Uri(customBackground.FilePath);
|
||||
bitmap.EndInit();
|
||||
@@ -69,16 +72,16 @@ namespace Ink_Canvas {
|
||||
// 加载背景
|
||||
LoadBackground(settings);
|
||||
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(100);
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
BorderBtnRand_MouseUp(BorderBtnRand, null);
|
||||
});
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
|
||||
public static int randSeed = 0;
|
||||
public bool isAutoClose = false;
|
||||
public bool isAutoClose;
|
||||
public bool isNotRepeatName = false;
|
||||
|
||||
public int TotalCount = 1;
|
||||
@@ -118,7 +121,7 @@ namespace Ink_Canvas {
|
||||
LabelOutput2.Visibility = Visibility.Collapsed;
|
||||
LabelOutput3.Visibility = Visibility.Collapsed;
|
||||
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
for (int i = 0; i < RandWaitingTimes; i++) {
|
||||
int rand = random.Next(1, PeopleCount + 1);
|
||||
while (rands.Contains(rand)) {
|
||||
@@ -152,55 +155,55 @@ namespace Ink_Canvas {
|
||||
outputString += Names[rand - 1] + Environment.NewLine;
|
||||
} else {
|
||||
outputs.Add(rand.ToString());
|
||||
outputString += rand.ToString() + Environment.NewLine;
|
||||
outputString += rand + Environment.NewLine;
|
||||
}
|
||||
}
|
||||
if (TotalCount <= 5) {
|
||||
LabelOutput.Content = outputString.ToString().Trim();
|
||||
LabelOutput.Content = outputString.Trim();
|
||||
} else if (TotalCount <= 10) {
|
||||
LabelOutput2.Visibility = Visibility.Visible;
|
||||
outputString = "";
|
||||
for (int i = 0; i < (outputs.Count + 1) / 2; i++) {
|
||||
outputString += outputs[i].ToString() + Environment.NewLine;
|
||||
outputString += outputs[i] + Environment.NewLine;
|
||||
}
|
||||
LabelOutput.Content = outputString.ToString().Trim();
|
||||
LabelOutput.Content = outputString.Trim();
|
||||
outputString = "";
|
||||
for (int i = (outputs.Count + 1) / 2; i < outputs.Count; i++) {
|
||||
outputString += outputs[i].ToString() + Environment.NewLine;
|
||||
outputString += outputs[i] + Environment.NewLine;
|
||||
}
|
||||
LabelOutput2.Content = outputString.ToString().Trim();
|
||||
LabelOutput2.Content = outputString.Trim();
|
||||
} else {
|
||||
LabelOutput2.Visibility = Visibility.Visible;
|
||||
LabelOutput3.Visibility = Visibility.Visible;
|
||||
outputString = "";
|
||||
for (int i = 0; i < (outputs.Count + 1) / 3; i++) {
|
||||
outputString += outputs[i].ToString() + Environment.NewLine;
|
||||
outputString += outputs[i] + Environment.NewLine;
|
||||
}
|
||||
LabelOutput.Content = outputString.ToString().Trim();
|
||||
LabelOutput.Content = outputString.Trim();
|
||||
outputString = "";
|
||||
for (int i = (outputs.Count + 1) / 3; i < (outputs.Count + 1) * 2 / 3; i++) {
|
||||
outputString += outputs[i].ToString() + Environment.NewLine;
|
||||
outputString += outputs[i] + Environment.NewLine;
|
||||
}
|
||||
LabelOutput2.Content = outputString.ToString().Trim();
|
||||
LabelOutput2.Content = outputString.Trim();
|
||||
outputString = "";
|
||||
for (int i = (outputs.Count + 1) * 2 / 3; i < outputs.Count; i++) {
|
||||
outputString += outputs[i].ToString() + Environment.NewLine;
|
||||
outputString += outputs[i] + Environment.NewLine;
|
||||
}
|
||||
LabelOutput3.Content = outputString.ToString().Trim();
|
||||
LabelOutput3.Content = outputString.Trim();
|
||||
}
|
||||
|
||||
if (isAutoClose) {
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(RandDoneAutoCloseWaitTime);
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
PeopleControlPane.Opacity = 1;
|
||||
PeopleControlPane.IsHitTestVisible = true;
|
||||
Close();
|
||||
});
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
});
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
@@ -261,7 +264,7 @@ namespace Ink_Canvas {
|
||||
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "classisland://plugins/IslandCaller/Run",
|
||||
UseShellExecute = true
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user