Skip to content

Commit ef0b53e

Browse files
committed
start building demo for progress button
1 parent 44f66b7 commit ef0b53e

File tree

5 files changed

+80
-16
lines changed

5 files changed

+80
-16
lines changed

MainDemo.Wpf/Buttons.xaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<RowDefinition Height="Auto" />
3333
<RowDefinition Height="Auto" />
3434
<RowDefinition Height="Auto" />
35+
<RowDefinition Height="Auto" />
36+
<RowDefinition Height="Auto" />
3537
</Grid.RowDefinitions>
3638
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}">Buttons</TextBlock>
3739
<Grid Grid.Row="1" >
@@ -212,10 +214,21 @@
212214
<Button Style="{StaticResource MaterialDesignFlatButton}" Click="ButtonBase_OnClick" ToolTip="MaterialDesignFlatButton" Margin="200 0 0 0">ACCEPT</Button>
213215
<Button Style="{StaticResource MaterialDesignFlatButton}" ToolTip="MaterialDesignFlatButton">CANCEL</Button>
214216
</StackPanel>
215-
216217
<Border Margin="0 16 0 0" BorderThickness="0 1 0 0" BorderBrush="{DynamicResource MaterialDesignDivider}" Grid.Row="4" />
217-
<TextBlock Margin="0 32 0 24" Grid.Row="4" Style="{StaticResource MaterialDesignHeadlineTextBlock}">Toggles</TextBlock>
218-
<Grid Grid.Row="5">
218+
219+
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}"
220+
Grid.Row="5" >Buttons - With Progress</TextBlock>
221+
<StackPanel Grid.Row="6" >
222+
<Button Command="{Binding DismissComand}"
223+
Style="{StaticResource MaterialDesignRaisedButton}"
224+
materialDesign:ButtonAssist.Value="{Binding DismissButtonProgress}">
225+
DISMISS
226+
</Button>
227+
</StackPanel>
228+
<Border Margin="0 16 0 0" BorderThickness="0 1 0 0" BorderBrush="{DynamicResource MaterialDesignDivider}" Grid.Row="7" />
229+
230+
<TextBlock Margin="0 32 0 24" Grid.Row="7" Style="{StaticResource MaterialDesignHeadlineTextBlock}">Toggles</TextBlock>
231+
<Grid Grid.Row="8">
219232
<Grid.RowDefinitions>
220233
<RowDefinition Height="Auto" />
221234
<RowDefinition Height="Auto" />
@@ -373,9 +386,9 @@
373386
</ListBox>
374387
</Grid>
375388

376-
<Border Grid.Row="6" Margin="0 16 0 0" BorderThickness="0 1 0 0" BorderBrush="{DynamicResource MaterialDesignDivider}" />
377-
<TextBlock Margin="0 32 0 0" Grid.Row="6" Style="{StaticResource MaterialDesignHeadlineTextBlock}">Rating bar</TextBlock>
378-
<StackPanel Grid.Row="7" Margin="0 16 0 0" Orientation="Horizontal">
389+
<Border Grid.Row="9" Margin="0 16 0 0" BorderThickness="0 1 0 0" BorderBrush="{DynamicResource MaterialDesignDivider}" />
390+
<TextBlock Margin="0 32 0 0" Grid.Row="9" Style="{StaticResource MaterialDesignHeadlineTextBlock}">Rating bar</TextBlock>
391+
<StackPanel Grid.Row="10" Margin="0 16 0 0" Orientation="Horizontal">
379392
<materialDesign:RatingBar Value="3" x:Name="BasicRatingBar" />
380393
<TextBlock Text="{Binding ElementName=BasicRatingBar, Path=Value, StringFormat=Rating: {0}}" VerticalAlignment="Top" Margin="10,2,0,0" />
381394
<materialDesign:RatingBar x:Name="CustomRatingBar" Max="3" Value="2" Margin="24 0 0 0" Orientation="Vertical">

MainDemo.Wpf/Buttons.xaml.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
using System.Windows.Navigation;
1414
using System.Windows.Shapes;
1515
using MaterialDesignColors.WpfExample.Domain;
16-
using System.ComponentModel;
1716

1817
namespace MaterialDesignColors.WpfExample
1918
{
@@ -62,11 +61,4 @@ private void CountingButton_OnClick(object sender, RoutedEventArgs e)
6261

6362
}
6463
}
65-
66-
public class ButtonsViewModel : INotifyPropertyChanged
67-
{
68-
69-
70-
public event PropertyChangedEventHandler PropertyChanged;
71-
}
7264
}

MainDemo.Wpf/ButtonsViewModel.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using MaterialDesignColors.WpfExample.Domain;
2+
using System;
3+
using System.ComponentModel;
4+
using System.Threading;
5+
using System.Windows.Input;
6+
using System.Windows.Threading;
7+
8+
namespace MaterialDesignColors.WpfExample
9+
{
10+
public class ButtonsViewModel : INotifyPropertyChanged
11+
{
12+
private bool _showDismissButton;
13+
private double _dismissButtonProgress;
14+
15+
public ButtonsViewModel()
16+
{
17+
var autoStartingActionCountdownStart = DateTime.Now;
18+
DismissComand = new AnotherCommandImplementation(_ => { });
19+
ShowDismissButton = true;
20+
21+
new DispatcherTimer(
22+
TimeSpan.FromMilliseconds(100),
23+
DispatcherPriority.Normal,
24+
new EventHandler((o, e) =>
25+
{
26+
if (ShowDismissButton)
27+
{
28+
var totalDuration = autoStartingActionCountdownStart.AddSeconds(20).Ticks - autoStartingActionCountdownStart.Ticks;
29+
var currentDuration = DateTime.Now.Ticks - autoStartingActionCountdownStart.Ticks;
30+
var autoCountdownPercentComplete = 100.0 / totalDuration * currentDuration;
31+
DismissButtonProgress = autoCountdownPercentComplete;
32+
}
33+
}), Dispatcher.CurrentDispatcher);
34+
}
35+
36+
public ICommand DismissComand { get; }
37+
38+
public bool ShowDismissButton
39+
{
40+
get { return _showDismissButton; }
41+
set { this.MutateVerbose(ref _showDismissButton, value, RaisePropertyChanged()); }
42+
}
43+
44+
public double DismissButtonProgress
45+
{
46+
get { return _dismissButtonProgress; }
47+
set { this.MutateVerbose(ref _dismissButtonProgress, value, RaisePropertyChanged()); }
48+
}
49+
50+
public event PropertyChangedEventHandler PropertyChanged;
51+
52+
private Action<PropertyChangedEventArgs> RaisePropertyChanged()
53+
{
54+
return args => PropertyChanged?.Invoke(this, args);
55+
}
56+
}
57+
}

MainDemo.Wpf/Domain/MainWindowViewModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ public MainWindowViewModel()
3030
DocumentationLink.DemoPageLink<PaletteSelectorViewModel>("Demo View Model"),
3131
DocumentationLink.ApiLink<PaletteHelper>()
3232
}),
33-
new DemoItem("Buttons & Toggles", new Buttons(),
33+
new DemoItem("Buttons & Toggles", new Buttons { DataContext = new ButtonsViewModel() } ,
3434
new []
3535
{
3636
DocumentationLink.WikiLink("Button-Styles", "Buttons"),
37-
DocumentationLink.DemoPageLink<Buttons>(),
37+
DocumentationLink.DemoPageLink<Buttons>("Demo View"),
38+
DocumentationLink.DemoPageLink<ButtonsViewModel>("Demo View Model"),
3839
DocumentationLink.StyleLink("Button"),
3940
DocumentationLink.StyleLink("CheckBox"),
4041
DocumentationLink.StyleLink("PopupBox"),

MainDemo.Wpf/MaterialDesignDemo.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
<Compile Include="Buttons.xaml.cs">
7676
<DependentUpon>Buttons.xaml</DependentUpon>
7777
</Compile>
78+
<Compile Include="ButtonsViewModel.cs" />
7879
<Compile Include="Cards.xaml.cs">
7980
<DependentUpon>Cards.xaml</DependentUpon>
8081
</Compile>

0 commit comments

Comments
 (0)