From 140e92eedae3724d5dee556ca3ed8665495206ce Mon Sep 17 00:00:00 2001 From: PrefacedCorg <1876568293@qq.com> Date: Sat, 4 Apr 2026 18:45:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/{About.xaml => AboutPage.xaml} | 2 +- .../{Colors.xaml.cs => AboutPage.xaml.cs} | 4 +- .../{Appearance.xaml => AppearancePage.xaml} | 20 +- ...earance.xaml.cs => AppearancePage.xaml.cs} | 10 +- .../Pages/{Basic.xaml => BasicPage.xaml} | 6 +- .../{Basic.xaml.cs => BasicPage.xaml.cs} | 6 +- .../Pages/{Colors.xaml => ColorsPage.xaml} | 2 +- .../{Theme.xaml.cs => ColorsPage.xaml.cs} | 4 +- .../Pages/{Design.xaml => DesignPage.xaml} | 14 +- .../{Design.xaml.cs => DesignPage.xaml.cs} | 8 +- .../Pages/{Fonts.xaml => FontsPage.xaml} | 2 +- .../{About.xaml.cs => FontsPage.xaml.cs} | 4 +- .../SettingsViews2/Pages/HomePage.xaml | 78 +++++++ .../SettingsViews2/Pages/HomePage.xaml.cs | 72 +++++++ ...{Iconography.xaml => IconographyPage.xaml} | 2 +- .../Pages/IconographyPage.xaml.cs | 12 ++ .../Pages/{Page2.xaml => Page2Page.xaml} | 2 +- .../{Page2.xaml.cs => Page2Page.xaml.cs} | 6 +- ...ewSettingStartup.xaml => StartupPage.xaml} | 2 +- ...ingStartup.xaml.cs => StartupPage.xaml.cs} | 196 ++++++++++++------ .../Pages/{Theme.xaml => ThemePage.xaml} | 2 +- .../{Fonts.xaml.cs => ThemePage.xaml.cs} | 4 +- .../SettingsViews2/Pages/Typography.xaml.cs | 12 -- .../{Typography.xaml => TypographyPage.xaml} | 2 +- ...ography.xaml.cs => TypographyPage.xaml.cs} | 4 +- .../SettingsViews2/SettingsWindow2.xaml | 87 ++++---- .../SettingsViews2/SettingsWindow2.xaml.cs | 79 +++++-- 27 files changed, 463 insertions(+), 179 deletions(-) rename Ink Canvas/Windows/SettingsViews2/Pages/{About.xaml => AboutPage.xaml} (92%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Colors.xaml.cs => AboutPage.xaml.cs} (69%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Appearance.xaml => AppearancePage.xaml} (74%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Appearance.xaml.cs => AppearancePage.xaml.cs} (82%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Basic.xaml => BasicPage.xaml} (92%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Basic.xaml.cs => BasicPage.xaml.cs} (87%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Colors.xaml => ColorsPage.xaml} (91%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Theme.xaml.cs => ColorsPage.xaml.cs} (68%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Design.xaml => DesignPage.xaml} (74%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Design.xaml.cs => DesignPage.xaml.cs} (83%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Fonts.xaml => FontsPage.xaml} (92%) rename Ink Canvas/Windows/SettingsViews2/Pages/{About.xaml.cs => FontsPage.xaml.cs} (69%) create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/HomePage.xaml create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/HomePage.xaml.cs rename Ink Canvas/Windows/SettingsViews2/Pages/{Iconography.xaml => IconographyPage.xaml} (99%) create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml.cs rename Ink Canvas/Windows/SettingsViews2/Pages/{Page2.xaml => Page2Page.xaml} (88%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Page2.xaml.cs => Page2Page.xaml.cs} (87%) rename Ink Canvas/Windows/SettingsViews2/Pages/{NewSettingStartup.xaml => StartupPage.xaml} (98%) rename Ink Canvas/Windows/SettingsViews2/Pages/{NewSettingStartup.xaml.cs => StartupPage.xaml.cs} (51%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Theme.xaml => ThemePage.xaml} (92%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Fonts.xaml.cs => ThemePage.xaml.cs} (69%) delete mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Typography.xaml.cs rename Ink Canvas/Windows/SettingsViews2/Pages/{Typography.xaml => TypographyPage.xaml} (91%) rename Ink Canvas/Windows/SettingsViews2/Pages/{Iconography.xaml.cs => TypographyPage.xaml.cs} (66%) diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/About.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/AboutPage.xaml similarity index 92% rename from Ink Canvas/Windows/SettingsViews2/Pages/About.xaml rename to Ink Canvas/Windows/SettingsViews2/Pages/AboutPage.xaml index 3c15245a..c828997d 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/About.xaml +++ b/Ink Canvas/Windows/SettingsViews2/Pages/AboutPage.xaml @@ -1,5 +1,5 @@ - - - + + + - - - + + + - - - + + + diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Appearance.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/AppearancePage.xaml.cs similarity index 82% rename from Ink Canvas/Windows/SettingsViews2/Pages/Appearance.xaml.cs rename to Ink Canvas/Windows/SettingsViews2/Pages/AppearancePage.xaml.cs index f1c3c118..2c88e8b5 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/Appearance.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews2/Pages/AppearancePage.xaml.cs @@ -15,9 +15,9 @@ using System.Windows.Shapes; namespace Ink_Canvas.Windows.SettingsViews2.Pages { - public partial class Appearance : Page + public partial class AppearancePage : Page { - public Appearance() + public AppearancePage() { InitializeComponent(); } @@ -27,7 +27,7 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages SettingsWindow2 settingsWindow = Window.GetWindow(this) as SettingsWindow2; if (settingsWindow != null) { - settingsWindow.NavigateToPage("Theme"); + settingsWindow.NavigateToPage("ThemePage"); } } @@ -36,7 +36,7 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages SettingsWindow2 settingsWindow = Window.GetWindow(this) as SettingsWindow2; if (settingsWindow != null) { - settingsWindow.NavigateToPage("Colors"); + settingsWindow.NavigateToPage("ColorsPage"); } } @@ -45,7 +45,7 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages SettingsWindow2 settingsWindow = Window.GetWindow(this) as SettingsWindow2; if (settingsWindow != null) { - settingsWindow.NavigateToPage("Fonts"); + settingsWindow.NavigateToPage("FontsPage"); } } } diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Basic.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/BasicPage.xaml similarity index 92% rename from Ink Canvas/Windows/SettingsViews2/Pages/Basic.xaml rename to Ink Canvas/Windows/SettingsViews2/Pages/BasicPage.xaml index 563243f5..345c46f7 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/Basic.xaml +++ b/Ink Canvas/Windows/SettingsViews2/Pages/BasicPage.xaml @@ -1,4 +1,4 @@ - - + - + diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Basic.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/BasicPage.xaml.cs similarity index 87% rename from Ink Canvas/Windows/SettingsViews2/Pages/Basic.xaml.cs rename to Ink Canvas/Windows/SettingsViews2/Pages/BasicPage.xaml.cs index 256eb5f0..9a534ea2 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/Basic.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews2/Pages/BasicPage.xaml.cs @@ -18,9 +18,9 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages /// /// Basic.xaml 的交互逻辑 /// - public partial class Basic : Page + public partial class BasicPage : Page { - public Basic() + public BasicPage() { InitializeComponent(); } @@ -32,7 +32,7 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages if (settingsWindow != null) { // 调用NavigateToPage方法导航到启动页面 - settingsWindow.NavigateToPage("NewSettingStartup"); + settingsWindow.NavigateToPage("StartupPage"); } } } diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/ColorsPage.xaml similarity index 91% rename from Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml rename to Ink Canvas/Windows/SettingsViews2/Pages/ColorsPage.xaml index 6ef55ebc..b048d795 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml +++ b/Ink Canvas/Windows/SettingsViews2/Pages/ColorsPage.xaml @@ -1,5 +1,5 @@ - - - + + + - - - + + + diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Design.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/DesignPage.xaml.cs similarity index 83% rename from Ink Canvas/Windows/SettingsViews2/Pages/Design.xaml.cs rename to Ink Canvas/Windows/SettingsViews2/Pages/DesignPage.xaml.cs index 99ca4813..4673afe8 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/Design.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews2/Pages/DesignPage.xaml.cs @@ -15,9 +15,9 @@ using System.Windows.Shapes; namespace Ink_Canvas.Windows.SettingsViews2.Pages { - public partial class Design : Page + public partial class DesignPage : Page { - public Design() + public DesignPage() { InitializeComponent(); } @@ -27,7 +27,7 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages SettingsWindow2 settingsWindow = Window.GetWindow(this) as SettingsWindow2; if (settingsWindow != null) { - settingsWindow.NavigateToPage("Iconography"); + settingsWindow.NavigateToPage("IconographyPage"); } } @@ -36,7 +36,7 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages SettingsWindow2 settingsWindow = Window.GetWindow(this) as SettingsWindow2; if (settingsWindow != null) { - settingsWindow.NavigateToPage("Typography"); + settingsWindow.NavigateToPage("TypographyPage"); } } } diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/FontsPage.xaml similarity index 92% rename from Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml rename to Ink Canvas/Windows/SettingsViews2/Pages/FontsPage.xaml index b6217e88..d1454099 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml +++ b/Ink Canvas/Windows/SettingsViews2/Pages/FontsPage.xaml @@ -1,5 +1,5 @@ + + + + + + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/HomePage.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/HomePage.xaml.cs new file mode 100644 index 00000000..428fdf27 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/HomePage.xaml.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Ink_Canvas.Windows.SettingsViews2.Pages +{ + /// + /// HomePage.xaml 的交互逻辑 + /// + public partial class HomePage : Page + { + public HomePage() + { + InitializeComponent(); + } + + private void SettingsCard_Basic_Click(object sender, RoutedEventArgs e) + { + // 找到SettingsWindow2窗口 + SettingsWindow2 settingsWindow = Window.GetWindow(this) as SettingsWindow2; + if (settingsWindow != null) + { + // 调用NavigateToPage方法导航到基本设置页面 + settingsWindow.NavigateToPage("BasicPage"); + } + } + + private void SettingsCard_Page2_Click(object sender, RoutedEventArgs e) + { + // 找到SettingsWindow2窗口 + SettingsWindow2 settingsWindow = Window.GetWindow(this) as SettingsWindow2; + if (settingsWindow != null) + { + // 调用NavigateToPage方法导航到页面2 + settingsWindow.NavigateToPage("Page2Page"); + } + } + + private void SettingsCard_Design_Click(object sender, RoutedEventArgs e) + { + // 找到SettingsWindow2窗口 + SettingsWindow2 settingsWindow = Window.GetWindow(this) as SettingsWindow2; + if (settingsWindow != null) + { + // 调用NavigateToPage方法导航到设计设置页面 + settingsWindow.NavigateToPage("DesignPage"); + } + } + + private void SettingsCard_Appearance_Click(object sender, RoutedEventArgs e) + { + // 找到SettingsWindow2窗口 + SettingsWindow2 settingsWindow = Window.GetWindow(this) as SettingsWindow2; + if (settingsWindow != null) + { + // 调用NavigateToPage方法导航到外观设置页面 + settingsWindow.NavigateToPage("AppearancePage"); + } + } + } +} diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml similarity index 99% rename from Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml rename to Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml index 4afc7c01..8c7eef53 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml +++ b/Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml @@ -1,5 +1,5 @@ /// Page2.xaml 的交互逻辑 /// - public partial class Page2 : Page + public partial class Page2Page : Page { - public Page2() + public Page2Page() { InitializeComponent(); } diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/StartupPage.xaml similarity index 98% rename from Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml rename to Ink Canvas/Windows/SettingsViews2/Pages/StartupPage.xaml index 5f8952ea..ed21124d 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml +++ b/Ink Canvas/Windows/SettingsViews2/Pages/StartupPage.xaml @@ -1,4 +1,4 @@ - - /// NewSettingStartup.xaml 的交互逻辑 + /// StartupPage.xaml 的交互逻辑 /// - public partial class NewSettingStartup : Page + public partial class StartupPage : Page { private bool _isLoaded = false; - public NewSettingStartup() + public StartupPage() { InitializeComponent(); - Loaded += NewSettingStartup_Loaded; + Loaded += StartupPage_Loaded; } - private void NewSettingStartup_Loaded(object sender, RoutedEventArgs e) + private void StartupPage_Loaded(object sender, RoutedEventArgs e) { LoadSettings(); _isLoaded = true; @@ -28,35 +29,23 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages /// private void LoadSettings() { - if (MainWindow.Settings == null) return; - _isLoaded = false; try { + var settings = SettingsService.Current; + // 窗口无焦点模式 - if (MainWindow.Settings.Advanced != null) - { - ToggleSwitchNoFocusMode.IsOn = MainWindow.Settings.Advanced.IsNoFocusMode; - } + ToggleSwitchNoFocusMode.IsOn = settings.Advanced?.IsNoFocusMode ?? true; // 窗口无边框模式 - if (MainWindow.Settings.Advanced != null) - { - ToggleSwitchWindowMode.IsOn = MainWindow.Settings.Advanced.WindowMode; - } + ToggleSwitchWindowMode.IsOn = settings.Advanced?.WindowMode ?? true; // 窗口置顶 - if (MainWindow.Settings.Advanced != null) - { - ToggleSwitchAlwaysOnTop.IsOn = MainWindow.Settings.Advanced.IsAlwaysOnTop; - } + ToggleSwitchAlwaysOnTop.IsOn = settings.Advanced?.IsAlwaysOnTop ?? true; // UIA置顶 - if (MainWindow.Settings.Advanced != null) - { - ToggleSwitchUIAccessTopMost.IsOn = MainWindow.Settings.Advanced.EnableUIAccessTopMost; - } + ToggleSwitchUIAccessTopMost.IsOn = settings.Advanced?.EnableUIAccessTopMost ?? false; // 开机时运行 bool runAtStartup = System.IO.File.Exists( @@ -64,16 +53,10 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages ToggleSwitchRunAtStartup.IsOn = runAtStartup; // 启动时折叠 - if (MainWindow.Settings.Startup != null) - { - ToggleSwitchFoldAtStartup.IsOn = MainWindow.Settings.Startup.IsFoldAtStartup; - } + ToggleSwitchFoldAtStartup.IsOn = settings.Startup?.IsFoldAtStartup ?? false; // 仅PPT模式 - if (MainWindow.Settings.ModeSettings != null) - { - ToggleSwitchPPTOnlyMode.IsOn = MainWindow.Settings.ModeSettings.IsPPTOnlyMode; - } + ToggleSwitchPPTOnlyMode.IsOn = settings.ModeSettings?.IsPPTOnlyMode ?? false; } catch (Exception ex) { @@ -95,9 +78,8 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages try { bool newState = ToggleSwitchNoFocusMode.IsOn; - - // 使用Helper类更新设置并应用 - Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchNoFocusMode", newState); + SettingsService.UpdateSetting("Advanced.IsNoFocusMode", newState); + ApplyWindowSettings(); } catch (Exception ex) { @@ -115,9 +97,8 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages try { bool newState = ToggleSwitchWindowMode.IsOn; - - // 使用Helper类更新设置并应用 - Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchWindowMode", newState); + SettingsService.UpdateSetting("Advanced.WindowMode", newState); + ApplyWindowSettings(); } catch (Exception ex) { @@ -135,9 +116,8 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages try { bool newState = ToggleSwitchAlwaysOnTop.IsOn; - - // 使用Helper类更新设置并应用 - Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAlwaysOnTop", newState); + SettingsService.UpdateSetting("Advanced.IsAlwaysOnTop", newState); + ApplyWindowSettings(); } catch (Exception ex) { @@ -155,18 +135,8 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages try { bool newState = ToggleSwitchUIAccessTopMost.IsOn; - - // 更新Settings对象 - if (MainWindow.Settings.Advanced != null) - { - MainWindow.Settings.Advanced.EnableUIAccessTopMost = newState; - } - - // 保存设置 - MainWindow.SaveSettingsToFile(); - - // 通知其他面板同步状态 - Windows.SettingsViews.MainWindowSettingsHelper.NotifySettingsPanelsSyncState("ToggleSwitchUIAccessTopMost"); + SettingsService.UpdateSetting("Advanced.EnableUIAccessTopMost", newState); + ApplyWindowSettings(); } catch (Exception ex) { @@ -174,6 +144,54 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages } } + /// + /// 应用窗口设置到主窗口 + /// + private void ApplyWindowSettings() + { + try + { + var mainWindow = Application.Current.MainWindow as MainWindow; + if (mainWindow == null) return; + + var settings = SettingsService.Current; + + // 应用窗口置顶 + mainWindow.Topmost = settings.Advanced?.IsAlwaysOnTop ?? true; + + // 应用窗口模式(无边框/有边框) + if (settings.Advanced?.WindowMode ?? true) + { + mainWindow.WindowStyle = WindowStyle.None; + } + else + { + mainWindow.WindowStyle = WindowStyle.SingleBorderWindow; + } + + // 应用无焦点模式 + if (settings.Advanced?.IsNoFocusMode ?? true) + { + // 使用反射调用主窗口的无焦点模式设置方法 + var method = mainWindow.GetType().GetMethod("SetNoFocusMode", + System.Reflection.BindingFlags.NonPublic | + System.Reflection.BindingFlags.Public | + System.Reflection.BindingFlags.Instance); + method?.Invoke(mainWindow, new object[] { true }); + } + + // 通知其他面板同步状态 + Windows.SettingsViews.MainWindowSettingsHelper.NotifySettingsPanelsSyncState("ToggleSwitchNoFocusMode"); + Windows.SettingsViews.MainWindowSettingsHelper.NotifySettingsPanelsSyncState("ToggleSwitchWindowMode"); + Windows.SettingsViews.MainWindowSettingsHelper.NotifySettingsPanelsSyncState("ToggleSwitchAlwaysOnTop"); + Windows.SettingsViews.MainWindowSettingsHelper.NotifySettingsPanelsSyncState("ToggleSwitchUIAccessTopMost"); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"应用窗口设置时出错: {ex.Message}"); + } + } + #endregion #region 启动设置事件处理 @@ -188,9 +206,7 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages try { bool newState = ToggleSwitchRunAtStartup.IsOn; - - // 使用Helper类更新设置并应用 - Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchRunAtStartup", newState); + SetRunAtStartup(newState); } catch (Exception ex) { @@ -198,6 +214,62 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages } } + /// + /// 设置开机启动 + /// + private void SetRunAtStartup(bool enable) + { + try + { + string startupPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup); + string shortcutPath = System.IO.Path.Combine(startupPath, "Ink Canvas Annotation.lnk"); + string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; + + if (enable) + { + // 创建快捷方式 + if (!System.IO.File.Exists(shortcutPath)) + { + CreateShortcut(shortcutPath, exePath); + } + } + else + { + // 删除快捷方式 + if (System.IO.File.Exists(shortcutPath)) + { + System.IO.File.Delete(shortcutPath); + } + } + + // 通知其他面板同步状态 + Windows.SettingsViews.MainWindowSettingsHelper.NotifySettingsPanelsSyncState("ToggleSwitchRunAtStartup"); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"设置开机启动失败: {ex.Message}"); + } + } + + /// + /// 创建快捷方式 + /// + private void CreateShortcut(string shortcutPath, string targetPath) + { + try + { + dynamic shell = Activator.CreateInstance(Type.GetTypeFromProgID("WScript.Shell")); + dynamic shortcut = shell.CreateShortcut(shortcutPath); + shortcut.TargetPath = targetPath; + shortcut.WorkingDirectory = System.IO.Path.GetDirectoryName(targetPath); + shortcut.Save(); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"创建快捷方式失败: {ex.Message}"); + } + } + /// /// 开机运行后收纳到侧边栏开关事件 /// @@ -208,9 +280,10 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages try { bool newState = ToggleSwitchFoldAtStartup.IsOn; - - // 使用Helper类更新设置并应用 - Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFoldAtStartup", newState); + SettingsService.UpdateSetting("Startup.IsFoldAtStartup", newState); + + // 通知其他面板同步状态 + Windows.SettingsViews.MainWindowSettingsHelper.NotifySettingsPanelsSyncState("ToggleSwitchFoldAtStartup"); } catch (Exception ex) { @@ -232,9 +305,10 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages try { bool newState = ToggleSwitchPPTOnlyMode.IsOn; - - // 使用Helper类更新设置并应用 - Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchMode", newState); + SettingsService.UpdateSetting("ModeSettings.IsPPTOnlyMode", newState); + + // 通知其他面板同步状态 + Windows.SettingsViews.MainWindowSettingsHelper.NotifySettingsPanelsSyncState("ToggleSwitchMode"); } catch (Exception ex) { diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/ThemePage.xaml similarity index 92% rename from Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml rename to Ink Canvas/Windows/SettingsViews2/Pages/ThemePage.xaml index 66a421c2..6a42b271 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml +++ b/Ink Canvas/Windows/SettingsViews2/Pages/ThemePage.xaml @@ -1,5 +1,5 @@ - + @@ -32,45 +32,40 @@ 56,34,0,0 - + + + + + - - + IsHitTestVisible="True" + Canvas.ZIndex="10"> - - + + + Text="应用设置" TextWrapping="NoWrap"/> - - - - - + ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.RowSpan="2"> + @@ -101,7 +97,7 @@ - + + + + + + @@ -133,7 +138,7 @@ @@ -146,7 +151,7 @@ + Tag="Page2Page"> @@ -156,7 +161,7 @@ @@ -165,20 +170,20 @@ - - + + - - + + @@ -187,7 +192,7 @@ @@ -196,25 +201,25 @@ - - + + - - + + @@ -229,7 +234,7 @@ + Tag="AboutPage"> diff --git a/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs b/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs index 12b2058b..273c3583 100644 --- a/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs @@ -48,17 +48,18 @@ namespace Ink_Canvas.Windows.SettingsViews2 // 初始化内置页面映射 _pageTypes = new Dictionary { - { "Basic", typeof(Basic) }, - { "Page2", typeof(Page2) }, - { "Design", typeof(Design) }, - { "Appearance", typeof(Appearance) }, - { "Iconography", typeof(Iconography) }, - { "Typography", typeof(Typography) }, - { "Theme", typeof(Theme) }, - { "Colors", typeof(Colors) }, - { "Fonts", typeof(Fonts) }, - { "NewSettingStartup", typeof(NewSettingStartup) }, - { "About", typeof(About) }, + { "HomePage", typeof(HomePage) }, + { "BasicPage", typeof(BasicPage) }, + { "Page2Page", typeof(Page2Page) }, + { "DesignPage", typeof(DesignPage) }, + { "AppearancePage", typeof(AppearancePage) }, + { "IconographyPage", typeof(IconographyPage) }, + { "TypographyPage", typeof(TypographyPage) }, + { "ThemePage", typeof(ThemePage) }, + { "ColorsPage", typeof(ColorsPage) }, + { "FontsPage", typeof(FontsPage) }, + { "StartupPage", typeof(StartupPage) }, + { "AboutPage", typeof(AboutPage) }, { "Settings", typeof(SettingsPage) } }; @@ -67,12 +68,19 @@ namespace Ink_Canvas.Windows.SettingsViews2 // 初始化导航菜单(内置+插件) InitializeNavigationMenu(); - // 默认选中第一个菜单项 + // 默认选中首页 if (NavigationViewControl.MenuItems.Count > 0) { + // 首先导航到首页 + NavigateToPage("HomePage"); + // 然后选中首页菜单项 NavigationViewControl.SelectedItem = NavigationViewControl.MenuItems[0]; + NavigationViewControl.Header = "首页"; } + // 初始化标题栏边距 + UpdateAppTitleBarMargin(); + // 窗口生命周期事件注册 this.Loaded += (sender, e) => { @@ -128,6 +136,18 @@ namespace Ink_Canvas.Windows.SettingsViews2 // 正常状态下只设置最大尺寸限制 SetMaxSizeOnly(); } + + // 窗口状态改变时更新标题栏显示 + UpdateAppTitleBarMargin(); + }; + + // 窗口大小改变时更新标题栏显示 + this.SizeChanged += (sender, e) => + { + if (NavigationViewControl.DisplayMode == NavigationViewDisplayMode.Minimal) + { + UpdateAppTitleBarMargin(); + } }; } @@ -375,6 +395,41 @@ namespace Ink_Canvas.Windows.SettingsViews2 } } + private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args) + { + UpdateAppTitleBarMargin(sender); + } + + private void UpdateAppTitleBarMargin() + { + UpdateAppTitleBarMargin(NavigationViewControl); + } + + private void UpdateAppTitleBarMargin(NavigationView sender) + { + Thickness currMargin = AppTitleBar.Margin; + if (sender.DisplayMode == NavigationViewDisplayMode.Minimal) + { + AppTitleBar.Margin = new Thickness((sender.CompactPaneLength * 2), currMargin.Top, currMargin.Right, currMargin.Bottom); + + // 当窗口宽度非常小时,隐藏图标和应用设置文字 + if (this.ActualWidth < 400) + { + AppTitle.Visibility = Visibility.Collapsed; + } + else + { + AppTitle.Visibility = Visibility.Visible; + } + } + else + { + AppTitleBar.Margin = new Thickness(sender.CompactPaneLength, currMargin.Top, currMargin.Right, currMargin.Bottom); + AppTitle.Visibility = Visibility.Visible; + } + AppTitleBar.Visibility = sender.PaneDisplayMode == NavigationViewPaneDisplayMode.Top ? Visibility.Collapsed : Visibility.Visible; + } + private NavigationViewItem FindNavigationViewItemByTag(string tag) { // 遍历主菜单