add:安全中心
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
<local:SettingsPanelBase x:Class="Ink_Canvas.Windows.SettingsViews.SecurityPanel"
|
||||
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.SettingsViews"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="950" d:DesignWidth="640">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<Style x:Key="ToggleSwitchStyle" TargetType="Border">
|
||||
<Setter Property="Width" Value="48"/>
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="CornerRadius" Value="12"/>
|
||||
<Setter Property="Padding" Value="3,0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||
<Setter Property="Margin" Value="0,0,15,0"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
<ScrollViewer ScrollChanged="ScrollViewerEx_ScrollChanged"
|
||||
IsManipulationEnabled="True"
|
||||
Name="ScrollViewerEx"
|
||||
IsDeferredScrollingEnabled="True"
|
||||
VerticalScrollBarVisibility="Visible"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
IsTabStop="False"
|
||||
TabIndex="-1"
|
||||
Margin="0,0,2,2">
|
||||
<StackPanel Margin="60,12,60,24">
|
||||
<Border BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8">
|
||||
<StackPanel Orientation="Vertical" Margin="18,18,18,18">
|
||||
<TextBlock Text="安全密码默认关闭。开启后可用于退出软件、进入设置与重置配置时的二次验证。"
|
||||
TextWrapping="Wrap"
|
||||
Foreground="#9a9996"
|
||||
FontSize="11"
|
||||
Margin="0,0,0,12"/>
|
||||
|
||||
<Grid Height="54">
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="启用安全密码" HorizontalAlignment="Left"/>
|
||||
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="开启后需要设置密码" HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
<Border x:Name="ToggleSwitchPasswordEnabled"
|
||||
Style="{StaticResource ToggleSwitchStyle}"
|
||||
Background="#e1e1e1"
|
||||
Tag="PasswordEnabled"
|
||||
MouseLeftButtonDown="ToggleSwitch_Click">
|
||||
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Border Height="1" Background="#ebebeb" Margin="0,8,0,8"/>
|
||||
|
||||
<Grid Height="54">
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="密码管理" HorizontalAlignment="Left"/>
|
||||
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="设置或修改安全密码" HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
|
||||
<Button x:Name="BtnSetOrChangePassword" Width="120" Height="32" Click="BtnSetOrChangePassword_Click" Content="设置/修改密码"/>
|
||||
<Button x:Name="BtnDisablePassword" Width="90" Height="32" Margin="8,0,0,0" Click="BtnDisablePassword_Click" Content="关闭密码"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Border Height="1" Background="#ebebeb" Margin="0,8,0,8"/>
|
||||
|
||||
<Grid Height="54">
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="退出软件需要密码" HorizontalAlignment="Left"/>
|
||||
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="关闭 InkCanvasForClass 时进行密码验证" HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
<Border x:Name="ToggleSwitchRequirePasswordOnExit" Style="{StaticResource ToggleSwitchStyle}" Background="#e1e1e1" Tag="RequirePasswordOnExit" MouseLeftButtonDown="ToggleSwitch_Click">
|
||||
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Border Height="1" Background="#ebebeb" Margin="0,8,0,8"/>
|
||||
|
||||
<Grid Height="54">
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="进入设置需要密码" HorizontalAlignment="Left"/>
|
||||
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="打开设置面板/新设置窗口时进行验证" HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
<Border x:Name="ToggleSwitchRequirePasswordOnEnterSettings" Style="{StaticResource ToggleSwitchStyle}" Background="#e1e1e1" Tag="RequirePasswordOnEnterSettings" MouseLeftButtonDown="ToggleSwitch_Click">
|
||||
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Border Height="1" Background="#ebebeb" Margin="0,8,0,8"/>
|
||||
|
||||
<Grid Height="54">
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="重置配置需要密码" HorizontalAlignment="Left"/>
|
||||
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="重置 Settings.json 前进行二次验证" HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
<Border x:Name="ToggleSwitchRequirePasswordOnResetConfig" Style="{StaticResource ToggleSwitchStyle}" Background="#e1e1e1" Tag="RequirePasswordOnResetConfig" MouseLeftButtonDown="ToggleSwitch_Click">
|
||||
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Margin="0,25,0,0" BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8">
|
||||
<StackPanel Orientation="Vertical" Margin="18,18,18,18">
|
||||
<TextBlock Text="进程保护默认开启:运行期间保护根目录下的程序文件(exe/dll/config)不被外部修改。"
|
||||
TextWrapping="Wrap"
|
||||
Foreground="#9a9996"
|
||||
FontSize="11"
|
||||
Margin="0,0,0,12"/>
|
||||
<Grid Height="54">
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="进程保护" HorizontalAlignment="Left"/>
|
||||
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="开启后关键文件会被只读占用" HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
<Border x:Name="ToggleSwitchEnableProcessProtection" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" Tag="EnableProcessProtection" MouseLeftButtonDown="ToggleSwitch_Click">
|
||||
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</local:SettingsPanelBase>
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Helpers;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
public partial class SecurityPanel : SettingsPanelBase
|
||||
{
|
||||
public SecurityPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override void LoadSettings()
|
||||
{
|
||||
if (MainWindow.Settings == null) return;
|
||||
if (MainWindow.Settings.Security == null) MainWindow.Settings.Security = new Security();
|
||||
|
||||
_isLoaded = false;
|
||||
try
|
||||
{
|
||||
var sec = MainWindow.Settings.Security;
|
||||
|
||||
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchPasswordEnabled"), sec.PasswordEnabled);
|
||||
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchRequirePasswordOnExit"), sec.RequirePasswordOnExit);
|
||||
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchRequirePasswordOnEnterSettings"), sec.RequirePasswordOnEnterSettings);
|
||||
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchRequirePasswordOnResetConfig"), sec.RequirePasswordOnResetConfig);
|
||||
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableProcessProtection"), sec.EnableProcessProtection);
|
||||
|
||||
UpdatePasswordUiState();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
_isLoaded = true;
|
||||
}
|
||||
|
||||
private void UpdatePasswordUiState()
|
||||
{
|
||||
var sec = MainWindow.Settings?.Security;
|
||||
var enabled = sec != null && sec.PasswordEnabled;
|
||||
|
||||
if (BtnSetOrChangePassword != null) BtnSetOrChangePassword.IsEnabled = enabled;
|
||||
if (BtnDisablePassword != null) BtnDisablePassword.IsEnabled = enabled;
|
||||
|
||||
// 用途开关:仅在启用密码功能时可操作
|
||||
var usageEnabled = enabled;
|
||||
var t1 = FindToggleSwitch("ToggleSwitchRequirePasswordOnExit");
|
||||
var t2 = FindToggleSwitch("ToggleSwitchRequirePasswordOnEnterSettings");
|
||||
var t3 = FindToggleSwitch("ToggleSwitchRequirePasswordOnResetConfig");
|
||||
if (t1 != null) t1.IsEnabled = usageEnabled;
|
||||
if (t2 != null) t2.IsEnabled = usageEnabled;
|
||||
if (t3 != null) t3.IsEnabled = usageEnabled;
|
||||
}
|
||||
|
||||
protected override async void HandleToggleSwitchChange(string tag, bool newState)
|
||||
{
|
||||
if (MainWindow.Settings == null) return;
|
||||
if (MainWindow.Settings.Security == null) MainWindow.Settings.Security = new Security();
|
||||
var sec = MainWindow.Settings.Security;
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case "PasswordEnabled":
|
||||
if (newState)
|
||||
{
|
||||
var havePassword = SecurityManager.HasPasswordConfigured(MainWindow.Settings);
|
||||
|
||||
if (!havePassword)
|
||||
{
|
||||
var pwd = await SecurityManager.PromptSetNewPasswordAsync(Window.GetWindow(this));
|
||||
if (string.IsNullOrEmpty(pwd))
|
||||
{
|
||||
_isLoaded = false;
|
||||
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchPasswordEnabled"), false);
|
||||
_isLoaded = true;
|
||||
return;
|
||||
}
|
||||
SecurityManager.SetPassword(MainWindow.Settings, pwd);
|
||||
}
|
||||
|
||||
sec.PasswordEnabled = true;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
UpdatePasswordUiState();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 关闭:需要输入当前密码确认(已设置密码时)
|
||||
if (SecurityManager.HasPasswordConfigured(MainWindow.Settings))
|
||||
{
|
||||
bool ok = await SecurityManager.PromptAndVerifyAsync(MainWindow.Settings, Window.GetWindow(this),
|
||||
"关闭安全密码", "请输入当前密码以关闭安全密码功能。");
|
||||
if (!ok)
|
||||
{
|
||||
_isLoaded = false;
|
||||
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchPasswordEnabled"), true);
|
||||
_isLoaded = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sec.PasswordEnabled = false;
|
||||
SecurityManager.ClearPassword(MainWindow.Settings);
|
||||
MainWindow.SaveSettingsToFile();
|
||||
UpdatePasswordUiState();
|
||||
}
|
||||
break;
|
||||
|
||||
case "RequirePasswordOnExit":
|
||||
sec.RequirePasswordOnExit = newState;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
break;
|
||||
case "RequirePasswordOnEnterSettings":
|
||||
sec.RequirePasswordOnEnterSettings = newState;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
break;
|
||||
case "RequirePasswordOnResetConfig":
|
||||
sec.RequirePasswordOnResetConfig = newState;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
break;
|
||||
case "EnableProcessProtection":
|
||||
sec.EnableProcessProtection = newState;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
ProcessProtectionManager.SetEnabled(newState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void HandleOptionChange(string group, string value)
|
||||
{
|
||||
// 本面板无选项按钮组
|
||||
}
|
||||
|
||||
protected override void ToggleSwitch_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
base.ToggleSwitch_Click(sender, e);
|
||||
}
|
||||
|
||||
private async void BtnSetOrChangePassword_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (MainWindow.Settings == null) return;
|
||||
if (MainWindow.Settings.Security == null) MainWindow.Settings.Security = new Security();
|
||||
|
||||
var owner = Window.GetWindow(this);
|
||||
|
||||
var newPwd = await SecurityManager.PromptChangePasswordAsync(MainWindow.Settings, owner);
|
||||
if (!string.IsNullOrEmpty(newPwd))
|
||||
{
|
||||
SecurityManager.SetPassword(MainWindow.Settings, newPwd);
|
||||
MainWindow.Settings.Security.PasswordEnabled = true;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
UpdatePasswordUiState();
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnDisablePassword_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 触发和开关一致的逻辑
|
||||
if (FindToggleSwitch("ToggleSwitchPasswordEnabled") is Border b)
|
||||
{
|
||||
// 模拟点击到 off
|
||||
if (MainWindow.Settings?.Security?.PasswordEnabled == true)
|
||||
{
|
||||
_isLoaded = true;
|
||||
SetToggleSwitchState(b, false);
|
||||
HandleToggleSwitchChange("PasswordEnabled", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
|
||||
public event EventHandler<RoutedEventArgs> IsTopBarNeedNoShadowEffect;
|
||||
|
||||
private void ScrollViewerEx_ScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||
{
|
||||
var scrollViewer = (ScrollViewer)sender;
|
||||
if (scrollViewer.VerticalOffset >= 10) IsTopBarNeedShadowEffect?.Invoke(this, new RoutedEventArgs());
|
||||
else IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
|
||||
}
|
||||
|
||||
public void ApplyTheme()
|
||||
{
|
||||
try
|
||||
{
|
||||
ThemeHelper.ApplyThemeToControl(this);
|
||||
LoadSettings();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"SettingsPanelBase 应用主题时出错: {ex.Message}");
|
||||
}
|
||||
LoadSettings();
|
||||
_isLoaded = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Window x:Class="Ink_Canvas.Windows.SettingsWindow"
|
||||
<Window x:Class="Ink_Canvas.Windows.SettingsWindow"
|
||||
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"
|
||||
@@ -196,6 +196,20 @@
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
<DrawingImage x:Key="SecurityIcon">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
|
||||
<GeometryDrawing Brush="Transparent">
|
||||
<GeometryDrawing.Geometry>
|
||||
<PathGeometry Figures="M12,3 C14.3358,5.06658 17.3844,6.14257 20.5,6 C20.9535,7.54302 21.0923,9.16147 20.9081,10.7592 C20.7238,12.3569 20.2203,13.9013 19.4274,15.3005 C18.6344,16.6998 17.5683,17.9254 16.2924,18.9045 C15.0165,19.8836 13.5567,20.5962 12,21 C10.4432,20.5962 8.98344,19.8836 7.7075,18.9045 C6.43157,17.9254 5.36547,16.6998 4.57255,15.3005 C3.77964,13.9013 3.27609,12.3569 3.09183,10.7592 C2.90757,9.16147 3.04636,7.54302 3.49996,6 C6.61548,6.14257 9.66413,5.06658 12,3 Z" />
|
||||
</GeometryDrawing.Geometry>
|
||||
<GeometryDrawing.Pen>
|
||||
<Pen Brush="#FF222222" Thickness="2" StartLineCap="Round" EndLineCap="Round" LineJoin="Round" />
|
||||
</GeometryDrawing.Pen>
|
||||
</GeometryDrawing>
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
<DrawingImage x:Key="UpdateCenterIcon">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup ClipGeometry="M0,0 V16 H16 V0 H0 Z">
|
||||
@@ -632,7 +646,11 @@
|
||||
<!--Sidebar-->
|
||||
<Border x:Name="SidebarBorder" Width="250" Background="#ebebeb" BorderBrush="#e1e1e1" CornerRadius="7,0,0,7" BorderThickness="0,0,2,0" HorizontalAlignment="Left">
|
||||
<Grid>
|
||||
<Grid Height="48" VerticalAlignment="Top">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Height="48" VerticalAlignment="Top" Grid.Row="0">
|
||||
<Border x:Name="SearchButtonBorder" CornerRadius="8" Background="#d9d9d9" Width="34" Height="34" Margin="8,0,0,0" HorizontalAlignment="Left" MouseLeftButtonDown="SearchButton_Click" Cursor="Hand">
|
||||
<Image Width="16" Height="16">
|
||||
<Image.Source>
|
||||
@@ -725,32 +743,45 @@
|
||||
</Border.ContextMenu>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ItemsControl Name="SidebarItemsControl">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Margin="0,54,0,6"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Line Visibility="{Binding _spVisibility}" Margin="0,6" HorizontalAlignment="Center" X1="0" X2="234" Y1="0" Y2="0" Stroke="{Binding _spStroke}" StrokeThickness="1" StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
|
||||
<Border MouseDown="SidebarItem_MouseDown" MouseUp="SidebarItem_MouseUp" MouseLeave="SidebarItem_MouseLeave"
|
||||
Tag="{Binding}" Visibility="{Binding _siVisibility}" Background="{Binding _siBackground}" Height="40" Margin="6,0,6,0" CornerRadius="7">
|
||||
<Grid>
|
||||
<Border Height="40" CornerRadius="7" Background="#09090b" IsHitTestVisible="false" Opacity="0" Name="MouseFeedbackBorder"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Width="18" Height="18" Margin="14,0,9,0" VerticalAlignment="Center" Source="{Binding IconSource}"/>
|
||||
<TextBlock FontSize="14" VerticalAlignment="Center" Text="{Binding Title}" Foreground="{Binding _siForeground}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<ScrollViewer Margin="0,0,0,6"
|
||||
VerticalScrollBarVisibility="Hidden"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
IsManipulationEnabled="True"
|
||||
PanningMode="VerticalOnly"
|
||||
CanContentScroll="True"
|
||||
Grid.Row="1">
|
||||
<ItemsControl Name="SidebarItemsControl">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Margin="0,6,0,0"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Line Visibility="{Binding _spVisibility}" Margin="0,6" HorizontalAlignment="Center" X1="0" X2="234" Y1="0" Y2="0" Stroke="{Binding _spStroke}" StrokeThickness="1" StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
|
||||
<Border MouseDown="SidebarItem_MouseDown" MouseUp="SidebarItem_MouseUp" MouseLeave="SidebarItem_MouseLeave"
|
||||
Tag="{Binding}" Visibility="{Binding _siVisibility}" Background="{Binding _siBackground}" Height="40" Margin="6,0,6,0" CornerRadius="7">
|
||||
<Grid>
|
||||
<Border Height="40" CornerRadius="7" Background="#09090b" IsHitTestVisible="false" Opacity="0" Name="MouseFeedbackBorder"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Width="18" Height="18" Margin="14,0,9,0" VerticalAlignment="Center" Source="{Binding IconSource}"/>
|
||||
<TextBlock FontSize="14" VerticalAlignment="Center" Text="{Binding Title}" Foreground="{Binding _siForeground}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Border>
|
||||
<!--SecurityPanel-->
|
||||
<Grid Margin="250,48,0,0" Visibility="Collapsed" Name="SecurityPane">
|
||||
<settingsViews:SecurityPanel x:Name="SecurityPanel"/>
|
||||
</Grid>
|
||||
|
||||
<!--UpdateCenterPanel-->
|
||||
<Grid Margin="250,48,0,0" Visibility="Collapsed" Name="UpdateCenterPane">
|
||||
<settingsViews:UpdateCenterPanel x:Name="UpdateCenterPanel"/>
|
||||
|
||||
@@ -153,6 +153,14 @@ namespace Ink_Canvas.Windows
|
||||
Type = SidebarItemType.Separator
|
||||
});
|
||||
SidebarItems.Add(new SidebarItem()
|
||||
{
|
||||
Type = SidebarItemType.Item,
|
||||
Title = "安全",
|
||||
Name = "SecurityItem",
|
||||
IconSource = FindResource("SecurityIcon") as DrawingImage,
|
||||
Selected = false,
|
||||
});
|
||||
SidebarItems.Add(new SidebarItem()
|
||||
{
|
||||
Type = SidebarItemType.Item,
|
||||
Title = "更新中心",
|
||||
@@ -169,6 +177,7 @@ namespace Ink_Canvas.Windows
|
||||
Selected = false,
|
||||
});
|
||||
SettingsPanes = new Grid[] {
|
||||
SecurityPane,
|
||||
UpdateCenterPane,
|
||||
AboutPane,
|
||||
CanvasAndInkPane,
|
||||
@@ -186,6 +195,7 @@ namespace Ink_Canvas.Windows
|
||||
};
|
||||
|
||||
SettingsPaneScrollViewers = new ScrollViewer[] {
|
||||
SecurityPanel.ScrollViewerEx,
|
||||
UpdateCenterPanel.UpdateCenterScrollViewerEx,
|
||||
SettingsAboutPanel.AboutScrollViewerEx,
|
||||
CanvasAndInkPanel.ScrollViewerEx,
|
||||
@@ -203,6 +213,7 @@ namespace Ink_Canvas.Windows
|
||||
};
|
||||
|
||||
SettingsPaneTitles = new string[] {
|
||||
"安全",
|
||||
"更新中心",
|
||||
"关于",
|
||||
"画板和墨迹",
|
||||
@@ -220,6 +231,7 @@ namespace Ink_Canvas.Windows
|
||||
};
|
||||
|
||||
SettingsPaneNames = new string[] {
|
||||
"SecurityItem",
|
||||
"UpdateCenterItem",
|
||||
"AboutItem",
|
||||
"CanvasAndInkItem",
|
||||
@@ -271,6 +283,8 @@ namespace Ink_Canvas.Windows
|
||||
AdvancedPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
|
||||
SnapshotPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25;
|
||||
SnapshotPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
|
||||
SecurityPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25;
|
||||
SecurityPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
|
||||
UpdateCenterPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25;
|
||||
UpdateCenterPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
|
||||
|
||||
@@ -321,7 +335,7 @@ namespace Ink_Canvas.Windows
|
||||
// 使用反射调用所有面板的 ApplyTheme 方法(如果存在)
|
||||
var panels = new UserControl[]
|
||||
{
|
||||
UpdateCenterPanel, StartupPanel, CanvasAndInkPanel, GesturesPanel, InkRecognitionPanel,
|
||||
SecurityPanel, UpdateCenterPanel, StartupPanel, CanvasAndInkPanel, GesturesPanel, InkRecognitionPanel,
|
||||
ThemePanel, ShortcutsPanel, CrashActionPanel, PowerPointPanel,
|
||||
AutomationPanel, LuckyRandomPanel, AdvancedPanel, SnapshotPanel,
|
||||
SettingsAboutPanel, AppearancePanel, SearchPanelControl
|
||||
@@ -766,6 +780,7 @@ namespace Ink_Canvas.Windows
|
||||
LuckyRandomPanel,
|
||||
AdvancedPanel,
|
||||
SnapshotPanel,
|
||||
SecurityPanel,
|
||||
UpdateCenterPanel,
|
||||
SettingsAboutPanel,
|
||||
AppearancePanel
|
||||
@@ -960,6 +975,7 @@ namespace Ink_Canvas.Windows
|
||||
{ "LuckyRandomItem", LuckyRandomPanel },
|
||||
{ "AdvancedItem", AdvancedPanel },
|
||||
{ "SnapshotItem", SnapshotPanel },
|
||||
{ "SecurityItem", SecurityPanel },
|
||||
{ "UpdateCenterItem", UpdateCenterPanel },
|
||||
{ "AppearanceItem", AppearancePanel }
|
||||
};
|
||||
@@ -978,6 +994,7 @@ namespace Ink_Canvas.Windows
|
||||
if (LuckyRandomPane != null) LuckyRandomPane.Visibility = _selectedSidebarItemName == "LuckyRandomItem" ? Visibility.Visible : Visibility.Collapsed;
|
||||
if (AdvancedPane != null) AdvancedPane.Visibility = _selectedSidebarItemName == "AdvancedItem" ? Visibility.Visible : Visibility.Collapsed;
|
||||
if (SnapshotPane != null) SnapshotPane.Visibility = _selectedSidebarItemName == "SnapshotItem" ? Visibility.Visible : Visibility.Collapsed;
|
||||
if (SecurityPane != null) SecurityPane.Visibility = _selectedSidebarItemName == "SecurityItem" ? Visibility.Visible : Visibility.Collapsed;
|
||||
if (UpdateCenterPane != null) UpdateCenterPane.Visibility = _selectedSidebarItemName == "UpdateCenterItem" ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
// 为新显示的面板应用主题(延迟执行,确保面板已完全显示)
|
||||
|
||||
Reference in New Issue
Block a user