Skip to content

Commit d30363d

Browse files
authored
Merge pull request #20 from ButchersBoy/master
update from original repo
2 parents 1a1aa34 + 186d7d8 commit d30363d

19 files changed

+1008
-189
lines changed

MainDemo.Wpf/Drawers.xaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<UserControl x:Class="MaterialDesignDemo.Drawers"
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:local="clr-namespace:MaterialDesignDemo"
7+
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
8+
mc:Ignorable="d"
9+
d:DesignHeight="300" d:DesignWidth="300">
10+
<materialDesign:DrawerHost Margin="64" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="2" BorderBrush="{DynamicResource MaterialDesignDivider}">
11+
<materialDesign:DrawerHost.LeftDrawerContent>
12+
<StackPanel Margin="16">
13+
<TextBlock Margin="4" HorizontalAlignment="Center">LEFT FIELD</TextBlock>
14+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
15+
CommandParameter="{x:Static Dock.Left}"
16+
Margin="4" HorizontalAlignment="Center"
17+
Style="{DynamicResource MaterialDesignFlatButton}">
18+
CLOSE THIS
19+
</Button>
20+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
21+
Margin="4" HorizontalAlignment="Center"
22+
Style="{DynamicResource MaterialDesignFlatButton}">
23+
CLOSE ALL
24+
</Button>
25+
</StackPanel>
26+
</materialDesign:DrawerHost.LeftDrawerContent>
27+
<materialDesign:DrawerHost.TopDrawerContent>
28+
<StackPanel Margin="16" HorizontalAlignment="Center" Orientation="Horizontal">
29+
<TextBlock Margin="4" VerticalAlignment="Center">TOP BANANA</TextBlock>
30+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
31+
Style="{DynamicResource MaterialDesignFlatButton}"
32+
Margin="4" VerticalAlignment="Center">
33+
CLOSE ALL
34+
</Button>
35+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
36+
CommandParameter="{x:Static Dock.Top}"
37+
Style="{DynamicResource MaterialDesignFlatButton}"
38+
Margin="4" VerticalAlignment="Center">
39+
CLOSE THIS
40+
</Button>
41+
</StackPanel>
42+
</materialDesign:DrawerHost.TopDrawerContent>
43+
<materialDesign:DrawerHost.RightDrawerContent>
44+
<StackPanel Margin="16">
45+
<TextBlock Margin="4" HorizontalAlignment="Center">THE RIGHT STUFF</TextBlock>
46+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
47+
CommandParameter="{x:Static Dock.Right}"
48+
Margin="4" HorizontalAlignment="Center"
49+
Style="{DynamicResource MaterialDesignFlatButton}">
50+
CLOSE THIS
51+
</Button>
52+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
53+
Margin="4" HorizontalAlignment="Center"
54+
Style="{DynamicResource MaterialDesignFlatButton}">
55+
CLOSE ALL
56+
</Button>
57+
</StackPanel>
58+
</materialDesign:DrawerHost.RightDrawerContent>
59+
<materialDesign:DrawerHost.BottomDrawerContent>
60+
<StackPanel Margin="16" HorizontalAlignment="Center" Orientation="Horizontal">
61+
<TextBlock Margin="4" VerticalAlignment="Center">BOTTOM BRACKET</TextBlock>
62+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
63+
Style="{DynamicResource MaterialDesignFlatButton}"
64+
Margin="4" VerticalAlignment="Center">
65+
CLOSE ALL
66+
</Button>
67+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
68+
CommandParameter="{x:Static Dock.Bottom}"
69+
Style="{DynamicResource MaterialDesignFlatButton}"
70+
Margin="4" VerticalAlignment="Center">
71+
CLOSE THIS
72+
</Button>
73+
</StackPanel>
74+
</materialDesign:DrawerHost.BottomDrawerContent>
75+
<Grid MinWidth="480" MinHeight="480">
76+
<Grid VerticalAlignment="Center" HorizontalAlignment="Center">
77+
<Grid.RowDefinitions>
78+
<RowDefinition />
79+
<RowDefinition />
80+
<RowDefinition />
81+
</Grid.RowDefinitions>
82+
<Grid.ColumnDefinitions>
83+
<ColumnDefinition />
84+
<ColumnDefinition />
85+
<ColumnDefinition />
86+
</Grid.ColumnDefinitions>
87+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
88+
CommandParameter="{x:Static Dock.Left}"
89+
Grid.Row="1" Grid.Column="0" Margin="4">
90+
<materialDesign:PackIcon Kind="ArrowLeft" />
91+
</Button>
92+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
93+
CommandParameter="{x:Static Dock.Top}"
94+
Grid.Row="0" Grid.Column="1" Margin="4">
95+
<materialDesign:PackIcon Kind="ArrowUp" />
96+
</Button>
97+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
98+
CommandParameter="{x:Static Dock.Right}"
99+
Grid.Row="1" Grid.Column="2" Margin="4">
100+
<materialDesign:PackIcon Kind="ArrowRight" />
101+
</Button>
102+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
103+
CommandParameter="{x:Static Dock.Bottom}"
104+
Grid.Row="2" Grid.Column="1" Margin="4">
105+
<materialDesign:PackIcon Kind="ArrowDown" />
106+
</Button>
107+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
108+
Grid.Row="1" Grid.Column="1" Margin="4"
109+
Style="{DynamicResource MaterialDesignRaisedAccentButton}">
110+
<materialDesign:PackIcon Kind="ArrowAll" />
111+
</Button>
112+
</Grid>
113+
</Grid>
114+
</materialDesign:DrawerHost>
115+
</UserControl>

MainDemo.Wpf/Drawers.xaml.cs

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 MaterialDesignDemo
17+
{
18+
/// <summary>
19+
/// Interaction logic for Drawers.xaml
20+
/// </summary>
21+
public partial class Drawers : UserControl
22+
{
23+
public Drawers()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

MainDemo.Wpf/MainWindow.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@
173173
</wpfExample:Dialogs>
174174
</domain:DemoItem.Content>
175175
</domain:DemoItem>
176+
<domain:DemoItem Name="Drawers">
177+
<domain:DemoItem.Content>
178+
<materialDesignDemo:Drawers />
179+
</domain:DemoItem.Content>
180+
</domain:DemoItem>
176181
<domain:DemoItem Name="Transitions">
177182
<domain:DemoItem.Content>
178183
<materialDesignDemo:Transitions />

MainDemo.Wpf/MaterialDesignDemo.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
<Compile Include="Domain\SimpleDateValidationRule.cs" />
112112
<Compile Include="Domain\TextFieldsViewModel.cs" />
113113
<Compile Include="Domain\TreesViewModel.cs" />
114+
<Compile Include="Drawers.xaml.cs">
115+
<DependentUpon>Drawers.xaml</DependentUpon>
116+
</Compile>
114117
<Compile Include="Expander.xaml.cs">
115118
<DependentUpon>Expander.xaml</DependentUpon>
116119
</Compile>
@@ -147,6 +150,7 @@
147150
<Compile Include="ProvingGround.xaml.cs">
148151
<DependentUpon>ProvingGround.xaml</DependentUpon>
149152
</Compile>
153+
<Compile Include="ProvingGroundStuff\MeasuringTextBox.cs" />
150154
<Compile Include="Shadows.xaml.cs">
151155
<DependentUpon>Shadows.xaml</DependentUpon>
152156
</Compile>
@@ -213,6 +217,10 @@
213217
<SubType>Designer</SubType>
214218
<Generator>MSBuild:Compile</Generator>
215219
</Page>
220+
<Page Include="Drawers.xaml">
221+
<SubType>Designer</SubType>
222+
<Generator>MSBuild:Compile</Generator>
223+
</Page>
216224
<Page Include="Expander.xaml">
217225
<SubType>Designer</SubType>
218226
<Generator>MSBuild:Compile</Generator>
@@ -409,9 +417,6 @@
409417
<ItemGroup>
410418
<Resource Include="favicon.ico" />
411419
</ItemGroup>
412-
<ItemGroup>
413-
<Folder Include="ProvingGroundStuff\" />
414-
</ItemGroup>
415420
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
416421
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
417422
Other similar extension points exist, see Microsoft.Common.targets.

MainDemo.Wpf/ProvingGround.xaml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
77
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
88
xmlns:wpfExample="clr-namespace:MaterialDesignColors.WpfExample"
9+
xmlns:provingGroundStuff="clr-namespace:MaterialDesignDemo.ProvingGroundStuff"
910
mc:Ignorable="d"
1011
d:DesignWidth="477" d:DesignHeight="272"
1112
d:DataContext="{d:DesignInstance wpfExample:ProvingGroundViewModel, d:IsDesignTimeCreatable=False}">
1213
<UserControl.Resources>
1314
<ResourceDictionary>
1415
<ResourceDictionary.MergedDictionaries>
16+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBox.xaml" />
1517
<!--
1618
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
1719
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ProgressBar.xaml" />
@@ -22,28 +24,24 @@
2224
</ResourceDictionary.MergedDictionaries>
2325

2426

27+
28+
<Style TargetType="{x:Type provingGroundStuff:MeasuringTextBox}" BasedOn="{StaticResource MaterialDesignTextBox}" />
2529

2630

2731

2832
</ResourceDictionary>
2933
</UserControl.Resources>
3034

31-
<materialDesign:DialogHost Identifier="RootDialog">
32-
<ScrollViewer VerticalScrollBarVisibility="Auto" Background="White">
33-
<Grid>
34-
<TextBox x:Name="loginText"
35-
materialDesign:HintAssist.FloatingScale=".56"
36-
materialDesign:HintAssist.FloatingOffset="1,-42"
37-
Style="{StaticResource MaterialDesignFloatingHintTextBox}" materialDesign:TextFieldAssist.TextBoxViewMargin="1 0 1 0" Margin="0,350,0,0" materialDesign:HintAssist.IsFloating="True" HorizontalAlignment="Center" VerticalAlignment="Top" Width="400" FontSize="36" Height="100" Background="White" Padding="6,0,0,2">
38-
<materialDesign:HintAssist.Hint>
39-
<StackPanel Orientation="Horizontal" Margin="0 0 0 0">
40-
<materialDesign:PackIcon Kind="Account" Width="50" Height="50" />
41-
<TextBlock Padding="5,0,0,0">Enter login</TextBlock>
42-
</StackPanel>
43-
</materialDesign:HintAssist.Hint>
44-
</TextBox>
45-
</Grid>
46-
</ScrollViewer>
47-
</materialDesign:DialogHost>
35+
<Grid HorizontalAlignment="Left">
36+
<StackPanel>
37+
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
38+
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
39+
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
40+
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
41+
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
42+
<provingGroundStuff:MeasuringTextBox materialDesign:HintAssist.Hint="Float">Hello World</provingGroundStuff:MeasuringTextBox>
43+
<provingGroundStuff:MeasuringTextBox materialDesign:HintAssist.IsFloating="True" materialDesign:HintAssist.Hint="Float">Hello World</provingGroundStuff:MeasuringTextBox>
44+
</StackPanel>
45+
</Grid>
4846

4947
</UserControl>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
using MaterialDesignThemes.Wpf;
10+
11+
namespace MaterialDesignDemo.ProvingGroundStuff
12+
{
13+
public class MeasuringTextBox : TextBox
14+
{
15+
static MeasuringTextBox()
16+
{
17+
DefaultStyleKeyProperty.OverrideMetadata(typeof(MeasuringTextBox), new FrameworkPropertyMetadata(typeof(TextBox)));
18+
}
19+
20+
protected override Size ArrangeOverride(Size arrangeBounds)
21+
{
22+
var stopwatch = Stopwatch.StartNew();
23+
var result = base.ArrangeOverride(arrangeBounds);
24+
stopwatch.Stop();
25+
Debug.WriteLine($"Arrange: {stopwatch.ElapsedMilliseconds} - {stopwatch.ElapsedTicks} - ({GetHashCode()})");
26+
return result;
27+
}
28+
29+
30+
protected override Size MeasureOverride(Size constraint)
31+
{
32+
var stopwatch = Stopwatch.StartNew();
33+
var result = base.MeasureOverride(constraint);
34+
stopwatch.Stop();
35+
Debug.WriteLine($"Measure: {stopwatch.ElapsedMilliseconds} - {stopwatch.ElapsedTicks} - ({GetHashCode()})");
36+
return result;
37+
}
38+
}
39+
}

MaterialDesignThemes.Wpf/Converters/DrawerOffsetConverter.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System.Linq;
55
using System.Text;
66
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
79
using System.Windows.Data;
810

911
namespace MaterialDesignThemes.Wpf.Converters
@@ -14,7 +16,20 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1416
{
1517
var d = value as double? ?? 0;
1618
if (double.IsInfinity(d) || double.IsNaN(d)) d = 0;
17-
return 0 - d;
19+
20+
var dock = (parameter is Dock) ? (Dock)parameter : Dock.Left;
21+
switch (dock)
22+
{
23+
case Dock.Top:
24+
return new Thickness(0, 0 - d, 0, 0);
25+
case Dock.Bottom:
26+
return new Thickness(0, 0, 0, 0 - d);
27+
case Dock.Right:
28+
return new Thickness(0, 0, 0 - d, 0);
29+
case Dock.Left:
30+
default:
31+
return new Thickness(0 - d, 0, 0, 0);
32+
}
1833
}
1934

2035
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

0 commit comments

Comments
 (0)