add:NewNewSettings
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<ui:Page
|
||||
x:Class="Ink_Canvas.Windows.SettingsViews2.Pages.Colors"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
Title="颜色设置"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<StackPanel Margin="24">
|
||||
<TextBlock Text="颜色设置" Style="{DynamicResource TitleTextBlockStyle}" Margin="0,0,0,16" />
|
||||
<TextBlock Text="这里是颜色设置页面" Style="{DynamicResource BodyTextBlockStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:Page>
|
||||
@@ -0,0 +1,12 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews2.Pages
|
||||
{
|
||||
public partial class Colors : Page
|
||||
{
|
||||
public Colors()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<ui:Page
|
||||
x:Class="Ink_Canvas.Windows.SettingsViews2.Pages.Fonts"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
Title="字体设置"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<StackPanel Margin="24">
|
||||
<TextBlock Text="字体设置" Style="{DynamicResource TitleTextBlockStyle}" Margin="0,0,0,16" />
|
||||
<TextBlock Text="这里是字体设置页面" Style="{DynamicResource BodyTextBlockStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:Page>
|
||||
@@ -0,0 +1,12 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews2.Pages
|
||||
{
|
||||
public partial class Fonts : Page
|
||||
{
|
||||
public Fonts()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<ui:Page
|
||||
x:Class="Ink_Canvas.Windows.SettingsViews2.Pages.Iconography"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
Title="图标设置"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<StackPanel Margin="24">
|
||||
<TextBlock Text="图标设置" Style="{DynamicResource TitleTextBlockStyle}" Margin="0,0,0,16" />
|
||||
<TextBlock Text="这里是图标设置页面" Style="{DynamicResource BodyTextBlockStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:Page>
|
||||
@@ -0,0 +1,12 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews2.Pages
|
||||
{
|
||||
public partial class Iconography : Page
|
||||
{
|
||||
public Iconography()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<ui:Page
|
||||
x:Class="Ink_Canvas.Windows.SettingsViews2.Pages.Theme"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
Title="主题设置"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<StackPanel Margin="24">
|
||||
<TextBlock Text="主题设置" Style="{DynamicResource TitleTextBlockStyle}" Margin="0,0,0,16" />
|
||||
<TextBlock Text="这里是主题设置页面" Style="{DynamicResource BodyTextBlockStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:Page>
|
||||
@@ -0,0 +1,12 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews2.Pages
|
||||
{
|
||||
public partial class Theme : Page
|
||||
{
|
||||
public Theme()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<ui:Page
|
||||
x:Class="Ink_Canvas.Windows.SettingsViews2.Pages.Typography"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
Title="排版设置"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<StackPanel Margin="24">
|
||||
<TextBlock Text="排版设置" Style="{DynamicResource TitleTextBlockStyle}" Margin="0,0,0,16" />
|
||||
<TextBlock Text="这里是排版设置页面" Style="{DynamicResource BodyTextBlockStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:Page>
|
||||
@@ -0,0 +1,12 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews2.Pages
|
||||
{
|
||||
public partial class Typography : Page
|
||||
{
|
||||
public Typography()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,6 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ui:ThemeResources />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Thickness x:Key="NavigationViewItemOnLeftPresenterMargin">4,2,4,2</Thickness>
|
||||
<Style TargetType="ui:NavigationViewItem">
|
||||
<Setter Property="Height" Value="40" />
|
||||
<Setter Property="MinWidth" Value="48" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
@@ -40,7 +33,9 @@
|
||||
IsTabStop="False"
|
||||
IsTitleBarAutoPaddingEnabled="False"
|
||||
SelectionChanged="OnNavigationViewSelectionChanged"
|
||||
BackRequested="OnNavigationViewBackRequested"
|
||||
IsSettingsVisible="True"
|
||||
PaneDisplayMode="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||
<ui:NavigationView.HeaderTemplate>
|
||||
@@ -86,27 +81,61 @@
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<ui:NavigationViewItem
|
||||
Content="Account"
|
||||
Tag="SamplePage2"
|
||||
ToolTipService.ToolTip="Account">
|
||||
x:Name="DesignItem"
|
||||
Content="设计"
|
||||
Tag="Design">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Contact}"/>
|
||||
<ui:SymbolIcon Symbol="Home" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
<ui:NavigationViewItem.MenuItems>
|
||||
<ui:NavigationViewItem
|
||||
Content="Mail"
|
||||
Tag="SamplePage3"
|
||||
ToolTipService.ToolTip="Mail">
|
||||
x:Name="IconographyItem"
|
||||
Content="图标"
|
||||
Tag="Iconography">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Mail}"/>
|
||||
<ui:SymbolIcon Symbol="Home" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<ui:NavigationViewItem
|
||||
Content="Calendar"
|
||||
Tag="SamplePage4"
|
||||
ToolTipService.ToolTip="Calendar">
|
||||
x:Name="TypographyItem"
|
||||
Content="排版"
|
||||
Tag="Typography">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Calendar}"/>
|
||||
<ui:SymbolIcon Symbol="Home" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
</ui:NavigationViewItem.MenuItems>
|
||||
</ui:NavigationViewItem>
|
||||
<ui:NavigationViewItem
|
||||
x:Name="AppearanceItem"
|
||||
Content="外观"
|
||||
Tag="Appearance">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Home" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
<ui:NavigationViewItem.MenuItems>
|
||||
<ui:NavigationViewItem
|
||||
x:Name="ThemeItem"
|
||||
Content="主题"
|
||||
Tag="Theme">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Home" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<ui:NavigationViewItem
|
||||
x:Name="ColorsItem"
|
||||
Content="颜色"
|
||||
Tag="Colors">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Home" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<ui:NavigationViewItem
|
||||
x:Name="FontsItem"
|
||||
Content="字体"
|
||||
Tag="Fonts">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Home" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
</ui:NavigationViewItem.MenuItems>
|
||||
@@ -123,8 +152,8 @@
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
</ui:NavigationView.FooterMenuItems>
|
||||
|
||||
<ui:Frame x:Name="rootFrame" />
|
||||
|
||||
<ui:Frame x:Name="rootFrame" Navigated="OnRootFrameNavigated" />
|
||||
</ui:NavigationView>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -20,7 +20,12 @@ namespace Ink_Canvas.Windows.SettingsViews2
|
||||
_pageTypes = new Dictionary<string, Type>
|
||||
{
|
||||
{ "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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user