Files
ShrlAlgoToolkit/AntDesignWPF/Styles/ProgressBar.xaml

255 lines
18 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:converters="clr-namespace:AntDesign.WPF.Converters"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<sys:Double x:Key="ProgressContentMinWidth">63.0</sys:Double>
<SolidColorBrush Color="#FF06B025" x:Key="ProgressBar.Progress" />
<SolidColorBrush Color="#FFE6E6E6" x:Key="ProgressBar.Background" />
<SolidColorBrush Color="#FFBCBCBC" x:Key="ProgressBar.Border" />
<Style TargetType="{x:Type ProgressBar}">
<Setter Property="Background" Value="{DynamicResource BorderBrushSecondary}" />
<Setter Property="BorderBrush" Value="{StaticResource ProgressBar.Border}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ProgressBar}">
<Grid x:Name="TemplateRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Border BorderThickness="{TemplateBinding BorderThickness}" />
<Rectangle
Fill="{TemplateBinding Background}"
Height="8"
RadiusX="{Binding RelativeSource={RelativeSource Mode=Self}, Path=ActualHeight, Converter={converters:MathConverter Operation=Divide}, ConverterParameter=2}"
RadiusY="{Binding RelativeSource={RelativeSource Mode=Self}, Path=ActualHeight, Converter={converters:MathConverter Operation=Divide}, ConverterParameter=2}"
x:Name="PART_Track" />
<Border
ClipToBounds="True"
CornerRadius="{Binding Height, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={converters:DoubleToCornerRadiusConverter}, ConverterParameter=2}"
Height="8"
VerticalAlignment="Center">
<Grid
ClipToBounds="true"
HorizontalAlignment="Left"
x:Name="PART_Indicator">
<Rectangle
Fill="{TemplateBinding Foreground}"
RadiusX="{Binding ElementName=PART_Track, Path=RadiusX}"
RadiusY="{Binding ElementName=PART_Track, Path=RadiusY}"
x:Name="Indicator" />
<Rectangle
Fill="{TemplateBinding Foreground}"
RadiusX="{Binding ElementName=PART_Track, Path=RadiusX}"
RadiusY="{Binding ElementName=PART_Track, Path=RadiusY}"
RenderTransformOrigin="0.5,0.5"
x:Name="Animation">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
</Border>
<TextBlock
Foreground="{DynamicResource InputForeground}"
Grid.Column="1"
Margin="4,-2,0,0"
Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Value, StringFormat='\{0:F0}%'}"
VerticalAlignment="Center"
x:Name="ValueContent" />
<Grid
Grid.Column="1"
Height="14"
Margin="4,0"
Name="pathDone"
VerticalAlignment="Center"
Visibility="Collapsed"
Width="14">
<Ellipse
Fill="{DynamicResource SuccessBrush}"
Height="14"
Width="14" />
<Path
Data="M16.3819 8.27342H15.2827C15.0436 8.27342 14.8163 8.38827 14.6757 8.58514L10.9913 13.6945L9.32252 11.3789C9.18189 11.1844 8.95689 11.0672 8.71549 11.0672H7.61626C7.46392 11.0672 7.37486 11.2406 7.46392 11.3648L10.3842 15.4148C10.4532 15.5111 10.5442 15.5896 10.6495 15.6437C10.7549 15.6978 10.8717 15.7261 10.9901 15.7261C11.1086 15.7261 11.2253 15.6978 11.3307 15.6437C11.436 15.5896 11.527 15.5111 11.596 15.4148L16.5319 8.57108C16.6233 8.44686 16.5343 8.27342 16.3819 8.27342Z"
Fill="White"
Height="6"
Stretch="Uniform"
StrokeThickness="30" />
</Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Determinate" />
<VisualState x:Name="Indeterminate">
<Storyboard RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Animation" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<EasingDoubleKeyFrame KeyTime="0" Value="0.25" />
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.25" />
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="0.25" />
</DoubleAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames Storyboard.TargetName="Animation" Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)">
<EasingPointKeyFrame KeyTime="0" Value="-0.5,0.5" />
<EasingPointKeyFrame KeyTime="0:0:1" Value="0.5,0.5" />
<EasingPointKeyFrame KeyTime="0:0:2" Value="1.5,0.5" />
</PointAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="LayoutTransform" TargetName="TemplateRoot">
<Setter.Value>
<RotateTransform Angle="-90" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsIndeterminate" Value="true">
<Setter Property="Visibility" TargetName="Indicator" Value="Collapsed" />
<Setter Property="Visibility" TargetName="ValueContent" Value="Collapsed" />
</Trigger>
<Trigger Property="Value" Value="100">
<Setter Property="Foreground" Value="{DynamicResource SuccessBrush}" />
<Setter Property="Visibility" TargetName="ValueContent" Value="Collapsed" />
<Setter Property="Visibility" TargetName="pathDone" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="ProgressBar" x:Key="Ant.CircularProgressBar">
<Setter Property="BorderThickness" Value="4" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ProgressBar}">
<Grid Height="{TemplateBinding Width}" Width="{TemplateBinding Width}">
<Grid Margin="2" x:Name="PathGrid" />
<Canvas>
<!-- 值0的时候 -->
<Path
Canvas.Left="2"
Canvas.Top="2"
Stroke="{DynamicResource BorderBrushSecondary}"
StrokeThickness="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=BorderThickness.Left}">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={converters:StartPointConverter}, Mode=OneWay}">
<ArcSegment Size="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={converters:ArcSizeConverter}, Mode=OneWay}" SweepDirection="Clockwise">
<ArcSegment.Point>
<MultiBinding Converter="{converters:ArcEndPointConverter}" ConverterParameter="{x:Static converters:ArcEndPointConverter.ParameterMidPoint}">
<Binding ElementName="PathGrid" Path="ActualWidth" />
<Binding Path="Maximum" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="Minimum" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="Maximum" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</ArcSegment.Point>
</ArcSegment>
<ArcSegment Size="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={converters:ArcSizeConverter}, Mode=OneWay}" SweepDirection="Clockwise">
<ArcSegment.Point>
<MultiBinding Converter="{converters:ArcEndPointConverter}">
<Binding ElementName="PathGrid" Path="ActualWidth" />
<Binding Path="Maximum" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="Minimum" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="Maximum" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</ArcSegment.Point>
</ArcSegment>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
<Path
Canvas.Left="2"
Canvas.Top="2"
Stroke="{TemplateBinding Foreground}"
StrokeEndLineCap="Round"
StrokeLineJoin="Round"
StrokeStartLineCap="Round"
StrokeThickness="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=BorderThickness.Left}"
x:Name="Path">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={converters:StartPointConverter}, Mode=OneWay}">
<ArcSegment Size="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={converters:ArcSizeConverter}, Mode=OneWay}" SweepDirection="Clockwise">
<ArcSegment.Point>
<MultiBinding Converter="{converters:ArcEndPointConverter}" ConverterParameter="{x:Static converters:ArcEndPointConverter.ParameterMidPoint}">
<Binding ElementName="PathGrid" Path="ActualWidth" />
<Binding Path="Value" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="Minimum" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="Maximum" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</ArcSegment.Point>
</ArcSegment>
<ArcSegment Size="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={converters:ArcSizeConverter}, Mode=OneWay}" SweepDirection="Clockwise">
<ArcSegment.Point>
<MultiBinding Converter="{converters:ArcEndPointConverter}">
<Binding ElementName="PathGrid" Path="ActualWidth" />
<Binding Path="Value" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="Minimum" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="Maximum" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</ArcSegment.Point>
</ArcSegment>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>
<TextBlock
FontSize="22"
Foreground="{DynamicResource InputForeground}"
HorizontalAlignment="Center"
Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Value, StringFormat='\{0:F0}%'}"
VerticalAlignment="Center"
x:Name="ValueContent" />
<Viewbox
HorizontalAlignment="Center"
Margin="22"
VerticalAlignment="Center">
<Path
Data="M21.3745 4.45312H19.7362C19.5065 4.45312 19.2885 4.55859 19.1479 4.73906L9.48462 16.9805L4.85103 11.1094C4.78093 11.0204 4.69159 10.9484 4.5897 10.8989C4.48781 10.8494 4.37603 10.8236 4.26274 10.8234H2.62446C2.46743 10.8234 2.38071 11.0039 2.47681 11.1258L8.89634 19.2586C9.19634 19.6383 9.7729 19.6383 10.0752 19.2586L21.5221 4.75313C21.6182 4.63359 21.5315 4.45312 21.3745 4.45312Z"
Fill="{DynamicResource SuccessBrush}"
Height="24"
Name="pathDone"
StrokeThickness="30"
Visibility="Collapsed"
Width="24" />
</Viewbox>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={converters:LessThanConverter}, ConverterParameter={StaticResource ProgressContentMinWidth}}" Value="True">
<Setter Property="Visibility" TargetName="ValueContent" Value="Collapsed" />
</DataTrigger>
<Trigger Property="Value" Value="100">
<Setter Property="Foreground" Value="{DynamicResource SuccessBrush}" />
<Setter Property="Visibility" TargetName="ValueContent" Value="Collapsed" />
<Setter Property="Visibility" TargetName="pathDone" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>