Skip to content

Commit d62a78f

Browse files
committed
more palette help
1 parent fd00482 commit d62a78f

File tree

11 files changed

+315
-93
lines changed

11 files changed

+315
-93
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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.Input;
7+
8+
namespace MahMaterialDragablzMashUp
9+
{
10+
/// <summary>
11+
/// No WPF project is complete without it's own version of this.
12+
/// </summary>
13+
public class AnotherCommandImplementation : ICommand
14+
{
15+
private readonly Action<object> _execute;
16+
private readonly Func<object, bool> _canExecute;
17+
18+
public AnotherCommandImplementation(Action<object> execute) : this(execute, null)
19+
{
20+
}
21+
22+
public AnotherCommandImplementation(Action<object> execute, Func<object, bool> canExecute)
23+
{
24+
if (execute == null) throw new ArgumentNullException(nameof(execute));
25+
26+
_execute = execute;
27+
_canExecute = canExecute ?? (x => true);
28+
}
29+
30+
public bool CanExecute(object parameter)
31+
{
32+
return _canExecute(parameter);
33+
}
34+
35+
public void Execute(object parameter)
36+
{
37+
_execute(parameter);
38+
}
39+
40+
public event EventHandler CanExecuteChanged
41+
{
42+
add
43+
{
44+
CommandManager.RequerySuggested += value;
45+
}
46+
remove
47+
{
48+
CommandManager.RequerySuggested -= value;
49+
}
50+
}
51+
52+
public void Refresh()
53+
{
54+
CommandManager.InvalidateRequerySuggested();
55+
}
56+
}
57+
}

MahMaterialDragablzMashUp/App.xaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616

1717
<!-- Material -->
1818
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
19-
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
20-
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
21-
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.CheckBox.xaml" />
22-
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ListBox.xaml" />
23-
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RadioButton.xaml" />
19+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
2420

2521
<!-- primary color -->
2622
<ResourceDictionary>
@@ -47,7 +43,6 @@
4743
<SolidColorBrush x:Key="AccentColorBrush4" Color="{StaticResource Primary200}" options:Freeze="True" />
4844
<SolidColorBrush x:Key="WindowTitleColorBrush" Color="{StaticResource Primary700}" options:Freeze="True" />
4945
<SolidColorBrush x:Key="AccentSelectedColorBrush" Color="{StaticResource Primary500Foreground}" options:Freeze="True" />
50-
5146
<LinearGradientBrush x:Key="ProgressBrush" EndPoint="0.001,0.5" StartPoint="1.002,0.5" options:Freeze="True">
5247
<GradientStop Color="{StaticResource Primary700}" Offset="0" />
5348
<GradientStop Color="{StaticResource Primary300}" Offset="1" />

MahMaterialDragablzMashUp/Cards.xaml

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,37 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:system="clr-namespace:System;assembly=mscorlib"
7+
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
78
mc:Ignorable="d"
89
d:DesignHeight="300" d:DesignWidth="300">
910
<ListBox Style="{StaticResource MaterialDesignCardsListBox}">
1011
<ItemsControl.ItemTemplate>
1112
<DataTemplate DataType="{x:Type system:DateTime}">
12-
<Grid Height="80">
13-
<Grid.ColumnDefinitions>
14-
<ColumnDefinition Width="60" />
15-
<ColumnDefinition Width="140" />
16-
</Grid.ColumnDefinitions>
17-
<Border Background="{DynamicResource PrimaryHueLightBrush}" TextBlock.Foreground="{DynamicResource PrimaryHueLightForegroundBrush}"
18-
CornerRadius="2 0 0 2"
19-
Padding="8">
20-
<TextBlock Text="{Binding StringFormat=yyy}" />
21-
</Border>
22-
<StackPanel Margin="8" Grid.Column="1" HorizontalAlignment="Right">
23-
<TextBlock Text="{Binding StringFormat=m}" FontWeight="Bold" />
24-
<TextBlock Text="{Binding StringFormat=T}" />
25-
</StackPanel>
26-
<Button Style="{StaticResource MaterialDesignFloatingActionAccentButton}"
27-
Grid.Column="1" Margin="-20 0 0 0" HorizontalAlignment="Left">
28-
<Viewbox Width="24" Height="24">
29-
<Canvas Width="24" Height="24">
30-
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="Black" />
31-
</Canvas>
32-
</Viewbox>
33-
</Button>
34-
</Grid>
13+
<wpf:Card Height="80">
14+
<Grid>
15+
<Grid.ColumnDefinitions>
16+
<ColumnDefinition Width="60" />
17+
<ColumnDefinition Width="140" />
18+
</Grid.ColumnDefinitions>
19+
<Border Background="{DynamicResource PrimaryHueLightBrush}" TextBlock.Foreground="{DynamicResource PrimaryHueLightForegroundBrush}"
20+
CornerRadius="2 0 0 2"
21+
Padding="8">
22+
<TextBlock Text="{Binding StringFormat=yyy}" />
23+
</Border>
24+
<StackPanel Margin="8" Grid.Column="1" HorizontalAlignment="Right">
25+
<TextBlock Text="{Binding StringFormat=m}" FontWeight="Bold" />
26+
<TextBlock Text="{Binding StringFormat=T}" />
27+
</StackPanel>
28+
<Button Style="{StaticResource MaterialDesignFloatingActionAccentButton}"
29+
Grid.Column="1" Margin="-20 0 0 0" HorizontalAlignment="Left">
30+
<Viewbox Width="24" Height="24">
31+
<Canvas Width="24" Height="24">
32+
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="Black" />
33+
</Canvas>
34+
</Viewbox>
35+
</Button>
36+
</Grid>
37+
</wpf:Card>
3538
</DataTemplate>
3639
</ItemsControl.ItemTemplate>
3740
<ItemsControl.ItemsPanel>

MahMaterialDragablzMashUp/MahMaterialDragablzMashUp.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
<Generator>MSBuild:Compile</Generator>
9898
<SubType>Designer</SubType>
9999
</Page>
100+
<Compile Include="AnotherCommandImplementation.cs" />
100101
<Compile Include="App.xaml.cs">
101102
<DependentUpon>App.xaml</DependentUpon>
102103
<SubType>Code</SubType>
@@ -107,6 +108,7 @@
107108
<Compile Include="Cards.xaml.cs">
108109
<DependentUpon>Cards.xaml</DependentUpon>
109110
</Compile>
111+
<Compile Include="PaletteSelectorViewModel.cs" />
110112
<Compile Include="TextFields.xaml.cs">
111113
<DependentUpon>TextFields.xaml</DependentUpon>
112114
</Compile>
@@ -117,15 +119,15 @@
117119
<DependentUpon>MainWindow.xaml</DependentUpon>
118120
<SubType>Code</SubType>
119121
</Compile>
120-
<Page Include="Palette.xaml">
122+
<Page Include="PaletteSelector.xaml">
121123
<SubType>Designer</SubType>
122124
<Generator>MSBuild:Compile</Generator>
123125
</Page>
124126
</ItemGroup>
125127
<ItemGroup>
126128
<Compile Include="NotEmptyValidationRule.cs" />
127-
<Compile Include="Palette.xaml.cs">
128-
<DependentUpon>Palette.xaml</DependentUpon>
129+
<Compile Include="PaletteSelector.xaml.cs">
130+
<DependentUpon>PaletteSelector.xaml</DependentUpon>
129131
</Compile>
130132
<Compile Include="Properties\AssemblyInfo.cs">
131133
<SubType>Code</SubType>

MahMaterialDragablzMashUp/MainWindow.xaml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
<controls:MetroWindow x:Class="MahMaterialDragablzMashUp.MainWindow"
2-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
5-
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
6-
xmlns:mahMaterialDragablzMashUp="clr-namespace:MahMaterialDragablzMashUp"
7-
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
8-
WindowTransitionsEnabled="False"
9-
Background="{DynamicResource MaterialDesignPaper}"
10-
GlowBrush="{DynamicResource AccentColorBrush}"
11-
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
12-
Title="Material-MahApps-Dragablz Mash Up" Height="350" Width="525">
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
5+
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
6+
xmlns:mahMaterialDragablzMashUp="clr-namespace:MahMaterialDragablzMashUp"
7+
WindowTransitionsEnabled="False"
8+
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
9+
Background="{DynamicResource MaterialDesignPaper}"
10+
GlowBrush="{DynamicResource AccentColorBrush}"
11+
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
12+
Title="Material-MahApps-Dragablz Mash Up" Height="350" Width="525">
1313
<dragablz:TabablzControl TextElement.Foreground="{DynamicResource MaterialDesignBody}" BorderThickness="0"
1414
Background="{DynamicResource MaterialDesignPaper}" Margin="0,-1,0,1">
1515
<dragablz:TabablzControl.InterTabController>
1616
<dragablz:InterTabController />
17-
</dragablz:TabablzControl.InterTabController>
17+
</dragablz:TabablzControl.InterTabController>
1818
<TabItem Header="CARDS">
1919
<mahMaterialDragablzMashUp:Cards Margin="8" />
2020
</TabItem>
2121
<TabItem Header="BUTTONS">
2222
<mahMaterialDragablzMashUp:Buttons Margin="8" />
2323
</TabItem>
24-
<TabItem Header="FIELDS">
24+
<TabItem Header="FIELDS">
2525
<mahMaterialDragablzMashUp:TextFields Margin="8" />
2626
</TabItem>
2727
<TabItem Header="PALETTE">
28-
<mahMaterialDragablzMashUp:Palette Margin="16" />
28+
<mahMaterialDragablzMashUp:PaletteSelector Margin="16">
29+
<mahMaterialDragablzMashUp:PaletteSelector.DataContext>
30+
<mahMaterialDragablzMashUp:PaletteSelectorViewModel />
31+
</mahMaterialDragablzMashUp:PaletteSelector.DataContext>
32+
</mahMaterialDragablzMashUp:PaletteSelector>
2933
</TabItem>
3034
<TabItem Header="MAHAPPS">
3135
<mahMaterialDragablzMashUp:Mah Margin="8" />

MahMaterialDragablzMashUp/MainWindow.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
using System.Windows.Navigation;
1414
using System.Windows.Shapes;
1515
using MahApps.Metro.Controls;
16+
using MaterialDesignColors;
17+
using MaterialDesignThemes.Wpf;
1618

1719
namespace MahMaterialDragablzMashUp
1820
{

MahMaterialDragablzMashUp/Palette.xaml

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)