add:软件启动动画
This commit is contained in:
@@ -45,12 +45,36 @@
|
||||
|
||||
<!-- 进度条 -->
|
||||
<ProgressBar x:Name="LoadingProgress"
|
||||
Width="500"
|
||||
Height="8"
|
||||
Width="530"
|
||||
Height="5"
|
||||
Margin="0,-170,0,0"
|
||||
Background="#40000000"
|
||||
Foreground="#0078D4"
|
||||
IsIndeterminate="True" />
|
||||
IsIndeterminate="True">
|
||||
<ProgressBar.Style>
|
||||
<Style TargetType="ProgressBar">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ProgressBar">
|
||||
<Grid>
|
||||
<Border Name="PART_Track"
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="4"/>
|
||||
<Border Name="PART_Indicator"
|
||||
Background="{TemplateBinding Foreground}"
|
||||
CornerRadius="4"
|
||||
HorizontalAlignment="Left">
|
||||
<Border.RenderTransform>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
</Border.RenderTransform>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ProgressBar.Style>
|
||||
</ProgressBar>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Threading;
|
||||
|
||||
@@ -91,8 +92,29 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
LoadingProgress.IsIndeterminate = false;
|
||||
LoadingProgress.Value = progress;
|
||||
if (LoadingProgress.IsIndeterminate)
|
||||
{
|
||||
LoadingProgress.IsIndeterminate = false;
|
||||
LoadingProgress.Value = 0;
|
||||
}
|
||||
|
||||
// 创建平滑过渡动画
|
||||
var animation = new DoubleAnimation
|
||||
{
|
||||
From = LoadingProgress.Value,
|
||||
To = progress,
|
||||
Duration = TimeSpan.FromMilliseconds(800),
|
||||
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
|
||||
};
|
||||
|
||||
// 添加动画完成事件
|
||||
animation.Completed += (s, e) =>
|
||||
{
|
||||
// 确保最终值正确设置
|
||||
LoadingProgress.Value = progress;
|
||||
};
|
||||
|
||||
LoadingProgress.BeginAnimation(ProgressBar.ValueProperty, animation);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user