636 lines
32 KiB
XML
636 lines
32 KiB
XML
<ResourceDictionary
|
||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations"
|
||
xmlns:internal="clr-namespace:Melskin.Converters.Internal">
|
||
|
||
<!--#region SlotProgress-->
|
||
<ControlTemplate x:Key="SlotHorizontalProgressTemplate" TargetType="{x:Type ProgressBar}">
|
||
<ControlTemplate.Resources>
|
||
<Storyboard x:Key="ProgressIndeterminateHorizontal" RepeatBehavior="Forever">
|
||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
|
||
<EasingDoubleKeyFrame KeyTime="0" Value="-1" />
|
||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="1" />
|
||
</DoubleAnimationUsingKeyFrames>
|
||
</Storyboard>
|
||
</ControlTemplate.Resources>
|
||
<decorations:SlotBorder
|
||
x:Name="backgroundBorder"
|
||
Padding="2"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
Intensity="0.7">
|
||
<Grid x:Name="BarGrid" HorizontalAlignment="Left">
|
||
<!-- 计算进度条宽度 -->
|
||
<Grid.Width>
|
||
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="7">
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Minimum"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Maximum"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Value"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="ActualWidth"
|
||
RelativeSource="{RelativeSource AncestorType={x:Type decorations:SlotBorder}}" />
|
||
</MultiBinding>
|
||
</Grid.Width>
|
||
<!-- 背景模糊效果 -->
|
||
<Border
|
||
x:Name="borderBlur"
|
||
Background="{TemplateBinding Foreground}"
|
||
CornerRadius="3">
|
||
<Border.Effect>
|
||
<BlurEffect Radius="8" />
|
||
</Border.Effect>
|
||
</Border>
|
||
<!-- 进度条 -->
|
||
<Border
|
||
x:Name="borderProgress"
|
||
Background="{TemplateBinding Foreground}"
|
||
CornerRadius="3" />
|
||
</Grid>
|
||
|
||
</decorations:SlotBorder>
|
||
<ControlTemplate.Triggers>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="IsIndeterminate" Value="True" />
|
||
<Condition Property="IsEnabled" Value="True" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter TargetName="BarGrid" Property="Width" Value="auto" />
|
||
<Setter TargetName="BarGrid" Property="HorizontalAlignment" Value="Stretch" />
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
|
||
<MultiTrigger.EnterActions>
|
||
<BeginStoryboard x:Name="beginIndeterminate" Storyboard="{StaticResource ProgressIndeterminateHorizontal}" />
|
||
</MultiTrigger.EnterActions>
|
||
<MultiTrigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
|
||
</MultiTrigger.ExitActions>
|
||
</MultiTrigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
<!--
|
||
Foreground: 控件的 Foreground 属性。
|
||
(Brush.RelativeTransform): 这个 Foreground 画刷(Brush)的 RelativeTransform 属性。
|
||
(TransformGroup.Children): 这个变换(Transform)的 Children 集合(这隐含地要求 RelativeTransform 必须是一个 TransformGroup)。
|
||
[3]: Children 集合中的第四个元素(索引从0开始)。
|
||
(TranslateTransform.X): 这个元素的 X 属性(这隐含地要求第四个元素必须是一个 TranslateTransform)。
|
||
|
||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,1" x:Key="PrimaryIndeterminateGradientBrush">
|
||
<GradientStop Color="{StaticResource PrimaryNormalColor}" Offset="0" />
|
||
<GradientStop Color="{StaticResource PrimaryVariantColor}" Offset="0.7" />
|
||
<GradientStop Color="{StaticResource PrimaryNormalColor}" Offset="0.8" />
|
||
<LinearGradientBrush.RelativeTransform>
|
||
<TransformGroup>
|
||
<ScaleTransform/>
|
||
<SkewTransform/>
|
||
<RotateTransform/>
|
||
<TranslateTransform/>
|
||
</TransformGroup>
|
||
</LinearGradientBrush.RelativeTransform>
|
||
</LinearGradientBrush>
|
||
-->
|
||
<ControlTemplate x:Key="SlotProgressVerticalTemplate" TargetType="{x:Type ProgressBar}">
|
||
<ControlTemplate.Resources>
|
||
<Storyboard x:Key="ProgressIndeterminateVertical" RepeatBehavior="Forever">
|
||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
|
||
<EasingDoubleKeyFrame KeyTime="0" Value="1" />
|
||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="-1" />
|
||
</DoubleAnimationUsingKeyFrames>
|
||
</Storyboard>
|
||
</ControlTemplate.Resources>
|
||
<decorations:SlotBorder
|
||
x:Name="backgroundBorder"
|
||
Padding="2"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
Intensity="0.7">
|
||
<Grid x:Name="BarGrid" VerticalAlignment="Bottom">
|
||
<!-- 计算进度条宽度 -->
|
||
<Grid.Height>
|
||
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="7">
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Minimum"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Maximum"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Value"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="ActualHeight"
|
||
RelativeSource="{RelativeSource AncestorType={x:Type decorations:SlotBorder}}" />
|
||
</MultiBinding>
|
||
</Grid.Height>
|
||
<!-- 背景模糊效果 -->
|
||
<Border Background="{TemplateBinding Foreground}" CornerRadius="3">
|
||
<Border.Effect>
|
||
<BlurEffect Radius="8" />
|
||
</Border.Effect>
|
||
</Border>
|
||
<!-- 进度条 -->
|
||
<Border Background="{TemplateBinding Foreground}" CornerRadius="3" />
|
||
</Grid>
|
||
</decorations:SlotBorder>
|
||
<ControlTemplate.Triggers>
|
||
<!--<Trigger Property="IsIndeterminate" Value="True">
|
||
<Setter TargetName="BarGrid" Property="Height" Value="auto" />
|
||
<Setter TargetName="BarGrid" Property="VerticalAlignment" Value="Stretch" />
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
|
||
<Trigger.EnterActions>
|
||
<BeginStoryboard x:Name="beginIndeterminate" Storyboard="{StaticResource ProgressIndeterminateVertical}" />
|
||
</Trigger.EnterActions>
|
||
<Trigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
|
||
</Trigger.ExitActions>
|
||
</Trigger>-->
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="IsIndeterminate" Value="True" />
|
||
<Condition Property="IsEnabled" Value="True" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter TargetName="BarGrid" Property="Height" Value="auto" />
|
||
<Setter TargetName="BarGrid" Property="VerticalAlignment" Value="Stretch" />
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
|
||
<MultiTrigger.EnterActions>
|
||
<BeginStoryboard x:Name="beginIndeterminate" Storyboard="{StaticResource ProgressIndeterminateVertical}" />
|
||
</MultiTrigger.EnterActions>
|
||
<MultiTrigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
|
||
</MultiTrigger.ExitActions>
|
||
</MultiTrigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
|
||
<Style x:Key="SlotProgressBarStyle" TargetType="{x:Type ProgressBar}">
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||
<Setter Property="BorderBrush" Value="Transparent" />
|
||
<Setter Property="Height" Value="20" />
|
||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||
<Setter Property="BorderThickness" Value="1" />
|
||
<Setter Property="Template" Value="{StaticResource SlotHorizontalProgressTemplate}" />
|
||
<Style.Triggers>
|
||
<Trigger Property="IsEnabled" Value="false">
|
||
<Setter Property="IsIndeterminate" Value="False" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="Orientation" Value="Vertical">
|
||
<Setter Property="Template" Value="{StaticResource SlotProgressVerticalTemplate}" />
|
||
<Setter Property="Width" Value="20" />
|
||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||
</Trigger>
|
||
</Style.Triggers>
|
||
</Style>
|
||
<!--#endregion-->
|
||
|
||
<!--<ControlTemplate x:Key="HorizontalProgressTemplate" TargetType="{x:Type ProgressBar}">
|
||
<ControlTemplate.Resources>
|
||
<Storyboard x:Key="ProgressIndeterminateHorizontal" RepeatBehavior="Forever">
|
||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
|
||
<EasingDoubleKeyFrame KeyTime="0" Value="-1" />
|
||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="1" />
|
||
</DoubleAnimationUsingKeyFrames>
|
||
</Storyboard>
|
||
</ControlTemplate.Resources>
|
||
|
||
<Border
|
||
x:Name="backgroundBorder"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="4">
|
||
|
||
-->
|
||
<!-- 核心改变:命名为 PART_Track,WPF 原生接管容器 -->
|
||
<!--
|
||
<Grid x:Name="PART_Track">
|
||
-->
|
||
<!-- 正常状态进度条:命名为 PART_Indicator,不绑Width,WPF自动算比例! -->
|
||
<!--
|
||
<Border
|
||
x:Name="PART_Indicator"
|
||
HorizontalAlignment="Left"
|
||
Background="{TemplateBinding Foreground}"
|
||
CornerRadius="3" />
|
||
|
||
-->
|
||
<!-- Indeterminate 动画层:默认隐藏,充满整个宽度 -->
|
||
<!--
|
||
<Border
|
||
x:Name="IndeterminateLayer"
|
||
HorizontalAlignment="Stretch"
|
||
Background="{TemplateBinding Foreground}"
|
||
CornerRadius="3"
|
||
Visibility="Collapsed" />
|
||
</Grid>
|
||
</Border>
|
||
|
||
<ControlTemplate.Triggers>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="IsIndeterminate" Value="True" />
|
||
<Condition Property="IsEnabled" Value="True" />
|
||
</MultiTrigger.Conditions>
|
||
-->
|
||
<!-- 进入不确定状态时,隐藏原进度条,显示充满的动画层 -->
|
||
<!--
|
||
<Setter TargetName="PART_Indicator" Property="Visibility" Value="Collapsed" />
|
||
<Setter TargetName="IndeterminateLayer" Property="Visibility" Value="Visible" />
|
||
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
|
||
<MultiTrigger.EnterActions>
|
||
<BeginStoryboard x:Name="beginIndeterminate" Storyboard="{StaticResource ProgressIndeterminateHorizontal}" />
|
||
</MultiTrigger.EnterActions>
|
||
<MultiTrigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
|
||
</MultiTrigger.ExitActions>
|
||
</MultiTrigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>-->
|
||
<!--<ControlTemplate x:Key="ProgressVerticalTemplate" TargetType="{x:Type ProgressBar}">
|
||
<ControlTemplate.Resources>
|
||
<Storyboard x:Key="ProgressIndeterminateVertical" RepeatBehavior="Forever">
|
||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
|
||
<EasingDoubleKeyFrame KeyTime="0" Value="1" />
|
||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="-1" />
|
||
</DoubleAnimationUsingKeyFrames>
|
||
</Storyboard>
|
||
</ControlTemplate.Resources>
|
||
<Border
|
||
x:Name="backgroundBorder"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="4">
|
||
<Grid x:Name="BarGrid" VerticalAlignment="Bottom">-->
|
||
<!-- 计算进度条宽度 -->
|
||
<!--
|
||
<Grid.Height>
|
||
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="1">
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Minimum"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Maximum"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Value"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="ActualHeight"
|
||
RelativeSource="{RelativeSource AncestorType={x:Type Border}}" />
|
||
</MultiBinding>
|
||
</Grid.Height>-->
|
||
<!-- 进度条 -->
|
||
<!--
|
||
<Border Background="{TemplateBinding Foreground}" CornerRadius="3" />
|
||
</Grid>
|
||
</Border>
|
||
<ControlTemplate.Triggers>
|
||
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="IsIndeterminate" Value="True" />
|
||
<Condition Property="IsEnabled" Value="True" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter TargetName="BarGrid" Property="Height" Value="auto" />
|
||
<Setter TargetName="BarGrid" Property="VerticalAlignment" Value="Stretch" />
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
|
||
<MultiTrigger.EnterActions>
|
||
<BeginStoryboard x:Name="beginIndeterminate" Storyboard="{StaticResource ProgressIndeterminateVertical}" />
|
||
</MultiTrigger.EnterActions>
|
||
<MultiTrigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
|
||
</MultiTrigger.ExitActions>
|
||
</MultiTrigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>-->
|
||
|
||
<!--<ControlTemplate x:Key="ProgressVerticalTemplate" TargetType="{x:Type ProgressBar}">
|
||
<ControlTemplate.Resources>
|
||
<Storyboard x:Key="ProgressIndeterminateVertical" RepeatBehavior="Forever">
|
||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
|
||
<EasingDoubleKeyFrame KeyTime="0" Value="1" />
|
||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="-1" />
|
||
</DoubleAnimationUsingKeyFrames>
|
||
</Storyboard>
|
||
</ControlTemplate.Resources>
|
||
<Border
|
||
x:Name="backgroundBorder"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="4">
|
||
<Grid x:Name="BarGrid" VerticalAlignment="Bottom">-->
|
||
<!-- 计算进度条宽度 -->
|
||
<!--
|
||
<Grid.Height>
|
||
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="1">
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Minimum"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Maximum"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Value"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="ActualHeight"
|
||
RelativeSource="{RelativeSource AncestorType={x:Type Border}}" />
|
||
</MultiBinding>
|
||
</Grid.Height>-->
|
||
<!-- 进度条 -->
|
||
<!--
|
||
<Border Background="{TemplateBinding Foreground}" CornerRadius="3" />
|
||
</Grid>
|
||
</Border>
|
||
<ControlTemplate.Triggers>
|
||
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="IsIndeterminate" Value="True" />
|
||
<Condition Property="IsEnabled" Value="True" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter TargetName="BarGrid" Property="Height" Value="auto" />
|
||
<Setter TargetName="BarGrid" Property="VerticalAlignment" Value="Stretch" />
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
|
||
<MultiTrigger.EnterActions>
|
||
<BeginStoryboard x:Name="beginIndeterminate" Storyboard="{StaticResource ProgressIndeterminateVertical}" />
|
||
</MultiTrigger.EnterActions>
|
||
<MultiTrigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
|
||
</MultiTrigger.ExitActions>
|
||
</MultiTrigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>-->
|
||
|
||
<ControlTemplate x:Key="HorizontalProgressTemplate" TargetType="{x:Type ProgressBar}">
|
||
<ControlTemplate.Resources>
|
||
<Storyboard x:Key="ProgressIndeterminateHorizontal" RepeatBehavior="Forever">
|
||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
|
||
<EasingDoubleKeyFrame KeyTime="0" Value="-1" />
|
||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="1" />
|
||
</DoubleAnimationUsingKeyFrames>
|
||
</Storyboard>
|
||
</ControlTemplate.Resources>
|
||
|
||
<Border
|
||
x:Name="backgroundBorder"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="4">
|
||
|
||
<!-- 核心改变:命名为 PART_Track,WPF 原生接管容器 -->
|
||
<Grid x:Name="PART_Track">
|
||
<!-- 正常状态进度条:命名为 PART_Indicator,不绑Width,WPF自动算比例! -->
|
||
<Border
|
||
x:Name="PART_Indicator"
|
||
HorizontalAlignment="Left"
|
||
Background="{TemplateBinding Foreground}"
|
||
CornerRadius="3" />
|
||
|
||
<!-- Indeterminate 动画层:默认隐藏,充满整个宽度 -->
|
||
<Border
|
||
x:Name="IndeterminateLayer"
|
||
HorizontalAlignment="Stretch"
|
||
Background="{TemplateBinding Foreground}"
|
||
CornerRadius="3"
|
||
Visibility="Collapsed" />
|
||
</Grid>
|
||
</Border>
|
||
|
||
<ControlTemplate.Triggers>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="IsIndeterminate" Value="True" />
|
||
<Condition Property="IsEnabled" Value="True" />
|
||
</MultiTrigger.Conditions>
|
||
<!-- 进入不确定状态时,隐藏原进度条,显示充满的动画层 -->
|
||
<Setter TargetName="PART_Indicator" Property="Visibility" Value="Collapsed" />
|
||
<Setter TargetName="IndeterminateLayer" Property="Visibility" Value="Visible" />
|
||
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
|
||
<MultiTrigger.EnterActions>
|
||
<BeginStoryboard x:Name="beginIndeterminate" Storyboard="{StaticResource ProgressIndeterminateHorizontal}" />
|
||
</MultiTrigger.EnterActions>
|
||
<MultiTrigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
|
||
</MultiTrigger.ExitActions>
|
||
</MultiTrigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
|
||
|
||
<ControlTemplate x:Key="ProgressVerticalTemplate" TargetType="{x:Type ProgressBar}">
|
||
<ControlTemplate.Resources>
|
||
<Storyboard x:Key="ProgressIndeterminateVertical" RepeatBehavior="Forever">
|
||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
|
||
<EasingDoubleKeyFrame KeyTime="0" Value="1" />
|
||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="-1" />
|
||
</DoubleAnimationUsingKeyFrames>
|
||
</Storyboard>
|
||
</ControlTemplate.Resources>
|
||
|
||
<Border
|
||
x:Name="backgroundBorder"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="4">
|
||
|
||
<!-- 这里不再使用 PART_Track 命名,避免WPF原生逻辑干预 -->
|
||
<Grid x:Name="BarGrid">
|
||
|
||
<!-- 正常状态进度条:靠底对齐,通过 Converter 计算高度 -->
|
||
<Border
|
||
x:Name="borderProgress"
|
||
VerticalAlignment="Bottom"
|
||
Background="{TemplateBinding Foreground}"
|
||
CornerRadius="3">
|
||
<Border.Height>
|
||
<!-- 将 ConverterParameter 改为 0,保证 100% 时完美充满 -->
|
||
<MultiBinding Converter="{x:Static internal:ValueToRangeWidthConverter.Instance}" ConverterParameter="0">
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Minimum"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Maximum"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
Mode="OneWay"
|
||
Path="Value"
|
||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding
|
||
ElementName="BarGrid"
|
||
Mode="OneWay"
|
||
Path="ActualHeight" />
|
||
</MultiBinding>
|
||
</Border.Height>
|
||
</Border>
|
||
|
||
<!-- Indeterminate 动画层:默认隐藏,充满整个高度 -->
|
||
<Border
|
||
x:Name="IndeterminateLayer"
|
||
VerticalAlignment="Stretch"
|
||
Background="{TemplateBinding Foreground}"
|
||
CornerRadius="3"
|
||
Visibility="Collapsed" />
|
||
</Grid>
|
||
</Border>
|
||
|
||
<ControlTemplate.Triggers>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="IsIndeterminate" Value="True" />
|
||
<Condition Property="IsEnabled" Value="True" />
|
||
</MultiTrigger.Conditions>
|
||
<!-- 切换状态时控制 Visibility 隐藏计算好的进度条,显示充满的动画层 -->
|
||
<Setter TargetName="borderProgress" Property="Visibility" Value="Collapsed" />
|
||
<Setter TargetName="IndeterminateLayer" Property="Visibility" Value="Visible" />
|
||
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
|
||
<MultiTrigger.EnterActions>
|
||
<BeginStoryboard x:Name="beginIndeterminate" Storyboard="{StaticResource ProgressIndeterminateVertical}" />
|
||
</MultiTrigger.EnterActions>
|
||
<MultiTrigger.ExitActions>
|
||
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
|
||
</MultiTrigger.ExitActions>
|
||
</MultiTrigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
<Style x:Key="CircularProgressBarStyle" TargetType="ProgressBar">
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||
<Setter Property="Width" Value="100" />
|
||
<Setter Property="Height" Value="100" />
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="ProgressBar">
|
||
<Viewbox>
|
||
<Grid Width="100" Height="100">
|
||
<!-- 底色轨道 -->
|
||
<Ellipse
|
||
Width="100"
|
||
Height="100"
|
||
HorizontalAlignment="Center"
|
||
VerticalAlignment="Center"
|
||
Stroke="{TemplateBinding Background}"
|
||
StrokeThickness="10" />
|
||
|
||
<!-- 进度层 -->
|
||
<Path
|
||
x:Name="ProgressPath"
|
||
RenderTransformOrigin="0.5,0.5"
|
||
Stretch="None"
|
||
Stroke="{TemplateBinding Foreground}"
|
||
StrokeEndLineCap="Round"
|
||
StrokeStartLineCap="Round"
|
||
StrokeThickness="10">
|
||
<Path.RenderTransform>
|
||
<RotateTransform x:Name="RotateTransform" Angle="0" />
|
||
</Path.RenderTransform>
|
||
<Path.Data>
|
||
<MultiBinding Converter="{x:Static internal:ProgressToAngleConverter.Instance}">
|
||
<Binding Path="Value" RelativeSource="{RelativeSource TemplatedParent}" />
|
||
<Binding Path="Maximum" RelativeSource="{RelativeSource TemplatedParent}" />
|
||
</MultiBinding>
|
||
</Path.Data>
|
||
</Path>
|
||
|
||
<!-- 文字显示(仅在非不确定模式下显示) -->
|
||
<TextBlock
|
||
x:Name="ValueText"
|
||
HorizontalAlignment="Center"
|
||
VerticalAlignment="Center"
|
||
FontSize="20"
|
||
FontWeight="Bold"
|
||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat={}{0:0}%}" />
|
||
</Grid>
|
||
</Viewbox>
|
||
|
||
<ControlTemplate.Triggers>
|
||
<!-- 不确定进度状态(转圈圈) -->
|
||
<Trigger Property="IsIndeterminate" Value="True">
|
||
<!-- 1. 隐藏文字 -->
|
||
<Setter TargetName="ValueText" Property="Visibility" Value="Collapsed" />
|
||
<!-- 2. 给 Path 一个固定的弧线数据 (大约 25% 长度) -->
|
||
<!-- M 50,5 代表起点;A 45,45... 代表半径45的圆弧到 95,50 -->
|
||
<Setter TargetName="ProgressPath" Property="Data" Value="M 50,5 A 45,45 0 0 1 95,50" />
|
||
<!-- 3. 执行旋转动画 -->
|
||
<Trigger.EnterActions>
|
||
<BeginStoryboard Name="SpinAnimation">
|
||
<Storyboard>
|
||
<DoubleAnimation
|
||
RepeatBehavior="Forever"
|
||
Storyboard.TargetName="ProgressPath"
|
||
Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
|
||
From="0"
|
||
To="360"
|
||
Duration="0:0:1" />
|
||
</Storyboard>
|
||
</BeginStoryboard>
|
||
</Trigger.EnterActions>
|
||
<Trigger.ExitActions>
|
||
<StopStoryboard BeginStoryboardName="SpinAnimation" />
|
||
</Trigger.ExitActions>
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Style>
|
||
|
||
<Style TargetType="{x:Type ProgressBar}">
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||
<Setter Property="BorderBrush" Value="Transparent" />
|
||
<Setter Property="Height" Value="8" />
|
||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||
<Setter Property="BorderThickness" Value="1" />
|
||
<Setter Property="Template" Value="{StaticResource HorizontalProgressTemplate}" />
|
||
<Style.Triggers>
|
||
<Trigger Property="IsEnabled" Value="false">
|
||
<Setter Property="IsIndeterminate" Value="False" />
|
||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
|
||
</Trigger>
|
||
<Trigger Property="Orientation" Value="Vertical">
|
||
<Setter Property="Template" Value="{StaticResource ProgressVerticalTemplate}" />
|
||
<Setter Property="Width" Value="8" />
|
||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||
</Trigger>
|
||
</Style.Triggers>
|
||
</Style>
|
||
|
||
</ResourceDictionary> |