Skip to content

Commit 747c9b2

Browse files
committed
Merge remote-tracking branch 'refs/remotes/ButchersBoy/master' into TreeViewRealExpand
Conflicts: MaterialDesignThemes.Wpf/Converters/MathMultipleConverter.cs MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj
2 parents 7168183 + 08205de commit 747c9b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1571
-696
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: 117 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,105 @@ 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", ExtendedOpenedEventHandler, 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 ExtendedOpenedEventHandler(object sender, DialogOpenedEventArgs eventargs)
67+
{
68+
Console.WriteLine("You could intercept the open and affect the dialog using eventArgs.Session.");
69+
}
70+
71+
private void ExtendedClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
72+
{
73+
if ((bool)eventArgs.Parameter == false) return;
74+
75+
//OK, lets cancel the close...
76+
eventArgs.Cancel();
77+
78+
//...now, lets update the "session" with some new content!
79+
eventArgs.Session.UpdateContent(new SampleProgressDialog());
80+
//note, you can also grab the session when the dialog opens via the DialogOpenedEventHandler
81+
82+
//lets run a fake operation for 3 seconds then close this baby.
83+
Task.Delay(TimeSpan.FromSeconds(3))
84+
.ContinueWith((t, _) => eventArgs.Session.Close(false), null,
85+
TaskScheduler.FromCurrentSynchronizationContext());
86+
}
87+
88+
#endregion
89+
90+
#region SAMPLE 4
91+
92+
//pretty much ignore all the stuff provided, and manage everything via custom commands and a binding for .IsOpen
93+
public ICommand OpenSample4DialogCommand { get; }
94+
public ICommand AcceptSample4DialogCommand { get; }
95+
public ICommand CancelSample4DialogCommand { get; }
96+
97+
private bool _isSample4DialogOpen;
98+
private object _sample4Content;
99+
100+
public bool IsSample4DialogOpen
101+
{
102+
get { return _isSample4DialogOpen; }
103+
set
104+
{
105+
if (_isSample4DialogOpen == value) return;
106+
_isSample4DialogOpen = value;
107+
OnPropertyChanged();
108+
}
109+
}
110+
111+
public object Sample4Content
112+
{
113+
get { return _sample4Content; }
114+
set
115+
{
116+
if (_sample4Content == value) return;
117+
_sample4Content = value;
118+
OnPropertyChanged();
119+
}
120+
}
121+
122+
private void OpenSample4Dialog(object obj)
123+
{
124+
Sample4Content = new Sample4Dialog();
125+
IsSample4DialogOpen = true;
126+
}
127+
128+
private void CancelSample4Dialog(object obj)
129+
{
130+
IsSample4DialogOpen = false;
131+
}
132+
133+
private void AcceptSample4Dialog(object obj)
134+
{
135+
//pretend to do something for 3 seconds, then close
136+
Sample4Content = new SampleProgressDialog();
137+
Task.Delay(TimeSpan.FromSeconds(3))
138+
.ContinueWith((t, _) => IsSample4DialogOpen = false, null,
139+
TaskScheduler.FromCurrentSynchronizationContext());
140+
}
141+
142+
#endregion
143+
144+
public event PropertyChangedEventHandler PropertyChanged;
145+
146+
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
147+
{
148+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
149+
}
35150
}
36151
}
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)