improve:UI

This commit is contained in:
2026-05-01 01:52:36 +08:00
parent ac399773d0
commit 8c2fc15d81
2 changed files with 161 additions and 199 deletions
+137 -103
View File
@@ -3,130 +3,164 @@
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:local="clr-namespace:Ink_Canvas"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
FontFamily="Microsoft YaHei UI"
Title="隐私说明 - InkCanvasForClass"
Height="640" Width="720"
MinHeight="420" MinWidth="520"
WindowStartupLocation="CenterScreen"
Topmost="True"
Title="隐私说明 - Ink Canvas" Height="600" Width="600"
ui:ThemeManager.IsThemeAware="True"
ui:TitleBar.ExtendViewIntoTitleBar="True"
ui:WindowHelper.SystemBackdropType="Mica"
ui:WindowHelper.UseModernWindowStyle="True"
ui:TitleBar.Height="48"
Loaded="Window_Loaded" Closing="Window_Closing">
<Window.Resources>
<SolidColorBrush x:Key="PrivacyAgreementWindowBackground" Color="White"/>
<SolidColorBrush x:Key="PrivacyAgreementWindowForeground" Color="Black"/>
<SolidColorBrush x:Key="PrivacyAgreementWindowButtonBackground" Color="#F4F4F5"/>
<SolidColorBrush x:Key="PrivacyAgreementWindowButtonForeground" Color="Black"/>
<SolidColorBrush x:Key="PrivacyAgreementWindowBorderBrush" Color="#E4E4E7"/>
<SolidColorBrush x:Key="PrivacyAgreementWindowButtonAcceptBackground" Color="#3584e4"/>
<SolidColorBrush x:Key="PrivacyAgreementWindowButtonAcceptForeground" Color="White"/>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemeResources CanBeAccessedAcrossThreads="True">
<ui:ThemeResources.ThemeDictionaries />
</ui:ThemeResources>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- 自定义标题栏 -->
<Border x:Name="Border_TitleBarRoot"
Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=(ui:TitleBar.Height)}">
<!-- 标题栏 -->
<Border Grid.Row="0"
Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=(ui:TitleBar.Height)}"
Background="Transparent">
<ikw:SimpleStackPanel Orientation="Horizontal"
Spacing="12"
VerticalAlignment="Center"
Margin="16,0,0,0">
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Shield}" FontSize="14" />
<TextBlock VerticalAlignment="Center"
Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=Title}"
TextWrapping="NoWrap" />
</ikw:SimpleStackPanel>
</Border>
<!-- Banner Header -->
<Border Grid.Row="1"
Padding="40,18,40,18"
BorderThickness="0,0,0,1"
BorderBrush="{DynamicResource SystemControlForegroundBaseLowBrush}">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="#1F3B82F6" Offset="0" />
<GradientStop Color="#0A8B5CF6" Offset="1" />
</LinearGradientBrush>
</Border.Background>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=Title}"
VerticalAlignment="Center" Margin="12,0,0,0" FontSize="12" FontWeight="SemiBold"/>
<Border Grid.Column="0" Grid.RowSpan="2"
Width="48" Height="48"
Margin="0,0,16,0"
VerticalAlignment="Top"
CornerRadius="10"
Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}">
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Shield}"
FontSize="24"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<!--Right Inset-->
<Rectangle Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=(ui:TitleBar.SystemOverlayRightInset)}"
Grid.Column="2"/>
<!--Right Buttons-->
<ikw:SimpleStackPanel x:Name="StackPanel_RightButtons"
Orientation="Horizontal" Grid.Column="1" Spacing="5">
</ikw:SimpleStackPanel>
<TextBlock Grid.Column="1" Grid.Row="0"
Style="{DynamicResource TitleTextBlockStyle}"
Text="隐私说明" />
<TextBlock Grid.Column="1" Grid.Row="1"
Style="{DynamicResource BodyTextBlockStyle}"
Margin="0,4,0,0"
Opacity="0.85"
TextWrapping="Wrap"
Text="请仔细阅读以下条款。点击&quot;同意&quot;即表示您理解并接受本软件的隐私实践。" />
</Grid>
</Border>
<!-- 主内容区 -->
<Grid Grid.Row="1" Background="{DynamicResource PrivacyAgreementWindowBackground}">
<ScrollViewer Margin="10,10,10,70"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled">
<TextBox Name="TextBoxPrivacyContent"
VerticalScrollBarVisibility="Auto"
AcceptsReturn="True"
IsReadOnly="True"
TextWrapping="Wrap"
Background="{DynamicResource PrivacyAgreementWindowBackground}"
Foreground="{DynamicResource PrivacyAgreementWindowForeground}"
BorderBrush="{DynamicResource PrivacyAgreementWindowBorderBrush}"
Padding="10"/>
</ScrollViewer>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Margin="10">
<Button Name="ButtonCancel"
Margin="0,0,10,0"
Content="取消"
Width="100"
Height="35"
Click="ButtonCancel_Click"
Background="{DynamicResource PrivacyAgreementWindowButtonBackground}"
Foreground="{DynamicResource PrivacyAgreementWindowButtonForeground}"
BorderBrush="{DynamicResource PrivacyAgreementWindowBorderBrush}"
OverridesDefaultStyle="True">
<Button.Template>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"/>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<Button Name="ButtonAccept"
Content="同意"
Width="100"
Height="35"
Click="ButtonAccept_Click"
Background="{DynamicResource PrivacyAgreementWindowButtonAcceptBackground}"
Foreground="{DynamicResource PrivacyAgreementWindowButtonAcceptForeground}"
BorderBrush="{DynamicResource PrivacyAgreementWindowBorderBrush}"
OverridesDefaultStyle="True">
<Button.Template>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"/>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
</Grid>
</Grid>
</Window>
<!-- 内容区 -->
<ScrollViewer Grid.Row="2"
x:Name="ContentScroll"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
PanningMode="VerticalFirst"
Padding="40,16,40,16">
<Border Background="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}"
CornerRadius="8"
Padding="20,16"
BorderThickness="1"
BorderBrush="{DynamicResource SystemControlForegroundBaseLowBrush}">
<TextBlock Name="TextBoxPrivacyContent"
TextWrapping="Wrap"
LineHeight="22"
FontSize="13"
Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}" />
</Border>
</ScrollViewer>
<!-- Footer -->
<Border Grid.Row="3"
Padding="40,12,40,16"
BorderThickness="0,1,0,0"
BorderBrush="{DynamicResource SystemControlForegroundBaseLowBrush}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
VerticalAlignment="Center"
Style="{DynamicResource CaptionTextBlockStyle}"
Opacity="0.7"
TextWrapping="Wrap"
Text="本软件不会收集课堂内容或可识别的个人信息。" />
<Button Grid.Column="1"
Name="ButtonCancel"
MinWidth="96"
Height="32"
Margin="0,0,8,0"
Click="ButtonCancel_Click">
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="6">
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Cancel}" FontSize="12" />
<TextBlock Text="取消" />
</ikw:SimpleStackPanel>
</Button>
<Button Grid.Column="2"
Name="ButtonAccept"
MinWidth="120"
Height="32"
IsDefault="True"
Style="{DynamicResource AccentButtonStyle}"
Click="ButtonAccept_Click">
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="6">
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Accept}" FontSize="12" />
<TextBlock Text="同意" />
</ikw:SimpleStackPanel>
</Button>
</Grid>
</Border>
</Grid>
</Window>
@@ -6,7 +6,6 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Threading;
namespace Ink_Canvas
@@ -18,7 +17,7 @@ namespace Ink_Canvas
public PrivacyAgreementWindow()
{
InitializeComponent();
this.Topmost = true;
Topmost = true;
AnimationsHelper.ShowWithSlideFromBottomAndFade(this, 0.25);
ApplyTheme();
}
@@ -27,13 +26,13 @@ namespace Ink_Canvas
{
try
{
this.Topmost = true;
Topmost = true;
Dispatcher.BeginInvoke(new Action(() =>
{
this.Activate();
this.Focus();
this.Topmost = true;
Activate();
Focus();
Topmost = true;
SetForegroundWindow(new WindowInteropHelper(this).Handle);
}), DispatcherPriority.Loaded);
@@ -76,9 +75,7 @@ namespace Ink_Canvas
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
private void Window_Closing(object sender, CancelEventArgs e)
{
}
private void Window_Closing(object sender, CancelEventArgs e) { }
private void ButtonCancel_Click(object sender, RoutedEventArgs e)
{
@@ -98,10 +95,19 @@ namespace Ink_Canvas
{
try
{
if (MainWindow.Settings != null)
var settings = MainWindow.Settings;
if (settings == null) return;
iNKORE.UI.WPF.Modern.ElementTheme target;
switch (settings.Appearance.Theme)
{
ApplyTheme(MainWindow.Settings);
case 0: target = iNKORE.UI.WPF.Modern.ElementTheme.Light; break;
case 1: target = iNKORE.UI.WPF.Modern.ElementTheme.Dark; break;
default: target = IsSystemThemeLight()
? iNKORE.UI.WPF.Modern.ElementTheme.Light
: iNKORE.UI.WPF.Modern.ElementTheme.Dark; break;
}
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, target);
}
catch (Exception ex)
{
@@ -109,97 +115,19 @@ namespace Ink_Canvas
}
}
private void ApplyTheme(Settings settings)
private static bool IsSystemThemeLight()
{
try
{
if (settings.Appearance.Theme == 0)
{
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Light);
ApplyThemeResources("Light");
}
else if (settings.Appearance.Theme == 1)
{
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Dark);
ApplyThemeResources("Dark");
}
else
{
bool isSystemLight = IsSystemThemeLight();
if (isSystemLight)
{
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Light);
ApplyThemeResources("Light");
}
else
{
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Dark);
ApplyThemeResources("Dark");
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"应用隐私说明窗口主题出错: {ex.Message}", LogHelper.LogType.Error);
}
}
private void ApplyThemeResources(string theme)
{
try
{
var resources = this.Resources;
if (theme == "Light")
{
resources["PrivacyAgreementWindowBackground"] = new SolidColorBrush(Color.FromRgb(255, 255, 255));
resources["PrivacyAgreementWindowForeground"] = new SolidColorBrush(Color.FromRgb(24, 24, 27));
resources["PrivacyAgreementWindowButtonBackground"] = new SolidColorBrush(Color.FromRgb(244, 244, 245));
resources["PrivacyAgreementWindowButtonForeground"] = new SolidColorBrush(Color.FromRgb(24, 24, 27));
resources["PrivacyAgreementWindowBorderBrush"] = new SolidColorBrush(Color.FromRgb(228, 228, 231));
resources["PrivacyAgreementWindowButtonAcceptBackground"] = new SolidColorBrush(Color.FromRgb(53, 132, 228));
resources["PrivacyAgreementWindowButtonAcceptForeground"] = new SolidColorBrush(Colors.White);
}
else
{
resources["PrivacyAgreementWindowBackground"] = new SolidColorBrush(Color.FromRgb(31, 31, 31));
resources["PrivacyAgreementWindowForeground"] = new SolidColorBrush(Colors.White);
resources["PrivacyAgreementWindowButtonBackground"] = new SolidColorBrush(Color.FromRgb(42, 42, 42));
resources["PrivacyAgreementWindowButtonForeground"] = new SolidColorBrush(Colors.White);
resources["PrivacyAgreementWindowBorderBrush"] = new SolidColorBrush(Color.FromRgb(224, 224, 224));
resources["PrivacyAgreementWindowButtonAcceptBackground"] = new SolidColorBrush(Color.FromRgb(53, 132, 228));
resources["PrivacyAgreementWindowButtonAcceptForeground"] = new SolidColorBrush(Colors.White);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"应用隐私说明窗口主题资源出错: {ex.Message}", LogHelper.LogType.Error);
}
}
private bool IsSystemThemeLight()
{
var light = false;
try
{
var registryKey = Microsoft.Win32.Registry.CurrentUser;
var themeKey = registryKey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize");
if (themeKey != null)
using (var themeKey = registryKey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"))
{
var value = themeKey.GetValue("AppsUseLightTheme");
if (value != null)
{
light = (int)value == 1;
}
themeKey.Close();
var value = themeKey?.GetValue("AppsUseLightTheme");
if (value is int i) return i == 1;
}
}
catch
{
light = true;
}
return light;
catch { }
return true;
}
}
}
}