兼容win7版应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

273 lines
14 KiB

<Window x:Class="AIK.Views.MenuPages.CommonPage.ProgressDialogWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:AIK.Views.MenuPages.CommonPage"
xmlns:convert="clr-namespace:AIK.Views.Converters"
mc:Ignorable="d"
Title="处理窗口" Height="400" Width="600"
WindowStartupLocation="CenterScreen"
ShowInTaskbar="False"
ResizeMode="NoResize"
Background="White"
WindowStyle="None">
<Window.Resources>
<!-- 关闭按钮样式 -->
<Style x:Key="CloseButtonStyle" TargetType="Button">
<Setter Property="Width" Value="32"/>
<Setter Property="Height" Value="32"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="#999999"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border"
Width="32" Height="32" CornerRadius="16"
Background="{TemplateBinding Background}"
HorizontalAlignment="Center" VerticalAlignment="Center">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#E0E0E0"/>
<Setter Property="Foreground" Value="#333333"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="border" Property="Background" Value="#D32F2F"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<Style x:Key="ConfirmButtonStyle" TargetType="Button">
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="40"/>
<Setter Property="Background" Value="#4CAF50"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border"
Background="{TemplateBinding Background}"
CornerRadius="20">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#43A047"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="border" Property="Background" Value="#388E3C"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="border" Property="Opacity" Value="0.6"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 进度值转发光条可见性转换器 -->
<convert:ProgressToGlowVisibilityConverter x:Key="ProgressToGlowVisibilityConverter"/>
<!-- 完整的进度条样式(核心) -->
<Style x:Key="CustomProgressBarStyle" TargetType="ProgressBar">
<Setter Property="Background" Value="#F0F0F0"/>
<Setter Property="BorderBrush" Value="#CCCCCC"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Height" Value="8"/>
<Setter Property="Maximum" Value="100"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ProgressBar">
<Grid>
<!-- 进度条背景容器 -->
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"/>
<Rectangle x:Name="PART_Track"/>
<!-- 进度条主体(带发光效果) -->
<Decorator x:Name="PART_Indicator" HorizontalAlignment="Left">
<Grid x:Name="Foreground">
<!-- 主进度条底色 -->
<Rectangle x:Name="Indicator"
Fill="#4CAF50"
RadiusX="4"
RadiusY="4"/>
<!-- 伪发光条容器(ClipToBounds防止溢出) -->
<Grid x:Name="Animation" ClipToBounds="True">
<!-- 动态发光条(核心:进度<100显示,100%隐藏) -->
<Rectangle x:Name="PART_GlowRect"
Width="40"
Opacity="0.7"
RadiusX="2"
RadiusY="2"
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=Value,
Converter={StaticResource ProgressToGlowVisibilityConverter}}">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="Transparent" Offset="0"/>
<GradientStop Color="White" Offset="0.5"/>
<GradientStop Color="Transparent" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
<!-- 发光条滚动动画(模拟加载效果) -->
<Rectangle.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.TargetProperty="(Canvas.Left)"
From="0"
To="100"
Duration="0:0:1.5"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
</Grid>
</Grid>
</Decorator>
</Grid>
<!-- 触发器:处理Indeterminate状态(隐藏发光条) -->
<ControlTemplate.Triggers>
<Trigger Property="IsIndeterminate" Value="True">
<Setter TargetName="PART_GlowRect" Property="Visibility" Value="Collapsed"/>
<Setter TargetName="Indicator" Property="Fill">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="#4CAF50" Offset="0"/>
<GradientStop Color="#81C784" Offset="0.5"/>
<GradientStop Color="#4CAF50" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<!-- 主容器:带阴影的圆角卡片 -->
<Border Background="White"
CornerRadius="20"
BorderThickness="1"
BorderBrush="#E0E0E0"
Margin="15">
<Border.Effect>
<DropShadowEffect BlurRadius="16" ShadowDepth="4" Direction="270" Opacity="0.2" Color="#000000"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<!-- Header -->
<RowDefinition Height="*"/>
<!-- Content (可伸缩) -->
<RowDefinition Height="Auto"/>
<!-- Footer -->
</Grid.RowDefinitions>
<!-- 🔷 顶部标题栏:白色背景 -->
<Border Grid.Row="0"
Background="White"
Padding="20,15"
CornerRadius="20,20,0,0">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Image Source="pack://application:,,,/AIK.Assets;component/Images/AIK.png" Width="200" Height="45"></Image>
</StackPanel>
</Border>
<!-- 🟨 中间内容区:浅灰色背景 -->
<Border Grid.Row="1" Background="#FAFAFA" Padding="20">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<!-- TextBlock -->
<RowDefinition Height="Auto"/>
<!-- ProgressBar -->
</Grid.RowDefinitions>
<!-- 消息文本 -->
<TextBlock Text="{Binding Message}"
Grid.Row="0"
FontSize="18"
FontWeight="Medium"
Foreground="#1A1A1A"
TextWrapping="Wrap"
TextAlignment="Center"
Margin="0,0,0,24"
LineHeight="24"
MaxWidth="480">
<TextBlock.Effect>
<!-- 轻微内阴影提升立体感(可选) -->
<DropShadowEffect Color="#000000" Opacity="0.05" BlurRadius="4" ShadowDepth="0"/>
</TextBlock.Effect>
</TextBlock>
<ProgressBar Grid.Row="1"
Style="{StaticResource CustomProgressBarStyle}"
Value="{Binding Progress, Mode=OneWay, FallbackValue=0}"
IsIndeterminate="{Binding IsIndeterminate}"
Margin="0,0,0,20"/>
<TextBlock Grid.Row="1"
Text="{Binding Progress, StringFormat={}{0:F2}%}"
FontSize="14"
FontWeight="SemiBold"
Foreground="#666666"
HorizontalAlignment="Center"
VerticalAlignment="Top" Margin="0,10,0,0"/>
<TextBlock Grid.Row="1"
Text="{Binding TimeTotalText}"
FontSize="14"
FontWeight="SemiBold"
Foreground="#666666"
HorizontalAlignment="Right"
VerticalAlignment="Top" Margin="0,10,0,0"/>
</Grid>
</Border>
<!-- ⬜ 底部区域:白色背景(当前留空,可加“取消”按钮等) -->
<Border Grid.Row="2"
Background="White"
Padding="20"
CornerRadius="0,0,20,20">
<Button Content="{DynamicResource ConfirmButton}"
Style="{StaticResource ConfirmButtonStyle}"
Click="ConfirmButton_Click"
Visibility="{Binding IsCompleted, Converter={StaticResource BooleanToVisibilityConverter}}"
HorizontalAlignment="Center"/>
</Border>
</Grid>
</Border>
<!-- 关闭按钮:置于卡片右上角 -->
<Button Content="×"
Style="{StaticResource CloseButtonStyle}"
Click="CloseButton_Click"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,15,15,0"/>
</Grid>
</Window>