improve:更新弹窗

This commit is contained in:
2025-09-20 15:25:08 +08:00
parent 1ad6405003
commit 4a0d13457a
3 changed files with 325 additions and 49 deletions
+3 -1
View File
@@ -1,4 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/PencilsConfiguration/ActualSeverity/@EntryValue">WARNING</s:String>
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe</s:String>
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">1114112</s:Int64></wpf:ResourceDictionary>
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">1114112</s:Int64>
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=InkCanvasForClass_002FProperties_002FResources/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>
+280 -44
View File
@@ -7,27 +7,218 @@
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml"
mc:Ignorable="d"
ui:WindowHelper.UseModernWindowStyle = "True"
ui:WindowHelper.UseModernWindowStyle = "False"
ui:WindowHelper.SystemBackdropType="Mica"
ui:TitleBar.Height="36"
Title="InkCanvasForClass CE有新版本可用" Height="600" Width="850" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen">
Title="InkCanvasForClass CE有新版本可用" Height="650" Width="900" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True"
Background="#f8fafc">
<Window.Template>
<ControlTemplate TargetType="Window">
<Border Background="{TemplateBinding Background}"
CornerRadius="16"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="30" ShadowDepth="0" Opacity="0.15"/>
</Border.Effect>
<ContentPresenter/>
</Border>
</ControlTemplate>
</Window.Template>
<Window.Resources>
<!-- 渐变背景定义 -->
<LinearGradientBrush x:Key="HeaderGradient" StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="#667eea" Offset="0"/>
<GradientStop Color="#764ba2" Offset="1"/>
</LinearGradientBrush>
<!-- 现代按钮样式 -->
<Style x:Key="ModernPrimaryButton" TargetType="Button">
<Setter Property="Background" Value="#4f46e5"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="Padding" Value="24,12"/>
<Setter Property="Height" Value="48"/>
<Setter Property="Width" Value="320"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
CornerRadius="12"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}">
<Border.Effect>
<DropShadowEffect Color="#4f46e5" BlurRadius="8" ShadowDepth="0" Opacity="0.3"/>
</Border.Effect>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#4338ca"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#3730a3"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ModernSecondaryButton" TargetType="Button">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="#374151"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="#e5e7eb"/>
<Setter Property="FontWeight" Value="Medium"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="Padding" Value="24,12"/>
<Setter Property="Height" Value="48"/>
<Setter Property="Width" Value="320"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
CornerRadius="12"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#f9fafb"/>
<Setter Property="BorderBrush" Value="#d1d5db"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#f3f4f6"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ModernTertiaryButton" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="#6b7280"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontWeight" Value="Medium"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="Padding" Value="24,12"/>
<Setter Property="Height" Value="48"/>
<Setter Property="Width" Value="320"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
CornerRadius="12"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#f9fafb"/>
<Setter Property="Foreground" Value="#374151"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#f3f4f6"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<Grid Background="#fafafa" Margin="0,0,0,30">
<Grid Margin="0,0,0,30">
<ui:SimpleStackPanel VerticalAlignment="Stretch" Spacing="0">
<!-- 标题栏 -->
<ui:SimpleStackPanel Orientation="Horizontal" Background="#2563eb" Margin="0,0,0,0">
<ui:SimpleStackPanel Orientation="Vertical" Width="735" Margin="24,18,0,12" Spacing="2">
<TextBlock Text="InkCanvasForClass CE新版本来了!" FontSize="24" FontWeight="Bold" Foreground="White" TextAlignment="Left"/>
<TextBlock Text="希望您能喜欢我们的新版本 :-)" FontSize="20" TextAlignment="Left" Foreground="White"/>
<!-- 现代化标题栏 -->
<Border Background="{StaticResource HeaderGradient}" CornerRadius="16,16,0,0" Margin="0,0,0,0"
MouseLeftButtonDown="TitleBar_MouseLeftButtonDown">
<Grid>
<!-- 标题栏内容 -->
<ui:SimpleStackPanel Orientation="Horizontal" Margin="32,24,80,24" Spacing="16">
<Border Background="White" CornerRadius="16" Padding="16" Margin="0,0,0,0">
<Image Source="/Resources/Icons-fluent/party.png" Width="24" Height="24"/>
</Border>
<ui:SimpleStackPanel Orientation="Vertical" Spacing="4">
<TextBlock Text="新版本发布" FontSize="28" FontWeight="Bold" Foreground="White" TextAlignment="Left"/>
<TextBlock Text="InkCanvasForClass CE 为您带来全新体验" FontSize="16" TextAlignment="Left" Foreground="White" Opacity="0.9"/>
</ui:SimpleStackPanel>
<Image Source="/Resources/Icons-fluent/party.png" Width="72" Height="72"/>
</ui:SimpleStackPanel>
<!-- 更新内容 -->
<Border BorderBrush="#3f3f46" Background="White" BorderThickness="1" CornerRadius="4" Margin="24,16,24,0">
<ui:ScrollViewerEx Margin="0" VerticalScrollBarVisibility="Auto" Height="180" PanningMode="VerticalOnly">
<mdxam:MarkdownScrollViewer x:Name="markdownContent" xml:space="preserve" Foreground="Black" MarkdownStyleName="GithubLike">
<!-- 自定义关闭按钮 -->
<Button x:Name="CloseButton"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,12,12,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="16"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}">
<Path Data="M8,8 L16,16 M16,8 L8,16"
Stroke="White"
StrokeThickness="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#33FFFFFF"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#4DFFFFFF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</Border>
<!-- 现代化内容区域 -->
<Border Background="White" CornerRadius="16" Margin="32,24,32,0"
BorderThickness="0" Padding="0">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="20" ShadowDepth="0" Opacity="0.08"/>
</Border.Effect>
<ui:SimpleStackPanel Spacing="0">
<!-- 内容标题 -->
<Border Background="#f8fafc" CornerRadius="16,16,0,0" Padding="24,20,24,16">
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="12">
<Border Background="#4f46e5" CornerRadius="8" Padding="8">
<TextBlock Text="📝" FontSize="16" Foreground="White"/>
</Border>
<ui:SimpleStackPanel Orientation="Vertical" Spacing="2">
<TextBlock Text="更新内容" FontSize="18" FontWeight="SemiBold" Foreground="#1f2937"/>
<TextBlock Text="查看本次更新的详细内容" FontSize="14" Foreground="#6b7280"/>
</ui:SimpleStackPanel>
</ui:SimpleStackPanel>
</Border>
<!-- 内容区域 -->
<ui:ScrollViewerEx Margin="0" VerticalScrollBarVisibility="Auto" Height="200" PanningMode="VerticalOnly">
<mdxam:MarkdownScrollViewer x:Name="markdownContent" xml:space="preserve"
Foreground="#374151" MarkdownStyleName="GithubLike"
Margin="24,16,24,16">
# InkCanvasForClass v5.0.2更新
你好,旅行者们,本次InkCanvasForClass Community Edition更新带来了如下新功能供您探索:
@@ -42,48 +233,93 @@
8. 带来了基于FitToCurve的笔迹平滑,基于贝塞尔曲线平滑,让墨迹线条更加优美好看。
</mdxam:MarkdownScrollViewer>
</ui:ScrollViewerEx>
</ui:SimpleStackPanel>
</Border>
<!-- 版本信息 -->
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="16" Margin="0,16,0,0">
<TextBlock x:Name="updateVersionInfo" Text="本次更新: 4.9.1 -> 5.9.1" FontWeight="Bold" FontSize="15" TextAlignment="Center"/>
<TextBlock x:Name="updateDateInfo" Text="2024年8月4日发布更新" FontSize="15" TextAlignment="Center"/>
<!-- 现代化版本信息 -->
<Border Background="White" CornerRadius="16" Margin="32,16,32,0" Padding="24,20">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="20" ShadowDepth="0" Opacity="0.08"/>
</Border.Effect>
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="24">
<ui:SimpleStackPanel Orientation="Vertical" Spacing="4" HorizontalAlignment="Center">
<TextBlock Text="版本信息" FontSize="14" FontWeight="Medium" Foreground="#6b7280"/>
<TextBlock x:Name="updateVersionInfo" Text="本次更新: 4.9.1 -> 5.9.1"
FontWeight="SemiBold" FontSize="16" Foreground="#1f2937" TextAlignment="Center"/>
</ui:SimpleStackPanel>
<Border Width="1" Background="#e5e7eb" Margin="0,8,0,8"/>
<ui:SimpleStackPanel Orientation="Vertical" Spacing="4" HorizontalAlignment="Center">
<TextBlock Text="发布日期" FontSize="14" FontWeight="Medium" Foreground="#6b7280"/>
<TextBlock x:Name="updateDateInfo" Text="2024年8月4日发布更新"
FontSize="16" Foreground="#1f2937" TextAlignment="Center"/>
</ui:SimpleStackPanel>
</ui:SimpleStackPanel>
</Border>
<!-- 更新按钮组 -->
<Border Background="#f1f5f9" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="4" Margin="24,16,24,20">
<ui:SimpleStackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="14" Margin="0,16,0,16">
<TextBlock Text="请选择更新方式" FontWeight="Bold" FontSize="16" HorizontalAlignment="Center" Margin="0,0,0,6"/>
<!-- 现代化按钮区域 -->
<Border Background="White" CornerRadius="16" Margin="32,16,32,20" Padding="32,24">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="20" ShadowDepth="0" Opacity="0.08"/>
</Border.Effect>
<ui:SimpleStackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="16">
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="12" HorizontalAlignment="Center">
<Border Background="#4f46e5" CornerRadius="8" Padding="8">
<TextBlock Text="⚡" FontSize="16" Foreground="White"/>
</Border>
<TextBlock Text="选择更新方式" FontWeight="SemiBold" FontSize="18"
Foreground="#1f2937" VerticalAlignment="Center"/>
</ui:SimpleStackPanel>
<!-- 立即更新按钮 -->
<Button x:Name="UpdateNowButton" Content="立下载并安装" Foreground="White" FontSize="15" FontWeight="SemiBold"
Padding="20,10" Width="360" Height="48" HorizontalAlignment="Center"
Click="UpdateNowButton_Click" ToolTip="立即下载更新并在完成后安装" Visibility="Visible" IsEnabled="True">
<Button.Resources>
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundKey}" Color="#15803d"/>
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundPointerOverKey}" Color="#15803d"/>
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundPressedKey}" Color="#166534"/>
</Button.Resources>
</Button>
<Button x:Name="UpdateNowButton" Content="立下载并安装"
Style="{StaticResource ModernPrimaryButton}"
Click="UpdateNowButton_Click" ToolTip="立即下载更新并在完成后安装"
Visibility="Visible" IsEnabled="True"/>
<!-- 稍后更新按钮 -->
<Button x:Name="UpdateLaterButton" Content="下载并在软件关闭时安装" Foreground="Black" FontSize="15"
Padding="20,10" Width="360" Height="48" HorizontalAlignment="Center"
Click="UpdateLaterButton_Click" Background="#e2e8f0" BorderBrush="#cbd5e1"
ToolTip="后台下载更新,在软件关闭时自动安装" Visibility="Visible" IsEnabled="True"/>
<Button x:Name="UpdateLaterButton" Content="下载并在软件关闭时安装"
Style="{StaticResource ModernSecondaryButton}"
Click="UpdateLaterButton_Click"
ToolTip="后台下载更新,在软件关闭时自动安装"
Visibility="Visible" IsEnabled="True"/>
<!-- 跳过版本按钮 -->
<Button x:Name="SkipVersionButton" Content="跳过该版本" HorizontalAlignment="Center" Foreground="#71717a"
FontSize="15" Padding="20,10" Width="360" Height="48" Click="SkipVersionButton_Click"
Background="#f8fafc" BorderBrush="#cbd5e1" ToolTip="跳过此版本更新" Visibility="Visible" IsEnabled="True"/>
<Button x:Name="SkipVersionButton" Content="跳过该版本"
Style="{StaticResource ModernTertiaryButton}"
Click="SkipVersionButton_Click"
ToolTip="跳过此版本更新" Visibility="Visible" IsEnabled="True"/>
</ui:SimpleStackPanel>
</Border>
<!-- 下载进度条和状态 -->
<StackPanel x:Name="DownloadProgressPanel" Orientation="Vertical" HorizontalAlignment="Center" Margin="0,10,0,0" Visibility="Collapsed">
<ProgressBar x:Name="DownloadProgressBar" Width="360" Height="18" Minimum="0" Maximum="100" Value="0"/>
<TextBlock x:Name="DownloadProgressText" Text="正在下载..." FontSize="14" Foreground="#2563eb" HorizontalAlignment="Center" Margin="0,6,0,0"/>
</StackPanel>
<!-- 现代化下载进度指示器 -->
<Border x:Name="DownloadProgressPanel" Background="White" CornerRadius="16"
Margin="32,16,32,20" Padding="32,24" Visibility="Collapsed">
<Border.Effect>
<DropShadowEffect Color="#000000" BlurRadius="20" ShadowDepth="0" Opacity="0.08"/>
</Border.Effect>
<ui:SimpleStackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="16">
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="12" HorizontalAlignment="Center">
<Border Background="#10b981" CornerRadius="8" Padding="8">
<TextBlock Text="📥" FontSize="16" Foreground="White"/>
</Border>
<TextBlock Text="正在下载更新" FontWeight="SemiBold" FontSize="18"
Foreground="#1f2937" VerticalAlignment="Center"/>
</ui:SimpleStackPanel>
<!-- 现代化进度条 -->
<Border Background="#f3f4f6" CornerRadius="12" Height="8" Width="400">
<Border x:Name="ProgressFill" Background="#4f46e5" CornerRadius="12"
Width="0" HorizontalAlignment="Left">
<Border.Effect>
<DropShadowEffect Color="#4f46e5" BlurRadius="8" ShadowDepth="0" Opacity="0.4"/>
</Border.Effect>
</Border>
</Border>
<TextBlock x:Name="DownloadProgressText" Text="正在准备下载..."
FontSize="14" Foreground="#6b7280" HorizontalAlignment="Center"/>
</ui:SimpleStackPanel>
</Border>
</ui:SimpleStackPanel>
</Grid>
</ScrollViewer>
+41 -3
View File
@@ -11,6 +11,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
@@ -143,7 +144,13 @@ namespace Ink_Canvas
UpdateLaterButton.IsEnabled = false;
SkipVersionButton.IsEnabled = false;
DownloadProgressPanel.Visibility = Visibility.Visible;
DownloadProgressBar.Value = 0;
// 重置进度条
var progressFill = FindName("ProgressFill") as Border;
if (progressFill != null)
{
progressFill.Width = 0;
}
DownloadProgressText.Text = "正在准备下载...";
// 启动多线路下载
@@ -156,7 +163,12 @@ namespace Ink_Canvas
{
Dispatcher.Invoke(() =>
{
DownloadProgressBar.Value = percent;
// 更新自定义进度条
progressFill = FindName("ProgressFill") as Border;
if (progressFill != null)
{
progressFill.Width = (percent / 100.0) * 400; // 400是进度条总宽度
}
DownloadProgressText.Text = text;
});
});
@@ -174,7 +186,12 @@ namespace Ink_Canvas
if (downloadSuccess)
{
DownloadProgressBar.Value = 100;
// 设置进度条为100%
progressFill = FindName("ProgressFill") as Border;
if (progressFill != null)
{
progressFill.Width = 400; // 100%完成
}
DownloadProgressText.Text = "下载完成,准备安装...";
await Task.Delay(800);
// 设置结果为立即更新
@@ -215,6 +232,27 @@ namespace Ink_Canvas
Close();
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
LogHelper.WriteLogToFile("AutoUpdate | Close button clicked");
// 设置结果为稍后更新(默认行为)
Result = UpdateResult.UpdateLater;
// 关闭窗口
DialogResult = false;
Close();
}
private void TitleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// 开始拖动窗口
if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
}
// 根据屏幕分辨率调整窗口大小