From e8be85141bf6e7ee72e3fe582814a218a4041615 Mon Sep 17 00:00:00 2001 From: PrefacedCorg <1876568293@qq.com> Date: Sun, 29 Mar 2026 13:47:19 +0800 Subject: [PATCH] add:NewNewSettings --- .../Windows/SettingsViews2/Pages/Colors.xaml | 17 ++++ .../SettingsViews2/Pages/Colors.xaml.cs | 12 +++ .../Windows/SettingsViews2/Pages/Fonts.xaml | 17 ++++ .../SettingsViews2/Pages/Fonts.xaml.cs | 12 +++ .../SettingsViews2/Pages/Iconography.xaml | 17 ++++ .../SettingsViews2/Pages/Iconography.xaml.cs | 12 +++ .../Windows/SettingsViews2/Pages/Theme.xaml | 17 ++++ .../SettingsViews2/Pages/Theme.xaml.cs | 12 +++ .../SettingsViews2/Pages/Typography.xaml | 17 ++++ .../SettingsViews2/Pages/Typography.xaml.cs | 12 +++ .../SettingsViews2/SettingsWindow2.xaml | 71 +++++++++----- .../SettingsViews2/SettingsWindow2.xaml.cs | 94 +++++++++++++++---- 12 files changed, 272 insertions(+), 38 deletions(-) create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml.cs create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml.cs create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml.cs create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml.cs create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Typography.xaml create mode 100644 Ink Canvas/Windows/SettingsViews2/Pages/Typography.xaml.cs diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml new file mode 100644 index 00000000..6ef55ebc --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml.cs new file mode 100644 index 00000000..8c7ea3f5 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/Colors.xaml.cs @@ -0,0 +1,12 @@ +using iNKORE.UI.WPF.Modern.Controls; + +namespace Ink_Canvas.Windows.SettingsViews2.Pages +{ + public partial class Colors : Page + { + public Colors() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml new file mode 100644 index 00000000..b6217e88 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml.cs new file mode 100644 index 00000000..890e0d67 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/Fonts.xaml.cs @@ -0,0 +1,12 @@ +using iNKORE.UI.WPF.Modern.Controls; + +namespace Ink_Canvas.Windows.SettingsViews2.Pages +{ + public partial class Fonts : Page + { + public Fonts() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml new file mode 100644 index 00000000..4afc7c01 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml.cs new file mode 100644 index 00000000..e43e7270 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/Iconography.xaml.cs @@ -0,0 +1,12 @@ +using iNKORE.UI.WPF.Modern.Controls; + +namespace Ink_Canvas.Windows.SettingsViews2.Pages +{ + public partial class Iconography : Page + { + public Iconography() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml new file mode 100644 index 00000000..66a421c2 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml.cs new file mode 100644 index 00000000..da5d8914 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/Theme.xaml.cs @@ -0,0 +1,12 @@ +using iNKORE.UI.WPF.Modern.Controls; + +namespace Ink_Canvas.Windows.SettingsViews2.Pages +{ + public partial class Theme : Page + { + public Theme() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Typography.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/Typography.xaml new file mode 100644 index 00000000..ba23bc2e --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/Typography.xaml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/Typography.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/Typography.xaml.cs new file mode 100644 index 00000000..17236dc9 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews2/Pages/Typography.xaml.cs @@ -0,0 +1,12 @@ +using iNKORE.UI.WPF.Modern.Controls; + +namespace Ink_Canvas.Windows.SettingsViews2.Pages +{ + public partial class Typography : Page + { + public Typography() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml b/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml index fc92a5ac..6c72f78e 100644 --- a/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml +++ b/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml @@ -20,13 +20,6 @@ - 4,2,4,2 - @@ -40,7 +33,9 @@ IsTabStop="False" IsTitleBarAutoPaddingEnabled="False" SelectionChanged="OnNavigationViewSelectionChanged" + BackRequested="OnNavigationViewBackRequested" IsSettingsVisible="True" + PaneDisplayMode="Auto" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> @@ -86,27 +81,61 @@ + x:Name="DesignItem" + Content="设计" + Tag="Design"> - + + x:Name="IconographyItem" + Content="图标" + Tag="Iconography"> - + + x:Name="TypographyItem" + Content="排版" + Tag="Typography"> - + + + + + + + + + + + + + + + + + + + + + + + @@ -123,8 +152,8 @@ - - + + diff --git a/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs b/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs index 0ab3d8d1..d970e918 100644 --- a/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs @@ -20,7 +20,12 @@ namespace Ink_Canvas.Windows.SettingsViews2 _pageTypes = new Dictionary { { "Page1", typeof(Page1) }, - { "Page2", typeof(Page2) } + { "Page2", typeof(Page2) }, + { "Iconography", typeof(Iconography) }, + { "Typography", typeof(Typography) }, + { "Theme", typeof(Theme) }, + { "Colors", typeof(Colors) }, + { "Fonts", typeof(Fonts) } }; // 默认选中第一个项目 @@ -39,11 +44,17 @@ namespace Ink_Canvas.Windows.SettingsViews2 } else if (args.SelectedItem is iNKORE.UI.WPF.Modern.Controls.NavigationViewItem item) { - var tag = item.Tag as string; - if (!string.IsNullOrEmpty(tag)) + // 检查是否是子导航项(没有子菜单) + if (item.MenuItems.Count == 0) { - NavigateToPage(tag); + // 如果是子导航项,直接导航 + var tag = item.Tag as string; + if (!string.IsNullOrEmpty(tag)) + { + NavigateToPage(tag); + } } + // 父级导航项(有子菜单)会自动展开,不需要额外处理 } } @@ -53,20 +64,12 @@ namespace Ink_Canvas.Windows.SettingsViews2 { try { - if (!_pages.TryGetValue(pageTag, out object page)) + // 使用Type参数导航,这样可以正确记录导航历史 + rootFrame.Navigate(pageType); + // 更新标题 + if (NavigationViewControl.SelectedItem is iNKORE.UI.WPF.Modern.Controls.NavigationViewItem selectedItem) { - page = Activator.CreateInstance(pageType); - _pages[pageTag] = page; - } - - if (page != null) - { - rootFrame.Navigate(page); - // 更新标题 - if (NavigationViewControl.SelectedItem is iNKORE.UI.WPF.Modern.Controls.NavigationViewItem selectedItem) - { - NavigationViewControl.Header = selectedItem.Content; - } + NavigationViewControl.Header = selectedItem.Content; } } catch (Exception ex) @@ -123,5 +126,62 @@ namespace Ink_Canvas.Windows.SettingsViews2 sender.ItemsSource = suggestions; } } + + private void OnNavigationViewBackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args) + { + if (rootFrame.CanGoBack) + { + rootFrame.GoBack(); + } + } + + private void OnRootFrameNavigated(object sender, NavigationEventArgs e) + { + // 更新NavigationView的选中状态 + var pageType = e.SourcePageType; + foreach (var kvp in _pageTypes) + { + if (kvp.Value == pageType) + { + // 找到对应的NavigationViewItem + var item = FindNavigationViewItemByTag(kvp.Key); + if (item != null) + { + NavigationViewControl.SelectedItem = item; + NavigationViewControl.Header = item.Content; + } + break; + } + } + } + + private NavigationViewItem FindNavigationViewItemByTag(string tag) + { + // 遍历所有菜单项 + foreach (var item in NavigationViewControl.MenuItems) + { + if (item is NavigationViewItem navItem) + { + if (navItem.Tag as string == tag) + { + return navItem; + } + // 检查子菜单项 + foreach (var child in navItem.MenuItems) + { + if (child is NavigationViewItem childNavItem) + { + if (childNavItem.Tag as string == tag) + { + // 展开父项 + navItem.IsExpanded = true; + return childNavItem; + } + } + } + } + } + return null; + } } }