改了两ui 适配了触摸

This commit is contained in:
PrefacedCorg
2026-03-21 16:18:36 +08:00
parent 3934270ed2
commit 4772b9cce7
4 changed files with 200 additions and 239 deletions
+123 -217
View File
@@ -9,120 +9,12 @@
mc:Ignorable="d" mc:Ignorable="d"
ui:WindowHelper.UseModernWindowStyle="False" ui:WindowHelper.UseModernWindowStyle="False"
ui:WindowHelper.SystemBackdropType="Mica" ui:WindowHelper.SystemBackdropType="Mica"
Title="历史版本回滚" Height="650" Width="900" ResizeMode="NoResize" Title="历史版本回滚" Height="650" Width="900" ResizeMode="CanResize"
WindowStartupLocation="CenterScreen" WindowStyle="None" WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow"
Background="Transparent" MinHeight="550" MinWidth="800"> Background="{DynamicResource SettingsPageBackground}" MinHeight="550" MinWidth="800"
<Window.Template> SnapsToDevicePixels="True"
<ControlTemplate TargetType="Window"> TextOptions.TextRenderingMode="ClearType"
<Border Background="{DynamicResource SettingsPageBackground}" TextOptions.TextFormattingMode="Display">
CornerRadius="8"
BorderBrush="{DynamicResource SettingsPageBorderBrush}"
BorderThickness="1">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="20" ShadowDepth="0" Opacity="0.1"/>
</Border.Effect>
<AdornerDecorator>
<Grid>
<!-- 标题栏 -->
<Border Background="{DynamicResource SettingsPageBackground}" Height="48" VerticalAlignment="Top">
<Grid>
<TextBlock Text="{TemplateBinding Title}"
FontSize="14" FontWeight="SemiBold"
Foreground="{DynamicResource SettingsPageForeground}"
VerticalAlignment="Center"
Margin="16,0,0,0"/>
<!-- 最小化按钮 -->
<Button Name="MinimizeButton"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,8,40,0"
Width="32" Height="32"
Background="Transparent"
BorderThickness="0"
Click="MinimizeButton_Click"
Cursor="Hand"
ToolTip="最小化">
<Button.Template>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
CornerRadius="4"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}">
<TextBlock Text="" FontSize="14"
Foreground="{DynamicResource SettingsPageForeground}"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#FF2563eb" Opacity="0.1"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#FF2563eb" Opacity="0.2"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<!-- 关闭按钮 -->
<Button Name="CloseButton"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,8,8,0"
Width="32" Height="32"
Background="Transparent"
BorderThickness="0"
Click="CloseButton_Click"
Cursor="Hand"
ToolTip="关闭">
<Button.Template>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
CornerRadius="4"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}">
<TextBlock Text="×" FontSize="14"
Foreground="{DynamicResource SettingsPageForeground}"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#ef4444" Opacity="0.1"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#ef4444" Opacity="0.2"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</Border>
<!-- 内容区域 -->
<ContentPresenter Margin="0,48,0,0"/>
</Grid>
</AdornerDecorator>
</Border>
</ControlTemplate>
</Window.Template>
<Window.Resources> <Window.Resources>
<!-- 主题相关颜色资源 --> <!-- 主题相关颜色资源 -->
<SolidColorBrush x:Key="PrimaryBrush" Color="#FF2563eb"/> <SolidColorBrush x:Key="PrimaryBrush" Color="#FF2563eb"/>
@@ -130,111 +22,125 @@
<SolidColorBrush x:Key="TextSecondaryBrush" Color="#FF6b7280"/> <SolidColorBrush x:Key="TextSecondaryBrush" Color="#FF6b7280"/>
</Window.Resources> </Window.Resources>
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled"> <Grid Background="Transparent" Margin="20">
<Grid Background="Transparent"> <Grid.RowDefinitions>
<!-- 主内容区域 --> <RowDefinition Height="Auto"/>
<ikw:SimpleStackPanel VerticalAlignment="Stretch" Spacing="0" Margin="20"> <RowDefinition Height="Auto"/>
<!-- 标题区域 --> <RowDefinition Height="*"/>
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="12" Margin="0,0,0,16"> <RowDefinition Height="Auto"/>
<Border Background="{DynamicResource PrimaryBrush}" CornerRadius="16" Padding="12" Margin="0,0,0,0"> </Grid.RowDefinitions>
<ui:SymbolIcon Symbol="Undo" FontSize="20" Foreground="White"
VerticalAlignment="Center"/>
</Border>
<ikw:SimpleStackPanel VerticalAlignment="Center" Spacing="4">
<TextBlock Text="历史版本回滚" FontSize="22" FontWeight="Bold"
Foreground="{DynamicResource TextPrimaryBrush}"/>
<TextBlock Text="选择要回滚到的历史版本" FontSize="14"
Foreground="{DynamicResource TextSecondaryBrush}"/>
</ikw:SimpleStackPanel>
</ikw:SimpleStackPanel>
<!-- 版本选择卡片 --> <!-- 标题区域 -->
<Border Background="{DynamicResource SettingsPageBackground}" <ikw:SimpleStackPanel Grid.Row="0" Orientation="Horizontal" Spacing="12" Margin="0,0,0,16">
BorderBrush="{DynamicResource SettingsPageBorderBrush}" <Border Background="{DynamicResource PrimaryBrush}" CornerRadius="16" Padding="12" Margin="0,0,0,0">
BorderThickness="1" <ui:SymbolIcon Symbol="Undo" FontSize="20" Foreground="White"
CornerRadius="12" VerticalAlignment="Center"/>
Margin="0,0,0,16"
Padding="20">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="8" ShadowDepth="0" Opacity="0.05"/>
</Border.Effect>
<ikw:SimpleStackPanel Spacing="16">
<TextBlock Text="选择版本" FontSize="16" FontWeight="SemiBold"
Foreground="{DynamicResource TextPrimaryBrush}"/>
<ComboBox x:Name="VersionComboBox"
Width="300" Height="40"
DisplayMemberPath="Version"
SelectionChanged="VersionComboBox_SelectionChanged"/>
</ikw:SimpleStackPanel>
</Border> </Border>
<ikw:SimpleStackPanel VerticalAlignment="Center" Spacing="4">
<!-- 发布说明卡片 --> <TextBlock Text="选择要回滚到的历史版本" FontSize="22" FontWeight="Bold"
<Border Background="{DynamicResource SettingsPageBackground}" Foreground="{DynamicResource TextPrimaryBrush}"/>
BorderBrush="{DynamicResource SettingsPageBorderBrush}"
BorderThickness="1"
CornerRadius="12"
Margin="0,0,0,16"
Padding="20">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="8" ShadowDepth="0" Opacity="0.05"/>
</Border.Effect>
<ikw:SimpleStackPanel Spacing="16">
<TextBlock Text="版本更新说明" FontSize="16" FontWeight="SemiBold"
Foreground="{DynamicResource TextPrimaryBrush}"/>
<Border Background="{DynamicResource SettingsPageBackground}"
BorderBrush="{DynamicResource SettingsPageBorderBrush}"
BorderThickness="1"
CornerRadius="8"
MinHeight="150" MaxHeight="250">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="4" ShadowDepth="0" Opacity="0.03"/>
</Border.Effect>
<ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
Padding="16">
<mdxam:MarkdownScrollViewer x:Name="ReleaseNotesViewer"
Foreground="{DynamicResource TextPrimaryBrush}"
MarkdownStyleName="GithubLike"/>
</ScrollViewer>
</Border>
</ikw:SimpleStackPanel> </ikw:SimpleStackPanel>
</Border>
<!-- 操作按钮区域 -->
<ikw:SimpleStackPanel Spacing="16" Margin="0,0,0,16">
<Button x:Name="RollbackButton"
Content="回滚到此版本"
HorizontalAlignment="Center"
Click="RollbackButton_Click"
Style="{DynamicResource AccentButtonStyle}"
Width="200" Height="48"
FontSize="16" FontWeight="SemiBold"/>
<!-- 下载进度面板 -->
<Border x:Name="DownloadProgressPanel"
Background="{DynamicResource SettingsPageBackground}"
BorderBrush="{DynamicResource SettingsPageBorderBrush}"
BorderThickness="1"
CornerRadius="12"
Visibility="Collapsed"
Margin="0,8,0,0"
Padding="24">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="8" ShadowDepth="0" Opacity="0.05"/>
</Border.Effect>
<ikw:SimpleStackPanel Spacing="12">
<ProgressBar x:Name="DownloadProgressBar"
Width="300" Height="8"
Minimum="0" Maximum="100" Value="0"/>
<TextBlock x:Name="DownloadProgressText"
Text="正在下载..."
FontSize="14"
Foreground="{DynamicResource TextPrimaryBrush}"
HorizontalAlignment="Center"/>
</ikw:SimpleStackPanel>
</Border>
</ikw:SimpleStackPanel>
</ikw:SimpleStackPanel> </ikw:SimpleStackPanel>
</Grid>
</ScrollViewer> <!-- 版本选择卡片 -->
<Border Grid.Row="1"
Background="{DynamicResource SettingsPageBackground}"
BorderBrush="{DynamicResource SettingsPageBorderBrush}"
BorderThickness="1"
CornerRadius="12"
Margin="0,0,0,16"
Padding="20">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="8" ShadowDepth="0" Opacity="0.05"/>
</Border.Effect>
<ikw:SimpleStackPanel Spacing="16">
<TextBlock Text="选择版本" FontSize="16" FontWeight="SemiBold"
Foreground="{DynamicResource TextPrimaryBrush}"/>
<ComboBox x:Name="VersionComboBox"
Width="300" Height="40"
DisplayMemberPath="Version"
SelectionChanged="VersionComboBox_SelectionChanged"/>
</ikw:SimpleStackPanel>
</Border>
<!-- 发布说明卡片 -->
<Border Grid.Row="2"
Background="{DynamicResource SettingsPageBackground}"
BorderBrush="{DynamicResource SettingsPageBorderBrush}"
BorderThickness="1"
CornerRadius="12"
Margin="0,0,0,16"
Padding="20">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="8" ShadowDepth="0" Opacity="0.05"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Text="版本更新说明" FontSize="16" FontWeight="SemiBold"
Foreground="{DynamicResource TextPrimaryBrush}"
Margin="0,0,0,16"/>
<Border Grid.Row="1"
Background="{DynamicResource SettingsPageBackground}"
BorderBrush="{DynamicResource SettingsPageBorderBrush}"
BorderThickness="1"
CornerRadius="8">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="4" ShadowDepth="0" Opacity="0.03"/>
</Border.Effect>
<ScrollViewer x:Name="InnerReleaseNotesScrollViewer"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
Padding="16"
PanningMode="VerticalOnly"
PanningRatio="1.0"
IsManipulationEnabled="True">
<mdxam:MarkdownScrollViewer x:Name="ReleaseNotesViewer"
Foreground="{DynamicResource TextPrimaryBrush}"
MarkdownStyleName="GithubLike"
IsHitTestVisible="False"
IsManipulationEnabled="False"/>
</ScrollViewer>
</Border>
</Grid>
</Border>
<!-- 操作按钮区域 -->
<ikw:SimpleStackPanel Grid.Row="3" Spacing="16" Margin="0,0,0,0">
<Button x:Name="RollbackButton"
Content="回滚到此版本"
HorizontalAlignment="Center"
Click="RollbackButton_Click"
Style="{DynamicResource AccentButtonStyle}"
Width="200" Height="48"
FontSize="16" FontWeight="SemiBold"/>
<!-- 下载进度面板 -->
<Border x:Name="DownloadProgressPanel"
Background="{DynamicResource SettingsPageBackground}"
BorderBrush="{DynamicResource SettingsPageBorderBrush}"
BorderThickness="1"
CornerRadius="12"
Visibility="Collapsed"
Margin="0,8,0,0"
Padding="24">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="8" ShadowDepth="0" Opacity="0.05"/>
</Border.Effect>
<ikw:SimpleStackPanel Spacing="12">
<ProgressBar x:Name="DownloadProgressBar"
Width="300" Height="8"
Minimum="0" Maximum="100" Value="0"/>
<TextBlock x:Name="DownloadProgressText"
Text="正在下载..."
FontSize="14"
Foreground="{DynamicResource TextPrimaryBrush}"
HorizontalAlignment="Center"/>
</ikw:SimpleStackPanel>
</Border>
</ikw:SimpleStackPanel>
</Grid>
</Window> </Window>
@@ -35,19 +35,37 @@ namespace Ink_Canvas
InitializeComponent(); InitializeComponent();
this.channel = channel; this.channel = channel;
// 设置窗口置顶
this.Topmost = true;
// 应用当前主题 // 应用当前主题
ApplyCurrentTheme(); ApplyCurrentTheme();
LoadVersions(); // 折叠浮动工具栏
CollapseFloatingBar();
// 添加窗口拖动功能 LoadVersions();
MouseDown += (sender, e) => }
/// <summary>
/// 折叠主窗口的浮动工具栏
/// </summary>
private async void CollapseFloatingBar()
{
try
{ {
if (e.ChangedButton == MouseButton.Left) // 获取主窗口实例
var mainWindow = Application.Current.MainWindow as MainWindow;
if (mainWindow != null)
{ {
DragMove(); // 调用折叠方法
await mainWindow.FoldFloatingBar(null);
} }
}; }
catch (Exception ex)
{
LogHelper.WriteLogToFile($"折叠浮动工具栏时出错: {ex.Message}", LogHelper.LogType.Error);
}
} }
/// <summary> /// <summary>
@@ -223,16 +241,16 @@ namespace Ink_Canvas
Foreground = (Brush)Resources["TextPrimaryBrush"] Foreground = (Brush)Resources["TextPrimaryBrush"]
}; };
var daysComboBox = new ComboBox var daysComboBox = new System.Windows.Controls.ComboBox
{ {
Width = 200, Width = 200,
Height = 36, Height = 36,
HorizontalAlignment = HorizontalAlignment.Left HorizontalAlignment = System.Windows.HorizontalAlignment.Left
}; };
for (int i = 0; i <= 7; i++) for (int i = 0; i <= 7; i++)
{ {
daysComboBox.Items.Add(new ComboBoxItem daysComboBox.Items.Add(new System.Windows.Controls.ComboBoxItem
{ {
Content = $"{i} 天", Content = $"{i} 天",
Tag = i Tag = i
@@ -250,7 +268,7 @@ namespace Ink_Canvas
if (dialogResult == ContentDialogResult.Primary) if (dialogResult == ContentDialogResult.Primary)
{ {
int days = 1; int days = 1;
if (daysComboBox.SelectedItem is ComboBoxItem selectedItemCombo && if (daysComboBox.SelectedItem is System.Windows.Controls.ComboBoxItem selectedItemCombo &&
selectedItemCombo.Tag != null && selectedItemCombo.Tag != null &&
int.TryParse(selectedItemCombo.Tag.ToString(), out int selectedDays)) int.TryParse(selectedItemCombo.Tag.ToString(), out int selectedDays))
{ {
@@ -323,20 +341,14 @@ namespace Ink_Canvas
} }
} }
private void MinimizeButton_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
protected override void OnClosing(CancelEventArgs e) protected override void OnClosing(CancelEventArgs e)
{ {
downloadCts?.Cancel(); downloadCts?.Cancel();
base.OnClosing(e); base.OnClosing(e);
} }
} }
} }
+13 -3
View File
@@ -7,11 +7,17 @@
Title="欢迎使用 InkCanvasForClass" Title="欢迎使用 InkCanvasForClass"
Height="460" Height="460"
Width="780" Width="780"
MinHeight="300"
MinWidth="400"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
ResizeMode="NoResize" ResizeMode="CanResize"
ShowInTaskbar="False" ShowInTaskbar="False"
Background="{DynamicResource SettingsPageBackground}" Background="{DynamicResource SettingsPageBackground}"
Loaded="OobeWindow_OnLoaded"> Loaded="OobeWindow_OnLoaded"
IsManipulationEnabled="True"
TouchDown="Window_TouchDown"
TouchMove="Window_TouchMove"
TouchUp="Window_TouchUp">
<Window.Resources> <Window.Resources>
<Style x:Key="OobeSecondaryButtonStyle" TargetType="Button"> <Style x:Key="OobeSecondaryButtonStyle" TargetType="Button">
@@ -20,6 +26,7 @@
<Setter Property="BorderBrush" Value="{DynamicResource SettingsPageBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource SettingsPageBorderBrush}" />
<Setter Property="BorderThickness" Value="1" /> <Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="6,0" /> <Setter Property="Padding" Value="6,0" />
<Setter Property="IsManipulationEnabled" Value="True" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
@@ -70,7 +77,10 @@
<ScrollViewer Grid.Row="1" <ScrollViewer Grid.Row="1"
Margin="0,24,0,24" Margin="0,24,0,24"
VerticalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"> HorizontalScrollBarVisibility="Disabled"
PanningMode="VerticalOnly"
PanningRatio="1.0"
IsManipulationEnabled="True">
<Border Padding="18" <Border Padding="18"
Background="{DynamicResource SettingsPageBackground}" Background="{DynamicResource SettingsPageBackground}"
CornerRadius="10"> CornerRadius="10">
+33
View File
@@ -474,6 +474,39 @@ namespace Ink_Canvas.Windows
} }
} }
/// <summary>
/// 处理触摸事件,确保窗口能够响应触摸屏操作。
/// </summary>
/// <param name="sender">事件发送者。</param>
/// <param name="e">触摸事件参数。</param>
private void Window_TouchDown(object sender, System.Windows.Input.TouchEventArgs e)
{
// 触摸事件处理逻辑
e.Handled = false;
}
/// <summary>
/// 处理触摸移动事件。
/// </summary>
/// <param name="sender">事件发送者。</param>
/// <param name="e">触摸事件参数。</param>
private void Window_TouchMove(object sender, System.Windows.Input.TouchEventArgs e)
{
// 触摸移动事件处理逻辑
e.Handled = false;
}
/// <summary>
/// 处理触摸抬起事件。
/// </summary>
/// <param name="sender">事件发送者。</param>
/// <param name="e">触摸事件参数。</param>
private void Window_TouchUp(object sender, System.Windows.Input.TouchEventArgs e)
{
// 触摸抬起事件处理逻辑
e.Handled = false;
}
/// <summary> /// <summary>
/// 根据当前步骤索引更新向导界面:显示对应步骤面板,播放切换动画,并刷新步骤指示、标题、子标题和按钮文本/可见性。 /// 根据当前步骤索引更新向导界面:显示对应步骤面板,播放切换动画,并刷新步骤指示、标题、子标题和按钮文本/可见性。
/// </summary> /// </summary>