1
This commit is contained in:
@@ -662,6 +662,9 @@
|
||||
<Button x:Name="BtnOpenNewSettings" Content="{i18n:I18n Key=Btn_OpenNewSettings}"
|
||||
HorizontalAlignment="Left" Click="BtnOpenNewSettings_Click"
|
||||
Padding="15,5" Margin="0,10,0,0"/>
|
||||
<Button x:Name="BtnOpenNewNewSettings" Content="打开新新设置"
|
||||
HorizontalAlignment="Left" Click="BtnOpenNewNewSettings_Click"
|
||||
Padding="15,5" Margin="0,10,0,0"/>
|
||||
</ikw:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
|
||||
|
||||
@@ -2907,6 +2907,18 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async void BtnOpenNewNewSettings_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isOpeningOrHidingSettingsPane) return;
|
||||
HideSubPanels();
|
||||
{
|
||||
var settingsWindow = new Windows.SettingsViews2.SettingsWindow2();
|
||||
settingsWindow.Owner = this;
|
||||
settingsWindow.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 新设置窗口
|
||||
|
||||
// 在MainWindow类中添加:
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<Page x:Class="Ink_Canvas.Windows.SettingsViews2.Pages.Page1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews2.Pages"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
Title="Page1">
|
||||
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,28 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Page1.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Page1 : Page
|
||||
{
|
||||
public Page1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<Page x:Class="Ink_Canvas.Windows.SettingsViews2.Pages.Page2"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews2.Pages"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
Title="Page2">
|
||||
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,28 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Page2.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Page2 : Page
|
||||
{
|
||||
public Page2()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<Window
|
||||
x:Class="Ink_Canvas.Windows.SettingsViews2.SettingsWindow2"
|
||||
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="InkCanvasForClass 设置"
|
||||
Width="1138" Height="750"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ui:ThemeManager.IsThemeAware="True"
|
||||
ui:TitleBar.ExtendViewIntoTitleBar="True"
|
||||
ui:WindowHelper.SystemBackdropType="Mica"
|
||||
ui:WindowHelper.UseModernWindowStyle="True"
|
||||
ui:TitleBar.Height="48"
|
||||
mc:Ignorable="d">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<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>
|
||||
<ui:NavigationView
|
||||
x:Name="NavigationViewControl"
|
||||
AlwaysShowHeader="True"
|
||||
CompactPaneLength="48"
|
||||
Header="设置"
|
||||
IsFooterSeparatorVisible="True"
|
||||
PaneTitle="设置"
|
||||
IsTabStop="False"
|
||||
IsTitleBarAutoPaddingEnabled="False"
|
||||
SelectionChanged="OnNavigationViewSelectionChanged"
|
||||
IsSettingsVisible="True"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||
<ui:NavigationView.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<TextBlock
|
||||
Text="{Binding}"
|
||||
Style="{DynamicResource TitleTextBlockStyle}"
|
||||
Margin="0,8,0,0" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ui:NavigationView.HeaderTemplate>
|
||||
<ui:NavigationView.AutoSuggestBox>
|
||||
<ui:AutoSuggestBox
|
||||
x:Name="controlsSearchBox"
|
||||
MinWidth="200"
|
||||
VerticalAlignment="Center"
|
||||
x:FieldModifier="public"
|
||||
PlaceholderText="搜索设置"
|
||||
QuerySubmitted="OnControlsSearchBoxQuerySubmitted"
|
||||
TextChanged="OnControlsSearchBoxTextChanged" >
|
||||
<ui:AutoSuggestBox.QueryIcon>
|
||||
<ui:SymbolIcon Symbol="Find" FontSize="12" />
|
||||
</ui:AutoSuggestBox.QueryIcon>
|
||||
</ui:AutoSuggestBox>
|
||||
</ui:NavigationView.AutoSuggestBox>
|
||||
|
||||
<ui:NavigationView.MenuItems>
|
||||
<ui:NavigationViewItem
|
||||
x:Name="Page1Item"
|
||||
Content="页面 1"
|
||||
Tag="Page1">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Home" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<ui:NavigationViewItem
|
||||
x:Name="Page2Item"
|
||||
Content="页面 2"
|
||||
Tag="Page2">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Document" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<ui:NavigationViewItem
|
||||
Content="Account"
|
||||
Tag="SamplePage2"
|
||||
ToolTipService.ToolTip="Account">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Contact}"/>
|
||||
</ui:NavigationViewItem.Icon>
|
||||
<ui:NavigationViewItem.MenuItems>
|
||||
<ui:NavigationViewItem
|
||||
Content="Mail"
|
||||
Tag="SamplePage3"
|
||||
ToolTipService.ToolTip="Mail">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Mail}"/>
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<ui:NavigationViewItem
|
||||
Content="Calendar"
|
||||
Tag="SamplePage4"
|
||||
ToolTipService.ToolTip="Calendar">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Calendar}"/>
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
</ui:NavigationViewItem.MenuItems>
|
||||
</ui:NavigationViewItem>
|
||||
</ui:NavigationView.MenuItems>
|
||||
|
||||
<ui:NavigationView.FooterMenuItems>
|
||||
<ui:NavigationViewItem
|
||||
x:Name="AboutItem"
|
||||
Content="关于 InkCanvasForClass"
|
||||
Tag="About">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Help" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
</ui:NavigationView.FooterMenuItems>
|
||||
|
||||
<ui:Frame x:Name="rootFrame" />
|
||||
</ui:NavigationView>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,127 @@
|
||||
using Ink_Canvas.Windows.SettingsViews2.Pages;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews2
|
||||
{
|
||||
public partial class SettingsWindow2 : Window
|
||||
{
|
||||
private Dictionary<string, Type> _pageTypes;
|
||||
private Dictionary<string, object> _pages = new Dictionary<string, object>();
|
||||
|
||||
public SettingsWindow2()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 初始化页面类型映射
|
||||
_pageTypes = new Dictionary<string, Type>
|
||||
{
|
||||
{ "Page1", typeof(Page1) },
|
||||
{ "Page2", typeof(Page2) }
|
||||
};
|
||||
|
||||
// 默认选中第一个项目
|
||||
if (NavigationViewControl.MenuItems.Count > 0)
|
||||
{
|
||||
NavigationViewControl.SelectedItem = NavigationViewControl.MenuItems[0];
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNavigationViewSelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
||||
{
|
||||
if (args.IsSettingsSelected)
|
||||
{
|
||||
// 暂时导航到 Page1 作为设置页示例
|
||||
NavigateToPage("Page1");
|
||||
}
|
||||
else if (args.SelectedItem is iNKORE.UI.WPF.Modern.Controls.NavigationViewItem item)
|
||||
{
|
||||
var tag = item.Tag as string;
|
||||
if (!string.IsNullOrEmpty(tag))
|
||||
{
|
||||
NavigateToPage(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NavigateToPage(string pageTag)
|
||||
{
|
||||
if (_pageTypes.TryGetValue(pageTag, out Type pageType))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_pages.TryGetValue(pageTag, out object page))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
iNKORE.UI.WPF.Modern.Controls.MessageBox.Show($"导航到页面时出错: {ex.Message}", "错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnControlsSearchBoxQuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
||||
{
|
||||
var query = args.QueryText.ToLower();
|
||||
var allItems = new List<object>();
|
||||
foreach (var item in NavigationViewControl.MenuItems) allItems.Add(item);
|
||||
foreach (var item in NavigationViewControl.FooterMenuItems) allItems.Add(item);
|
||||
|
||||
foreach (var item in allItems)
|
||||
{
|
||||
if (item is iNKORE.UI.WPF.Modern.Controls.NavigationViewItem navItem)
|
||||
{
|
||||
var content = navItem.Content?.ToString().ToLower();
|
||||
if (content != null && content.Contains(query))
|
||||
{
|
||||
NavigationViewControl.SelectedItem = navItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnControlsSearchBoxTextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
|
||||
{
|
||||
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
|
||||
{
|
||||
var query = sender.Text.ToLower();
|
||||
var suggestions = new List<string>();
|
||||
|
||||
var allItems = new List<object>();
|
||||
foreach (var item in NavigationViewControl.MenuItems) allItems.Add(item);
|
||||
foreach (var item in NavigationViewControl.FooterMenuItems) allItems.Add(item);
|
||||
|
||||
foreach (var item in allItems)
|
||||
{
|
||||
if (item is iNKORE.UI.WPF.Modern.Controls.NavigationViewItem navItem)
|
||||
{
|
||||
var content = navItem.Content?.ToString();
|
||||
if (content != null && content.ToLower().Contains(query))
|
||||
{
|
||||
suggestions.Add(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sender.ItemsSource = suggestions;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user