b1640f44c2
重构设置界面,将墨迹纠正相关功能从画板设置中分离出来,新增独立的墨迹纠正设置页面。主要变更包括: - 新增 InkRecognitionPage 用于集中管理墨迹纠正功能 - 调整设置窗口导航结构,将墨迹纠正设为画板设置的子页面 - 优化设置项布局,使用折叠面板组织复杂选项 - 移除主窗口中冗余的崩溃处理和手势设置 - 修复多指手势时橡皮擦状态保存问题 - 新增笔尖模式相关字符串资源
258 lines
7.8 KiB
C#
258 lines
7.8 KiB
C#
using Ink_Canvas.Helpers;
|
|
using Ink_Canvas.Windows.SettingsViews.Helpers;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace Ink_Canvas.Windows.SettingsViews.Pages
|
|
{
|
|
public partial class StartupPage : iNKORE.UI.WPF.Modern.Controls.Page
|
|
{
|
|
private bool _isLoaded = false;
|
|
|
|
public StartupPage()
|
|
{
|
|
InitializeComponent();
|
|
Loaded += StartupPage_Loaded;
|
|
}
|
|
|
|
private void StartupPage_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
LoadSettings();
|
|
_isLoaded = true;
|
|
}
|
|
|
|
private void LoadSettings()
|
|
{
|
|
_isLoaded = false;
|
|
|
|
try
|
|
{
|
|
var settings = SettingsManager.Settings;
|
|
|
|
bool runAtStartup = AutoStartHelper.IsAutoStartEnabled("Ink Canvas Annotation");
|
|
CardRunAtStartup.IsOn = runAtStartup;
|
|
|
|
if (settings.Startup != null)
|
|
{
|
|
CardFoldAtStartup.IsOn = settings.Startup.IsFoldAtStartup;
|
|
}
|
|
|
|
if (settings.ModeSettings != null)
|
|
{
|
|
CardPPTOnlyMode.IsOn = settings.ModeSettings.IsPPTOnlyMode;
|
|
}
|
|
|
|
CardExternalProtocol.IsOn = settings.Advanced.IsEnableUriScheme;
|
|
|
|
if (settings.Startup != null)
|
|
{
|
|
CardEnableNibMode.IsOn = settings.Startup.IsEnableNibMode;
|
|
|
|
if (settings.Startup.CrashAction == 0)
|
|
{
|
|
RadioCrashSilentRestart.IsChecked = true;
|
|
}
|
|
else
|
|
{
|
|
RadioCrashNoAction.IsChecked = true;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine($"加载启动设置时出错: {ex.Message}");
|
|
}
|
|
|
|
_isLoaded = true;
|
|
}
|
|
|
|
#region 启动设置事件处理
|
|
|
|
private void ToggleSwitchRunAtStartup_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!_isLoaded) return;
|
|
|
|
try
|
|
{
|
|
bool newState = CardRunAtStartup.IsOn;
|
|
|
|
if (newState)
|
|
{
|
|
AutoStartHelper.StartAutomaticallyDel("InkCanvas");
|
|
AutoStartHelper.StartAutomaticallyCreate("Ink Canvas Annotation");
|
|
}
|
|
else
|
|
{
|
|
AutoStartHelper.StartAutomaticallyDel("InkCanvas");
|
|
AutoStartHelper.StartAutomaticallyDel("Ink Canvas Annotation");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine($"设置开机启动时出错: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
private void ToggleSwitchFoldAtStartup_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!_isLoaded) return;
|
|
|
|
try
|
|
{
|
|
bool newState = CardFoldAtStartup.IsOn;
|
|
|
|
SettingsManager.Settings.Startup.IsFoldAtStartup = newState;
|
|
SettingsManager.SaveSettingsToFile();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine($"设置开机折叠时出错: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
private void ToggleSwitchExternalProtocol_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!_isLoaded) return;
|
|
|
|
try
|
|
{
|
|
bool newState = CardExternalProtocol.IsOn;
|
|
bool success = false;
|
|
|
|
if (newState)
|
|
{
|
|
if (!UriSchemeHelper.IsUriSchemeRegistered())
|
|
{
|
|
success = UriSchemeHelper.RegisterUriScheme();
|
|
}
|
|
else
|
|
{
|
|
success = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (UriSchemeHelper.IsUriSchemeRegistered())
|
|
{
|
|
success = UriSchemeHelper.UnregisterUriScheme();
|
|
}
|
|
else
|
|
{
|
|
success = true;
|
|
}
|
|
}
|
|
|
|
if (success)
|
|
{
|
|
SettingsManager.Settings.Advanced.IsEnableUriScheme = newState;
|
|
SettingsManager.SaveSettingsToFile();
|
|
}
|
|
else
|
|
{
|
|
_isLoaded = false;
|
|
CardExternalProtocol.IsOn = !newState;
|
|
_isLoaded = true;
|
|
|
|
LogHelper.WriteLogToFile("设置外部协议失败,请检查权限或日志", LogHelper.LogType.Error);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine($"设置外部协议时出错: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 笔尖模式事件处理
|
|
|
|
private void ToggleSwitchEnableNibMode_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!_isLoaded) return;
|
|
|
|
try
|
|
{
|
|
bool newState = CardEnableNibMode.IsOn;
|
|
SettingsManager.Settings.Startup.IsEnableNibMode = newState;
|
|
|
|
var window = Application.Current.MainWindow;
|
|
if (window is MainWindow mw)
|
|
{
|
|
if (mw.ToggleSwitchEnableNibMode != null)
|
|
mw.ToggleSwitchEnableNibMode.IsOn = newState;
|
|
if (mw.BoardToggleSwitchEnableNibMode != null)
|
|
mw.BoardToggleSwitchEnableNibMode.IsOn = newState;
|
|
|
|
if (newState)
|
|
mw.BoundsWidth = SettingsManager.Settings.Advanced.NibModeBoundsWidth;
|
|
else
|
|
mw.BoundsWidth = SettingsManager.Settings.Advanced.FingerModeBoundsWidth;
|
|
}
|
|
|
|
SettingsManager.SaveSettingsToFile();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine($"设置笔尖模式时出错: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 崩溃后操作事件处理
|
|
|
|
private void RadioCrashAction_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!_isLoaded) return;
|
|
|
|
try
|
|
{
|
|
if (RadioCrashSilentRestart != null && RadioCrashSilentRestart.IsChecked == true)
|
|
{
|
|
App.CrashAction = App.CrashActionType.SilentRestart;
|
|
SettingsManager.Settings.Startup.CrashAction = 0;
|
|
}
|
|
else if (RadioCrashNoAction != null && RadioCrashNoAction.IsChecked == true)
|
|
{
|
|
App.CrashAction = App.CrashActionType.NoAction;
|
|
SettingsManager.Settings.Startup.CrashAction = 1;
|
|
}
|
|
SettingsManager.SaveSettingsToFile();
|
|
App.SyncCrashActionFromSettings();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine($"设置崩溃操作时出错: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 模式设置事件处理
|
|
|
|
private void ToggleSwitchPPTOnlyMode_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!_isLoaded) return;
|
|
|
|
try
|
|
{
|
|
bool newState = CardPPTOnlyMode.IsOn;
|
|
|
|
var window = Application.Current.MainWindow;
|
|
if (window != null)
|
|
{
|
|
WindowSettingsHelper.ApplyPptOnlyMode(window, newState);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine($"设置仅PPT模式时出错: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|