Skip to content

Commit

Permalink
Merge pull request #20 from ButchersBoy/master
Browse files Browse the repository at this point in the history
update from original repo
  • Loading branch information
spiegelp committed Oct 23, 2016
2 parents 1a1aa34 + 186d7d8 commit d30363d
Show file tree
Hide file tree
Showing 19 changed files with 1,008 additions and 189 deletions.
115 changes: 115 additions & 0 deletions MainDemo.Wpf/Drawers.xaml
@@ -0,0 +1,115 @@
<UserControl x:Class="MaterialDesignDemo.Drawers"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MaterialDesignDemo"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<materialDesign:DrawerHost Margin="64" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="2" BorderBrush="{DynamicResource MaterialDesignDivider}">
<materialDesign:DrawerHost.LeftDrawerContent>
<StackPanel Margin="16">
<TextBlock Margin="4" HorizontalAlignment="Center">LEFT FIELD</TextBlock>
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
CommandParameter="{x:Static Dock.Left}"
Margin="4" HorizontalAlignment="Center"
Style="{DynamicResource MaterialDesignFlatButton}">
CLOSE THIS
</Button>
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
Margin="4" HorizontalAlignment="Center"
Style="{DynamicResource MaterialDesignFlatButton}">
CLOSE ALL
</Button>
</StackPanel>
</materialDesign:DrawerHost.LeftDrawerContent>
<materialDesign:DrawerHost.TopDrawerContent>
<StackPanel Margin="16" HorizontalAlignment="Center" Orientation="Horizontal">
<TextBlock Margin="4" VerticalAlignment="Center">TOP BANANA</TextBlock>
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
Style="{DynamicResource MaterialDesignFlatButton}"
Margin="4" VerticalAlignment="Center">
CLOSE ALL
</Button>
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
CommandParameter="{x:Static Dock.Top}"
Style="{DynamicResource MaterialDesignFlatButton}"
Margin="4" VerticalAlignment="Center">
CLOSE THIS
</Button>
</StackPanel>
</materialDesign:DrawerHost.TopDrawerContent>
<materialDesign:DrawerHost.RightDrawerContent>
<StackPanel Margin="16">
<TextBlock Margin="4" HorizontalAlignment="Center">THE RIGHT STUFF</TextBlock>
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
CommandParameter="{x:Static Dock.Right}"
Margin="4" HorizontalAlignment="Center"
Style="{DynamicResource MaterialDesignFlatButton}">
CLOSE THIS
</Button>
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
Margin="4" HorizontalAlignment="Center"
Style="{DynamicResource MaterialDesignFlatButton}">
CLOSE ALL
</Button>
</StackPanel>
</materialDesign:DrawerHost.RightDrawerContent>
<materialDesign:DrawerHost.BottomDrawerContent>
<StackPanel Margin="16" HorizontalAlignment="Center" Orientation="Horizontal">
<TextBlock Margin="4" VerticalAlignment="Center">BOTTOM BRACKET</TextBlock>
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
Style="{DynamicResource MaterialDesignFlatButton}"
Margin="4" VerticalAlignment="Center">
CLOSE ALL
</Button>
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
CommandParameter="{x:Static Dock.Bottom}"
Style="{DynamicResource MaterialDesignFlatButton}"
Margin="4" VerticalAlignment="Center">
CLOSE THIS
</Button>
</StackPanel>
</materialDesign:DrawerHost.BottomDrawerContent>
<Grid MinWidth="480" MinHeight="480">
<Grid VerticalAlignment="Center" HorizontalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
CommandParameter="{x:Static Dock.Left}"
Grid.Row="1" Grid.Column="0" Margin="4">
<materialDesign:PackIcon Kind="ArrowLeft" />
</Button>
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
CommandParameter="{x:Static Dock.Top}"
Grid.Row="0" Grid.Column="1" Margin="4">
<materialDesign:PackIcon Kind="ArrowUp" />
</Button>
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
CommandParameter="{x:Static Dock.Right}"
Grid.Row="1" Grid.Column="2" Margin="4">
<materialDesign:PackIcon Kind="ArrowRight" />
</Button>
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
CommandParameter="{x:Static Dock.Bottom}"
Grid.Row="2" Grid.Column="1" Margin="4">
<materialDesign:PackIcon Kind="ArrowDown" />
</Button>
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
Grid.Row="1" Grid.Column="1" Margin="4"
Style="{DynamicResource MaterialDesignRaisedAccentButton}">
<materialDesign:PackIcon Kind="ArrowAll" />
</Button>
</Grid>
</Grid>
</materialDesign:DrawerHost>
</UserControl>
28 changes: 28 additions & 0 deletions MainDemo.Wpf/Drawers.xaml.cs
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MaterialDesignDemo
{
/// <summary>
/// Interaction logic for Drawers.xaml
/// </summary>
public partial class Drawers : UserControl
{
public Drawers()
{
InitializeComponent();
}
}
}
5 changes: 5 additions & 0 deletions MainDemo.Wpf/MainWindow.xaml
Expand Up @@ -173,6 +173,11 @@
</wpfExample:Dialogs>
</domain:DemoItem.Content>
</domain:DemoItem>
<domain:DemoItem Name="Drawers">
<domain:DemoItem.Content>
<materialDesignDemo:Drawers />
</domain:DemoItem.Content>
</domain:DemoItem>
<domain:DemoItem Name="Transitions">
<domain:DemoItem.Content>
<materialDesignDemo:Transitions />
Expand Down
11 changes: 8 additions & 3 deletions MainDemo.Wpf/MaterialDesignDemo.csproj
Expand Up @@ -111,6 +111,9 @@
<Compile Include="Domain\SimpleDateValidationRule.cs" />
<Compile Include="Domain\TextFieldsViewModel.cs" />
<Compile Include="Domain\TreesViewModel.cs" />
<Compile Include="Drawers.xaml.cs">
<DependentUpon>Drawers.xaml</DependentUpon>
</Compile>
<Compile Include="Expander.xaml.cs">
<DependentUpon>Expander.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -147,6 +150,7 @@
<Compile Include="ProvingGround.xaml.cs">
<DependentUpon>ProvingGround.xaml</DependentUpon>
</Compile>
<Compile Include="ProvingGroundStuff\MeasuringTextBox.cs" />
<Compile Include="Shadows.xaml.cs">
<DependentUpon>Shadows.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -213,6 +217,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Drawers.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Expander.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -409,9 +417,6 @@
<ItemGroup>
<Resource Include="favicon.ico" />
</ItemGroup>
<ItemGroup>
<Folder Include="ProvingGroundStuff\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
32 changes: 15 additions & 17 deletions MainDemo.Wpf/ProvingGround.xaml
Expand Up @@ -6,12 +6,14 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
xmlns:wpfExample="clr-namespace:MaterialDesignColors.WpfExample"
xmlns:provingGroundStuff="clr-namespace:MaterialDesignDemo.ProvingGroundStuff"
mc:Ignorable="d"
d:DesignWidth="477" d:DesignHeight="272"
d:DataContext="{d:DesignInstance wpfExample:ProvingGroundViewModel, d:IsDesignTimeCreatable=False}">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBox.xaml" />
<!--
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ProgressBar.xaml" />
Expand All @@ -22,28 +24,24 @@
</ResourceDictionary.MergedDictionaries>



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



</ResourceDictionary>
</UserControl.Resources>

<materialDesign:DialogHost Identifier="RootDialog">
<ScrollViewer VerticalScrollBarVisibility="Auto" Background="White">
<Grid>
<TextBox x:Name="loginText"
materialDesign:HintAssist.FloatingScale=".56"
materialDesign:HintAssist.FloatingOffset="1,-42"
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">
<materialDesign:HintAssist.Hint>
<StackPanel Orientation="Horizontal" Margin="0 0 0 0">
<materialDesign:PackIcon Kind="Account" Width="50" Height="50" />
<TextBlock Padding="5,0,0,0">Enter login</TextBlock>
</StackPanel>
</materialDesign:HintAssist.Hint>
</TextBox>
</Grid>
</ScrollViewer>
</materialDesign:DialogHost>
<Grid HorizontalAlignment="Left">
<StackPanel>
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
<provingGroundStuff:MeasuringTextBox materialDesign:HintAssist.Hint="Float">Hello World</provingGroundStuff:MeasuringTextBox>
<provingGroundStuff:MeasuringTextBox materialDesign:HintAssist.IsFloating="True" materialDesign:HintAssist.Hint="Float">Hello World</provingGroundStuff:MeasuringTextBox>
</StackPanel>
</Grid>

</UserControl>
39 changes: 39 additions & 0 deletions MainDemo.Wpf/ProvingGroundStuff/MeasuringTextBox.cs
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using MaterialDesignThemes.Wpf;

namespace MaterialDesignDemo.ProvingGroundStuff
{
public class MeasuringTextBox : TextBox
{
static MeasuringTextBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MeasuringTextBox), new FrameworkPropertyMetadata(typeof(TextBox)));
}

protected override Size ArrangeOverride(Size arrangeBounds)
{
var stopwatch = Stopwatch.StartNew();
var result = base.ArrangeOverride(arrangeBounds);
stopwatch.Stop();
Debug.WriteLine($"Arrange: {stopwatch.ElapsedMilliseconds} - {stopwatch.ElapsedTicks} - ({GetHashCode()})");
return result;
}


protected override Size MeasureOverride(Size constraint)
{
var stopwatch = Stopwatch.StartNew();
var result = base.MeasureOverride(constraint);
stopwatch.Stop();
Debug.WriteLine($"Measure: {stopwatch.ElapsedMilliseconds} - {stopwatch.ElapsedTicks} - ({GetHashCode()})");
return result;
}
}
}
17 changes: 16 additions & 1 deletion MaterialDesignThemes.Wpf/Converters/DrawerOffsetConverter.cs
Expand Up @@ -4,6 +4,8 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace MaterialDesignThemes.Wpf.Converters
Expand All @@ -14,7 +16,20 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
{
var d = value as double? ?? 0;
if (double.IsInfinity(d) || double.IsNaN(d)) d = 0;
return 0 - d;

var dock = (parameter is Dock) ? (Dock)parameter : Dock.Left;
switch (dock)
{
case Dock.Top:
return new Thickness(0, 0 - d, 0, 0);
case Dock.Bottom:
return new Thickness(0, 0, 0, 0 - d);
case Dock.Right:
return new Thickness(0, 0, 0 - d, 0);
case Dock.Left:
default:
return new Thickness(0 - d, 0, 0, 0);
}
}

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

0 comments on commit d30363d

Please sign in to comment.