Skip to content

Commit be2016e

Browse files
committed
think this is how we have to do colours
1 parent 721937c commit be2016e

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

MainDemo.Wpf/ProvingGround.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<Button Style="{StaticResource MaterialDesignFloatingActionButton}">
5050
<materialDesign:PackIcon Kind="CloudSync" Height="24" Width="24" />
5151
</Button>
52-
<Button Style="{StaticResource MaterialDesignFloatingActionAccentButton}">
52+
<Button Style="{StaticResource MaterialDesignFloatingActionAccentButton}" Margin="0 12 0 12">
5353
<materialDesign:PackIcon Kind="CloudSync" Height="24" Width="24" />
5454
</Button>
5555
<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" Value="33" Width="50" Height="50" />

MaterialDesignThemes.Wpf/ButtonProgressAssist.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Threading.Tasks;
66
using System.Windows;
77
using System.Windows.Controls;
8+
using System.Windows.Media;
89

910
namespace MaterialDesignThemes.Wpf
1011
{
@@ -49,8 +50,30 @@ public static double GetValue(DependencyObject element)
4950
return (double)element.GetValue(ValueProperty);
5051
}
5152

52-
public static ResourceKey StrokeForeground { get; } = new ComponentResourceKey(typeof(ButtonProgressAssist), nameof(StrokeForeground));
53+
public static readonly DependencyProperty IndicatorForegroundProperty = DependencyProperty.RegisterAttached(
54+
"IndicatorForeground", typeof(Brush), typeof(ButtonProgressAssist), new FrameworkPropertyMetadata(default(Brush)));
5355

54-
public static ResourceKey StrokeBackground { get; } = new ComponentResourceKey(typeof(ButtonProgressAssist), nameof(StrokeBackground));
56+
public static void SetIndicatorForeground(DependencyObject element, Brush indicatorForeground)
57+
{
58+
element.SetValue(IndicatorForegroundProperty, indicatorForeground);
59+
}
60+
61+
public static Brush GetIndicatorForeground(DependencyObject element)
62+
{
63+
return (Brush)element.GetValue(IndicatorForegroundProperty);
64+
}
65+
66+
public static readonly DependencyProperty IndicatorBackgroundProperty = DependencyProperty.RegisterAttached(
67+
"IndicatorBackground", typeof(Brush), typeof(ButtonProgressAssist), new FrameworkPropertyMetadata(default(Brush)));
68+
69+
public static void SetIndicatorBackground(DependencyObject element, Brush indicatorBackground)
70+
{
71+
element.SetValue(IndicatorBackgroundProperty, indicatorBackground);
72+
}
73+
74+
public static Brush GetIndicatorBackground(DependencyObject element)
75+
{
76+
return (Brush)element.GetValue(IndicatorForegroundProperty);
77+
}
5578
}
5679
}

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<converters:RangeLengthConverter x:Key="RangeLengthConverter" />
2323
<converters:MathConverter x:Key="MathAddConverter" Operation="Add" />
24-
<system:Int32 x:Key="ProgressRingStrokeWidth">3</system:Int32>
24+
<system:Int32 x:Key="ProgressRingStrokeWidth">4</system:Int32>
2525

2626
<SolidColorBrush x:Key="AttentionToActionBrush" Color="{StaticResource MaterialDesignShadow}" Opacity=".23" po:Freeze="True" />
2727

@@ -177,15 +177,13 @@
177177
</Style>
178178

179179
<Style x:Key="MaterialDesignFloatingActionMiniButton" TargetType="{x:Type Button}">
180-
<Style.Resources>
181-
<SolidColorBrush x:Key="SecondaryAccentBrush" Color="{x:Static wpf:ButtonProgressAssist.StrokeForeground}" po:Freeze="True" />
182-
<SolidColorBrush x:Key="SecondaryAccentBrush" Color="{x:Static wpf:ButtonProgressAssist.StrokeBackground}" po:Freeze="True" Opacity=".28" />
183-
</Style.Resources>
184180
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
185181
<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
186182
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
187183
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
188184
<Setter Property="wpf:RippleAssist.Feedback" Value="White" />
185+
<Setter Property="wpf:ButtonProgressAssist.IndicatorForeground" Value="{DynamicResource PrimaryHueDarkBrush}" />
186+
<Setter Property="wpf:ButtonProgressAssist.IndicatorBackground" Value="{DynamicResource PrimaryHueLightBrush}" />
189187
<Setter Property="BorderThickness" Value="1"/>
190188
<Setter Property="Cursor" Value="Hand"/>
191189
<Setter Property="HorizontalContentAlignment" Value="Center"/>
@@ -205,15 +203,16 @@
205203
</Ellipse>
206204
</AdornerDecorator>
207205
<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}"
208-
Foreground="{DynamicResource {x:Static wpf:ButtonProgressAssist.StrokeForeground}}"
209-
Foreground="{DynamicResource {x:Static wpf:ButtonProgressAssist.StrokeBackground}}"
210-
Value="-1"
211-
IsIndeterminate="True"
212-
Margin="-3"
213-
Width="{TemplateBinding Width, Converter={StaticResource MathAddConverter}, ConverterParameter={StaticResource ProgressRingStrokeWidth}}"
214-
Height="{TemplateBinding Height, Converter={StaticResource MathAddConverter}, ConverterParameter={StaticResource ProgressRingStrokeWidth}}"
215-
HorizontalAlignment="Stretch"
216-
VerticalAlignment="Stretch" />
206+
Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IndicatorForeground)}"
207+
Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IndicatorBackground)}"
208+
Value="-1"
209+
IsIndeterminate="True"
210+
Margin="-3"
211+
Width="{TemplateBinding Width, Converter={StaticResource MathAddConverter}, ConverterParameter={StaticResource ProgressRingStrokeWidth}}"
212+
Height="{TemplateBinding Height, Converter={StaticResource MathAddConverter}, ConverterParameter={StaticResource ProgressRingStrokeWidth}}"
213+
HorizontalAlignment="Stretch"
214+
VerticalAlignment="Stretch" />
215+
<Ellipse Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" />
217216
<wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
218217
Clip="{Binding ElementName=GeometryEllipse, Path=RenderedGeometry}" ClipToBounds="True"
219218
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
@@ -280,9 +279,6 @@
280279
<Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
281280
<Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
282281
<Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
283-
<Style.Resources>
284-
<SolidColorBrush Color="Yellow" x:Key="{x:Static wpf:ButtonProgressAssist.TestOne}" />
285-
</Style.Resources>
286282
</Style>
287283

288284
</ResourceDictionary>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ProgressBar.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,13 @@
140140
RepeatBehavior="Forever">
141141
<SplineDoubleKeyFrame KeyTime="0" Value="0.0" />
142142
<SplineDoubleKeyFrame KeyTime="0:0:1" Value="1.0" />
143-
<SplineDoubleKeyFrame KeyTime="0:0:3" Value="0.0" />
143+
<SplineDoubleKeyFrame KeyTime="0:0:4" Value="0.0" />
144144
</DoubleAnimationUsingKeyFrames>
145145
<DoubleAnimation Storyboard.TargetName="RotateTransform"
146146
Storyboard.TargetProperty="Angle"
147147
RepeatBehavior="Forever"
148-
From="00" To="359" Duration="0:0:0.75" />
148+
From="00" To="359" Duration="0:0:1.25" />
149+
149150
</Storyboard>
150151
</ControlTemplate.Resources>
151152
<Grid x:Name="TemplateRoot" ClipToBounds="False">

0 commit comments

Comments
 (0)