Files
Shrlalgo.RvKits/NeuWPF/NeuWPF/Controls/ProgressBarStyle.xaml

158 lines
8.1 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2025-07-31 20:12:24 +08:00
xmlns:internal="clr-namespace:NeuWPF.Converters.Internal"
xmlns:svd="clr-namespace:NeuWPF.Controls.Decorations"
2025-07-31 20:12:01 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2025-07-11 09:20:23 +08:00
2025-07-31 20:12:24 +08:00
<internal:ValueToRangeWidthConverter x:Key="ValueToRangeWidth" />
2025-07-31 20:12:01 +08:00
<ControlTemplate TargetType="{x:Type ProgressBar}" x:Key="ProgressHorizontalDefault">
2025-07-11 09:20:23 +08:00
<ControlTemplate.Resources>
2025-07-31 20:12:01 +08:00
<Storyboard RepeatBehavior="Forever" x:Key="ProgressIndeterminateHoriziontal">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform) .(TransformGroup.Children)[3].(TranslateTransform.X)">
<EasingDoubleKeyFrame KeyTime="0" Value="-1" />
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="1" />
2025-07-11 09:20:23 +08:00
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
2025-07-31 20:12:01 +08:00
<svd:SlotBorder
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0.7"
Padding="2"
x:Name="backgroundBorder">
<Grid HorizontalAlignment="Left" x:Name="BarGrid">
<!-- 计算进度条宽度 -->
2025-07-11 09:20:23 +08:00
<Grid.Width>
2025-07-31 20:12:01 +08:00
<MultiBinding Converter="{StaticResource ResourceKey=ValueToRangeWidth}" 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 svd:SlotBorder}}" />
2025-07-11 09:20:23 +08:00
</MultiBinding>
</Grid.Width>
2025-07-31 20:12:01 +08:00
<!-- 背景模糊效果 -->
<Border
Background="{TemplateBinding Foreground}"
CornerRadius="3"
x:Name="borderBlur">
2025-07-11 09:20:23 +08:00
<Border.Effect>
2025-07-31 20:12:01 +08:00
<BlurEffect Radius="8" />
2025-07-11 09:20:23 +08:00
</Border.Effect>
</Border>
2025-07-31 20:12:01 +08:00
<!-- 进度条 -->
<Border
Background="{TemplateBinding Foreground}"
CornerRadius="3"
x:Name="borderProgress" />
2025-07-11 09:20:23 +08:00
</Grid>
</svd:SlotBorder>
<ControlTemplate.Triggers>
<Trigger Property="IsIndeterminate" Value="true">
<Setter Property="Width" TargetName="BarGrid" Value="auto" />
<Setter Property="HorizontalAlignment" TargetName="BarGrid" Value="Stretch" />
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
2025-07-11 09:20:23 +08:00
<Trigger.EnterActions>
2025-07-31 20:12:01 +08:00
<BeginStoryboard Storyboard="{StaticResource ProgressIndeterminateHoriziontal}" x:Name="beginIndeterminate" />
2025-07-11 09:20:23 +08:00
</Trigger.EnterActions>
<Trigger.ExitActions>
2025-07-31 20:12:01 +08:00
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
2025-07-11 09:20:23 +08:00
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
2025-07-31 20:12:01 +08:00
<ControlTemplate TargetType="{x:Type ProgressBar}" x:Key="ProgressVerticalDefault">
2025-07-11 09:20:23 +08:00
<ControlTemplate.Resources>
2025-07-31 20:12:01 +08:00
<Storyboard RepeatBehavior="Forever" x:Key="ProgressIndeterminateVertical">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground.(Brush.RelativeTransform) .(TransformGroup.Children)[3].(TranslateTransform.Y)">
<EasingDoubleKeyFrame KeyTime="0" Value="1" />
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="-1" />
2025-07-11 09:20:23 +08:00
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
2025-07-31 20:12:01 +08:00
<svd:SlotBorder
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0.7"
Padding="2"
x:Name="backgroundBorder">
<Grid VerticalAlignment="Bottom" x:Name="BarGrid">
<!-- 计算进度条宽度 -->
2025-07-11 09:20:23 +08:00
<Grid.Height>
2025-07-31 20:12:01 +08:00
<MultiBinding Converter="{StaticResource ResourceKey=ValueToRangeWidth}" 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 svd:SlotBorder}}" />
2025-07-11 09:20:23 +08:00
</MultiBinding>
</Grid.Height>
2025-07-31 20:12:01 +08:00
<!-- 背景模糊效果 -->
<Border Background="{TemplateBinding Foreground}" CornerRadius="3">
2025-07-11 09:20:23 +08:00
<Border.Effect>
2025-07-31 20:12:01 +08:00
<BlurEffect Radius="8" />
2025-07-11 09:20:23 +08:00
</Border.Effect>
</Border>
2025-07-31 20:12:01 +08:00
<!-- 进度条 -->
<Border Background="{TemplateBinding Foreground}" CornerRadius="3" />
2025-07-11 09:20:23 +08:00
</Grid>
</svd:SlotBorder>
<ControlTemplate.Triggers>
<Trigger Property="IsIndeterminate" Value="true">
<Setter Property="Height" TargetName="BarGrid" Value="auto" />
<Setter Property="VerticalAlignment" TargetName="BarGrid" Value="Stretch" />
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource PrimaryIndeterminateGradientBrush}" />
2025-07-11 09:20:23 +08:00
<Trigger.EnterActions>
2025-07-31 20:12:01 +08:00
<BeginStoryboard Storyboard="{StaticResource ProgressIndeterminateVertical}" x:Name="beginIndeterminate" />
2025-07-11 09:20:23 +08:00
</Trigger.EnterActions>
<Trigger.ExitActions>
2025-07-31 20:12:01 +08:00
<RemoveStoryboard BeginStoryboardName="beginIndeterminate" />
2025-07-11 09:20:23 +08:00
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type ProgressBar}">
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
2025-07-31 20:12:01 +08:00
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Height" Value="20" />
2025-08-12 23:08:54 +08:00
<Setter Property="HorizontalAlignment" Value="Stretch" />
2025-07-31 20:12:01 +08:00
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Template" Value="{StaticResource ProgressHorizontalDefault}" />
2025-07-11 09:20:23 +08:00
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
2025-07-31 20:12:01 +08:00
<Setter Property="Template" Value="{StaticResource ProgressVerticalDefault}" />
<Setter Property="Width" Value="20" />
2025-08-12 23:08:54 +08:00
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
2025-07-11 09:20:23 +08:00
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>