Skip to content

Commit 4bdf4d9

Browse files
committed
Merge pull request #6 from ButchersBoy/master
update from original repo
2 parents 41d69f9 + 1e1cc19 commit 4bdf4d9

34 files changed

+1662
-715
lines changed

MahMaterialDragablzMashUp/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Title="Material-MahApps-Dragablz Mash Up" Height="350" Width="525">
1313
<controls:MetroWindow.Flyouts>
1414
<controls:FlyoutsControl>
15-
<controls:Flyout x:Name="LeftFlyout" Position="Left">
15+
<controls:Flyout x:Name="LeftFlyout" Position="Left" Header="Settings">
1616
<mahMaterialDragablzMashUp:FlyoutContent />
1717
</controls:Flyout>
1818
</controls:FlyoutsControl>

MahMaterialDragablzMashUp/PaletteSelectorViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private static void ApplyBase(bool isDark)
2525

2626
private static void ApplyPrimary(Swatch swatch)
2727
{
28-
new PaletteHelper().ReplacePrimaryColor(swatch, true);
28+
new PaletteHelper().ReplacePrimaryColor(swatch);
2929
}
3030

3131
public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o));

MainDemo.Wpf/Dialogs.xaml

Lines changed: 133 additions & 107 deletions
Large diffs are not rendered by default.

MainDemo.Wpf/Domain/DialogsViewModel.cs

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.ComponentModel;
34
using System.Linq;
5+
using System.Runtime.CompilerServices;
46
using System.Text;
57
using System.Threading.Tasks;
68
using System.Windows.Controls;
79
using System.Windows.Input;
10+
using System.Windows.Threading;
811
using MaterialDesignThemes.Wpf;
912

1013
namespace MaterialDesignColors.WpfExample.Domain
1114
{
12-
public class DialogsViewModel
15+
public class DialogsViewModel : INotifyPropertyChanged
1316
{
17+
public DialogsViewModel()
18+
{
19+
//Sample 4
20+
OpenSample4DialogCommand = new AnotherCommandImplementation(OpenSample4Dialog);
21+
AcceptSample4DialogCommand = new AnotherCommandImplementation(AcceptSample4Dialog);
22+
CancelSample4DialogCommand = new AnotherCommandImplementation(CancelSample4Dialog);
23+
}
24+
25+
#region SAMPLE 3
26+
1427
public ICommand RunDialogCommand => new AnotherCommandImplementation(ExecuteRunDialog);
1528

29+
public ICommand RunExtendedDialogCommand => new AnotherCommandImplementation(ExecuteRunExtendedDialog);
30+
1631
private async void ExecuteRunDialog(object o)
1732
{
1833
//let's set up a little MVVM, cos that's what the cool kids are doing:
1934
var view = new SampleDialog
2035
{
2136
DataContext = new object()
2237
};
23-
38+
2439
//show the dialog
2540
var result = await DialogHost.Show(view, "RootDialog", ClosingEventHandler);
2641

@@ -32,5 +47,100 @@ private void ClosingEventHandler(object sender, DialogClosingEventArgs eventArgs
3247
{
3348
Console.WriteLine("You can intercept the closing event, and cancel here.");
3449
}
50+
51+
private async void ExecuteRunExtendedDialog(object o)
52+
{
53+
//let's set up a little MVVM, cos that's what the cool kids are doing:
54+
var view = new SampleDialog
55+
{
56+
DataContext = new object()
57+
};
58+
59+
//show the dialog
60+
var result = await DialogHost.Show(view, "RootDialog", ExtendedClosingEventHandler);
61+
62+
//check the result...
63+
Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL"));
64+
}
65+
66+
private void ExtendedClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
67+
{
68+
if ((bool)eventArgs.Parameter == false) return;
69+
70+
//OK, lets cancel the close...
71+
eventArgs.Cancel();
72+
73+
//...now, lets update the "session" with some new content!
74+
eventArgs.Session.UpdateContent(new SampleProgressDialog());
75+
//note, you can also grab the session when the dialog opens via the DialogOpenedEventHandler
76+
77+
//lets run a fake operation for 3 seconds then close this baby.
78+
Task.Delay(TimeSpan.FromSeconds(3))
79+
.ContinueWith((t, _) => eventArgs.Session.Close(false), null,
80+
TaskScheduler.FromCurrentSynchronizationContext());
81+
}
82+
83+
#endregion
84+
85+
#region SAMPLE 4
86+
87+
//pretty much ignore all the stuff provided, and manage everything via custom commands and a binding for .IsOpen
88+
public ICommand OpenSample4DialogCommand { get; }
89+
public ICommand AcceptSample4DialogCommand { get; }
90+
public ICommand CancelSample4DialogCommand { get; }
91+
92+
private bool _isSample4DialogOpen;
93+
private object _sample4Content;
94+
95+
public bool IsSample4DialogOpen
96+
{
97+
get { return _isSample4DialogOpen; }
98+
set
99+
{
100+
if (_isSample4DialogOpen == value) return;
101+
_isSample4DialogOpen = value;
102+
OnPropertyChanged();
103+
}
104+
}
105+
106+
public object Sample4Content
107+
{
108+
get { return _sample4Content; }
109+
set
110+
{
111+
if (_sample4Content == value) return;
112+
_sample4Content = value;
113+
OnPropertyChanged();
114+
}
115+
}
116+
117+
private void OpenSample4Dialog(object obj)
118+
{
119+
Sample4Content = new Sample4Dialog();
120+
IsSample4DialogOpen = true;
121+
}
122+
123+
private void CancelSample4Dialog(object obj)
124+
{
125+
IsSample4DialogOpen = false;
126+
}
127+
128+
private void AcceptSample4Dialog(object obj)
129+
{
130+
//pretend to do something for 3 seconds, then close
131+
Sample4Content = new SampleProgressDialog();
132+
Task.Delay(TimeSpan.FromSeconds(3))
133+
.ContinueWith((t, _) => IsSample4DialogOpen = false, null,
134+
TaskScheduler.FromCurrentSynchronizationContext());
135+
}
136+
137+
#endregion
138+
139+
public event PropertyChangedEventHandler PropertyChanged;
140+
141+
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
142+
{
143+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
144+
}
35145
}
36146
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<UserControl x:Class="MaterialDesignColors.WpfExample.Domain.Sample4Dialog"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
7+
mc:Ignorable="d" >
8+
<Grid Margin="16">
9+
<Grid.RowDefinitions>
10+
<RowDefinition />
11+
<RowDefinition />
12+
</Grid.RowDefinitions>
13+
<TextBox wpf:TextFieldAssist.Hint="Name" Style="{DynamicResource MaterialDesignFloatingHintTextBox}"
14+
Margin="0 6 0 0"
15+
FontSize="18" Grid.Row="0"
16+
/>
17+
<StackPanel Orientation="Horizontal" Grid.Row="1"
18+
Margin="0 16 0 0">
19+
<Button IsDefault="True" Style="{DynamicResource MaterialDesignFlatButton}"
20+
Command="{Binding AcceptSample4DialogCommand}">
21+
ACCEPT
22+
</Button>
23+
<Button IsCancel="True" Margin="8 0 0 0" Style="{DynamicResource MaterialDesignFlatButton}"
24+
Command="{Binding CancelSample4DialogCommand}">
25+
CANCEL
26+
</Button>
27+
</StackPanel>
28+
</Grid>
29+
</UserControl>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace MaterialDesignColors.WpfExample.Domain
17+
{
18+
/// <summary>
19+
/// Interaction logic for SampleDialog.xaml
20+
/// </summary>
21+
public partial class Sample4Dialog : UserControl
22+
{
23+
public Sample4Dialog()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<UserControl x:Class="MaterialDesignColors.WpfExample.Domain.SampleProgressDialog"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
mc:Ignorable="d">
7+
<ProgressBar Width="24" Height="24" Margin="16"
8+
Style="{DynamicResource MaterialDesignCircularProgressBar}"
9+
IsIndeterminate="True"
10+
Value="33"/>
11+
</UserControl>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace MaterialDesignColors.WpfExample.Domain
17+
{
18+
/// <summary>
19+
/// Interaction logic for SampleProgressDialog.xaml
20+
/// </summary>
21+
public partial class SampleProgressDialog : UserControl
22+
{
23+
public SampleProgressDialog()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

MainDemo.Wpf/Domain/TextFieldsViewModel.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
44
using System.Linq;
55
using System.Runtime.CompilerServices;
66
using System.Runtime.InteropServices;
7+
using System.Security.Cryptography.X509Certificates;
78
using System.Text;
89
using System.Threading.Tasks;
910

1011
namespace MaterialDesignColors.WpfExample.Domain
1112
{
1213
public class TextFieldsViewModel : INotifyPropertyChanged
13-
{
14+
{
15+
private readonly IList<int> _longListToTestComboVirtualization;
16+
1417
private string _name;
18+
private int _selectedValueOne;
19+
20+
public TextFieldsViewModel()
21+
{
22+
_longListToTestComboVirtualization = new List<int>(Enumerable.Range(0, 1000));
23+
24+
SelectedValueOne = _longListToTestComboVirtualization.Skip(2).First();
25+
}
1526

1627
public string Name
1728
{
@@ -23,13 +34,23 @@ public string Name
2334
}
2435
}
2536

37+
public int SelectedValueOne
38+
{
39+
get { return _selectedValueOne; }
40+
set
41+
{
42+
_selectedValueOne = value;
43+
OnPropertyChanged();
44+
}
45+
}
46+
47+
public IList<int> LongListToTestComboVirtualization => _longListToTestComboVirtualization;
48+
2649
public event PropertyChangedEventHandler PropertyChanged;
2750

2851
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
2952
{
30-
if (PropertyChanged != null)
31-
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
32-
//PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
53+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
3354
}
3455
}
3556
}

MainDemo.Wpf/MainDemo.Wpf.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,15 @@
8585
<Compile Include="Domain\DemoItem.cs" />
8686
<Compile Include="Domain\DialogsViewModel.cs" />
8787
<Compile Include="Domain\ListFieldsViewModel.cs" />
88+
<Compile Include="Domain\Sample4Dialog.xaml.cs">
89+
<DependentUpon>Sample4Dialog.xaml</DependentUpon>
90+
</Compile>
8891
<Compile Include="Domain\SampleDialog.xaml.cs">
8992
<DependentUpon>SampleDialog.xaml</DependentUpon>
9093
</Compile>
94+
<Compile Include="Domain\SampleProgressDialog.xaml.cs">
95+
<DependentUpon>SampleProgressDialog.xaml</DependentUpon>
96+
</Compile>
9197
<Compile Include="Domain\SelectableViewModel.cs" />
9298
<Compile Include="Domain\TextFieldsViewModel.cs" />
9399
<Compile Include="Grids.xaml.cs">
@@ -138,10 +144,18 @@
138144
<SubType>Designer</SubType>
139145
<Generator>MSBuild:Compile</Generator>
140146
</Page>
147+
<Page Include="Domain\Sample4Dialog.xaml">
148+
<Generator>MSBuild:Compile</Generator>
149+
<SubType>Designer</SubType>
150+
</Page>
141151
<Page Include="Domain\SampleDialog.xaml">
142152
<SubType>Designer</SubType>
143153
<Generator>MSBuild:Compile</Generator>
144154
</Page>
155+
<Page Include="Domain\SampleProgressDialog.xaml">
156+
<SubType>Designer</SubType>
157+
<Generator>MSBuild:Compile</Generator>
158+
</Page>
145159
<Page Include="Grids.xaml">
146160
<SubType>Designer</SubType>
147161
<Generator>MSBuild:Compile</Generator>

0 commit comments

Comments
 (0)