improve:历史版本回滚窗口
This commit is contained in:
@@ -6,19 +6,320 @@
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml"
|
||||
mc:Ignorable="d"
|
||||
Title="历史版本回滚" Height="600" Width="850" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
|
||||
<Grid Background="#fafafa">
|
||||
<ui:SimpleStackPanel VerticalAlignment="Stretch" Spacing="0">
|
||||
<TextBlock Text="选择历史版本进行回滚" FontSize="24" FontWeight="Bold" Foreground="#2563eb" Margin="24,24,0,12"/>
|
||||
<ComboBox x:Name="VersionComboBox" Width="400" Height="36" Margin="24,0,0,0" DisplayMemberPath="Version" SelectionChanged="VersionComboBox_SelectionChanged"/>
|
||||
<Border BorderBrush="#3f3f46" Background="White" BorderThickness="1" CornerRadius="4" Margin="24,16,24,0" Height="180">
|
||||
<mdxam:MarkdownScrollViewer x:Name="ReleaseNotesViewer" Foreground="Black" MarkdownStyleName="GithubLike"/>
|
||||
ui:WindowHelper.UseModernWindowStyle="False"
|
||||
ui:WindowHelper.SystemBackdropType="Mica"
|
||||
Title="历史版本回滚" Height="650" Width="900" ResizeMode="CanResize"
|
||||
WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True"
|
||||
Background="Transparent" MinHeight="550" MinWidth="800">
|
||||
<Window.Template>
|
||||
<ControlTemplate TargetType="Window">
|
||||
<Border Background="#f8fafc"
|
||||
CornerRadius="16"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="0">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect Color="#000000" BlurRadius="30" ShadowDepth="0" Opacity="0.15"/>
|
||||
</Border.Effect>
|
||||
<Grid>
|
||||
<!-- 标题栏 -->
|
||||
<Border Background="Transparent" Height="40" VerticalAlignment="Top">
|
||||
<Grid>
|
||||
<TextBlock Text="{TemplateBinding Title}"
|
||||
FontSize="16" FontWeight="SemiBold"
|
||||
Foreground="#374151"
|
||||
VerticalAlignment="Center"
|
||||
Margin="20,0,0,0"/>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center">
|
||||
<Button Name="MinimizeButton"
|
||||
Width="40" Height="30"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Click="MinimizeButton_Click"
|
||||
Margin="0,0,2,0">
|
||||
<TextBlock Text="−" FontSize="16" Foreground="#6b7280"/>
|
||||
</Button>
|
||||
<Button Name="CloseButton"
|
||||
Width="40" Height="30"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Click="CloseButton_Click">
|
||||
<TextBlock Text="×" FontSize="16" Foreground="#6b7280"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
<!-- 内容区域 -->
|
||||
<ContentPresenter Margin="0,40,0,0"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Window.Template>
|
||||
<Window.Resources>
|
||||
<!-- 现代化按钮样式 -->
|
||||
<Style x:Key="ModernPrimaryButton" TargetType="Button">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
<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="#3b82f6" 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="#2563eb"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="#1d4ed8"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Background" Value="#9ca3af"/>
|
||||
<Setter Property="Foreground" Value="#6b7280"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 现代化ComboBox样式 -->
|
||||
<Style x:Key="ModernComboBox" TargetType="ComboBox">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Setter Property="Foreground" Value="#374151"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush" Value="#d1d5db"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Height" Value="40"/>
|
||||
<Setter Property="Padding" Value="12,8"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ComboBox">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
CornerRadius="8"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<Grid>
|
||||
<ToggleButton Name="ToggleButton"
|
||||
Grid.Column="2"
|
||||
Focusable="false"
|
||||
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
ClickMode="Press"
|
||||
Background="Transparent"
|
||||
BorderThickness="0">
|
||||
<Grid>
|
||||
<Path Name="Arrow"
|
||||
Fill="#6b7280"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,12,0"
|
||||
Data="M 0 0 L 4 4 L 8 0 Z"/>
|
||||
</Grid>
|
||||
</ToggleButton>
|
||||
<ContentPresenter Name="ContentSite"
|
||||
IsHitTestVisible="False"
|
||||
Content="{TemplateBinding SelectionBoxItem}"
|
||||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
|
||||
Margin="12,8,30,8"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"/>
|
||||
<TextBox Name="PART_EditableTextBox"
|
||||
IsReadOnly="{TemplateBinding IsReadOnly}"
|
||||
Background="{TemplateBinding Background}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
BorderThickness="0"
|
||||
Padding="12,8,30,8"
|
||||
Margin="0"
|
||||
Focusable="True"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"/>
|
||||
<Popup Name="Popup"
|
||||
Placement="Bottom"
|
||||
IsOpen="{TemplateBinding IsDropDownOpen}"
|
||||
AllowsTransparency="True"
|
||||
Focusable="False"
|
||||
PopupAnimation="Slide">
|
||||
<Grid Name="DropDown"
|
||||
SnapsToDevicePixels="True"
|
||||
MinWidth="{TemplateBinding ActualWidth}"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}">
|
||||
<Border Name="DropDownBorder"
|
||||
Background="White"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#d1d5db"
|
||||
CornerRadius="8"
|
||||
Margin="0,4,0,0">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect Color="#000000" BlurRadius="20" ShadowDepth="0" Opacity="0.15"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
<ScrollViewer Margin="4,6,4,6"
|
||||
SnapsToDevicePixels="True">
|
||||
<StackPanel IsItemsHost="True"
|
||||
KeyboardNavigation.DirectionalNavigation="Contained"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Popup>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="DropDownBorder" Property="BorderBrush" Value="#3b82f6"/>
|
||||
<Setter Property="BorderBrush" Value="#3b82f6"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter TargetName="DropDownBorder" Property="BorderBrush" Value="#3b82f6"/>
|
||||
<Setter Property="BorderBrush" Value="#3b82f6"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsDropDownOpen" Value="True">
|
||||
<Setter Property="BorderBrush" Value="#3b82f6"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- ComboBoxItem样式 -->
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Setter Property="Foreground" Value="#374151"/>
|
||||
<Setter Property="Padding" Value="12,8"/>
|
||||
<Setter Property="Margin" Value="0,1"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ComboBoxItem">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
CornerRadius="4"
|
||||
Margin="2">
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#f0f9ff"/>
|
||||
<Setter Property="Foreground" Value="#1e40af"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Background="Transparent">
|
||||
<!-- 主内容区域 -->
|
||||
<Border Background="White" CornerRadius="16" Margin="20"
|
||||
BorderThickness="0" Padding="0">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect Color="#000000" BlurRadius="20" ShadowDepth="0" Opacity="0.08"/>
|
||||
</Border.Effect>
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<ui:SimpleStackPanel VerticalAlignment="Stretch" Spacing="0" Margin="28">
|
||||
<!-- 标题区域 -->
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="12" Margin="0,32,0,24">
|
||||
<Border Background="#3b82f6" CornerRadius="8" Width="40" Height="40"
|
||||
VerticalAlignment="Center">
|
||||
<TextBlock Text="↶" FontSize="20" Foreground="White"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ui:SimpleStackPanel VerticalAlignment="Center" Spacing="4">
|
||||
<TextBlock Text="历史版本回滚" FontSize="28" FontWeight="Bold"
|
||||
Foreground="#1f2937"/>
|
||||
<TextBlock Text="选择要回滚到的历史版本" FontSize="14"
|
||||
Foreground="#6b7280"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</ui:SimpleStackPanel>
|
||||
|
||||
<!-- 版本选择卡片 -->
|
||||
<Border Background="#f8fafc" CornerRadius="12" Padding="20" Margin="0,0,0,20">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect Color="#000000" BlurRadius="8" ShadowDepth="0" Opacity="0.05"/>
|
||||
</Border.Effect>
|
||||
<ui:SimpleStackPanel Spacing="12">
|
||||
<TextBlock Text="选择版本" FontSize="16" FontWeight="SemiBold"
|
||||
Foreground="#374151"/>
|
||||
<ComboBox x:Name="VersionComboBox"
|
||||
Style="{StaticResource ModernComboBox}"
|
||||
Width="400" Height="40"
|
||||
DisplayMemberPath="Version"
|
||||
SelectionChanged="VersionComboBox_SelectionChanged"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 发布说明卡片 -->
|
||||
<Border Background="#f8fafc" CornerRadius="12" Padding="20" Margin="0,0,0,20">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect Color="#000000" BlurRadius="8" ShadowDepth="0" Opacity="0.05"/>
|
||||
</Border.Effect>
|
||||
<ui:SimpleStackPanel Spacing="12">
|
||||
<TextBlock Text="版本更新说明" FontSize="16" FontWeight="SemiBold"
|
||||
Foreground="#374151"/>
|
||||
<Border Background="White" BorderBrush="#e5e7eb" BorderThickness="1"
|
||||
CornerRadius="8" MinHeight="200" MaxHeight="300">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
Padding="16">
|
||||
<mdxam:MarkdownScrollViewer x:Name="ReleaseNotesViewer"
|
||||
Foreground="#374151"
|
||||
MarkdownStyleName="GithubLike"/>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 操作按钮区域 -->
|
||||
<ui:SimpleStackPanel Spacing="16" Margin="0,0,0,32">
|
||||
<Button x:Name="RollbackButton"
|
||||
Content="回滚到此版本"
|
||||
Style="{StaticResource ModernPrimaryButton}"
|
||||
Click="RollbackButton_Click"/>
|
||||
|
||||
<!-- 下载进度面板 -->
|
||||
<StackPanel x:Name="DownloadProgressPanel"
|
||||
Orientation="Vertical"
|
||||
HorizontalAlignment="Center"
|
||||
Visibility="Collapsed"
|
||||
Margin="0,8,0,0">
|
||||
<Border Background="#f0f9ff" BorderBrush="#3b82f6"
|
||||
BorderThickness="1" CornerRadius="8" Padding="16">
|
||||
<ui:SimpleStackPanel Spacing="12">
|
||||
<ProgressBar x:Name="DownloadProgressBar"
|
||||
Width="400" Height="8"
|
||||
Minimum="0" Maximum="100" Value="0"
|
||||
Background="#e0f2fe"
|
||||
Foreground="#3b82f6"/>
|
||||
<TextBlock x:Name="DownloadProgressText"
|
||||
Text="正在下载..."
|
||||
FontSize="14"
|
||||
Foreground="#1e40af"
|
||||
HorizontalAlignment="Center"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
<Button x:Name="RollbackButton" Content="回滚到此版本" Width="360" Height="48" Margin="24,24,0,0" Click="RollbackButton_Click"/>
|
||||
<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>
|
||||
</ui:SimpleStackPanel>
|
||||
</ui:SimpleStackPanel>
|
||||
</ui:SimpleStackPanel>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
</Window>
|
||||
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
|
||||
// Added for OrderByDescending
|
||||
|
||||
@@ -32,6 +33,15 @@ namespace Ink_Canvas
|
||||
InitializeComponent();
|
||||
this.channel = channel;
|
||||
LoadVersions();
|
||||
|
||||
// 添加窗口拖动功能
|
||||
this.MouseDown += (sender, e) =>
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left)
|
||||
{
|
||||
this.DragMove();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private async void LoadVersions()
|
||||
@@ -135,6 +145,16 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
private void MinimizeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.WindowState = WindowState.Minimized;
|
||||
}
|
||||
|
||||
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
downloadCts?.Cancel();
|
||||
|
||||
Reference in New Issue
Block a user