Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c70f35714 | |||
| 7b4d13c16f | |||
| 0e561ad24e | |||
| d09d8223c9 | |||
| 6dafde9735 | |||
| a0f84bf017 | |||
| 7049c53889 | |||
| 7750fa799d | |||
| 5f828736de | |||
| 869c8ce31b | |||
| 0b7b55224f | |||
| 2a23be44f2 | |||
| fa0cbb4d3f | |||
| 38bc4decf6 | |||
| b5ec6e0d79 | |||
| 82486c707d | |||
| 5ff437bed5 | |||
| 2f7e0b85c0 | |||
| c9548af008 | |||
| b20e4a041f | |||
| 87f64ccc81 | |||
| 58028ea95c | |||
| 35fa062cc3 | |||
| 9de6555519 | |||
| a9baf47823 | |||
| a9b64d2899 |
@@ -1 +1 @@
|
||||
1.4.7
|
||||
1.6.3
|
||||
+573
-4
@@ -1,16 +1,20 @@
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
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; // 添加SecurityException所需命名空间
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Window = System.Windows.Window;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -49,12 +53,11 @@ namespace Ink_Canvas
|
||||
LogHelper.NewLog(e.Exception.ToString());
|
||||
e.Handled = true;
|
||||
|
||||
// 新增:根据设置自动处理崩溃
|
||||
if (CrashAction == CrashActionType.SilentRestart)
|
||||
// 修改:仅当非用户主动退出时才触发自动重启
|
||||
if (CrashAction == CrashActionType.SilentRestart && !IsAppExitByUser)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 静默重启:启动新进程并退出当前进程
|
||||
string exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
|
||||
System.Diagnostics.Process.Start(exePath);
|
||||
}
|
||||
@@ -87,6 +90,127 @@ namespace Ink_Canvas
|
||||
_taskbar = (TaskbarIcon)FindResource("TaskbarTrayIcon");
|
||||
|
||||
StartArgs = e.Args;
|
||||
|
||||
// 新增:Office注册表检测
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile("开始Office注册表检测");
|
||||
|
||||
// 检查Office安装
|
||||
if (!IsOfficeInstalled())
|
||||
{
|
||||
LogHelper.WriteLogToFile("未检测到Office安装", LogHelper.LogType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
// 尝试获取所有可能的Office版本路径
|
||||
var officeVersions = GetOfficeVersions();
|
||||
if (officeVersions.Count == 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile("未找到任何Office版本", LogHelper.LogType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var version in officeVersions)
|
||||
{
|
||||
string regPath = $"Software\\Microsoft\\Office\\{version}\\Common\\Security";
|
||||
LogHelper.WriteLogToFile($"正在处理Office版本 {version}, 注册表路径: {regPath}");
|
||||
|
||||
try
|
||||
{
|
||||
using (Microsoft.Win32.RegistryKey baseKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(regPath))
|
||||
{
|
||||
if (baseKey == null)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"注册表路径不存在: {regPath}", LogHelper.LogType.Warning);
|
||||
// 尝试创建路径
|
||||
try
|
||||
{
|
||||
using (Microsoft.Win32.RegistryKey createKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(regPath, true))
|
||||
{
|
||||
if (createKey != null)
|
||||
{
|
||||
createKey.SetValue("DisableProtectedView", 1, Microsoft.Win32.RegistryValueKind.DWord);
|
||||
LogHelper.WriteLogToFile($"创建并设置注册表路径: {regPath}", LogHelper.LogType.Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception createEx)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"创建注册表路径失败: {createEx.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// 备份路径更改为软件根目录下的saves/RegistryBackups文件夹
|
||||
string backupPath = Path.Combine(RootPath, "saves", "RegistryBackups");
|
||||
LogHelper.WriteLogToFile($"备份路径: {backupPath}");
|
||||
|
||||
if (!Directory.Exists(backupPath))
|
||||
{
|
||||
Directory.CreateDirectory(backupPath);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupPath}");
|
||||
}
|
||||
|
||||
string backupFile = Path.Combine(backupPath, $"SecurityBackup_{version}_{DateTime.Now:yyyyMMddHHmmss}.reg");
|
||||
LogHelper.WriteLogToFile($"创建备份文件: {backupFile}");
|
||||
|
||||
// 使用UTF8编码写入注册表文件
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, System.Text.Encoding.UTF8))
|
||||
{
|
||||
sw.WriteLine("Windows Registry Editor Version 5.00\n");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine($"[{Microsoft.Win32.Registry.CurrentUser.Name}\\{regPath}]");
|
||||
|
||||
foreach (string valueName in baseKey.GetValueNames())
|
||||
{
|
||||
object value = baseKey.GetValue(valueName);
|
||||
sw.WriteLine($"\"{valueName}\"=dword:{((int)value):x8}");
|
||||
LogHelper.WriteLogToFile($"备份注册表值: {valueName} = {value}");
|
||||
}
|
||||
}
|
||||
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.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);
|
||||
LogHelper.WriteLogToFile($"Office {version} 注册表值已设置: DisableProtectedView = 1");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"Office {version} 注册表值已存在且无需更改: DisableProtectedView = 1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"处理Office版本 {version} 时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理Office 365的特殊路径
|
||||
TryModifyOffice365Registry();
|
||||
}
|
||||
catch (SecurityException secEx)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"安全异常: {secEx.Message}", LogHelper.LogType.Error);
|
||||
ShowPermissionError();
|
||||
}
|
||||
catch (UnauthorizedAccessException authEx)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"访问被拒绝: {authEx.Message}", LogHelper.LogType.Error);
|
||||
ShowPermissionError();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"未知错误: {ex.GetType().FullName} - {ex.Message}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile(ex.StackTrace, LogHelper.LogType.Info);
|
||||
}
|
||||
}
|
||||
|
||||
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
|
||||
@@ -208,5 +332,450 @@ namespace Ink_Canvas
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查Office是否安装
|
||||
/// </summary>
|
||||
private bool IsOfficeInstalled()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 检查多个可能的注册表路径
|
||||
// 1. 检查传统的Office版本
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office"))
|
||||
{
|
||||
if (key != null && key.GetSubKeyNames().Any(name => name.Contains(".0")))
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到传统Office安装", LogHelper.LogType.Info);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 检查64位注册表中的Office
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Office"))
|
||||
{
|
||||
if (key != null && key.GetSubKeyNames().Any(name => name.Contains(".0")))
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到64位注册表中的Office安装", LogHelper.LogType.Info);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 检查Office 365/Click-to-Run安装
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\ClickToRun"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到Office 365 Click-to-Run", LogHelper.LogType.Info);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 检查Office 365部署配置
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\15.0\\ClickToRun"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到Office 365 (15.0)", LogHelper.LogType.Info);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\16.0\\ClickToRun"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到Office 365 (16.0)", LogHelper.LogType.Info);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 检查Office 365零售订阅信息
|
||||
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\ClickToRun\\Configuration"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到Office 365配置", LogHelper.LogType.Info);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile("未检测到任何Office安装", LogHelper.LogType.Warning);
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查Office安装时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示权限不足的错误提示
|
||||
/// </summary>
|
||||
private void ShowPermissionError()
|
||||
{
|
||||
const string message = "需要管理员权限才能完成此操作\n请以管理员身份重新启动应用程序";
|
||||
LogHelper.WriteLogToFile(message, LogHelper.LogType.Error);
|
||||
System.Windows.MessageBox.Show(message, "权限错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有已安装的Office版本
|
||||
/// </summary>
|
||||
private List<string> GetOfficeVersions()
|
||||
{
|
||||
var versions = new List<string>();
|
||||
try
|
||||
{
|
||||
// 检查HKLM
|
||||
using (var key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
foreach (var subKeyName in key.GetSubKeyNames())
|
||||
{
|
||||
if (subKeyName.Contains(".0"))
|
||||
{
|
||||
versions.Add(subKeyName);
|
||||
LogHelper.WriteLogToFile($"在HKLM中找到Office版本: {subKeyName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查HKCU
|
||||
using (var key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Office"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
foreach (var subKeyName in key.GetSubKeyNames())
|
||||
{
|
||||
if (subKeyName.Contains(".0") && !versions.Contains(subKeyName))
|
||||
{
|
||||
versions.Add(subKeyName);
|
||||
LogHelper.WriteLogToFile($"在HKCU中找到Office版本: {subKeyName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查64位注册表
|
||||
using (var key = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Office"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
foreach (var subKeyName in key.GetSubKeyNames())
|
||||
{
|
||||
if (subKeyName.Contains(".0") && !versions.Contains(subKeyName))
|
||||
{
|
||||
versions.Add(subKeyName);
|
||||
LogHelper.WriteLogToFile($"在64位注册表中找到Office版本: {subKeyName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查Office 365的特殊路径
|
||||
CheckOffice365Versions(versions);
|
||||
|
||||
// 如果没有找到任何版本,添加默认的Office 365版本号
|
||||
if (versions.Count == 0 && IsOffice365Installed())
|
||||
{
|
||||
versions.Add("16.0");
|
||||
LogHelper.WriteLogToFile("未找到具体版本,添加默认Office 365版本: 16.0");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取Office版本时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
// 按版本号排序
|
||||
versions.Sort((a, b) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
double va = double.Parse(a.Replace(".0", ""));
|
||||
double vb = double.Parse(b.Replace(".0", ""));
|
||||
return vb.CompareTo(va); // 降序排列,最新版本在前
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
return versions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测Office 365是否已安装
|
||||
/// </summary>
|
||||
private bool IsOffice365Installed()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 检查多个Office 365特定路径
|
||||
using (var key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\ClickToRun"))
|
||||
{
|
||||
if (key != null)
|
||||
return true;
|
||||
}
|
||||
|
||||
using (var key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\15.0\\ClickToRun"))
|
||||
{
|
||||
if (key != null)
|
||||
return true;
|
||||
}
|
||||
|
||||
using (var key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\16.0\\ClickToRun"))
|
||||
{
|
||||
if (key != null)
|
||||
return true;
|
||||
}
|
||||
|
||||
using (var key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\ClickToRun\\Configuration"))
|
||||
{
|
||||
if (key != null)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查Office 365特有的版本信息
|
||||
/// </summary>
|
||||
private void CheckOffice365Versions(List<string> versions)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 检查Click-to-Run版本路径
|
||||
using (var key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\ClickToRun\\Configuration"))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
var platformVersion = key.GetValue("Platform") as string;
|
||||
var clickToRunVersion = key.GetValue("VersionToReport") as string;
|
||||
|
||||
if (!string.IsNullOrEmpty(platformVersion))
|
||||
{
|
||||
var majorVersion = platformVersion.Split('.').FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(majorVersion) && !versions.Contains($"{majorVersion}.0"))
|
||||
{
|
||||
versions.Add($"{majorVersion}.0");
|
||||
LogHelper.WriteLogToFile($"在Office 365配置中找到平台版本: {majorVersion}.0");
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(clickToRunVersion))
|
||||
{
|
||||
var majorVersion = clickToRunVersion.Split('.').FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(majorVersion) && !versions.Contains($"{majorVersion}.0"))
|
||||
{
|
||||
versions.Add($"{majorVersion}.0");
|
||||
LogHelper.WriteLogToFile($"在Office 365配置中找到报告版本: {majorVersion}.0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查安装路径来确认版本
|
||||
var possibleVersions = new[] { "15.0", "16.0" }; // Office 2013 (15.0) 和 Office 2016/2019/365 (16.0)
|
||||
foreach (var version in possibleVersions)
|
||||
{
|
||||
using (var key = Registry.LocalMachine.OpenSubKey($"Software\\Microsoft\\Office\\{version}\\Common\\InstallRoot"))
|
||||
{
|
||||
if (key != null && key.GetValue("Path") != null && !versions.Contains(version))
|
||||
{
|
||||
versions.Add(version);
|
||||
LogHelper.WriteLogToFile($"在InstallRoot中找到Office版本: {version}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查Office 365版本时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试修改Office 365的特殊注册表路径
|
||||
/// </summary>
|
||||
private void TryModifyOffice365Registry()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 准备备份目录
|
||||
string backupPath = Path.Combine(RootPath, "saves", "RegistryBackups");
|
||||
if (!Directory.Exists(backupPath))
|
||||
{
|
||||
Directory.CreateDirectory(backupPath);
|
||||
LogHelper.WriteLogToFile($"创建Office 365备份目录: {backupPath}");
|
||||
}
|
||||
|
||||
// 检查Office 365 Outlook和PowerPoint的特定路径
|
||||
string[] apps = { "outlook", "powerpoint" };
|
||||
|
||||
foreach (var app in apps)
|
||||
{
|
||||
// 检查用户级别的注册表
|
||||
string regPath = $"Software\\Microsoft\\Office\\16.0\\{app}\\Security";
|
||||
LogHelper.WriteLogToFile($"检查Office 365特定应用注册表: {regPath}");
|
||||
|
||||
try
|
||||
{
|
||||
// 先检查是否存在该路径
|
||||
using (var baseKey = Registry.CurrentUser.OpenSubKey(regPath))
|
||||
{
|
||||
// 如果路径存在,先备份
|
||||
if (baseKey != null)
|
||||
{
|
||||
string backupFile = Path.Combine(backupPath, $"SecurityBackup_365_{app}_{DateTime.Now:yyyyMMddHHmmss}.reg");
|
||||
LogHelper.WriteLogToFile($"创建Office 365 {app}备份文件: {backupFile}");
|
||||
|
||||
// 使用UTF8编码写入注册表文件
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, System.Text.Encoding.UTF8))
|
||||
{
|
||||
sw.WriteLine("Windows Registry Editor Version 5.00\n");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine($"[{Microsoft.Win32.Registry.CurrentUser.Name}\\{regPath}]");
|
||||
|
||||
foreach (string valueName in baseKey.GetValueNames())
|
||||
{
|
||||
object value = baseKey.GetValue(valueName);
|
||||
sw.WriteLine($"\"{valueName}\"=dword:{((int)value):x8}");
|
||||
LogHelper.WriteLogToFile($"备份Office 365 {app}注册表值: {valueName} = {value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修改或创建注册表项
|
||||
using (var key = Registry.CurrentUser.CreateSubKey(regPath, true))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
object currentValue = key.GetValue("DisableProtectedView");
|
||||
if (currentValue == null || (int)currentValue != 1)
|
||||
{
|
||||
key.SetValue("DisableProtectedView", 1, RegistryValueKind.DWord);
|
||||
LogHelper.WriteLogToFile($"Office 365 {app} 注册表值已设置: DisableProtectedView = 1");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"Office 365 {app} 注册表值已存在且无需更改");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"修改 {app} 注册表时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试通过Office信任中心路径修改
|
||||
string trustCenterPath = "Software\\Microsoft\\Office\\16.0\\Common\\Security\\FileValidation";
|
||||
LogHelper.WriteLogToFile($"检查信任中心路径: {trustCenterPath}");
|
||||
|
||||
try
|
||||
{
|
||||
// 先检查是否存在该路径
|
||||
using (var baseKey = Registry.CurrentUser.OpenSubKey(trustCenterPath))
|
||||
{
|
||||
// 如果路径存在,先备份
|
||||
if (baseKey != null)
|
||||
{
|
||||
string backupFile = Path.Combine(backupPath, $"SecurityBackup_365_TrustCenter_{DateTime.Now:yyyyMMddHHmmss}.reg");
|
||||
LogHelper.WriteLogToFile($"创建信任中心备份文件: {backupFile}");
|
||||
|
||||
// 使用UTF8编码写入注册表文件
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, System.Text.Encoding.UTF8))
|
||||
{
|
||||
sw.WriteLine("Windows Registry Editor Version 5.00\n");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine($"[{Microsoft.Win32.Registry.CurrentUser.Name}\\{trustCenterPath}]");
|
||||
|
||||
foreach (string valueName in baseKey.GetValueNames())
|
||||
{
|
||||
object value = baseKey.GetValue(valueName);
|
||||
sw.WriteLine($"\"{valueName}\"=dword:{((int)value):x8}");
|
||||
LogHelper.WriteLogToFile($"备份信任中心注册表值: {valueName} = {value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (var key = Registry.CurrentUser.CreateSubKey(trustCenterPath, true))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
key.SetValue("DisableEditFromPV", 1, RegistryValueKind.DWord);
|
||||
LogHelper.WriteLogToFile("已禁用受保护视图中的编辑");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"修改信任中心路径时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
// 尝试修改EnableEditWhileViewingPolicy
|
||||
string policyPath = "Software\\Policies\\Microsoft\\Office\\16.0\\Common\\Security";
|
||||
try
|
||||
{
|
||||
// 先检查是否存在该路径
|
||||
using (var baseKey = Registry.CurrentUser.OpenSubKey(policyPath))
|
||||
{
|
||||
// 如果路径存在,先备份
|
||||
if (baseKey != null)
|
||||
{
|
||||
string backupFile = Path.Combine(backupPath, $"SecurityBackup_365_Policy_{DateTime.Now:yyyyMMddHHmmss}.reg");
|
||||
LogHelper.WriteLogToFile($"创建策略备份文件: {backupFile}");
|
||||
|
||||
// 使用UTF8编码写入注册表文件
|
||||
using (StreamWriter sw = new StreamWriter(backupFile, false, System.Text.Encoding.UTF8))
|
||||
{
|
||||
sw.WriteLine("Windows Registry Editor Version 5.00\n");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine($"[{Microsoft.Win32.Registry.CurrentUser.Name}\\{policyPath}]");
|
||||
|
||||
foreach (string valueName in baseKey.GetValueNames())
|
||||
{
|
||||
object value = baseKey.GetValue(valueName);
|
||||
sw.WriteLine($"\"{valueName}\"=dword:{((int)value):x8}");
|
||||
LogHelper.WriteLogToFile($"备份策略注册表值: {valueName} = {value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (var key = Registry.CurrentUser.CreateSubKey(policyPath, true))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
key.SetValue("EnableEditWhileViewingPolicy", 1, RegistryValueKind.DWord);
|
||||
LogHelper.WriteLogToFile("已启用查看时编辑策略");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"修改策略路径时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"修改Office 365注册表时发生未知错误: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("5.0.2.0")]
|
||||
[assembly: AssemblyFileVersion("5.0.2.0")]
|
||||
[assembly: AssemblyVersion("1.6.3.0")]
|
||||
[assembly: AssemblyFileVersion("1.6.3.0")]
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Windows;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Controls;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
{
|
||||
@@ -19,7 +20,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
string localVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
string remoteAddress = proxy;
|
||||
remoteAddress += "https://github.com/CJKmkp/ICC-CE/blob/main/AutomaticUpdateVersionControl.txt";
|
||||
remoteAddress += "https://github.com/awesome-iwb/icc-ce/blob/main/AutomaticUpdateVersionControl.txt";
|
||||
string remoteVersion = await GetRemoteVersion(remoteAddress);
|
||||
|
||||
if (remoteVersion != null)
|
||||
@@ -85,10 +86,11 @@ namespace Ink_Canvas.Helpers
|
||||
return true;
|
||||
}
|
||||
|
||||
string downloadUrl = $"{proxy}https://github.com/ChangSakura/Ink-Canvas/releases/download/v{version}/Ink.Canvas.Annotation.V{version}.Setup.exe";
|
||||
string downloadUrl = $"{proxy}https://github.com/awesome-iwb/icc-ce/releases/download/{version}/InkCanvasForClass.CE.{version}.zip";
|
||||
|
||||
SaveDownloadStatus(false);
|
||||
await DownloadFile(downloadUrl, $"{updatesFolderPath}\\Ink.Canvas.Annotation.V{version}.Setup.exe");
|
||||
string zipFilePath = Path.Combine(updatesFolderPath, $"InkCanvasForClass.CE.{version}.zip");
|
||||
await DownloadFile(downloadUrl, zipFilePath);
|
||||
SaveDownloadStatus(true);
|
||||
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Setup file successfully downloaded.");
|
||||
@@ -96,7 +98,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error downloading and installing update: {ex.Message}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error downloading update: {ex.Message}", LogHelper.LogType.Error);
|
||||
|
||||
SaveDownloadStatus(false);
|
||||
return false;
|
||||
@@ -155,21 +157,43 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
string setupFilePath = Path.Combine(updatesFolderPath, $"Ink.Canvas.Annotation.V{version}.Setup.exe");
|
||||
string zipFilePath = Path.Combine(updatesFolderPath, $"InkCanvasForClass.CE.{version}.zip");
|
||||
|
||||
if (!File.Exists(setupFilePath))
|
||||
if (!File.Exists(zipFilePath))
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Setup file not found: {setupFilePath}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | ZIP file not found: {zipFilePath}", LogHelper.LogType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
string InstallCommand = $"\"{setupFilePath}\" /SILENT";
|
||||
if (isInSilence) InstallCommand += " /VERYSILENT";
|
||||
ExecuteCommandLine(InstallCommand);
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
// 创建临时解压目录
|
||||
string extractPath = Path.Combine(updatesFolderPath, $"Extract_{version}");
|
||||
if (Directory.Exists(extractPath))
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
});
|
||||
Directory.Delete(extractPath, true);
|
||||
}
|
||||
Directory.CreateDirectory(extractPath);
|
||||
|
||||
// 解压ZIP文件
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Extracting ZIP file to: {extractPath}");
|
||||
ZipFile.ExtractToDirectory(zipFilePath, extractPath);
|
||||
|
||||
// 获取当前应用程序路径
|
||||
string currentAppDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Current application directory: {currentAppDir}");
|
||||
|
||||
// 复制解压的文件到应用程序目录
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Copying files to application directory");
|
||||
CopyDirectory(extractPath, currentAppDir);
|
||||
|
||||
// 清理临时文件
|
||||
if (Directory.Exists(extractPath))
|
||||
{
|
||||
Directory.Delete(extractPath, true);
|
||||
}
|
||||
|
||||
// 重启应用程序
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Update completed, restarting application");
|
||||
RestartApplication();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -177,6 +201,49 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
private static void CopyDirectory(string sourceDir, string destinationDir)
|
||||
{
|
||||
// 创建目标目录(如果不存在)
|
||||
Directory.CreateDirectory(destinationDir);
|
||||
|
||||
// 复制所有文件
|
||||
foreach (string filePath in Directory.GetFiles(sourceDir))
|
||||
{
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
string destPath = Path.Combine(destinationDir, fileName);
|
||||
try
|
||||
{
|
||||
// 如果目标文件存在,先删除
|
||||
if (File.Exists(destPath))
|
||||
{
|
||||
File.Delete(destPath);
|
||||
}
|
||||
File.Copy(filePath, destPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error copying file {fileName}: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
// 递归复制所有子目录
|
||||
foreach (string subDirPath in Directory.GetDirectories(sourceDir))
|
||||
{
|
||||
string subDirName = Path.GetFileName(subDirPath);
|
||||
string destSubDir = Path.Combine(destinationDir, subDirName);
|
||||
CopyDirectory(subDirPath, destSubDir);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RestartApplication()
|
||||
{
|
||||
string appPath = Assembly.GetExecutingAssembly().Location;
|
||||
Process.Start(appPath);
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
});
|
||||
}
|
||||
|
||||
private static void ExecuteCommandLine(string command)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,44 @@ namespace Ink_Canvas.Helpers
|
||||
[DllImport("user32.dll")]
|
||||
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
private static extern IntPtr SHAppBarMessage(uint dwMessage, ref APPBARDATA pData);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool GetMonitorInfo(IntPtr hMonitor, ref MONITORINFO lpmi);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags);
|
||||
|
||||
private const uint ABM_GETTASKBARPOS = 0x00000005;
|
||||
private const uint ABM_GETSTATE = 0x00000004;
|
||||
private const int SPI_GETWORKAREA = 0x0030;
|
||||
private const uint MONITOR_DEFAULTTOPRIMARY = 1;
|
||||
private const int ABS_AUTOHIDE = 0x0000001;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct MONITORINFO
|
||||
{
|
||||
public int cbSize;
|
||||
public RECT rcMonitor;
|
||||
public RECT rcWork;
|
||||
public uint dwFlags;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct APPBARDATA
|
||||
{
|
||||
public int cbSize;
|
||||
public IntPtr hWnd;
|
||||
public uint uCallbackMessage;
|
||||
public uint uEdge;
|
||||
public RECT rc;
|
||||
public IntPtr lParam;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT {
|
||||
public int Left;
|
||||
@@ -34,6 +72,72 @@ namespace Ink_Canvas.Helpers
|
||||
public int Height => Bottom - Top;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Windows任务栏的高度(仅计算任务栏,不包括其他应用的停靠栏)
|
||||
/// </summary>
|
||||
/// <param name="screen">当前屏幕</param>
|
||||
/// <param name="dpiScaleY">DPI缩放Y值</param>
|
||||
/// <returns>任务栏高度</returns>
|
||||
public static double GetTaskbarHeight(System.Windows.Forms.Screen screen, double dpiScaleY)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 创建APPBARDATA结构
|
||||
var abd = new APPBARDATA();
|
||||
abd.cbSize = Marshal.SizeOf(abd);
|
||||
|
||||
// 获取任务栏状态
|
||||
IntPtr state = SHAppBarMessage(ABM_GETSTATE, ref abd);
|
||||
bool isAutoHide = (state.ToInt32() & ABS_AUTOHIDE) == ABS_AUTOHIDE;
|
||||
|
||||
// 如果任务栏是自动隐藏的,返回0
|
||||
if (isAutoHide)
|
||||
{
|
||||
LogHelper.WriteLogToFile("任务栏处于自动隐藏状态", LogHelper.LogType.Info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 获取任务栏信息
|
||||
IntPtr result = SHAppBarMessage(ABM_GETTASKBARPOS, ref abd);
|
||||
if (result != IntPtr.Zero)
|
||||
{
|
||||
// 获取当前屏幕的工作区
|
||||
RECT workArea = new RECT();
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, Marshal.AllocHGlobal(Marshal.SizeOf(workArea)), 0);
|
||||
|
||||
// 根据任务栏位置计算高度
|
||||
int taskbarHeight = 0;
|
||||
|
||||
// 任务栏的uEdge: 0=左, 1=上, 2=右, 3=下
|
||||
switch (abd.uEdge)
|
||||
{
|
||||
case 1: // 上
|
||||
taskbarHeight = abd.rc.Height;
|
||||
break;
|
||||
case 3: // 下
|
||||
taskbarHeight = abd.rc.Height;
|
||||
break;
|
||||
case 0: // 左
|
||||
case 2: // 右
|
||||
// 水平任务栏不影响高度
|
||||
taskbarHeight = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// 考虑DPI缩放
|
||||
return taskbarHeight / dpiScaleY;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"获取任务栏高度出错: {ex.Message}");
|
||||
LogHelper.WriteLogToFile($"获取任务栏高度出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
// 如果获取失败,回退到通用方法
|
||||
return (screen.Bounds.Height - screen.WorkingArea.Height) / dpiScaleY;
|
||||
}
|
||||
|
||||
public static string WindowTitle() {
|
||||
IntPtr foregroundWindowHandle = GetForegroundWindow();
|
||||
|
||||
|
||||
+469
-57
@@ -53,9 +53,72 @@
|
||||
<RoutedUICommand x:Key="HotKey_ChangeToPen3" Text=" " />
|
||||
<RoutedUICommand x:Key="HotKey_ChangeToPen4" Text=" " />
|
||||
<RoutedUICommand x:Key="HotKey_ChangeToPen5" Text=" " />
|
||||
<RoutedUICommand x:Key="HotKey_DrawLine" Text=" " />
|
||||
<RoutedUICommand x:Key="NothingWillHappened" Text=" " />
|
||||
</Window.Resources>
|
||||
<RoutedUICommand x:Key="HotKey_DrawLine" Text=" " />
|
||||
<RoutedUICommand x:Key="NothingWillHappened" Text=" " />
|
||||
|
||||
<!-- Navigation Button Style -->
|
||||
<Style x:Key="NavButton" TargetType="Button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#27272a"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</Trigger>
|
||||
<!-- 使用多个DataTrigger替代动态绑定 -->
|
||||
<DataTrigger Binding="{Binding Tag}" Value="startup">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="canvas">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="gesture">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="inkrecognition">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="crashaction">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="ppt">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="advanced">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="automation">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="randomwindow">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="theme">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="shortcuts">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="about">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
<!--输入命令绑定-->
|
||||
<Window.InputBindings>
|
||||
<KeyBinding Gesture="Escape" Command="{StaticResource KeyExit}" />
|
||||
@@ -109,13 +172,301 @@
|
||||
<!--// 设置界面 //-->
|
||||
<Grid Panel.ZIndex="999" x:Name="BorderSettingsMask" MouseDown="SettingsOverlayClick" IsHitTestVisible="False"
|
||||
Margin="0,0,0,0">
|
||||
<Border Name="BorderSettings" Background="#ee18181b" ui:ThemeManager.RequestedTheme="Dark" Width="440"
|
||||
<Border Name="BorderSettings" Background="#ee18181b" ui:ThemeManager.RequestedTheme="Dark" Width="490"
|
||||
HorizontalAlignment="Left" Margin="300,150,0,350" Visibility="Visible">
|
||||
<Grid>
|
||||
<ui:ScrollViewerEx Margin="0,80,0,50" VerticalScrollBarVisibility="Auto"
|
||||
PanningMode="VerticalOnly" ui:ThemeManager.RequestedTheme="Dark"
|
||||
ManipulationBoundaryFeedback="SCManipulationBoundaryFeedback"
|
||||
Name="SettingsPanelScrollViewer">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Navigation Sidebar -->
|
||||
<Border Grid.Column="0" Background="#1e1e1e" BorderBrush="#27272a" BorderThickness="0,0,1,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 顶部Logo区域 -->
|
||||
<Border Grid.Row="0" Height="50" Background="#2d2d30" BorderBrush="#3f3f46" BorderThickness="0,0,0,1">
|
||||
<Image Width="30" Height="30" Source="/Resources/icc.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
</Border>
|
||||
|
||||
<!-- 主要导航按钮 -->
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<StackPanel>
|
||||
<!-- Startup -->
|
||||
<Button Width="40" Height="40" Margin="0,10,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavStartup_Click" Tag="startup" ToolTip="启动设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M2.81,14.12L5.64,11.29L8.17,10.79C11.39,6.41 17.55,4.22 19.78,4.22C19.78,6.45 17.59,12.61 13.21,15.83L12.71,18.36L9.88,21.19L9.17,17.66C7.76,17.66 7.76,17.66 7.05,16.95C6.34,16.24 6.34,16.24 6.34,14.83L2.81,14.12M5.64,16.95L7.05,18.36L4.39,21.03H2.97V19.61L5.64,16.95M4.22,15.54L5.46,15.71L3,18.16V16.74L4.22,15.54M8.29,18.54L8.46,19.78L7.26,21H5.84L8.29,18.54M13,9.5A1.5,1.5 0 0,0 11.5,11A1.5,1.5 0 0,0 13,12.5A1.5,1.5 0 0,0 14.5,11A1.5,1.5 0 0,0 13,9.5Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Canvas -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavCanvas_Click" Tag="canvas" ToolTip="画布设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M19,1L17.74,3.75L15,5L17.74,6.26L19,9L20.25,6.26L23,5L20.25,3.75M9,4L6.5,9.5L1,12L6.5,14.5L9,20L11.5,14.5L17,12L11.5,9.5"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Gesture -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavGesture_Click" Tag="gesture" ToolTip="手势设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Ink Recognition -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavInkRecognition_Click" Tag="inkrecognition" ToolTip="墨迹识别">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Crash Action -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavCrashAction_Click" Tag="crashaction" ToolTip="崩溃处理">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M13 14H11V9H13M13 18H11V16H13M1 21H23L12 2L1 21Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- PPT -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavPPT_Click" Tag="ppt" ToolTip="PPT设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M2 2H22V4H2V2M2 8H22V10H2V8M2 14H22V16H2V14M2 20H22V22H2V20Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Advanced -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavAdvanced_Click" Tag="advanced" ToolTip="高级设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Automation -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavAutomation_Click" Tag="automation" ToolTip="自动化设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M12,0C8.96,0 6.21,1.23 4.22,3.22L5.63,4.63C7.24,3.01 9.5,2 12,2C14.5,2 16.76,3.01 18.36,4.63L19.77,3.22C17.79,1.23 15.04,0 12,0M7.05,6.05L8.46,7.46C9.37,6.56 10.62,6 12,6C13.38,6 14.63,6.56 15.54,7.46L16.95,6.05C15.68,4.78 13.93,4 12,4C10.07,4 8.32,4.78 7.05,6.05M12,15A2,2 0 0,1 10,13A2,2 0 0,1 12,11A2,2 0 0,1 14,13A2,2 0 0,1 12,15M15,9H9A1,1 0 0,0 8,10V22A1,1 0 0,0 9,23H15A1,1 0 0,0 16,22V10A1,1 0 0,0 15,9Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Random Window -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavRandomWindow_Click" Tag="randomwindow" ToolTip="随机窗口设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M4,4V16H8.83L12,19.17L15.17,16H20V4H4M6,7H18V9H6V7M6,11H16V13H6V11Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- 新增:个性化设置 -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavTheme_Click" Tag="theme" ToolTip="个性化设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M12,18V6A6,6 0 0,1 18,12A6,6 0 0,1 12,18M20,15.31L23.31,12L20,8.69V4H15.31L12,0.69L8.69,4H4V8.69L0.69,12L4,15.31V20H8.69L12,23.31L15.31,20H20V15.31Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- 新增:快捷键设置 -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavShortcuts_Click" Tag="shortcuts" ToolTip="快捷键设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M20,5H4A2,2 0 0,0 2,7V17A2,2 0 0,0 4,19H20A2,2 0 0,0 22,17V7A2,2 0 0,0 20,5M20,17H4V7H20V17M5,8H7V10H5V8M8,8H10V10H8V8M11,8H13V10H11V8M14,8H16V10H14V8M17,8H19V10H17V8M5,11H7V13H5V11M8,11H10V13H8V11M11,11H13V13H11V11M14,11H16V13H14V11M17,11H19V13H17V11M8,14H16V16H8V14Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- About -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavAbout_Click" Tag="about" ToolTip="关于">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<StackPanel Grid.Row="2" Margin="0,5,0,10">
|
||||
<Separator Background="#3f3f46" Margin="5,0,5,10"/>
|
||||
|
||||
<!-- 折叠侧边栏按钮 -->
|
||||
<Button Width="40" Height="40" Style="{StaticResource NavButton}"
|
||||
Click="CollapseNavSidebar_Click" ToolTip="折叠侧边栏">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Content Area -->
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Grid ClipToBounds="True" Grid.Row="0" Margin="0,0,0,0" Height="80" VerticalAlignment="Top">
|
||||
<Border Background="#18181b" CornerRadius="0" Margin="-1,-1,-1,0">
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<!-- 显示侧边栏按钮 -->
|
||||
<Button Width="40" Height="40" Margin="10,0,0,0" Style="{StaticResource NavButton}"
|
||||
Click="ShowNavSidebar_Click" ToolTip="显示侧边栏">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
<TextBlock Foreground="White" Margin="15,-2,0,0" Text="设置" FontWeight="Bold"
|
||||
FontSize="32" />
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
<Canvas>
|
||||
<Image Canvas.Top="12" Canvas.Right="-16" Width="98" Height="98" Opacity="0.4">
|
||||
<Image.RenderTransform>
|
||||
<!-- giving the transform a name tells the framework not to freeze it -->
|
||||
<RotateTransform CenterX="49" CenterY="49" />
|
||||
</Image.RenderTransform>
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup ClipGeometry="M0,0 V257 H257 V0 H0 Z">
|
||||
<GeometryDrawing Brush="GhostWhite"
|
||||
Geometry="F0 M257,257z M0,0z M93.339,256.594L88.2444,215.634C85.4849,214.567 82.8846,213.287 80.4434,211.794 78.0023,210.301 75.6142,208.701 73.2793,206.994L35.3887,222.994 0.363831,162.194 33.1598,137.234C32.9476,135.741,32.8414,134.301,32.8414,132.914L32.8414,124.274C32.8414,122.887,32.9476,121.447,33.1598,119.954L0.363831,94.9941 35.3887,34.1941 73.2793,50.1941C75.6142,48.4874 78.0554,46.8874 80.6026,45.3941 83.1499,43.9007 85.6972,42.6207 88.2444,41.5541L93.339,0.594055 163.389,0.594055 168.483,41.5541C171.243,42.6207 173.843,43.9007 176.284,45.3941 178.725,46.8874 181.113,48.4874 183.448,50.1941L221.339,34.1941 256.364,94.9941 223.568,119.954C223.78,121.447,223.886,122.887,223.886,124.274L223.886,132.914C223.886,134.301,223.674,135.741,223.249,137.234L256.045,162.194 221.021,222.994 183.448,206.994C181.113,208.701 178.672,210.301 176.125,211.794 173.578,213.287 171.031,214.567 168.483,215.634L163.389,256.594 93.339,256.594z M160.523,160.274C151.82,169.021 141.312,173.394 129.001,173.394 116.477,173.394 105.916,169.021 97.3191,160.274 88.722,151.527 84.4235,140.967 84.4235,128.594 84.4235,116.221 88.722,105.661 97.3191,96.9141 105.916,88.1674 116.477,83.7941 129.001,83.7941 141.312,83.7941 151.82,88.1674 160.523,96.9141 169.226,105.661 173.578,116.221 173.578,128.594 173.578,140.967 169.226,151.527 160.523,160.274z" />
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
<Image.Triggers>
|
||||
<EventTrigger RoutedEvent="Loaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)"
|
||||
To="-360" Duration="0:0:3" RepeatBehavior="Forever" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</Image.Triggers>
|
||||
</Image>
|
||||
</Canvas>
|
||||
</Grid>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<ui:ScrollViewerEx Grid.Row="1" Margin="0,0,0,0" VerticalScrollBarVisibility="Auto"
|
||||
PanningMode="VerticalOnly" ui:ThemeManager.RequestedTheme="Dark"
|
||||
ManipulationBoundaryFeedback="SCManipulationBoundaryFeedback"
|
||||
Name="SettingsPanelScrollViewer">
|
||||
<StackPanel Margin="20,20,20,20">
|
||||
|
||||
<Border Margin="0,0,0,10" Height="100" CornerRadius="5" BorderBrush="#a1a1aa"
|
||||
@@ -226,7 +577,7 @@
|
||||
<ui:SimpleStackPanel VerticalAlignment="Center">
|
||||
<TextBlock Foreground="#fafafa" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" FontSize="15" Margin="0,0,0,10"
|
||||
Text="开发中..." />
|
||||
Text="开发中...请不要点击,可能会导致ICC异常崩溃" />
|
||||
<ui:SimpleStackPanel Spacing="5">
|
||||
<ui:SimpleStackPanel Spacing="5" Orientation="Horizontal"
|
||||
HorizontalAlignment="Center">
|
||||
@@ -377,6 +728,23 @@
|
||||
IsOn="True" FontFamily="Microsoft YaHei UI" FontWeight="Bold"
|
||||
Toggled="ToggleSwitchShowCursor_Toggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#fafafa" Text="启用压感触屏模式" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchEnablePressureTouchMode"
|
||||
IsOn="True" FontFamily="Microsoft YaHei UI" FontWeight="Bold"
|
||||
Toggled="ToggleSwitchEnablePressureTouchMode_Toggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<TextBlock Text="# 开启后,触屏设备也将支持压感效果,适用于部分支持压感但无法被系统识别的触屏设备。" TextWrapping="Wrap" Foreground="#a1a1aa" />
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#fafafa" Text="屏蔽压感" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchDisablePressure"
|
||||
IsOn="True" FontFamily="Microsoft YaHei UI" FontWeight="Bold"
|
||||
Toggled="ToggleSwitchDisablePressure_Toggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<TextBlock Text="# 开启后,将忽略所有设备的压感信息,使所有笔画具有统一的粗细。与压感触屏模式互斥。" TextWrapping="Wrap" Foreground="#a1a1aa" />
|
||||
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#fafafa" Text="橡皮大小" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
@@ -553,7 +921,56 @@
|
||||
</CheckBox>
|
||||
</ui:SimpleStackPanel>
|
||||
</ui:SimpleStackPanel>
|
||||
|
||||
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0"
|
||||
Stroke="#3f3f46" StrokeThickness="1" Margin="0,4,0,4" />
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#fafafa" Text="直线自动拉直" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchAutoStraightenLine"
|
||||
IsOn="True" FontFamily="Microsoft YaHei UI" FontWeight="Bold"
|
||||
Toggled="ToggleSwitchAutoStraightenLine_Toggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left"
|
||||
Visibility="{Binding ElementName=ToggleSwitchAutoStraightenLine, Path=IsOn, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<TextBlock Foreground="#fafafa" Text="长度阈值" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<Slider Name="AutoStraightenLineThresholdSlider" Width="150" Minimum="30" Maximum="300"
|
||||
Value="30" TickFrequency="30" IsSnapToTickEnabled="True"
|
||||
ValueChanged="AutoStraightenLineThresholdSlider_ValueChanged" />
|
||||
<TextBlock Foreground="#fafafa" Text="{Binding ElementName=AutoStraightenLineThresholdSlider, Path=Value, StringFormat={}{0:0}}"
|
||||
VerticalAlignment="Center" FontSize="14" Margin="16,0,0,0" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left"
|
||||
Visibility="{Binding ElementName=ToggleSwitchAutoStraightenLine, Path=IsOn, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<TextBlock Foreground="#fafafa" Text="灵敏度" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<Slider Name="LineStraightenSensitivitySlider" Width="150" Minimum="0.05" Maximum="0.75"
|
||||
Value="0.10" TickFrequency="0.05" IsSnapToTickEnabled="True"
|
||||
ValueChanged="LineStraightenSensitivitySlider_ValueChanged" />
|
||||
<TextBlock Foreground="#fafafa" Text="{Binding ElementName=LineStraightenSensitivitySlider, Path=Value, StringFormat={}{0:F2}}"
|
||||
VerticalAlignment="Center" FontSize="14" Margin="16,0,0,0" />
|
||||
</ui:SimpleStackPanel>
|
||||
<TextBlock Text="# 开启后,当绘制的直线超过设定长度阈值时,将自动调整为完美直线。灵敏度范围0.05-0.75,越小要求越严格,弯曲的线条越不容易被拉直;值越大越容易识别为直线。" TextWrapping="Wrap" Foreground="#a1a1aa" />
|
||||
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0"
|
||||
Stroke="#3f3f46" StrokeThickness="1" Margin="0,4,0,4" />
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#fafafa" Text="直线端点吸附" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchLineEndpointSnapping"
|
||||
IsOn="True" FontFamily="Microsoft YaHei UI" FontWeight="Bold"
|
||||
Toggled="ToggleSwitchLineEndpointSnapping_Toggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left"
|
||||
Visibility="{Binding ElementName=ToggleSwitchLineEndpointSnapping, Path=IsOn, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<TextBlock Foreground="#fafafa" Text="吸附距离" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<Slider Name="LineEndpointSnappingThresholdSlider" Width="150" Minimum="5" Maximum="50"
|
||||
Value="15" TickFrequency="5" IsSnapToTickEnabled="True"
|
||||
ValueChanged="LineEndpointSnappingThresholdSlider_ValueChanged" />
|
||||
<TextBlock Foreground="#fafafa" Text="{Binding ElementName=LineEndpointSnappingThresholdSlider, Path=Value, StringFormat={}{0:0}}"
|
||||
VerticalAlignment="Center" FontSize="14" Margin="16,0,0,0" />
|
||||
</ui:SimpleStackPanel>
|
||||
<TextBlock Text="# 开启后,当绘制的直线端点靠近其他直线端点时,将自动吸附连接。" TextWrapping="Wrap" Foreground="#a1a1aa" />
|
||||
</ui:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
<GroupBox Name="GroupBoxAppearanceNewUI">
|
||||
@@ -1965,6 +2382,15 @@
|
||||
FontWeight="Bold"
|
||||
Toggled="ToggleSwitchDisplayRandWindowNamesInputBtn_OnToggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#fafafa" Text="启用随机抽和单次抽按钮"
|
||||
VerticalAlignment="Center" FontSize="14" Margin="0,0,16,0" />
|
||||
<ui:ToggleSwitch OnContent="" OffContent=""
|
||||
Name="ToggleSwitchShowRandomAndSingleDraw"
|
||||
IsOn="True" FontFamily="Microsoft YaHei UI"
|
||||
FontWeight="Bold"
|
||||
Toggled="ToggleSwitchShowRandomAndSingleDraw_Toggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0"
|
||||
Stroke="#3f3f46" StrokeThickness="1" Margin="0,4,0,4" />
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
@@ -2006,7 +2432,7 @@
|
||||
<ui:SimpleStackPanel Orientation="Horizontal">
|
||||
<TextBlock FontSize="18" FontWeight="Bold" Text="Version:" />
|
||||
<TextBlock x:Name="AppVersionTextBlock" FontSize="18" FontWeight="Bold"
|
||||
Text="5.X.X.X" />
|
||||
Text="1.X.X.X" />
|
||||
</ui:SimpleStackPanel>
|
||||
<TextBlock
|
||||
Text="# 使用和分发本软件前,请您应当且务必知晓相关开源协议,且您应当知晓本软件基于 https://github.com/WXRIW/Ink-Canvas 修改而成。"
|
||||
@@ -2320,55 +2746,41 @@
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
</ui:ScrollViewerEx>
|
||||
<Grid ClipToBounds="True" Margin="0,0,0,0" Height="80" VerticalAlignment="Top">
|
||||
<Border Background="#18181b" CornerRadius="0" Margin="-1,-1,-1,0">
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock Foreground="White" Margin="25,-2,0,0" Text="设置" FontWeight="Bold"
|
||||
FontSize="32" />
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
<Canvas>
|
||||
<Image Canvas.Top="12" Canvas.Right="-16" Width="98" Height="98" Opacity="0.4">
|
||||
<Image.RenderTransform>
|
||||
<!-- giving the transform a name tells the framework not to freeze it -->
|
||||
<RotateTransform CenterX="49" CenterY="49" />
|
||||
</Image.RenderTransform>
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup ClipGeometry="M0,0 V257 H257 V0 H0 Z">
|
||||
<GeometryDrawing Brush="GhostWhite"
|
||||
Geometry="F0 M257,257z M0,0z M93.339,256.594L88.2444,215.634C85.4849,214.567 82.8846,213.287 80.4434,211.794 78.0023,210.301 75.6142,208.701 73.2793,206.994L35.3887,222.994 0.363831,162.194 33.1598,137.234C32.9476,135.741,32.8414,134.301,32.8414,132.914L32.8414,124.274C32.8414,122.887,32.9476,121.447,33.1598,119.954L0.363831,94.9941 35.3887,34.1941 73.2793,50.1941C75.6142,48.4874 78.0554,46.8874 80.6026,45.3941 83.1499,43.9007 85.6972,42.6207 88.2444,41.5541L93.339,0.594055 163.389,0.594055 168.483,41.5541C171.243,42.6207 173.843,43.9007 176.284,45.3941 178.725,46.8874 181.113,48.4874 183.448,50.1941L221.339,34.1941 256.364,94.9941 223.568,119.954C223.78,121.447,223.886,122.887,223.886,124.274L223.886,132.914C223.886,134.301,223.674,135.741,223.249,137.234L256.045,162.194 221.021,222.994 183.448,206.994C181.113,208.701 178.672,210.301 176.125,211.794 173.578,213.287 171.031,214.567 168.483,215.634L163.389,256.594 93.339,256.594z M160.523,160.274C151.82,169.021 141.312,173.394 129.001,173.394 116.477,173.394 105.916,169.021 97.3191,160.274 88.722,151.527 84.4235,140.967 84.4235,128.594 84.4235,116.221 88.722,105.661 97.3191,96.9141 105.916,88.1674 116.477,83.7941 129.001,83.7941 141.312,83.7941 151.82,88.1674 160.523,96.9141 169.226,105.661 173.578,116.221 173.578,128.594 173.578,140.967 169.226,151.527 160.523,160.274z" />
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
<Image.Triggers>
|
||||
<EventTrigger RoutedEvent="Loaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)"
|
||||
To="-360" Duration="0:0:3" RepeatBehavior="Forever" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</Image.Triggers>
|
||||
</Image>
|
||||
</Canvas>
|
||||
</Grid>
|
||||
<Grid VerticalAlignment="Bottom" Height="50">
|
||||
<Button FontFamily="Microsoft YaHei UI"
|
||||
|
||||
<!-- 底部按钮区域 -->
|
||||
<Grid Grid.Row="2" VerticalAlignment="Bottom" Height="50">
|
||||
<Button FontFamily="Microsoft YaHei UI"
|
||||
Width="120" Margin="10"
|
||||
HorizontalAlignment="Right"
|
||||
Content="关闭"
|
||||
Click="BtnSettings_Click" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
Click="BtnCloseSettings_Click">
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center" Spacing="0">
|
||||
<Image RenderOptions.BitmapScalingMode="HighQuality"
|
||||
Margin="0,0,6,0" Height="20" Width="20">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M19,6.41 L17.59,5 L12,10.59 L6.41,5 L5,6.41 L10.59,12 L5,17.59 L6.41,19 L12,13.41 L17.59,19 L19,17.59 L13.41,12 Z" />
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Label FontSize="16" Foreground="#fafafa" VerticalAlignment="Center"
|
||||
FontFamily="Microsoft YaHei UI" FontWeight="Bold">
|
||||
关闭
|
||||
</Label>
|
||||
</ui:SimpleStackPanel>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid></Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
<!--// 黑/白 板幕布 //-->
|
||||
<Grid Name="GridBackgroundCoverHolder">
|
||||
<Grid Name="GridBackgroundCover" Visibility="Collapsed" Background="#1F1F1F">
|
||||
@@ -2381,7 +2793,7 @@
|
||||
<Grid Name="GridTransparencyFakeBackground" Opacity="0" />
|
||||
<Label Name="Label" Visibility="Collapsed" Foreground="Gray" Content="0" />
|
||||
<Grid Name="InkCanvasGridForInkReplay">
|
||||
<InkCanvas x:Name="inkCanvas" ForceCursor="False"
|
||||
<InkCanvas x:Name="inkCanvas" ForceCursor="True" UseCustomCursor="True"
|
||||
TouchUp="Main_Grid_TouchUp" TouchDown="Main_Grid_TouchDown"
|
||||
TouchMove="inkCanvas_TouchMove"
|
||||
ManipulationDelta="Main_Grid_ManipulationDelta"
|
||||
@@ -4386,7 +4798,7 @@
|
||||
<Label Content="计时器" FontSize="8"
|
||||
HorizontalAlignment="Center" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel MouseDown="Border_MouseDown"
|
||||
<ui:SimpleStackPanel x:Name="RandomDrawPanel" Visibility="Collapsed" MouseDown="Border_MouseDown"
|
||||
MouseUp="SymbolIconRand_MouseUp"
|
||||
Margin="0,0,0,0" Height="38" Width="32"
|
||||
Orientation="Vertical">
|
||||
@@ -4406,7 +4818,7 @@
|
||||
<Label Content="随机抽" FontSize="8"
|
||||
HorizontalAlignment="Center" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel MouseDown="Border_MouseDown"
|
||||
<ui:SimpleStackPanel x:Name="SingleDrawPanel" Visibility="Collapsed" MouseDown="Border_MouseDown"
|
||||
MouseUp="SymbolIconRandOne_MouseUp"
|
||||
Margin="0,0,0,0" Height="38" Width="32"
|
||||
Orientation="Vertical">
|
||||
|
||||
+270
-23
@@ -18,6 +18,9 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -154,20 +157,9 @@ namespace Ink_Canvas {
|
||||
private void inkCanvas_EditingModeChanged(object sender, RoutedEventArgs e) {
|
||||
var inkCanvas1 = sender as InkCanvas;
|
||||
if (inkCanvas1 == null) return;
|
||||
// 修复“显示画笔光标”选项不可用的问题
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
inkCanvas1.UseCustomCursor = true;
|
||||
// 修复触屏和数位笔时光标不显示:只要有输入设备悬停、捕获,或有任何Stylus设备连接就显示
|
||||
if ((inkCanvas1.EditingMode == InkCanvasEditingMode.Ink || drawingShapeMode != 0)
|
||||
&& (inkCanvas1.IsStylusDirectlyOver || inkCanvas1.IsMouseDirectlyOver || inkCanvas1.IsStylusCaptured || inkCanvas1.IsMouseCaptured
|
||||
|| Stylus.CurrentStylusDevice != null))
|
||||
inkCanvas1.ForceCursor = true;
|
||||
else
|
||||
inkCanvas1.ForceCursor = false;
|
||||
} else {
|
||||
inkCanvas1.UseCustomCursor = false;
|
||||
inkCanvas1.ForceCursor = false;
|
||||
}
|
||||
|
||||
// 使用辅助方法设置光标
|
||||
SetCursorBasedOnEditingMode(inkCanvas1);
|
||||
|
||||
if (inkCanvas1.EditingMode == InkCanvasEditingMode.Ink) forcePointEraser = !forcePointEraser;
|
||||
}
|
||||
@@ -292,8 +284,8 @@ namespace Ink_Canvas {
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
|
||||
|
||||
private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e) {
|
||||
|
||||
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})");
|
||||
@@ -347,32 +339,287 @@ namespace Ink_Canvas {
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
// 添加一个辅助方法,根据当前编辑模式设置光标
|
||||
private void SetCursorBasedOnEditingMode(InkCanvas canvas)
|
||||
{
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
canvas.UseCustomCursor = true;
|
||||
canvas.ForceCursor = true;
|
||||
|
||||
// 根据编辑模式设置不同的光标
|
||||
if (canvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
canvas.Cursor = Cursors.Cross;
|
||||
} else if (canvas.EditingMode == InkCanvasEditingMode.Ink) {
|
||||
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Pen.cur", UriKind.Relative));
|
||||
if (sri != null)
|
||||
canvas.Cursor = new Cursor(sri.Stream);
|
||||
} else if (canvas.EditingMode == InkCanvasEditingMode.Select) {
|
||||
canvas.Cursor = Cursors.Cross;
|
||||
}
|
||||
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
} else {
|
||||
canvas.UseCustomCursor = false;
|
||||
canvas.ForceCursor = false;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标输入
|
||||
private void inkCanvas_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
inkCanvas.Cursor = Cursors.Arrow;
|
||||
// 使用辅助方法设置光标
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
}
|
||||
|
||||
// 手写笔输入
|
||||
private void inkCanvas_StylusDown(object sender, StylusDownEventArgs e)
|
||||
{
|
||||
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Pen.cur", UriKind.Relative));
|
||||
if (sri != null)
|
||||
inkCanvas.Cursor = new Cursor(sri.Stream);
|
||||
// 使用辅助方法设置光标
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
}
|
||||
|
||||
// 触摸输入,通常隐藏光标
|
||||
// 触摸输入,不隐藏光标
|
||||
private void inkCanvas_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
// 使用辅助方法设置光标
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
}
|
||||
|
||||
// 触摸结束,恢复光标
|
||||
private void inkCanvas_TouchUp(object sender, TouchEventArgs e)
|
||||
{
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
// 使用辅助方法设置光标
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
|
||||
// 确保光标可见
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
inkCanvas.ForceCursor = true;
|
||||
inkCanvas.UseCustomCursor = true;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Definations and Loading
|
||||
|
||||
#region Navigation Sidebar Methods
|
||||
|
||||
// 侧边栏导航按钮事件处理
|
||||
private void NavStartup_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到启动设置页面
|
||||
ShowSettingsSection("startup");
|
||||
}
|
||||
|
||||
private void NavCanvas_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到画布设置页面
|
||||
ShowSettingsSection("canvas");
|
||||
}
|
||||
|
||||
private void NavGesture_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到手势设置页面
|
||||
ShowSettingsSection("gesture");
|
||||
}
|
||||
|
||||
private void NavInkRecognition_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到墨迹识别设置页面
|
||||
ShowSettingsSection("inkrecognition");
|
||||
}
|
||||
|
||||
private void NavCrashAction_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到崩溃处理设置页面
|
||||
ShowSettingsSection("crashaction");
|
||||
}
|
||||
|
||||
private void NavPPT_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到PPT设置页面
|
||||
ShowSettingsSection("ppt");
|
||||
}
|
||||
|
||||
private void NavAdvanced_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到高级设置页面
|
||||
ShowSettingsSection("advanced");
|
||||
}
|
||||
|
||||
private void NavAutomation_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到自动化设置页面
|
||||
ShowSettingsSection("automation");
|
||||
}
|
||||
|
||||
private void NavRandomWindow_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到随机窗口设置页面
|
||||
ShowSettingsSection("randomwindow");
|
||||
}
|
||||
|
||||
private void NavAbout_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到关于页面
|
||||
ShowSettingsSection("about");
|
||||
}
|
||||
|
||||
// 新增:个性化设置
|
||||
private void NavTheme_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到个性化设置页面
|
||||
ShowSettingsSection("theme");
|
||||
}
|
||||
|
||||
// 新增:快捷键设置
|
||||
private void NavShortcuts_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到快捷键设置页面
|
||||
ShowSettingsSection("shortcuts");
|
||||
// 如果设置部分尚未快捷键
|
||||
MessageBox.Show("设置功能正在开发中", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
private void BtnCloseSettings_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 关闭设置面板
|
||||
BorderSettings.Visibility = Visibility.Collapsed;
|
||||
BorderSettingsMask.IsHitTestVisible = false;
|
||||
}
|
||||
|
||||
// 新增:折叠侧边栏
|
||||
private void CollapseNavSidebar_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 折叠/展开侧边栏
|
||||
var columnDefinitions = ((Grid)BorderSettings.Child).ColumnDefinitions;
|
||||
if (columnDefinitions[0].Width.Value == 50)
|
||||
{
|
||||
// 折叠侧边栏
|
||||
columnDefinitions[0].Width = new GridLength(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 展开侧边栏
|
||||
columnDefinitions[0].Width = new GridLength(50);
|
||||
}
|
||||
}
|
||||
|
||||
// 新增:显示侧边栏
|
||||
private void ShowNavSidebar_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 确保侧边栏展开
|
||||
var columnDefinitions = ((Grid)BorderSettings.Child).ColumnDefinitions;
|
||||
columnDefinitions[0].Width = new GridLength(50);
|
||||
}
|
||||
|
||||
// 辅助方法:显示指定的设置部分
|
||||
private void ShowSettingsSection(string sectionTag)
|
||||
{
|
||||
// 显示设置面板
|
||||
BorderSettings.Visibility = Visibility.Visible;
|
||||
BorderSettingsMask.IsHitTestVisible = true;
|
||||
|
||||
// 获取SettingsPanelScrollViewer中的所有GroupBox
|
||||
var stackPanel = SettingsPanelScrollViewer.Content as StackPanel;
|
||||
if (stackPanel == null) return;
|
||||
|
||||
// 首先隐藏所有GroupBox
|
||||
foreach (var child in stackPanel.Children)
|
||||
{
|
||||
if (child is GroupBox groupBox)
|
||||
{
|
||||
groupBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
// 根据传入的sectionTag显示相应的设置部分
|
||||
switch (sectionTag.ToLower())
|
||||
{
|
||||
case "startup":
|
||||
// 显示启动设置
|
||||
ShowGroupBoxByHeader(stackPanel, "启动");
|
||||
break;
|
||||
case "canvas":
|
||||
// 显示画板和墨迹设置
|
||||
ShowGroupBoxByHeader(stackPanel, "画板和墨迹");
|
||||
break;
|
||||
case "gesture":
|
||||
// 显示手势设置
|
||||
ShowGroupBoxByHeader(stackPanel, "手势");
|
||||
break;
|
||||
case "inkrecognition":
|
||||
// 显示墨迹纠正设置
|
||||
ShowGroupBoxByHeader(stackPanel, "墨迹纠正");
|
||||
if (GroupBoxInkRecognition != null)
|
||||
GroupBoxInkRecognition.Visibility = Visibility.Visible;
|
||||
break;
|
||||
case "crashaction":
|
||||
// 显示崩溃后操作设置
|
||||
ShowGroupBoxByHeader(stackPanel, "崩溃后操作");
|
||||
break;
|
||||
case "ppt":
|
||||
// 显示PPT联动设置
|
||||
ShowGroupBoxByHeader(stackPanel, "PPT联动");
|
||||
break;
|
||||
case "advanced":
|
||||
// 显示高级设置
|
||||
// 这里可能需要根据实际情况调整
|
||||
break;
|
||||
case "automation":
|
||||
// 显示自动化设置
|
||||
// 这里可能需要根据实际情况调整
|
||||
break;
|
||||
case "randomwindow":
|
||||
// 显示随机窗口设置
|
||||
if (GroupBoxRandWindow != null)
|
||||
GroupBoxRandWindow.Visibility = Visibility.Visible;
|
||||
break;
|
||||
case "theme":
|
||||
// 显示主题设置
|
||||
if (GroupBoxAppearanceNewUI != null)
|
||||
GroupBoxAppearanceNewUI.Visibility = Visibility.Visible;
|
||||
break;
|
||||
case "shortcuts":
|
||||
// 显示快捷键设置
|
||||
// 快捷键设置部分可能尚未实现
|
||||
break;
|
||||
case "about":
|
||||
// 显示关于页面
|
||||
ShowGroupBoxByHeader(stackPanel, "关于");
|
||||
break;
|
||||
default:
|
||||
// 默认显示第一个GroupBox
|
||||
if (stackPanel.Children.Count > 0 && stackPanel.Children[0] is GroupBox firstGroupBox)
|
||||
{
|
||||
firstGroupBox.Visibility = Visibility.Visible;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// 滚动到顶部
|
||||
SettingsPanelScrollViewer.ScrollToTop();
|
||||
}
|
||||
|
||||
// 根据Header文本查找并显示GroupBox
|
||||
private void ShowGroupBoxByHeader(StackPanel parent, string headerText)
|
||||
{
|
||||
foreach (var child in parent.Children)
|
||||
{
|
||||
if (child is GroupBox groupBox)
|
||||
{
|
||||
// 查找GroupBox的Header
|
||||
if (groupBox.Header is TextBlock headerTextBlock &&
|
||||
headerTextBlock.Text != null &&
|
||||
headerTextBlock.Text.Contains(headerText))
|
||||
{
|
||||
groupBox.Visibility = Visibility.Visible;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Navigation Sidebar Methods
|
||||
}
|
||||
}
|
||||
@@ -740,9 +740,11 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void SymbolIconRand_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
// 如果控件被隐藏,不处理事件
|
||||
if (RandomDrawPanel.Visibility != Visibility.Visible) return;
|
||||
|
||||
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
|
||||
RightUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
|
||||
//if (lastBorderMouseDownObject != sender) return;
|
||||
|
||||
AnimationsHelper.HideWithSlideAndFade(BorderTools);
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
|
||||
@@ -808,14 +810,16 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void SymbolIconRandOne_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
// 如果控件被隐藏,不处理事件
|
||||
if (SingleDrawPanel.Visibility != Visibility.Visible) return;
|
||||
|
||||
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
|
||||
RightUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
|
||||
//if (lastBorderMouseDownObject != sender) return;
|
||||
|
||||
AnimationsHelper.HideWithSlideAndFade(BorderTools);
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
|
||||
|
||||
new RandWindow(Settings,true).ShowDialog();
|
||||
new RandWindow(Settings, true).ShowDialog();
|
||||
}
|
||||
|
||||
private void GridInkReplayButton_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
@@ -1074,15 +1078,38 @@ namespace Ink_Canvas {
|
||||
var windowHandle = new WindowInteropHelper(this).Handle;
|
||||
var screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
var toolbarHeight = SystemParameters.PrimaryScreenHeight - SystemParameters.FullPrimaryScreenHeight -
|
||||
SystemParameters.WindowCaptionHeight;
|
||||
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
|
||||
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
|
||||
pos.X = (screenWidth - ViewboxFloatingBar.ActualWidth * ViewboxFloatingBarScaleTransform.ScaleX) / 2;
|
||||
|
||||
if (PosXCaculatedWithTaskbarHeight == false)
|
||||
pos.Y = screenHeight - MarginFromEdge * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
{
|
||||
// 如果任务栏高度为0(隐藏状态),则使用固定边距
|
||||
if (toolbarHeight == 0)
|
||||
{
|
||||
pos.Y = screenHeight - MarginFromEdge * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定边距: {MarginFromEdge}", LogHelper.LogType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.Y = screenHeight - MarginFromEdge * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
}
|
||||
}
|
||||
else if (PosXCaculatedWithTaskbarHeight == true)
|
||||
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
|
||||
toolbarHeight - ViewboxFloatingBarScaleTransform.ScaleY * 3;
|
||||
{
|
||||
// 如果任务栏高度为0(隐藏状态),则使用固定高度
|
||||
if (toolbarHeight == 0)
|
||||
{
|
||||
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
|
||||
3 * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}", LogHelper.LogType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
|
||||
toolbarHeight - ViewboxFloatingBarScaleTransform.ScaleY * 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (MarginFromEdge != -60) {
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) {
|
||||
@@ -1137,12 +1164,22 @@ namespace Ink_Canvas {
|
||||
var windowHandle = new WindowInteropHelper(this).Handle;
|
||||
var screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
var toolbarHeight = SystemParameters.PrimaryScreenHeight - SystemParameters.FullPrimaryScreenHeight -
|
||||
SystemParameters.WindowCaptionHeight;
|
||||
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
|
||||
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
|
||||
pos.X = (screenWidth - ViewboxFloatingBar.ActualWidth * ViewboxFloatingBarScaleTransform.ScaleX) / 2;
|
||||
|
||||
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
|
||||
toolbarHeight - ViewboxFloatingBarScaleTransform.ScaleY * 3;
|
||||
// 如果任务栏高度为0(隐藏状态),则使用固定边距
|
||||
if (toolbarHeight == 0)
|
||||
{
|
||||
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
|
||||
3 * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}", LogHelper.LogType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
|
||||
toolbarHeight - ViewboxFloatingBarScaleTransform.ScaleY * 3;
|
||||
}
|
||||
|
||||
if (pointDesktop.X != -1 || pointDesktop.Y != -1) pointDesktop = pos;
|
||||
|
||||
@@ -1180,8 +1217,8 @@ namespace Ink_Canvas {
|
||||
var windowHandle = new WindowInteropHelper(this).Handle;
|
||||
var screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
var toolbarHeight = SystemParameters.PrimaryScreenHeight - SystemParameters.FullPrimaryScreenHeight -
|
||||
SystemParameters.WindowCaptionHeight;
|
||||
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
|
||||
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
|
||||
pos.X = (screenWidth - ViewboxFloatingBar.ActualWidth * ViewboxFloatingBarScaleTransform.ScaleX) / 2;
|
||||
|
||||
pos.Y = screenHeight - 55 * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
@@ -1585,7 +1622,7 @@ namespace Ink_Canvas {
|
||||
|
||||
public void BtnRestart_Click(object sender, RoutedEventArgs e) {
|
||||
Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m");
|
||||
|
||||
App.IsAppExitByUser = true;
|
||||
CloseIsFromButton = true;
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Microsoft.Win32;
|
||||
using Application = System.Windows.Application;
|
||||
using File = System.IO.File;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
@@ -86,6 +87,61 @@ namespace Ink_Canvas {
|
||||
|
||||
Settings.PowerPointSettings.IsSupportWPS = ToggleSwitchSupportWPS.IsOn;
|
||||
SaveSettingsToFile();
|
||||
|
||||
// 重置PowerPoint/WPS实例状态
|
||||
ResetPresentationObjects();
|
||||
isPowerPointInitialized = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置所有演示相关的COM对象
|
||||
/// </summary>
|
||||
private void ResetPresentationObjects()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 清理对象引用
|
||||
if (pptApplication != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 尝试解除事件绑定
|
||||
pptApplication.PresentationOpen -= PptApplication_PresentationOpen;
|
||||
pptApplication.PresentationClose -= PptApplication_PresentationClose;
|
||||
pptApplication.SlideShowBegin -= PptApplication_SlideShowBegin;
|
||||
pptApplication.SlideShowNextSlide -= PptApplication_SlideShowNextSlide;
|
||||
pptApplication.SlideShowEnd -= PptApplication_SlideShowEnd;
|
||||
}
|
||||
catch { }
|
||||
|
||||
try { Marshal.ReleaseComObject(pptApplication); } catch { }
|
||||
pptApplication = null;
|
||||
}
|
||||
|
||||
if (presentation != null)
|
||||
{
|
||||
try { Marshal.ReleaseComObject(presentation); } catch { }
|
||||
presentation = null;
|
||||
}
|
||||
|
||||
if (slides != null)
|
||||
{
|
||||
try { Marshal.ReleaseComObject(slides); } catch { }
|
||||
slides = null;
|
||||
}
|
||||
|
||||
slide = null;
|
||||
|
||||
// 强制GC回收
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
|
||||
LogHelper.WriteLogToFile("成功重置所有演示对象", LogHelper.LogType.Info);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"重置演示对象时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool isWPSSupportOn => Settings.PowerPointSettings.IsSupportWPS;
|
||||
@@ -93,8 +149,34 @@ namespace Ink_Canvas {
|
||||
public static bool IsShowingRestoreHiddenSlidesWindow = false;
|
||||
private static bool IsShowingAutoplaySlidesWindow = false;
|
||||
private bool isPowerPointInitialized = false;
|
||||
private bool isWPSMode = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有可能的WPS进程名
|
||||
/// </summary>
|
||||
private string[] GetPossibleWPSProcessNames()
|
||||
{
|
||||
return new[] { "wpp", "wppmain", "wps", "et" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查WPS进程是否正在运行
|
||||
/// </summary>
|
||||
/// <param name="writeLog">是否记录日志,默认为true</param>
|
||||
private bool IsWPSRunning(bool writeLog = true)
|
||||
{
|
||||
foreach (var processName in GetPossibleWPSProcessNames())
|
||||
{
|
||||
var processes = Process.GetProcessesByName(processName);
|
||||
if (processes.Length > 0)
|
||||
{
|
||||
if (writeLog)
|
||||
LogHelper.WriteLogToFile($"检测到WPS进程: {processName}", LogHelper.LogType.Info);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void TimerCheckPPT_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
@@ -107,19 +189,44 @@ namespace Ink_Canvas {
|
||||
// 检查是否已有初始化的 PowerPoint 实例
|
||||
if (!isPowerPointInitialized)
|
||||
{
|
||||
// 优先检测WPS进程
|
||||
var wpsProcesses = Process.GetProcessesByName("wpp");
|
||||
// 检测WPS和PowerPoint进程
|
||||
bool wpsRunning = IsWPSRunning(true);
|
||||
var pptProcesses = Process.GetProcessesByName("POWERPNT");
|
||||
|
||||
// 根据设置和进程状态决定模式
|
||||
isWPSMode = isWPSSupportOn && wpsRunning;
|
||||
|
||||
LogHelper.WriteLogToFile($"初始化模式: {(isWPSMode ? "WPS" : "PowerPoint")}", LogHelper.LogType.Info);
|
||||
|
||||
// 优先获取WPS实例
|
||||
if (isWPSSupportOn && wpsProcesses.Length > 0)
|
||||
if (isWPSMode)
|
||||
{
|
||||
try
|
||||
{
|
||||
pptApplication = (Microsoft.Office.Interop.PowerPoint.Application)Marshal.GetActiveObject("wpp.Application");
|
||||
// 尝试多种可能的ProgID
|
||||
string[] possibleProgIds = { "wpp.Application", "WPS.Application" };
|
||||
|
||||
foreach (var progId in possibleProgIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile($"尝试获取COM对象: {progId}", LogHelper.LogType.Info);
|
||||
pptApplication = (Microsoft.Office.Interop.PowerPoint.Application)Marshal.GetActiveObject(progId);
|
||||
if (pptApplication != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"成功连接到WPS: {progId}", LogHelper.LogType.Info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (COMException)
|
||||
catch (COMException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取WPS实例失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
pptApplication = null;
|
||||
}
|
||||
}
|
||||
@@ -129,74 +236,71 @@ namespace Ink_Canvas {
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile("尝试获取PowerPoint实例", LogHelper.LogType.Info);
|
||||
pptApplication = (Microsoft.Office.Interop.PowerPoint.Application)Marshal.GetActiveObject("PowerPoint.Application");
|
||||
if (pptApplication != null)
|
||||
LogHelper.WriteLogToFile("成功连接到PowerPoint", LogHelper.LogType.Info);
|
||||
}
|
||||
catch (COMException)
|
||||
catch (COMException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取PowerPoint实例失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
pptApplication = null;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果都没有找到,且未启用WPS支持,则自动创建PowerPoint进程
|
||||
if (pptApplication == null && !isWPSSupportOn)
|
||||
if (pptApplication == null && !isWPSMode && pptProcesses.Length == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile("尝试创建新的PowerPoint实例", LogHelper.LogType.Info);
|
||||
pptApplication = (Microsoft.Office.Interop.PowerPoint.Application)Activator.CreateInstance(
|
||||
Marshal.GetTypeFromCLSID(new Guid("91493441-5A91-11CF-8700-00AA0060263B")));
|
||||
if (pptApplication != null)
|
||||
LogHelper.WriteLogToFile("成功创建PowerPoint实例", LogHelper.LogType.Info);
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"创建PowerPoint实例失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
pptApplication = null;
|
||||
}
|
||||
}
|
||||
|
||||
isPowerPointInitialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查进程是否还在
|
||||
var pptProcessesCheck = Process.GetProcessesByName("POWERPNT");
|
||||
var wpsProcessesCheck = Process.GetProcessesByName("wpp");
|
||||
bool isWpsMode = isWPSSupportOn && wpsProcessesCheck.Length > 0;
|
||||
bool isPptMode = !isWPSSupportOn && pptProcessesCheck.Length > 0;
|
||||
bool currentWpsRunning = IsWPSRunning(false); // 定期检查不输出日志
|
||||
var currentPptProcesses = Process.GetProcessesByName("POWERPNT");
|
||||
|
||||
// 检测应用程序是否关闭
|
||||
bool applicationClosed = isWPSMode ? !currentWpsRunning : currentPptProcesses.Length == 0;
|
||||
|
||||
if ((isWpsMode && wpsProcessesCheck.Length == 0) || (!isWpsMode && pptProcessesCheck.Length == 0))
|
||||
if (applicationClosed)
|
||||
{
|
||||
// 进程已关闭,清理对象
|
||||
if (pptApplication != null)
|
||||
{
|
||||
try { Marshal.ReleaseComObject(pptApplication); } catch { }
|
||||
pptApplication = null;
|
||||
}
|
||||
if (presentation != null)
|
||||
{
|
||||
try { Marshal.ReleaseComObject(presentation); } catch { }
|
||||
presentation = null;
|
||||
}
|
||||
if (slides != null)
|
||||
{
|
||||
try { Marshal.ReleaseComObject(slides); } catch { }
|
||||
slides = null;
|
||||
}
|
||||
slide = null;
|
||||
LogHelper.WriteLogToFile($"{(isWPSMode ? "WPS" : "PowerPoint")}进程已关闭,清理对象", LogHelper.LogType.Info);
|
||||
|
||||
// 进程已关闭,调用重置方法清理对象
|
||||
ResetPresentationObjects();
|
||||
isPowerPointInitialized = false;
|
||||
|
||||
// PowerPoint进程守护:自动重启PowerPoint进程(仅在未启用WPS支持时)
|
||||
if (!isWPSSupportOn)
|
||||
if (!isWPSSupportOn && !isWPSMode)
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile("尝试重启PowerPoint进程", LogHelper.LogType.Info);
|
||||
pptApplication = (Microsoft.Office.Interop.PowerPoint.Application)Activator.CreateInstance(
|
||||
Marshal.GetTypeFromCLSID(new Guid("91493441-5A91-11CF-8700-00AA0060263B")));
|
||||
isPowerPointInitialized = true;
|
||||
LogHelper.WriteLogToFile("PowerPoint进程重启成功", LogHelper.LogType.Info);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile("PowerPoint 守护重启失败: " + ex.ToString(), LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"PowerPoint守护重启失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 启用WPS支持时不守护PowerPoint进程
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -273,7 +377,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"TimerCheckPPT_Elapsed 异常: {ex.Message}", LogHelper.LogType.Error);
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
BtnPPTSlideShow.Visibility = Visibility.Collapsed;
|
||||
timerCheckPPT.Start();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
@@ -17,6 +17,13 @@ namespace Ink_Canvas {
|
||||
private object lastBorderMouseDownObject;
|
||||
|
||||
private void Border_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
// 如果发送者是 RandomDrawPanel 或 SingleDrawPanel,且它们被隐藏,则不处理事件
|
||||
if (sender is SimpleStackPanel panel) {
|
||||
if ((panel == RandomDrawPanel || panel == SingleDrawPanel) &&
|
||||
panel.Visibility != Visibility.Visible) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
lastBorderMouseDownObject = sender;
|
||||
}
|
||||
|
||||
@@ -380,6 +387,11 @@ namespace Ink_Canvas {
|
||||
isProgramChangeStrokeSelection = false;
|
||||
inkCanvas.Strokes.Add(StrokesSelectionClone);
|
||||
}
|
||||
else {
|
||||
// 新增:启动套索选择模式
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
|
||||
inkCanvas.Select(new StrokeCollection());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -694,6 +694,69 @@ namespace Ink_Canvas {
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void ToggleSwitchEnablePressureTouchMode_Toggled(object sender, RoutedEventArgs e) {
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.Canvas.EnablePressureTouchMode = ToggleSwitchEnablePressureTouchMode.IsOn;
|
||||
|
||||
// 如果启用了压感触屏模式,则自动关闭屏蔽压感
|
||||
if (Settings.Canvas.EnablePressureTouchMode && Settings.Canvas.DisablePressure) {
|
||||
Settings.Canvas.DisablePressure = false;
|
||||
ToggleSwitchDisablePressure.IsOn = false;
|
||||
}
|
||||
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void ToggleSwitchDisablePressure_Toggled(object sender, RoutedEventArgs e) {
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.Canvas.DisablePressure = ToggleSwitchDisablePressure.IsOn;
|
||||
|
||||
// 如果启用了屏蔽压感,则自动关闭压感触屏模式
|
||||
if (Settings.Canvas.DisablePressure && Settings.Canvas.EnablePressureTouchMode) {
|
||||
Settings.Canvas.EnablePressureTouchMode = false;
|
||||
ToggleSwitchEnablePressureTouchMode.IsOn = false;
|
||||
}
|
||||
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void ToggleSwitchAutoStraightenLine_Toggled(object sender, RoutedEventArgs e) {
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.Canvas.AutoStraightenLine = ToggleSwitchAutoStraightenLine.IsOn;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void AutoStraightenLineThresholdSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.Canvas.AutoStraightenLineThreshold = (int)e.NewValue;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void ToggleSwitchLineEndpointSnapping_Toggled(object sender, RoutedEventArgs e) {
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.Canvas.LineEndpointSnapping = ToggleSwitchLineEndpointSnapping.IsOn;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void LineEndpointSnappingThresholdSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.Canvas.LineEndpointSnappingThreshold = (int)e.NewValue;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void LineStraightenSensitivitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.InkToShape.LineStraightenSensitivity = e.NewValue;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Canvas
|
||||
@@ -1412,7 +1475,7 @@ namespace Ink_Canvas {
|
||||
Settings.Automation.IsAutoKillVComYouJiao = false;
|
||||
Settings.Automation.IsAutoKillInkCanvas = false;
|
||||
Settings.Automation.IsAutoKillICA = false;
|
||||
Settings.Automation.IsAutoKillIDT = true;
|
||||
Settings.Automation.IsAutoKillIDT = false;
|
||||
Settings.Automation.IsAutoKillSeewoLauncher2DesktopAnnotation = false;
|
||||
Settings.Automation.IsSaveScreenshotsInDateFolders = false;
|
||||
Settings.Automation.IsAutoSaveStrokesAtScreenshot = true;
|
||||
@@ -1447,6 +1510,12 @@ namespace Ink_Canvas {
|
||||
Settings.Canvas.HideStrokeWhenSelecting = false;
|
||||
Settings.Canvas.ClearCanvasAndClearTimeMachine = false;
|
||||
Settings.Canvas.FitToCurve = true;
|
||||
Settings.Canvas.EnablePressureTouchMode = false;
|
||||
Settings.Canvas.DisablePressure = false;
|
||||
Settings.Canvas.AutoStraightenLine = true;
|
||||
Settings.Canvas.AutoStraightenLineThreshold = 30;
|
||||
Settings.Canvas.LineEndpointSnapping = true;
|
||||
Settings.Canvas.LineEndpointSnappingThreshold = 15;
|
||||
Settings.Canvas.UsingWhiteboard = false;
|
||||
Settings.Canvas.HyperbolaAsymptoteOption = 0;
|
||||
|
||||
@@ -1690,6 +1759,21 @@ namespace Ink_Canvas {
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void ToggleSwitchShowRandomAndSingleDraw_Toggled(object sender, RoutedEventArgs e) {
|
||||
if (!isLoaded) return;
|
||||
|
||||
// 获取开关状态并保存到设置中
|
||||
bool isToggled = ToggleSwitchShowRandomAndSingleDraw.IsOn;
|
||||
Settings.RandSettings.ShowRandomAndSingleDraw = isToggled;
|
||||
|
||||
// 更新UI显示
|
||||
RandomDrawPanel.Visibility = isToggled ? Visibility.Visible : Visibility.Collapsed;
|
||||
SingleDrawPanel.Visibility = isToggled ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
// 保存设置到文件
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static void SaveSettingsToFile() {
|
||||
|
||||
@@ -434,6 +434,12 @@ namespace Ink_Canvas {
|
||||
inkCanvas.ForceCursor = false;
|
||||
}
|
||||
|
||||
// 初始化压感触屏模式开关状态
|
||||
ToggleSwitchEnablePressureTouchMode.IsOn = Settings.Canvas.EnablePressureTouchMode;
|
||||
|
||||
// 初始化屏蔽压感开关状态
|
||||
ToggleSwitchDisablePressure.IsOn = Settings.Canvas.DisablePressure;
|
||||
|
||||
ComboBoxPenStyle.SelectedIndex = Settings.Canvas.InkStyle;
|
||||
BoardComboBoxPenStyle.SelectedIndex = Settings.Canvas.InkStyle;
|
||||
|
||||
@@ -500,6 +506,14 @@ namespace Ink_Canvas {
|
||||
ToggleSwitchFitToCurve.IsOn = false;
|
||||
drawingAttributes.FitToCurve = false;
|
||||
}
|
||||
|
||||
// 初始化直线自动拉直相关设置
|
||||
ToggleSwitchAutoStraightenLine.IsOn = Settings.Canvas.AutoStraightenLine;
|
||||
AutoStraightenLineThresholdSlider.Value = Settings.Canvas.AutoStraightenLineThreshold;
|
||||
|
||||
// 初始化直线端点吸附相关设置
|
||||
ToggleSwitchLineEndpointSnapping.IsOn = Settings.Canvas.LineEndpointSnapping;
|
||||
LineEndpointSnappingThresholdSlider.Value = Settings.Canvas.LineEndpointSnappingThreshold;
|
||||
} else {
|
||||
Settings.Canvas = new Canvas();
|
||||
}
|
||||
@@ -564,12 +578,22 @@ namespace Ink_Canvas {
|
||||
ToggleCheckboxEnableInkToShapeRectangle.IsChecked = Settings.InkToShape.IsInkToShapeRectangle;
|
||||
|
||||
ToggleCheckboxEnableInkToShapeRounded.IsChecked = Settings.InkToShape.IsInkToShapeRounded;
|
||||
|
||||
// 初始化直线拉直灵敏度
|
||||
LineStraightenSensitivitySlider.Value = Settings.InkToShape.LineStraightenSensitivity;
|
||||
} else {
|
||||
Settings.InkToShape = new InkToShape();
|
||||
}
|
||||
|
||||
// RandSettings
|
||||
if (Settings.RandSettings != null) { } else {
|
||||
if (Settings.RandSettings != null) {
|
||||
ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn;
|
||||
RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
|
||||
RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
|
||||
ToggleSwitchShowRandomAndSingleDraw.IsOn = Settings.RandSettings.ShowRandomAndSingleDraw;
|
||||
RandomDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
|
||||
SingleDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
|
||||
} else {
|
||||
Settings.RandSettings = new RandSettings();
|
||||
ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn;
|
||||
RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Ink_Canvas {
|
||||
#endregion Floating Bar Control
|
||||
|
||||
private int drawingShapeMode = 0;
|
||||
private bool isLongPressSelected = false; // 用于存是否是“选中”状态,便于后期抬笔后不做切换到笔的处理
|
||||
private bool isLongPressSelected = false; // 用于存是否是"选中"状态,便于后期抬笔后不做切换到笔的处理
|
||||
|
||||
#region Buttons
|
||||
|
||||
@@ -429,6 +429,8 @@ namespace Ink_Canvas {
|
||||
|
||||
private void inkCanvas_TouchMove(object sender, TouchEventArgs e) {
|
||||
if (isSingleFingerDragMode) return;
|
||||
|
||||
// 处理形状绘制模式
|
||||
if (drawingShapeMode != 0) {
|
||||
if (isLastTouchEraser) return;
|
||||
//EraserContainer.Background = null;
|
||||
@@ -443,15 +445,82 @@ namespace Ink_Canvas {
|
||||
catch {
|
||||
Trace.WriteLine("lastTempStrokeCollection failed.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.None)
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
}
|
||||
|
||||
MouseTouchMove(e.GetTouchPoint(inkCanvas).Position);
|
||||
// 触摸移动时保持自定义光标显示
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
inkCanvas.ForceCursor = true;
|
||||
inkCanvas.UseCustomCursor = true; // 确保使用自定义光标
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
|
||||
if (NeedUpdateIniP()) iniP = e.GetTouchPoint(inkCanvas).Position;
|
||||
if (drawingShapeMode == 9 && isFirstTouchCuboid == false) MouseTouchMove(iniP);
|
||||
inkCanvas.Opacity = 1;
|
||||
double boundsWidth = GetTouchBoundWidth(e), eraserMultiplier = 1.0;
|
||||
if (!Settings.Advanced.EraserBindTouchMultiplier && Settings.Advanced.IsSpecialScreen)
|
||||
eraserMultiplier = 1 / Settings.Advanced.TouchMultiplier;
|
||||
if (boundsWidth > BoundsWidth) {
|
||||
isLastTouchEraser = true;
|
||||
if (drawingShapeMode == 0 && forceEraser) return;
|
||||
if (boundsWidth > BoundsWidth * 2.5) {
|
||||
double k = 1;
|
||||
switch (Settings.Canvas.EraserSize) {
|
||||
case 0:
|
||||
k = 0.5;
|
||||
break;
|
||||
case 1:
|
||||
k = 0.8;
|
||||
break;
|
||||
case 3:
|
||||
k = 1.25;
|
||||
break;
|
||||
case 4:
|
||||
k = 1.8;
|
||||
break;
|
||||
}
|
||||
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(boundsWidth * k * eraserMultiplier,
|
||||
boundsWidth * k * eraserMultiplier);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
|
||||
|
||||
// 立即应用光标设置
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
inkCanvas.Cursor = Cursors.Cross;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (StackPanelPPTControls.Visibility == Visibility.Visible && inkCanvas.Strokes.Count == 0 &&
|
||||
Settings.PowerPointSettings.IsEnableFingerGestureSlideShowControl) {
|
||||
isLastTouchEraser = false;
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.GestureOnly;
|
||||
inkCanvas.Opacity = 0.1;
|
||||
}
|
||||
else {
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(5, 5);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
isLastTouchEraser = false;
|
||||
// 修复面积擦时不显示橡皮形状:无论 forcePointEraser 状态,均显示 50x50 橡皮
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(50, 50);
|
||||
if (forceEraser) return;
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||
}
|
||||
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.None)
|
||||
return;
|
||||
|
||||
if (e.TouchDevice == null) {
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
} else {
|
||||
System.Windows.Forms.Cursor.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private int drawMultiStepShapeCurrentStep = 0; //多笔完成的图形 当前所处在的笔画
|
||||
@@ -1607,9 +1676,24 @@ namespace Ink_Canvas {
|
||||
|
||||
private void MainWindow_OnMouseMove(object sender, MouseEventArgs e) {
|
||||
if (e.StylusDevice == null) {
|
||||
// 鼠标移动时保持光标可见
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
|
||||
// 如果用户设置了显示光标,则确保光标显示正确
|
||||
if (Settings.Canvas.IsShowCursor && inkCanvas != null) {
|
||||
inkCanvas.ForceCursor = true;
|
||||
inkCanvas.UseCustomCursor = true;
|
||||
}
|
||||
} else {
|
||||
System.Windows.Forms.Cursor.Hide();
|
||||
// 只有当用户未设置显示光标时才隐藏
|
||||
if (!Settings.Canvas.IsShowCursor) {
|
||||
System.Windows.Forms.Cursor.Hide();
|
||||
} else if (inkCanvas != null) {
|
||||
// 如果用户设置了显示光标,则确保光标显示正确
|
||||
inkCanvas.ForceCursor = true;
|
||||
inkCanvas.UseCustomCursor = true;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,154 @@ namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
private StrokeCollection newStrokes = new StrokeCollection();
|
||||
private List<Circle> circles = new List<Circle>();
|
||||
private const double SNAP_THRESHOLD = 15.0; // Distance threshold for endpoint snapping
|
||||
private const double LINE_STRAIGHTEN_THRESHOLD = 0.10; // 降低阈值,让直线检测更严格
|
||||
|
||||
private void inkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e) {
|
||||
if (Settings.Canvas.FitToCurve == true) drawingAttributes.FitToCurve = false;
|
||||
|
||||
try {
|
||||
inkCanvas.Opacity = 1;
|
||||
|
||||
// 应用屏蔽压感功能 - 如果启用,所有笔画都使用统一粗细
|
||||
if (Settings.Canvas.DisablePressure) {
|
||||
var uniformPoints = new StylusPointCollection();
|
||||
foreach (StylusPoint point in e.Stroke.StylusPoints) {
|
||||
StylusPoint newPoint = new StylusPoint(point.X, point.Y, 0.5f); // 统一压感值为0.5
|
||||
uniformPoints.Add(newPoint);
|
||||
}
|
||||
e.Stroke.StylusPoints = uniformPoints;
|
||||
}
|
||||
// 应用压感触屏模式 - 如果启用并且检测到触屏输入
|
||||
else if (Settings.Canvas.EnablePressureTouchMode) {
|
||||
bool isTouchInput = true;
|
||||
foreach (StylusPoint point in e.Stroke.StylusPoints) {
|
||||
// 检测是否为压感笔输入(压感笔的PressureFactor不等于0.5或0)
|
||||
if ((point.PressureFactor > 0.501 || point.PressureFactor < 0.5) && point.PressureFactor != 0) {
|
||||
isTouchInput = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是触屏输入,则应用模拟压感
|
||||
if (isTouchInput) {
|
||||
switch (Settings.Canvas.InkStyle) {
|
||||
case 1:
|
||||
if (penType == 0)
|
||||
try {
|
||||
var stylusPoints = new StylusPointCollection();
|
||||
var n = e.Stroke.StylusPoints.Count - 1;
|
||||
|
||||
for (var i = 0; i <= n; i++) {
|
||||
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());
|
||||
var point = new StylusPoint();
|
||||
if (speed >= 0.25)
|
||||
point.PressureFactor = (float)(0.5 - 0.3 * (Math.Min(speed, 1.5) - 0.3) / 1.2);
|
||||
else if (speed >= 0.05)
|
||||
point.PressureFactor = (float)0.5;
|
||||
else
|
||||
point.PressureFactor = (float)(0.5 + 0.4 * (0.05 - speed) / 0.05);
|
||||
|
||||
point.X = e.Stroke.StylusPoints[i].X;
|
||||
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||
stylusPoints.Add(point);
|
||||
}
|
||||
|
||||
e.Stroke.StylusPoints = stylusPoints;
|
||||
}
|
||||
catch { }
|
||||
break;
|
||||
case 0:
|
||||
if (penType == 0)
|
||||
try {
|
||||
var stylusPoints = new StylusPointCollection();
|
||||
var n = e.Stroke.StylusPoints.Count - 1;
|
||||
var pressure = 0.1;
|
||||
var x = 10;
|
||||
if (n == 1) return;
|
||||
if (n >= x) {
|
||||
for (var i = 0; i < n - x; i++) {
|
||||
var point = new StylusPoint();
|
||||
|
||||
point.PressureFactor = (float)0.5;
|
||||
point.X = e.Stroke.StylusPoints[i].X;
|
||||
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||
stylusPoints.Add(point);
|
||||
}
|
||||
|
||||
for (var i = n - x; i <= n; i++) {
|
||||
var point = new StylusPoint();
|
||||
|
||||
point.PressureFactor = (float)((0.5 - pressure) * (n - i) / x + pressure);
|
||||
point.X = e.Stroke.StylusPoints[i].X;
|
||||
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||
stylusPoints.Add(point);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i <= n; i++) {
|
||||
var point = new StylusPoint();
|
||||
|
||||
point.PressureFactor = (float)(0.4 * (n - i) / n + pressure);
|
||||
point.X = e.Stroke.StylusPoints[i].X;
|
||||
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||
stylusPoints.Add(point);
|
||||
}
|
||||
}
|
||||
|
||||
e.Stroke.StylusPoints = stylusPoints;
|
||||
}
|
||||
catch { }
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply line straightening and endpoint snapping if ink-to-shape is enabled
|
||||
if (Settings.InkToShape.IsInkToShapeEnabled) {
|
||||
// Check if this stroke could be a straight line
|
||||
if (IsPotentialStraightLine(e.Stroke)) {
|
||||
// Get start and end points of the stroke
|
||||
Point startPoint = e.Stroke.StylusPoints[0].ToPoint();
|
||||
Point endPoint = e.Stroke.StylusPoints[e.Stroke.StylusPoints.Count - 1].ToPoint();
|
||||
|
||||
// Try to snap endpoints to existing strokes
|
||||
bool snapped = false;
|
||||
if (Settings.InkToShape.IsInkToShapeRectangle || Settings.InkToShape.IsInkToShapeTriangle) {
|
||||
Point[] snappedPoints = GetSnappedEndpoints(startPoint, endPoint);
|
||||
if (snappedPoints != null) {
|
||||
startPoint = snappedPoints[0];
|
||||
endPoint = snappedPoints[1];
|
||||
snapped = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Create straight line stroke
|
||||
if (snapped || ShouldStraightenLine(e.Stroke)) {
|
||||
StylusPointCollection straightLinePoints = CreateStraightLine(startPoint, endPoint);
|
||||
Stroke straightStroke = new Stroke(straightLinePoints) {
|
||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||
};
|
||||
|
||||
// Replace the original stroke with the straightened one
|
||||
SetNewBackupOfStroke();
|
||||
_currentCommitType = CommitReason.ShapeRecognition;
|
||||
inkCanvas.Strokes.Remove(e.Stroke);
|
||||
inkCanvas.Strokes.Add(straightStroke);
|
||||
_currentCommitType = CommitReason.UserInput;
|
||||
|
||||
// We can't modify e.Stroke directly, but we need to update newStrokes
|
||||
// to ensure proper shape recognition for the straightened line
|
||||
if (newStrokes.Contains(e.Stroke)) {
|
||||
newStrokes.Remove(e.Stroke);
|
||||
newStrokes.Add(straightStroke);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.InkToShape.IsInkToShapeEnabled && !Environment.Is64BitProcess) {
|
||||
void InkToShapeProcess() {
|
||||
try {
|
||||
@@ -422,6 +564,203 @@ namespace Ink_Canvas {
|
||||
if (Settings.Canvas.FitToCurve == true) drawingAttributes.FitToCurve = true;
|
||||
}
|
||||
|
||||
// New method: Checks if a stroke is potentially a straight line
|
||||
private bool IsPotentialStraightLine(Stroke stroke) {
|
||||
// 确保有足够的点来进行线条分析
|
||||
if (stroke.StylusPoints.Count < 5)
|
||||
return false;
|
||||
|
||||
Point start = stroke.StylusPoints.First().ToPoint();
|
||||
Point end = stroke.StylusPoints.Last().ToPoint();
|
||||
double lineLength = GetDistance(start, end);
|
||||
|
||||
// 线条必须足够长才考虑拉直,至少30像素
|
||||
if (lineLength < 30)
|
||||
return false;
|
||||
|
||||
// 获取用户设置的灵敏度值
|
||||
double sensitivity = Settings.InkToShape.LineStraightenSensitivity;
|
||||
// 快速检查使用略宽松的阈值
|
||||
double quickThreshold = Math.Min(sensitivity * 1.5, 0.20);
|
||||
|
||||
// 快速检查:计算几个关键点与直线的距离
|
||||
if (stroke.StylusPoints.Count >= 10) {
|
||||
// 取中点和1/4、3/4位置的点,快速检查偏差
|
||||
int quarterIdx = stroke.StylusPoints.Count / 4;
|
||||
int midIdx = stroke.StylusPoints.Count / 2;
|
||||
int threeQuarterIdx = quarterIdx * 3;
|
||||
|
||||
Point quarterPoint = stroke.StylusPoints[quarterIdx].ToPoint();
|
||||
Point midPoint = stroke.StylusPoints[midIdx].ToPoint();
|
||||
Point threeQuarterPoint = stroke.StylusPoints[threeQuarterIdx].ToPoint();
|
||||
|
||||
double quarterDeviation = DistanceFromLineToPoint(start, end, quarterPoint);
|
||||
double midDeviation = DistanceFromLineToPoint(start, end, midPoint);
|
||||
double threeQuarterDeviation = DistanceFromLineToPoint(start, end, threeQuarterPoint);
|
||||
|
||||
// 如果任一点偏离太大,直接排除
|
||||
double quickRelativeThreshold = lineLength * quickThreshold;
|
||||
if (quarterDeviation > quickRelativeThreshold ||
|
||||
midDeviation > quickRelativeThreshold ||
|
||||
threeQuarterDeviation > quickRelativeThreshold) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// New method: Determines if a stroke should be straightened into a line
|
||||
private bool ShouldStraightenLine(Stroke stroke) {
|
||||
// Basic implementation: check if points roughly follow a straight line
|
||||
Point start = stroke.StylusPoints.First().ToPoint();
|
||||
Point end = stroke.StylusPoints.Last().ToPoint();
|
||||
|
||||
// Calculate max deviation from the straight line between start and end
|
||||
double maxDeviation = 0;
|
||||
double lineLength = GetDistance(start, end);
|
||||
|
||||
// 如果线条太短,不进行拉直处理
|
||||
if (lineLength < 50) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取用户设置的灵敏度值
|
||||
double sensitivity = Settings.InkToShape.LineStraightenSensitivity;
|
||||
|
||||
// 计算点与直线的偏差
|
||||
double totalDeviation = 0;
|
||||
int pointCount = 0;
|
||||
|
||||
// Calculate deviation for each point
|
||||
foreach (StylusPoint sp in stroke.StylusPoints) {
|
||||
Point p = sp.ToPoint();
|
||||
double deviation = DistanceFromLineToPoint(start, end, p);
|
||||
maxDeviation = Math.Max(maxDeviation, deviation);
|
||||
totalDeviation += deviation;
|
||||
pointCount++;
|
||||
}
|
||||
|
||||
// 计算平均偏差
|
||||
double avgDeviation = totalDeviation / pointCount;
|
||||
|
||||
// 检查点分布的一致性 - 如果有些点偏离很大而其他点很接近直线,表明线条有明显弯曲
|
||||
double deviationVariance = 0;
|
||||
foreach (StylusPoint sp in stroke.StylusPoints) {
|
||||
Point p = sp.ToPoint();
|
||||
double deviation = DistanceFromLineToPoint(start, end, p);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
deviationVariance /= pointCount;
|
||||
|
||||
// 如果最大偏差超过线长的阈值比例,或者偏差方差较大(表示不均匀弯曲),则不拉直
|
||||
if ((maxDeviation / lineLength) > sensitivity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 如果偏差方差大,说明线条弯曲不均匀
|
||||
if (deviationVariance > (sensitivity * lineLength * 0.05)) {
|
||||
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);
|
||||
|
||||
// 如果中点偏离过大,不拉直
|
||||
if (midDeviation > (lineLength * sensitivity * 0.8)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// New method: Creates a straight line stroke between two points
|
||||
private StylusPointCollection CreateStraightLine(Point start, Point end) {
|
||||
StylusPointCollection points = new StylusPointCollection();
|
||||
|
||||
// Create a more natural pressure profile for the line
|
||||
if (Settings.InkToShape.IsInkToShapeNoFakePressureRectangle == true || penType == 1) {
|
||||
points.Add(new StylusPoint(start.X, start.Y));
|
||||
points.Add(new StylusPoint(end.X, end.Y));
|
||||
} else {
|
||||
points.Add(new StylusPoint(start.X, start.Y, 0.4f));
|
||||
|
||||
// Add a middle point with higher pressure
|
||||
Point midPoint = new Point((start.X + end.X) / 2, (start.Y + end.Y) / 2);
|
||||
points.Add(new StylusPoint(midPoint.X, midPoint.Y, 0.8f));
|
||||
|
||||
points.Add(new StylusPoint(end.X, end.Y, 0.4f));
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
// New method: Gets distance from point to a line defined by two points
|
||||
private double DistanceFromLineToPoint(Point lineStart, Point lineEnd, Point point) {
|
||||
// Calculate distance from point to line defined by lineStart and lineEnd
|
||||
double lineLength = GetDistance(lineStart, lineEnd);
|
||||
if (lineLength == 0) return GetDistance(point, lineStart);
|
||||
|
||||
// Calculate the cross product to get the perpendicular distance
|
||||
double distance = Math.Abs((lineEnd.Y - lineStart.Y) * point.X -
|
||||
(lineEnd.X - lineStart.X) * point.Y +
|
||||
lineEnd.X * lineStart.Y - lineEnd.Y * lineStart.X) / lineLength;
|
||||
return distance;
|
||||
}
|
||||
|
||||
// New method: Attempts to snap endpoints to existing stroke endpoints
|
||||
private Point[] GetSnappedEndpoints(Point start, Point end) {
|
||||
bool startSnapped = false;
|
||||
bool endSnapped = false;
|
||||
Point snappedStart = start;
|
||||
Point snappedEnd = end;
|
||||
|
||||
// Check all strokes in canvas for potential snap points
|
||||
foreach (Stroke stroke in inkCanvas.Strokes) {
|
||||
if (stroke.StylusPoints.Count == 0) continue;
|
||||
|
||||
// Get stroke endpoints
|
||||
Point strokeStart = stroke.StylusPoints.First().ToPoint();
|
||||
Point strokeEnd = stroke.StylusPoints.Last().ToPoint();
|
||||
|
||||
// Check if start point should snap to an endpoint
|
||||
if (!startSnapped) {
|
||||
if (GetDistance(start, strokeStart) < SNAP_THRESHOLD) {
|
||||
snappedStart = strokeStart;
|
||||
startSnapped = true;
|
||||
} else if (GetDistance(start, strokeEnd) < SNAP_THRESHOLD) {
|
||||
snappedStart = strokeEnd;
|
||||
startSnapped = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if end point should snap to an endpoint
|
||||
if (!endSnapped) {
|
||||
if (GetDistance(end, strokeStart) < SNAP_THRESHOLD) {
|
||||
snappedEnd = strokeStart;
|
||||
endSnapped = true;
|
||||
} else if (GetDistance(end, strokeEnd) < SNAP_THRESHOLD) {
|
||||
snappedEnd = strokeEnd;
|
||||
endSnapped = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If both endpoints are snapped, we're done
|
||||
if (startSnapped && endSnapped) break;
|
||||
}
|
||||
|
||||
// Return snapped points if any snapping occurred
|
||||
if (startSnapped || endSnapped) {
|
||||
return new Point[] { snappedStart, snappedEnd };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void SetNewBackupOfStroke() {
|
||||
lastTouchDownStrokeCollection = inkCanvas.Strokes.Clone();
|
||||
var whiteboardIndex = CurrentWhiteboardIndex;
|
||||
|
||||
@@ -183,6 +183,11 @@ namespace Ink_Canvas {
|
||||
private bool forcePointEraser = true;
|
||||
|
||||
private void Main_Grid_TouchDown(object sender, TouchEventArgs e) {
|
||||
// 确保触摸时显示自定义光标
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
inkCanvas.ForceCursor = true;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
|
||||
inkCanvas.CaptureTouch(e.TouchDevice);
|
||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||
|
||||
@@ -63,7 +63,11 @@ namespace Ink_Canvas
|
||||
|
||||
private void RestartAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
if (mainWin.IsLoaded) mainWin.BtnRestart_Click(null,null);
|
||||
if (mainWin.IsLoaded) {
|
||||
App.IsAppExitByUser = true;
|
||||
Application.Current.Shutdown();
|
||||
// mainWin.BtnExit_Click(null,null);
|
||||
}
|
||||
}
|
||||
|
||||
private void ForceFullScreenTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("5.0.5.1")]
|
||||
[assembly: AssemblyFileVersion("5.0.5.1")]
|
||||
[assembly: AssemblyVersion("1.6.3.0")]
|
||||
[assembly: AssemblyFileVersion("1.6.3.0")]
|
||||
@@ -48,6 +48,18 @@ namespace Ink_Canvas
|
||||
public bool FitToCurve { get; set; } = true;
|
||||
[JsonProperty("clearCanvasAndClearTimeMachine")]
|
||||
public bool ClearCanvasAndClearTimeMachine { get; set; } = false;
|
||||
[JsonProperty("enablePressureTouchMode")]
|
||||
public bool EnablePressureTouchMode { get; set; } = false; // 是否启用压感触屏模式
|
||||
[JsonProperty("disablePressure")]
|
||||
public bool DisablePressure { get; set; } = false; // 是否屏蔽压感
|
||||
[JsonProperty("autoStraightenLine")]
|
||||
public bool AutoStraightenLine { get; set; } = true; // 是否启用直线自动拉直
|
||||
[JsonProperty("autoStraightenLineThreshold")]
|
||||
public int AutoStraightenLineThreshold { get; set; } = 30; // 直线自动拉直的长度阈值(像素)
|
||||
[JsonProperty("lineEndpointSnapping")]
|
||||
public bool LineEndpointSnapping { get; set; } = true; // 是否启用直线端点吸附
|
||||
[JsonProperty("lineEndpointSnappingThreshold")]
|
||||
public int LineEndpointSnappingThreshold { get; set; } = 15; // 直线端点吸附的距离阈值(像素)
|
||||
|
||||
[JsonProperty("usingWhiteboard")]
|
||||
public bool UsingWhiteboard { get; set; }
|
||||
@@ -308,7 +320,7 @@ namespace Ink_Canvas
|
||||
public bool IsAutoKillICA { get; set; } = false;
|
||||
|
||||
[JsonProperty("isAutoKillIDT")]
|
||||
public bool IsAutoKillIDT { get; set; } = true;
|
||||
public bool IsAutoKillIDT { get; set; } = false;
|
||||
|
||||
[JsonProperty("isSaveScreenshotsInDateFolders")]
|
||||
public bool IsSaveScreenshotsInDateFolders { get; set; } = false;
|
||||
@@ -397,6 +409,8 @@ namespace Ink_Canvas
|
||||
public bool IsInkToShapeRectangle { get; set; } = true;
|
||||
[JsonProperty("isInkToShapeRounded")]
|
||||
public bool IsInkToShapeRounded { get; set; } = true;
|
||||
[JsonProperty("lineStraightenSensitivity")]
|
||||
public double LineStraightenSensitivity { get; set; } = 0.10; // 直线检测灵敏度,值越小越严格(0.05-0.75)
|
||||
}
|
||||
|
||||
public class RandSettings {
|
||||
@@ -406,5 +420,7 @@ namespace Ink_Canvas
|
||||
public double RandWindowOnceCloseLatency { get; set; } = 2.5;
|
||||
[JsonProperty("randWindowOnceMaxStudents")]
|
||||
public int RandWindowOnceMaxStudents { get; set; } = 10;
|
||||
[JsonProperty("showRandomAndSingleDraw")]
|
||||
public bool ShowRandomAndSingleDraw { get; set; } = true;
|
||||
}
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -373,15 +373,6 @@ E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\App.g.cs
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\GeneratedInternalTypeHelper.g.cs
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass_MarkupCompile.cache
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass_MarkupCompile.lref
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\App.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\MainWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\CountdownTimerWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\CycleProcessBar.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\HasNewUpdateWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\NamesInputWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\OperatingGuideWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\RandWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\YesOrNoNotificationWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass.g.resources
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Ink_Canvas.Properties.Resources.resources
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass.csproj.GenerateResource.cache
|
||||
@@ -391,3 +382,12 @@ E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass.sourc
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanva.0F57E7D5.Up2Date
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass.exe
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass.exe.config
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\App.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\MainWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\CountdownTimerWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\CycleProcessBar.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\HasNewUpdateWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\NamesInputWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\OperatingGuideWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\RandWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\YesOrNoNotificationWindow.baml
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+3809
-3543
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Administrator\.nuget\packages\;E:\Program Files\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.13.2</NuGetToolVersion>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.14.0</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="C:\Users\Administrator\.nuget\packages\" />
|
||||
|
||||
Reference in New Issue
Block a user