feat: add color variant.

This commit is contained in:
rabbitism 2023-01-18 16:36:10 +08:00
parent 3688199035
commit eab1a7a808
3 changed files with 43 additions and 3 deletions

View File

@ -4,7 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450" d:DesignHeight="800"
d:DesignWidth="800" d:DesignWidth="800"
mc:Ignorable="d"> mc:Ignorable="d">
<StackPanel <StackPanel
@ -92,5 +92,32 @@
ShowProgressText="False" ShowProgressText="False"
Value="20" /> Value="20" />
</StackPanel> </StackPanel>
<ProgressBar
Width="200"
Classes="Success"
Maximum="100"
Minimum="0"
ShowProgressText="True"
Value="60" />
<ProgressBar
Width="200"
Classes="Warning"
Maximum="100"
Minimum="0"
ShowProgressText="True"
Value="60" />
<ProgressBar
Width="200"
Classes="Error"
Maximum="100"
Minimum="0"
ShowProgressText="True"
Value="60" />
<ProgressBar
Width="200"
Maximum="100"
Minimum="0"
ShowProgressText="True"
Value="60" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -150,7 +150,7 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
IsVisible="{TemplateBinding ShowProgressText}"> IsVisible="{TemplateBinding ShowProgressText}">
<TextBlock Foreground="{DynamicResource ProgressBarTextForeground}"> <TextBlock FontWeight="{DynamicResource ProgressBarTextFontWeight}" Foreground="{DynamicResource ProgressBarTextForeground}">
<TextBlock.Text> <TextBlock.Text>
<MultiBinding Converter="{StaticResource StringFormatConverter}"> <MultiBinding Converter="{StaticResource StringFormatConverter}">
<TemplateBinding Property="ProgressTextFormat" /> <TemplateBinding Property="ProgressTextFormat" />
@ -165,13 +165,22 @@
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Style Selector="^.Warning">
<Setter Property="ProgressBar.Foreground" Value="{DynamicResource ProgressBarWarningForeground}" />
</Style>
<Style Selector="^.Error">
<Setter Property="ProgressBar.Foreground" Value="{DynamicResource ProgressBarErrorForeground}" />
</Style>
<Style Selector="^.Success">
<Setter Property="ProgressBar.Foreground" Value="{DynamicResource ProgressBarSuccessForeground}" />
</Style>
<Style Selector="^:horizontal /template/ Border#PART_Indicator"> <Style Selector="^:horizontal /template/ Border#PART_Indicator">
<Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Stretch" /> <Setter Property="VerticalAlignment" Value="Stretch" />
</Style> </Style>
<Style Selector="^:vertical /template/ Border#PART_Indicator"> <Style Selector="^:vertical /template/ Border#PART_Indicator">
<Setter Property="HorizontalAlignment" Value="Stretch" /> <Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Bottom" /> <Setter Property="VerticalAlignment" Value="Top" />
</Style> </Style>
<Style Selector="^:horizontal"> <Style Selector="^:horizontal">
<Setter Property="MinWidth" Value="200" /> <Setter Property="MinWidth" Value="200" />

View File

@ -5,4 +5,8 @@
<SolidColorBrush x:Key="ProgressBarBackground" Color="LightGray" /> <SolidColorBrush x:Key="ProgressBarBackground" Color="LightGray" />
<SolidColorBrush x:Key="ProgressBarTextForeground" Color="#1C1F23" /> <SolidColorBrush x:Key="ProgressBarTextForeground" Color="#1C1F23" />
<SolidColorBrush x:Key="ProgressBarRootBorderBrush" Color="Transparent" /> <SolidColorBrush x:Key="ProgressBarRootBorderBrush" Color="Transparent" />
<FontWeight x:Key="ProgressBarTextFontWeight">600</FontWeight>
<SolidColorBrush x:Key="ProgressBarSuccessForeground" Color="#3BB346" />
<SolidColorBrush x:Key="ProgressBarWarningForeground" Color="#FC8800" />
<SolidColorBrush x:Key="ProgressBarErrorForeground" Color="#F93920" />
</ResourceDictionary> </ResourceDictionary>