Skip to content

Commit 721937c

Browse files
committed
start building floating action progress style...not quite happy with API aspects yet
1 parent 1c2664e commit 721937c

File tree

7 files changed

+47
-70
lines changed

7 files changed

+47
-70
lines changed

MainDemo.Wpf/App.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Application x:Class="MaterialDesignColors.WpfExample.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
StartupUri="MainWindow.xaml">
4+
StartupUri="ProvingGround.xaml">
55
<Application.Resources>
66
<ResourceDictionary>
77
<ResourceDictionary.MergedDictionaries>

MainDemo.Wpf/Buttons.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
<Button Command="{Binding DismissComand}"
226226
Style="{StaticResource MaterialDesignRaisedButton}"
227227
HorizontalAlignment="Left"
228-
materialDesign:ButtonAssist.Value="{Binding DismissButtonProgress}"
228+
materialDesign:ButtonProgressAssist.Value="{Binding DismissButtonProgress}"
229229
Visibility="{Binding ShowDismissButton, Converter={StaticResource BooleanToVisibilityConverter}}">
230230
<StackPanel Orientation="Horizontal">
231231
<TextBlock>DISMISS</TextBlock>

MainDemo.Wpf/ProvingGround.xaml

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<ResourceDictionary.MergedDictionaries>
2121

2222
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
23-
23+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ProgressBar.xaml" />
2424
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Flipper.xaml" />
2525

2626
<!--
@@ -45,63 +45,15 @@
4545
</ResourceDictionary>
4646
</UserControl.Resources>
4747

48-
<Grid>
49-
<Grid.ColumnDefinitions>
50-
<ColumnDefinition />
51-
<ColumnDefinition />
52-
<ColumnDefinition />
53-
</Grid.ColumnDefinitions>
54-
55-
<materialDesign:Flipper Style="{StaticResource MaterialDesignCardFlipper}" Margin="4 4 0 0">
56-
<materialDesign:Flipper.FrontContent>
57-
<Button Style="{StaticResource MaterialDesignFlatButton}"
58-
Command="{x:Static materialDesign:Flipper.FlipCommand}"
59-
Margin="8"
60-
Width="200"
61-
>RESIZING...</Button>
62-
</materialDesign:Flipper.FrontContent>
63-
<materialDesign:Flipper.BackContent>
64-
<Grid Height="256" Width="200">
65-
<Grid.RowDefinitions>
66-
<RowDefinition Height="Auto" />
67-
<RowDefinition Height="*" />
68-
</Grid.RowDefinitions>
69-
<materialDesign:ColorZone Mode="Accent" Padding="6">
70-
<StackPanel Orientation="Horizontal">
71-
<Button Style="{StaticResource MaterialDesignToolForegroundButton}"
72-
Command="{x:Static materialDesign:Flipper.FlipCommand}"
73-
HorizontalAlignment="Left">
74-
<materialDesign:PackIcon Kind="ArrowLeft" HorizontalAlignment="Right" />
75-
</Button>
76-
<TextBlock Margin="8 0 0 0" VerticalAlignment="Center">EDIT USER</TextBlock>
77-
</StackPanel>
78-
</materialDesign:ColorZone>
79-
<Grid Grid.Row="1" Margin="0 6 0 0" HorizontalAlignment="Center" VerticalAlignment="Top"
80-
Width="172">
81-
<Grid.RowDefinitions>
82-
<RowDefinition />
83-
<RowDefinition />
84-
<RowDefinition />
85-
<RowDefinition />
86-
</Grid.RowDefinitions>
87-
<TextBox materialDesign:HintAssist.Hint="First name" materialDesign:HintAssist.IsFloating="True"
88-
Margin="0 12 0 0">James</TextBox>
89-
<TextBox Grid.Row="1" materialDesign:HintAssist.Hint="Last name" materialDesign:HintAssist.IsFloating="True"
90-
Margin="0 12 0 0">Willock</TextBox>
91-
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0 12 0 0" HorizontalAlignment="Right">
92-
<TextBlock VerticalAlignment="Center">Email Contact</TextBlock>
93-
<ToggleButton Margin="8 0 0 0"></ToggleButton>
94-
</StackPanel>
95-
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0 12 0 0" HorizontalAlignment="Right">
96-
<TextBlock VerticalAlignment="Center">Telephone Contact</TextBlock>
97-
<ToggleButton Margin="8 0 0 0"></ToggleButton>
98-
</StackPanel>
99-
</Grid>
100-
</Grid>
101-
</materialDesign:Flipper.BackContent>
102-
</materialDesign:Flipper>
103-
104-
</Grid>
48+
<StackPanel Margin="32">
49+
<Button Style="{StaticResource MaterialDesignFloatingActionButton}">
50+
<materialDesign:PackIcon Kind="CloudSync" Height="24" Width="24" />
51+
</Button>
52+
<Button Style="{StaticResource MaterialDesignFloatingActionAccentButton}">
53+
<materialDesign:PackIcon Kind="CloudSync" Height="24" Width="24" />
54+
</Button>
55+
<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" Value="33" Width="50" Height="50" />
56+
</StackPanel>
10557
</UserControl>
10658

10759

MaterialDesignThemes.Wpf/ButtonAssist.cs renamed to MaterialDesignThemes.Wpf/ButtonProgressAssist.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
namespace MaterialDesignThemes.Wpf
1010
{
11-
public static class ButtonAssist
11+
public static class ButtonProgressAssist
1212
{
1313
public static readonly DependencyProperty MinimumProperty = DependencyProperty.RegisterAttached(
14-
"Minimum", typeof(double), typeof(ButtonAssist), new FrameworkPropertyMetadata(default(double)));
14+
"Minimum", typeof(double), typeof(ButtonProgressAssist), new FrameworkPropertyMetadata(default(double)));
1515

1616
public static void SetMinimum(DependencyObject element, double value)
1717
{
@@ -24,7 +24,7 @@ public static double GetMinimum(DependencyObject element)
2424
}
2525

2626
public static readonly DependencyProperty MaximumProperty = DependencyProperty.RegisterAttached(
27-
"Maximum", typeof(double), typeof(ButtonAssist), new FrameworkPropertyMetadata(100.0));
27+
"Maximum", typeof(double), typeof(ButtonProgressAssist), new FrameworkPropertyMetadata(100.0));
2828

2929
public static void SetMaximum(DependencyObject element, double value)
3030
{
@@ -37,7 +37,7 @@ public static double GetMaximum(DependencyObject element)
3737
}
3838

3939
public static readonly DependencyProperty ValueProperty = DependencyProperty.RegisterAttached(
40-
"Value", typeof(double), typeof(ButtonAssist), new FrameworkPropertyMetadata(default(double)));
40+
"Value", typeof(double), typeof(ButtonProgressAssist), new FrameworkPropertyMetadata(default(double)));
4141

4242
public static void SetValue(DependencyObject element, double value)
4343
{
@@ -48,5 +48,9 @@ public static double GetValue(DependencyObject element)
4848
{
4949
return (double)element.GetValue(ValueProperty);
5050
}
51+
52+
public static ResourceKey StrokeForeground { get; } = new ComponentResourceKey(typeof(ButtonProgressAssist), nameof(StrokeForeground));
53+
54+
public static ResourceKey StrokeBackground { get; } = new ComponentResourceKey(typeof(ButtonProgressAssist), nameof(StrokeBackground));
5155
}
5256
}

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@
257257
</ItemGroup>
258258
<ItemGroup>
259259
<Compile Include="Badged.cs" />
260-
<Compile Include="ButtonAssist.cs" />
260+
<Compile Include="ButtonProgressAssist.cs" />
261261
<Compile Include="Card.cs" />
262262
<Compile Include="Chip.cs" />
263263
<Compile Include="Clock.cs" />

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"
44
xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
5-
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters">
5+
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"
6+
xmlns:system="clr-namespace:System;assembly=mscorlib">
67

78
<ResourceDictionary.MergedDictionaries>
89
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
@@ -19,6 +20,8 @@
1920
</Style>
2021

2122
<converters:RangeLengthConverter x:Key="RangeLengthConverter" />
23+
<converters:MathConverter x:Key="MathAddConverter" Operation="Add" />
24+
<system:Int32 x:Key="ProgressRingStrokeWidth">3</system:Int32>
2225

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

@@ -51,9 +54,9 @@
5154
<Border HorizontalAlignment="Left" Background="{DynamicResource MaterialDesignBackground}" Opacity=".4">
5255
<Border.Width>
5356
<MultiBinding Converter="{StaticResource RangeLengthConverter}">
54-
<Binding Path="(wpf:ButtonAssist.Minimum)" RelativeSource="{RelativeSource TemplatedParent}" />
55-
<Binding Path="(wpf:ButtonAssist.Maximum)" RelativeSource="{RelativeSource TemplatedParent}" />
56-
<Binding Path="(wpf:ButtonAssist.Value)" RelativeSource="{RelativeSource TemplatedParent}" />
57+
<Binding Path="(wpf:ButtonProgressAssist.Minimum)" RelativeSource="{RelativeSource TemplatedParent}" />
58+
<Binding Path="(wpf:ButtonProgressAssist.Maximum)" RelativeSource="{RelativeSource TemplatedParent}" />
59+
<Binding Path="(wpf:ButtonProgressAssist.Value)" RelativeSource="{RelativeSource TemplatedParent}" />
5760
<Binding Path="ActualWidth" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type ButtonBase}}" />
5861
</MultiBinding>
5962
</Border.Width>
@@ -174,6 +177,10 @@
174177
</Style>
175178

176179
<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>
177184
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
178185
<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
179186
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
@@ -197,6 +204,16 @@
197204
x:Name="border">
198205
</Ellipse>
199206
</AdornerDecorator>
207+
<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" />
200217
<wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
201218
Clip="{Binding ElementName=GeometryEllipse, Path=RenderedGeometry}" ClipToBounds="True"
202219
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
@@ -263,6 +280,9 @@
263280
<Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
264281
<Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
265282
<Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
283+
<Style.Resources>
284+
<SolidColorBrush Color="Yellow" x:Key="{x:Static wpf:ButtonProgressAssist.TestOne}" />
285+
</Style.Resources>
266286
</Style>
267287

268288
</ResourceDictionary>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ProgressBar.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,15 @@
148148
From="00" To="359" Duration="0:0:0.75" />
149149
</Storyboard>
150150
</ControlTemplate.Resources>
151-
<Grid x:Name="TemplateRoot" Background="{TemplateBinding Background}" ClipToBounds="False">
151+
<Grid x:Name="TemplateRoot" ClipToBounds="False">
152152
<Grid x:Name="FullyIndeterminateGrid">
153153
<Grid.RenderTransform>
154154
<ScaleTransform x:Name="FullyIndeterminateGridScaleTransform" ScaleX="0" />
155155
</Grid.RenderTransform>
156156
</Grid>
157157
<Grid x:Name="PathGrid" Margin="2" />
158158
<Canvas>
159+
<Ellipse Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" />
159160
<Path x:Name="Path" Stroke="{TemplateBinding Foreground}" StrokeThickness="3"
160161
Canvas.Top="2" Canvas.Left="2"
161162
RenderTransformOrigin="0, 0">

0 commit comments

Comments
 (0)