未验证 提交 b05c439c 编写于 作者: K Kevin B 提交者: GitHub

5.0.0!!!!!!!!! (#3230)

* Removing DrawerHostOpenMode.Model

* Removing obsolete scrollbar styles

* File scope namespace for MaterialDesignColors.Wpf

* Rename all *Extensions to *Mixins

* Removing obsolete ComboBox members

* Removed ComboBoxPopupPlacement

* Removing obsolete content templates

* Remove MaterialDesignNavigatilRailTabControl

* Removed RatingBarButton.IsWithinSelectedValue

* Removed obsolete members from FlyoutAssist

File scoped namespaces in MahApps project

* Removed ShadowDepth

* Fixing #3064

Do not freeze the converted drop shadow. 
Removed duplicated code

* Fixing project swatch generation

* Removed ShadowAssist.ShadowEdges

* Removed PickerInnerPaddingConverter

* Rename ShadowEdgeConverter

Renamed to ShadowOpacityMaskConverter because that is where it is used.

* Color work


Updating tests to query obsolete brushes too


WIP


Theming tests to make sure all brushes exist

* Version bumps

* Adding script for updating brushes.

Ran the script against MaterialDesignTheme.Wpf

* Fixing color zone tests

* More test fixes

* More test fixes

* Reverting demo app change

* Renaming color converter classes to be *Extensions classes

* Missed LabExtensions

* Applied XAMLStyler format

* Adding script for running XAML Styler

* Removing un-used obsolete dictionaries

Cleaned up generation of code

* Update MaterialDesignThemes.UITests/TestBase.cs
Co-authored-by: NNicolai Henriksen <nicolai.h80@gmail.com>

* Renaming converter key

* Renaming converter key

* Fixing casing of properties

* Replacing light/dark brushes with theme brushes

Moved to theme brushes

* Adding new MaterialDesign.Brush.CheckBox.UncheckedBorder brush

* Adding new theme brush MaterialDesign.Brush.Chip.OutlineBorder

* Adding MaterialDesign.Brush.DataGrid.ComboBoxHover brush

* Adding MaterialDesign.Brush.DataGrid.PopupBorder

Adding MaterialDesign.Brush.DataGrid.Border

* Adding MaterialDesign.Brush.GridSplitter.PreviewBackground

To handle the grid splitter.

* Adding MaterialDesign.Brush.ListBoxItem.Border

* Adding new ListView brushes

* Adding toolbar brushes

* Replacing textbox brushes

* Adding tab control brush

* Add ScrollBar brush

* Radio button brushes

* Cleaner expression bottom name

* Adding comment indicating obsolete brushes will be removed

* Fixing migration script

* Updating brushes from powershell script.

* Adding ComboBox disabled brush

* Adding ListBoxItem selected

* Adding RadioButton Border brush

* Removing obsolete toggle button

* Adding ToolBar Separator brush

* Adding MaterialDesign.Brush.RadioButton.Disabled

* Added MaterialDesign.Brush.ToggleButton.Switch.TrackOffBackground

Removed obsolete style MaterialDesignSwitchAccentToggleButton

* Adding combo box brushes

* Adding MaterialDesign.Brush.ToggleButton.Background

Adding MaterialDesign.Brush.ToggleButton.Foreground

---------
Co-authored-by: NNicolai Henriksen <nicolai.h80@gmail.com>
上级 9b1a62ee
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"version": 1, "version": 1,
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"paket": { "xamlstyler.console": {
"version": "7.2.1", "version": "3.2206.4",
"commands": [ "commands": [
"paket" "xstyler"
] ]
} }
} }
} }
\ No newline at end of file
...@@ -23,9 +23,9 @@ jobs: ...@@ -23,9 +23,9 @@ jobs:
getting_versions: getting_versions:
env: env:
#Update these base version numbers #Update these base version numbers
mdix-version: "4.10.0" mdix-version: "5.0.0"
mdix-colors-version: "2.1.5" mdix-colors-version: "3.0.0"
mdix-mahapps-version: "0.3.1" mdix-mahapps-version: "1.0.0"
name: Set version numbers name: Set version numbers
runs-on: ubuntu-latest runs-on: ubuntu-latest
defaults: defaults:
......
<Project> <Project>
</Project> </Project>
\ No newline at end of file
...@@ -2,84 +2,83 @@ ...@@ -2,84 +2,83 @@
using MaterialDesignColors; using MaterialDesignColors;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
namespace MahMaterialDragablzMashUp namespace MahMaterialDragablzMashUp;
public class PaletteSelectorViewModel : INotifyPropertyChanged
{ {
public class PaletteSelectorViewModel : INotifyPropertyChanged public event PropertyChangedEventHandler? PropertyChanged;
{
public event PropertyChangedEventHandler? PropertyChanged;
public PaletteSelectorViewModel() public PaletteSelectorViewModel()
{ {
Swatches = new SwatchesProvider().Swatches; Swatches = new SwatchesProvider().Swatches;
PaletteHelper paletteHelper = new PaletteHelper(); PaletteHelper paletteHelper = new PaletteHelper();
ITheme theme = paletteHelper.GetTheme(); Theme theme = paletteHelper.GetTheme();
IsDarkTheme = theme.GetBaseTheme() == BaseTheme.Dark; IsDarkTheme = theme.GetBaseTheme() == BaseTheme.Dark;
} }
public ICommand ToggleStyleCommand { get; } = new AnotherCommandImplementation(o => ApplyStyle((bool)o!)); public ICommand ToggleStyleCommand { get; } = new AnotherCommandImplementation(o => ApplyStyle((bool)o!));
public IEnumerable<Swatch> Swatches { get; } public IEnumerable<Swatch> Swatches { get; }
public ICommand ApplyPrimaryCommand { get; } = new AnotherCommandImplementation(o => ApplyPrimary((Swatch)o!)); public ICommand ApplyPrimaryCommand { get; } = new AnotherCommandImplementation(o => ApplyPrimary((Swatch)o!));
public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o!)); public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o!));
private bool _isDarkTheme; private bool _isDarkTheme;
public bool IsDarkTheme public bool IsDarkTheme
{
get => _isDarkTheme;
set
{ {
get => _isDarkTheme; if (_isDarkTheme != value)
set
{ {
if (_isDarkTheme != value) _isDarkTheme = value;
{ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsDarkTheme)));
_isDarkTheme = value; ApplyBase(value);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsDarkTheme)));
ApplyBase(value);
}
} }
} }
}
private static void ApplyStyle(bool alternate) private static void ApplyStyle(bool alternate)
{
var resourceDictionary = new ResourceDictionary
{ {
var resourceDictionary = new ResourceDictionary Source = new Uri(@"pack://application:,,,/Dragablz;component/Themes/materialdesign.xaml")
{ };
Source = new Uri(@"pack://application:,,,/Dragablz;component/Themes/materialdesign.xaml")
};
var styleKey = alternate ? "MaterialDesignAlternateTabablzControlStyle" : "MaterialDesignTabablzControlStyle"; var styleKey = alternate ? "MaterialDesignAlternateTabablzControlStyle" : "MaterialDesignTabablzControlStyle";
var style = (Style)resourceDictionary[styleKey]; var style = (Style)resourceDictionary[styleKey];
foreach (var tabablzControl in Dragablz.TabablzControl.GetLoadedInstances()) foreach (var tabablzControl in Dragablz.TabablzControl.GetLoadedInstances())
{ {
tabablzControl.Style = style; tabablzControl.Style = style;
}
} }
}
private static void ApplyBase(bool isDark) private static void ApplyBase(bool isDark)
=> ModifyTheme(theme => theme.SetBaseTheme(isDark ? Theme.Dark : Theme.Light)); => ModifyTheme(theme => theme.SetBaseTheme(isDark ? BaseTheme.Dark : BaseTheme.Light));
private static void ApplyPrimary(Swatch swatch) private static void ApplyPrimary(Swatch swatch)
=> ModifyTheme(theme => theme.SetPrimaryColor(swatch.ExemplarHue.Color)); => ModifyTheme(theme => theme.SetPrimaryColor(swatch.ExemplarHue.Color));
private static void ApplyAccent(Swatch swatch) private static void ApplyAccent(Swatch swatch)
{
if (swatch.AccentExemplarHue is Hue accentHue)
{ {
if (swatch.AccentExemplarHue is Hue accentHue) ModifyTheme(theme => theme.SetSecondaryColor(accentHue.Color));
{
ModifyTheme(theme => theme.SetSecondaryColor(accentHue.Color));
}
} }
}
private static void ModifyTheme(Action<ITheme> modificationAction) private static void ModifyTheme(Action<Theme> modificationAction)
{ {
PaletteHelper paletteHelper = new PaletteHelper(); PaletteHelper paletteHelper = new PaletteHelper();
ITheme theme = paletteHelper.GetTheme(); Theme theme = paletteHelper.GetTheme();
modificationAction?.Invoke(theme); modificationAction?.Invoke(theme);
paletteHelper.SetTheme(theme); paletteHelper.SetTheme(theme);
}
} }
} }
...@@ -20,12 +20,17 @@ ...@@ -20,12 +20,17 @@
<!-- If you would prefer to use your own colors there is an option for that as well --> <!-- If you would prefer to use your own colors there is an option for that as well -->
<!--<materialDesign:CustomColorTheme BaseTheme="Light" PrimaryColor="Aqua" SecondaryColor="DarkGreen" />--> <!--<materialDesign:CustomColorTheme BaseTheme="Light" PrimaryColor="Aqua" SecondaryColor="DarkGreen" />-->
<!-- You can also use the built in theme dictionaries as well <!-- You can also use the built in theme dictionaries as well -->
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" /> <!--
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
--> -->
<!-- NB: For anyone migrating and not wanting to update your brushes you will want this resource dictionary for old brush names -->
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ObsoleteBrushes.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/ShowMeTheXAML.AvalonEdit;component/Themes/xamldisplayer.xaml" /> <ResourceDictionary Source="pack://application:,,,/ShowMeTheXAML.AvalonEdit;component/Themes/xamldisplayer.xaml" />
......
...@@ -950,8 +950,8 @@ ...@@ -950,8 +950,8 @@
<StackPanel Grid.Row="13" Orientation="Horizontal"> <StackPanel Grid.Row="13" Orientation="Horizontal">
<smtx:XamlDisplay Margin="0,0,20,0" UniqueKey="button_duration_1"> <smtx:XamlDisplay Margin="0,0,20,0" UniqueKey="button_duration_1">
<Button materialDesign:ShadowAssist.ShadowAnimationDuration="0:0:0" <Button materialDesign:ShadowAssist.ShadowAnimationDuration="0:0:0"
Style="{StaticResource MaterialDesignRaisedSecondaryButton}" Content="Instant Duration"
Content="Instant Duration" /> Style="{StaticResource MaterialDesignRaisedSecondaryButton}" />
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,0,20,0" UniqueKey="button_duration_2"> <smtx:XamlDisplay Margin="0,0,20,0" UniqueKey="button_duration_2">
<Button> <Button>
......
...@@ -329,8 +329,7 @@ ...@@ -329,8 +329,7 @@
<materialDesign:Card Margin="4"> <materialDesign:Card Margin="4">
<smtx:XamlDisplay Margin="0,0,6,4" UniqueKey="chips_30"> <smtx:XamlDisplay Margin="0,0,6,4" UniqueKey="chips_30">
<ListBox x:Name="RadioButtonGroupChoiceChipSecondary" <ListBox x:Name="RadioButtonGroupChoiceChipSecondary" Style="{StaticResource MaterialDesignChoiceChipSecondaryListBox}">
Style="{StaticResource MaterialDesignChoiceChipSecondaryListBox}">
<ListBoxItem Content="Mercury" /> <ListBoxItem Content="Mercury" />
<ListBoxItem Content="Venus" IsSelected="True" /> <ListBoxItem Content="Venus" IsSelected="True" />
<ListBoxItem Content="Earth" /> <ListBoxItem Content="Earth" />
...@@ -365,8 +364,7 @@ ...@@ -365,8 +364,7 @@
<materialDesign:Card Margin="4"> <materialDesign:Card Margin="4">
<smtx:XamlDisplay Margin="0,0,6,4" UniqueKey="chips_33"> <smtx:XamlDisplay Margin="0,0,6,4" UniqueKey="chips_33">
<ListBox x:Name="RadioButtonGroupChoiceChipSecondaryOutline" <ListBox x:Name="RadioButtonGroupChoiceChipSecondaryOutline" Style="{StaticResource MaterialDesignChoiceChipSecondaryOutlineListBox}">
Style="{StaticResource MaterialDesignChoiceChipSecondaryOutlineListBox}">
<ListBoxItem Content="Mercury" /> <ListBoxItem Content="Mercury" />
<ListBoxItem Content="Venus" IsSelected="True" /> <ListBoxItem Content="Venus" IsSelected="True" />
<ListBoxItem Content="Earth" /> <ListBoxItem Content="Earth" />
......
...@@ -137,7 +137,6 @@ ...@@ -137,7 +137,6 @@
<Setter Property="materialDesign:ElevationAssist.Elevation" Value="Dp0" /> <Setter Property="materialDesign:ElevationAssist.Elevation" Value="Dp0" />
<Setter Property="materialDesign:RippleAssist.Feedback" Value="LightGray" /> <Setter Property="materialDesign:RippleAssist.Feedback" Value="LightGray" />
<Setter Property="materialDesign:RippleAssist.RippleOnTop" Value="True" /> <Setter Property="materialDesign:RippleAssist.RippleOnTop" Value="True" />
<Setter Property="materialDesign:ShadowAssist.ShadowEdges" Value="All" />
</Style> </Style>
</Grid.Resources> </Grid.Resources>
......
<UserControl x:Class="MaterialDesignDemo.ComboBoxes" <UserControl x:Class="MaterialDesignDemo.ComboBoxes"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:colorsDomain="clr-namespace:MaterialDesignDemo.Domain" xmlns:colorsDomain="clr-namespace:MaterialDesignDemo.Domain"
xmlns:converters="clr-namespace:MaterialDesignDemo.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:demoAppDomain="clr-namespace:MaterialDesignDemo.Domain" xmlns:demoAppDomain="clr-namespace:MaterialDesignDemo.Domain"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:materialDesignDemo="clr-namespace:MaterialDesignDemo"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:smtx="clr-namespace:ShowMeTheXAML;assembly=ShowMeTheXAML" xmlns:smtx="clr-namespace:ShowMeTheXAML;assembly=ShowMeTheXAML"
xmlns:converters="clr-namespace:MaterialDesignDemo.Converters"
xmlns:materialDesignDemo="clr-namespace:MaterialDesignDemo"
d:DataContext="{d:DesignInstance colorsDomain:ComboBoxesViewModel, d:DataContext="{d:DesignInstance colorsDomain:ComboBoxesViewModel,
IsDesignTimeCreatable=False}" IsDesignTimeCreatable=False}"
d:DesignHeight="300" d:DesignHeight="300"
...@@ -122,22 +122,6 @@ ...@@ -122,22 +122,6 @@
</StackPanel> </StackPanel>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay UniqueKey="comboboxes_10">
<StackPanel>
<CheckBox x:Name="ClassicModeCheckBox"
Content="Use classic mode"
IsChecked="True"
IsThreeState="False" />
<ComboBox materialDesign:ComboBoxAssist.ClassicMode="{Binding ElementName=ClassicModeCheckBox, Path=IsChecked}">
<ComboBoxItem Content="Apple" IsSelected="True" />
<ComboBoxItem Content="Banana" />
<ComboBoxItem Content="Pear" />
<ComboBoxItem Content="Orange" />
</ComboBox>
</StackPanel>
</smtx:XamlDisplay>
</StackPanel> </StackPanel>
<Rectangle Height="1" <Rectangle Height="1"
...@@ -345,20 +329,25 @@ ...@@ -345,20 +329,25 @@
<TextBlock Style="{StaticResource SectionTitle}" Text="Rotation Clockwise" /> <TextBlock Style="{StaticResource SectionTitle}" Text="Rotation Clockwise" />
<StackPanel Margin="0,8,0,0"> <StackPanel Margin="0,8,0,0">
<CheckBox x:Name="CheckBoxClockwiseRotateContent" IsChecked="False" Content="Rotate drop-down content" Margin="16,0" /> <CheckBox x:Name="CheckBoxClockwiseRotateContent"
Margin="16,0"
Content="Rotate drop-down content"
IsChecked="False" />
<StackPanel Margin="16,15,0,0" Orientation="Horizontal"> <StackPanel Margin="16,15,0,0" Orientation="Horizontal">
<smtx:XamlDisplay UniqueKey="clockwise_1" Margin="0"> <smtx:XamlDisplay Margin="0" UniqueKey="clockwise_1">
<ComboBox Style="{StaticResource MaterialDesignFloatingHintComboBox}" Width="150" materialDesign:HintAssist.Hint="Selected Item" <ComboBox Width="150"
materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesClockWiseCallback}"> materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesClockWiseCallback}"
materialDesign:HintAssist.Hint="Selected Item"
Style="{StaticResource MaterialDesignFloatingHintComboBox}">
<ComboBox.LayoutTransform> <ComboBox.LayoutTransform>
<RotateTransform Angle="90"/> <RotateTransform Angle="90" />
</ComboBox.LayoutTransform> </ComboBox.LayoutTransform>
<ComboBox.ItemsPanel> <ComboBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<StackPanel.LayoutTransform> <StackPanel.LayoutTransform>
<RotateTransform Angle="{Binding ElementName=CheckBoxClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=-90, FalseValue=0}}"/> <RotateTransform Angle="{Binding ElementName=CheckBoxClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=-90, FalseValue=0}}" />
</StackPanel.LayoutTransform> </StackPanel.LayoutTransform>
</StackPanel> </StackPanel>
</ItemsPanelTemplate> </ItemsPanelTemplate>
...@@ -370,17 +359,19 @@ ...@@ -370,17 +359,19 @@
</ComboBox> </ComboBox>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay UniqueKey="clockwise_2" Margin="150,0"> <smtx:XamlDisplay Margin="150,0" UniqueKey="clockwise_2">
<ComboBox Style="{StaticResource MaterialDesignFilledComboBox}" Width="150" materialDesign:HintAssist.Hint="Selected Item" <ComboBox Width="150"
materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesClockWiseCallback}"> materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesClockWiseCallback}"
materialDesign:HintAssist.Hint="Selected Item"
Style="{StaticResource MaterialDesignFilledComboBox}">
<ComboBox.LayoutTransform> <ComboBox.LayoutTransform>
<RotateTransform Angle="90"/> <RotateTransform Angle="90" />
</ComboBox.LayoutTransform> </ComboBox.LayoutTransform>
<ComboBox.ItemsPanel> <ComboBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<StackPanel.LayoutTransform> <StackPanel.LayoutTransform>
<RotateTransform Angle="{Binding ElementName=CheckBoxClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=-90, FalseValue=0}}"/> <RotateTransform Angle="{Binding ElementName=CheckBoxClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=-90, FalseValue=0}}" />
</StackPanel.LayoutTransform> </StackPanel.LayoutTransform>
</StackPanel> </StackPanel>
</ItemsPanelTemplate> </ItemsPanelTemplate>
...@@ -392,17 +383,19 @@ ...@@ -392,17 +383,19 @@
</ComboBox> </ComboBox>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay UniqueKey="clockwise_3" Margin="0"> <smtx:XamlDisplay Margin="0" UniqueKey="clockwise_3">
<ComboBox Style="{StaticResource MaterialDesignOutlinedComboBox}" Width="150" materialDesign:HintAssist.Hint="Selected Item" <ComboBox Width="150"
materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesClockWiseCallback}"> materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesClockWiseCallback}"
materialDesign:HintAssist.Hint="Selected Item"
Style="{StaticResource MaterialDesignOutlinedComboBox}">
<ComboBox.LayoutTransform> <ComboBox.LayoutTransform>
<RotateTransform Angle="90"/> <RotateTransform Angle="90" />
</ComboBox.LayoutTransform> </ComboBox.LayoutTransform>
<ComboBox.ItemsPanel> <ComboBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<StackPanel.LayoutTransform> <StackPanel.LayoutTransform>
<RotateTransform Angle="{Binding ElementName=CheckBoxClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=-90, FalseValue=0}}"/> <RotateTransform Angle="{Binding ElementName=CheckBoxClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=-90, FalseValue=0}}" />
</StackPanel.LayoutTransform> </StackPanel.LayoutTransform>
</StackPanel> </StackPanel>
</ItemsPanelTemplate> </ItemsPanelTemplate>
...@@ -420,20 +413,25 @@ ...@@ -420,20 +413,25 @@
<TextBlock Style="{StaticResource SectionTitle}" Text="Rotation Counter-Clockwise" /> <TextBlock Style="{StaticResource SectionTitle}" Text="Rotation Counter-Clockwise" />
<StackPanel Margin="0,8,0,0"> <StackPanel Margin="0,8,0,0">
<CheckBox x:Name="CheckBoxCounterClockwiseRotateContent" IsChecked="False" Content="Rotate drop-down content" Margin="16,0" /> <CheckBox x:Name="CheckBoxCounterClockwiseRotateContent"
Margin="16,0"
Content="Rotate drop-down content"
IsChecked="False" />
<StackPanel Margin="16,15,0,0" Orientation="Horizontal"> <StackPanel Margin="16,15,0,0" Orientation="Horizontal">
<smtx:XamlDisplay UniqueKey="counter_clockwise_1" Margin="0"> <smtx:XamlDisplay Margin="0" UniqueKey="counter_clockwise_1">
<ComboBox Style="{StaticResource MaterialDesignFloatingHintComboBox}" Width="150" materialDesign:HintAssist.Hint="Selected Item" <ComboBox Width="150"
materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesCounterClockWiseCallback}"> materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesCounterClockWiseCallback}"
materialDesign:HintAssist.Hint="Selected Item"
Style="{StaticResource MaterialDesignFloatingHintComboBox}">
<ComboBox.LayoutTransform> <ComboBox.LayoutTransform>
<RotateTransform Angle="-90"/> <RotateTransform Angle="-90" />
</ComboBox.LayoutTransform> </ComboBox.LayoutTransform>
<ComboBox.ItemsPanel> <ComboBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<StackPanel.LayoutTransform> <StackPanel.LayoutTransform>
<RotateTransform Angle="{Binding ElementName=CheckBoxCounterClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=90, FalseValue=0}}"/> <RotateTransform Angle="{Binding ElementName=CheckBoxCounterClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=90, FalseValue=0}}" />
</StackPanel.LayoutTransform> </StackPanel.LayoutTransform>
</StackPanel> </StackPanel>
</ItemsPanelTemplate> </ItemsPanelTemplate>
...@@ -445,17 +443,19 @@ ...@@ -445,17 +443,19 @@
</ComboBox> </ComboBox>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay UniqueKey="counter_clockwise_2" Margin="150,0"> <smtx:XamlDisplay Margin="150,0" UniqueKey="counter_clockwise_2">
<ComboBox Style="{StaticResource MaterialDesignFilledComboBox}" Width="150" materialDesign:HintAssist.Hint="Selected Item" <ComboBox Width="150"
materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesCounterClockWiseCallback}"> materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesCounterClockWiseCallback}"
materialDesign:HintAssist.Hint="Selected Item"
Style="{StaticResource MaterialDesignFilledComboBox}">
<ComboBox.LayoutTransform> <ComboBox.LayoutTransform>
<RotateTransform Angle="-90"/> <RotateTransform Angle="-90" />
</ComboBox.LayoutTransform> </ComboBox.LayoutTransform>
<ComboBox.ItemsPanel> <ComboBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<StackPanel.LayoutTransform> <StackPanel.LayoutTransform>
<RotateTransform Angle="{Binding ElementName=CheckBoxCounterClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=90, FalseValue=0}}"/> <RotateTransform Angle="{Binding ElementName=CheckBoxCounterClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=90, FalseValue=0}}" />
</StackPanel.LayoutTransform> </StackPanel.LayoutTransform>
</StackPanel> </StackPanel>
</ItemsPanelTemplate> </ItemsPanelTemplate>
...@@ -467,17 +467,19 @@ ...@@ -467,17 +467,19 @@
</ComboBox> </ComboBox>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay UniqueKey="counter_clockwise_3" Margin="0"> <smtx:XamlDisplay Margin="0" UniqueKey="counter_clockwise_3">
<ComboBox Style="{StaticResource MaterialDesignOutlinedComboBox}" Width="150" materialDesign:HintAssist.Hint="Selected Item" <ComboBox Width="150"
materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesCounterClockWiseCallback}"> materialDesign:ComboBoxAssist.CustomPopupPlacementCallback="{x:Static materialDesignDemo:ComboBoxes.Rotate90DegreesCounterClockWiseCallback}"
materialDesign:HintAssist.Hint="Selected Item"
Style="{StaticResource MaterialDesignOutlinedComboBox}">
<ComboBox.LayoutTransform> <ComboBox.LayoutTransform>
<RotateTransform Angle="-90"/> <RotateTransform Angle="-90" />
</ComboBox.LayoutTransform> </ComboBox.LayoutTransform>
<ComboBox.ItemsPanel> <ComboBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<StackPanel.LayoutTransform> <StackPanel.LayoutTransform>
<RotateTransform Angle="{Binding ElementName=CheckBoxCounterClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=90, FalseValue=0}}"/> <RotateTransform Angle="{Binding ElementName=CheckBoxCounterClockwiseRotateContent, Path=IsChecked, Converter={converters:BooleanToDoubleConverter TrueValue=90, FalseValue=0}}" />
</StackPanel.LayoutTransform> </StackPanel.LayoutTransform>
</StackPanel> </StackPanel>
</ItemsPanelTemplate> </ItemsPanelTemplate>
...@@ -491,6 +493,6 @@ ...@@ -491,6 +493,6 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</UserControl> </UserControl>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
SelectedIndex="0" /> SelectedIndex="0" />
</StackPanel> </StackPanel>
<FrameworkElement x:Name="DataContextProxy" DataContext="{Binding}"/> <FrameworkElement x:Name="DataContextProxy" DataContext="{Binding}" />
<smtx:XamlDisplay UniqueKey="grids_1"> <smtx:XamlDisplay UniqueKey="grids_1">
<DataGrid AutoGenerateColumns="False" <DataGrid AutoGenerateColumns="False"
......
...@@ -62,8 +62,8 @@ ...@@ -62,8 +62,8 @@
UniqueKey="dialogs_sample1"> UniqueKey="dialogs_sample1">
<materialDesign:DialogHost DialogClosed="Sample1_DialogHost_OnDialogClosed" <materialDesign:DialogHost DialogClosed="Sample1_DialogHost_OnDialogClosed"
DialogClosing="Sample1_DialogHost_OnDialogClosing" DialogClosing="Sample1_DialogHost_OnDialogClosing"
DialogTheme="Inherit" DialogContentUniformCornerRadius="20"
DialogContentUniformCornerRadius="20"> DialogTheme="Inherit">
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<StackPanel Margin="16"> <StackPanel Margin="16">
<TextBlock Text="Add a new fruit." /> <TextBlock Text="Add a new fruit." />
......
...@@ -66,9 +66,8 @@ public ColorScheme ActiveScheme ...@@ -66,9 +66,8 @@ public ColorScheme ActiveScheme
private void ApplyBase(bool isDark) private void ApplyBase(bool isDark)
{ {
ITheme theme = _paletteHelper.GetTheme(); Theme theme = _paletteHelper.GetTheme();
IBaseTheme baseTheme = isDark ? new MaterialDesignDarkTheme() : (IBaseTheme)new MaterialDesignLightTheme(); theme.SetBaseTheme(isDark ? BaseTheme.Dark : BaseTheme.Light);
theme.SetBaseTheme(baseTheme);
_paletteHelper.SetTheme(theme); _paletteHelper.SetTheme(theme);
} }
...@@ -83,7 +82,7 @@ public ColorToolViewModel() ...@@ -83,7 +82,7 @@ public ColorToolViewModel()
ChangeToSecondaryForegroundCommand = new AnotherCommandImplementation(o => ChangeScheme(ColorScheme.SecondaryForeground)); ChangeToSecondaryForegroundCommand = new AnotherCommandImplementation(o => ChangeScheme(ColorScheme.SecondaryForeground));
ITheme theme = _paletteHelper.GetTheme(); Theme theme = _paletteHelper.GetTheme();
_primaryColor = theme.PrimaryMid.Color; _primaryColor = theme.PrimaryMid.Color;
_secondaryColor = theme.SecondaryMid.Color; _secondaryColor = theme.SecondaryMid.Color;
...@@ -177,7 +176,7 @@ private void ChangeHue(object? obj) ...@@ -177,7 +176,7 @@ private void ChangeHue(object? obj)
private void SetPrimaryForegroundToSingleColor(Color color) private void SetPrimaryForegroundToSingleColor(Color color)
{ {
ITheme theme = _paletteHelper.GetTheme(); Theme theme = _paletteHelper.GetTheme();
theme.PrimaryLight = new ColorPair(theme.PrimaryLight.Color, color); theme.PrimaryLight = new ColorPair(theme.PrimaryLight.Color, color);
theme.PrimaryMid = new ColorPair(theme.PrimaryMid.Color, color); theme.PrimaryMid = new ColorPair(theme.PrimaryMid.Color, color);
...@@ -188,7 +187,7 @@ private void SetPrimaryForegroundToSingleColor(Color color) ...@@ -188,7 +187,7 @@ private void SetPrimaryForegroundToSingleColor(Color color)
private void SetSecondaryForegroundToSingleColor(Color color) private void SetSecondaryForegroundToSingleColor(Color color)
{ {
ITheme theme = _paletteHelper.GetTheme(); Theme theme = _paletteHelper.GetTheme();
theme.SecondaryLight = new ColorPair(theme.SecondaryLight.Color, color); theme.SecondaryLight = new ColorPair(theme.SecondaryLight.Color, color);
theme.SecondaryMid = new ColorPair(theme.SecondaryMid.Color, color); theme.SecondaryMid = new ColorPair(theme.SecondaryMid.Color, color);
......
...@@ -110,8 +110,8 @@ private void CopyToClipboard(object? obj) ...@@ -110,8 +110,8 @@ private void CopyToClipboard(object? obj)
private void SetDefaultIconColors() private void SetDefaultIconColors()
{ {
var helper = new PaletteHelper(); var helper = new PaletteHelper();
ITheme theme = helper.GetTheme(); Theme theme = helper.GetTheme();
GeneratedIconBackground = theme.Paper; GeneratedIconBackground = theme.Background;
GeneratedIconForeground = theme.PrimaryMid.Color; GeneratedIconForeground = theme.PrimaryMid.Color;
} }
......
using MaterialDesignColors; using MaterialDesignColors;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
namespace MaterialDesignDemo.Domain namespace MaterialDesignDemo.Domain;
public class PaletteSelectorViewModel : ViewModelBase
{ {
public class PaletteSelectorViewModel : ViewModelBase public PaletteSelectorViewModel()
{ {
public PaletteSelectorViewModel() Swatches = new SwatchesProvider().Swatches;
{ }
Swatches = new SwatchesProvider().Swatches;
}
public IEnumerable<Swatch> Swatches { get; } public IEnumerable<Swatch> Swatches { get; }
public ICommand ApplyPrimaryCommand { get; } = new AnotherCommandImplementation(o => ApplyPrimary((Swatch)o!)); public ICommand ApplyPrimaryCommand { get; } = new AnotherCommandImplementation(o => ApplyPrimary((Swatch)o!));
private static void ApplyPrimary(Swatch swatch) private static void ApplyPrimary(Swatch swatch)
=> ModifyTheme(theme => theme.SetPrimaryColor(swatch.ExemplarHue.Color)); => ModifyTheme(theme => theme.SetPrimaryColor(swatch.ExemplarHue.Color));
public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o!)); public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o!));
private static void ApplyAccent(Swatch swatch) private static void ApplyAccent(Swatch swatch)
{
if (swatch is { AccentExemplarHue: not null })
{ {
if (swatch is { AccentExemplarHue: not null }) ModifyTheme(theme => theme.SetSecondaryColor(swatch.AccentExemplarHue.Color));
{
ModifyTheme(theme => theme.SetSecondaryColor(swatch.AccentExemplarHue.Color));
}
} }
}
private static void ModifyTheme(Action<ITheme> modificationAction) private static void ModifyTheme(Action<Theme> modificationAction)
{ {
var paletteHelper = new PaletteHelper(); var paletteHelper = new PaletteHelper();
ITheme theme = paletteHelper.GetTheme(); Theme theme = paletteHelper.GetTheme();
modificationAction?.Invoke(theme); modificationAction?.Invoke(theme);
paletteHelper.SetTheme(theme); paletteHelper.SetTheme(theme);
}
} }
} }
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
namespace MaterialDesignDemo.Domain namespace MaterialDesignDemo.Domain;
public class ThemeSettingsViewModel : ViewModelBase
{ {
public class ThemeSettingsViewModel : ViewModelBase public ThemeSettingsViewModel()
{ {
public ThemeSettingsViewModel() PaletteHelper paletteHelper = new PaletteHelper();
{ Theme theme = paletteHelper.GetTheme();
PaletteHelper paletteHelper = new PaletteHelper();
ITheme theme = paletteHelper.GetTheme();
IsDarkTheme = theme.GetBaseTheme() == BaseTheme.Dark; IsDarkTheme = theme.GetBaseTheme() == BaseTheme.Dark;
if (theme is Theme internalTheme) if (theme is Theme internalTheme)
{ {
_isColorAdjusted = internalTheme.ColorAdjustment is not null; _isColorAdjusted = internalTheme.ColorAdjustment is not null;
var colorAdjustment = internalTheme.ColorAdjustment ?? new ColorAdjustment(); var colorAdjustment = internalTheme.ColorAdjustment ?? new ColorAdjustment();
_desiredContrastRatio = colorAdjustment.DesiredContrastRatio; _desiredContrastRatio = colorAdjustment.DesiredContrastRatio;
_contrastValue = colorAdjustment.Contrast; _contrastValue = colorAdjustment.Contrast;
_colorSelectionValue = colorAdjustment.Colors; _colorSelectionValue = colorAdjustment.Colors;
} }
if (paletteHelper.GetThemeManager() is { } themeManager) if (paletteHelper.GetThemeManager() is { } themeManager)
{
themeManager.ThemeChanged += (_, e) =>
{ {
themeManager.ThemeChanged += (_, e) => IsDarkTheme = e.NewTheme?.GetBaseTheme() == BaseTheme.Dark;
{ };
IsDarkTheme = e.NewTheme?.GetBaseTheme() == BaseTheme.Dark;
};
}
} }
}
private bool _isDarkTheme; private bool _isDarkTheme;
public bool IsDarkTheme public bool IsDarkTheme
{
get => _isDarkTheme;
set
{ {
get => _isDarkTheme; if (SetProperty(ref _isDarkTheme, value))
set
{ {
if (SetProperty(ref _isDarkTheme, value)) ModifyTheme(theme => theme.SetBaseTheme(value ? BaseTheme.Dark : BaseTheme.Light));
{
ModifyTheme(theme => theme.SetBaseTheme(value ? Theme.Dark : Theme.Light));
}
} }
} }
}
private bool _isColorAdjusted; private bool _isColorAdjusted;
public bool IsColorAdjusted public bool IsColorAdjusted
{
get => _isColorAdjusted;
set
{ {
get => _isColorAdjusted; if (SetProperty(ref _isColorAdjusted, value))
set
{ {
if (SetProperty(ref _isColorAdjusted, value)) ModifyTheme(theme =>
{ {
ModifyTheme(theme => if (theme is Theme internalTheme)
{ {
if (theme is Theme internalTheme) internalTheme.ColorAdjustment = value
{ ? new ColorAdjustment
internalTheme.ColorAdjustment = value {
? new ColorAdjustment DesiredContrastRatio = DesiredContrastRatio,
{ Contrast = ContrastValue,
DesiredContrastRatio = DesiredContrastRatio, Colors = ColorSelectionValue
Contrast = ContrastValue, }
Colors = ColorSelectionValue : null;
} }
: null; });
}
});
}
} }
} }
}
private float _desiredContrastRatio = 4.5f; private float _desiredContrastRatio = 4.5f;
public float DesiredContrastRatio public float DesiredContrastRatio
{
get => _desiredContrastRatio;
set
{ {
get => _desiredContrastRatio; if (SetProperty(ref _desiredContrastRatio, value))
set
{ {
if (SetProperty(ref _desiredContrastRatio, value)) ModifyTheme(theme =>
{ {
ModifyTheme(theme => if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null)
{ internalTheme.ColorAdjustment.DesiredContrastRatio = value;
if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null) });
internalTheme.ColorAdjustment.DesiredContrastRatio = value;
});
}
} }
} }
}
public IEnumerable<Contrast> ContrastValues => Enum.GetValues(typeof(Contrast)).Cast<Contrast>(); public IEnumerable<Contrast> ContrastValues => Enum.GetValues(typeof(Contrast)).Cast<Contrast>();
private Contrast _contrastValue; private Contrast _contrastValue;
public Contrast ContrastValue public Contrast ContrastValue
{
get => _contrastValue;
set
{ {
get => _contrastValue; if (SetProperty(ref _contrastValue, value))
set
{ {
if (SetProperty(ref _contrastValue, value)) ModifyTheme(theme =>
{ {
ModifyTheme(theme => if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null)
{ internalTheme.ColorAdjustment.Contrast = value;
if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null) });
internalTheme.ColorAdjustment.Contrast = value;
});
}
} }
} }
}
public IEnumerable<ColorSelection> ColorSelectionValues => Enum.GetValues(typeof(ColorSelection)).Cast<ColorSelection>(); public IEnumerable<ColorSelection> ColorSelectionValues => Enum.GetValues(typeof(ColorSelection)).Cast<ColorSelection>();
private ColorSelection _colorSelectionValue; private ColorSelection _colorSelectionValue;
public ColorSelection ColorSelectionValue public ColorSelection ColorSelectionValue
{
get => _colorSelectionValue;
set
{ {
get => _colorSelectionValue; if (SetProperty(ref _colorSelectionValue, value))
set
{ {
if (SetProperty(ref _colorSelectionValue, value)) ModifyTheme(theme =>
{ {
ModifyTheme(theme => if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null)
{ internalTheme.ColorAdjustment.Colors = value;
if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null) });
internalTheme.ColorAdjustment.Colors = value;
});
}
} }
} }
}
private static void ModifyTheme(Action<ITheme> modificationAction) private static void ModifyTheme(Action<Theme> modificationAction)
{ {
var paletteHelper = new PaletteHelper(); var paletteHelper = new PaletteHelper();
ITheme theme = paletteHelper.GetTheme(); Theme theme = paletteHelper.GetTheme();
modificationAction?.Invoke(theme); modificationAction?.Invoke(theme);
paletteHelper.SetTheme(theme); paletteHelper.SetTheme(theme);
}
} }
} }
...@@ -133,17 +133,17 @@ ...@@ -133,17 +133,17 @@
</Style> </Style>
</WrapPanel.Resources> </WrapPanel.Resources>
<smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_26"> <smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_26">
<materialDesign:Card materialDesign:ShadowAssist.ShadowEdges="Bottom,Right"> <materialDesign:Card>
<TextBlock Text="Custom shadow clip&#10;Bottom, Right" /> <TextBlock Text="Custom shadow clip&#10;Bottom, Right" />
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_27"> <smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_27">
<materialDesign:Card materialDesign:ShadowAssist.ShadowEdges="Top"> <materialDesign:Card>
<TextBlock Text="Custom shadow clip&#10;Top" /> <TextBlock Text="Custom shadow clip&#10;Top" />
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_28"> <smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_28">
<materialDesign:Card materialDesign:ShadowAssist.ShadowEdges="Bottom,Left"> <materialDesign:Card>
<TextBlock Text="Custom shadow clip&#10;Bottom, Left" /> <TextBlock Text="Custom shadow clip&#10;Bottom, Left" />
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
......
<UserControl x:Class="MaterialDesignDemo.GroupBoxes" <UserControl x:Class="MaterialDesignDemo.GroupBoxes"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
...@@ -184,12 +184,12 @@ ...@@ -184,12 +184,12 @@
Grid.Column="0" Grid.Column="0"
UniqueKey="groupbox_9"> UniqueKey="groupbox_9">
<GroupBox Margin="16" <GroupBox Margin="16"
Header="Elevation"
Background="White"
materialDesign:ElevationAssist.Elevation="Dp6" materialDesign:ElevationAssist.Elevation="Dp6"
Background="White"
Header="Elevation"
Style="{StaticResource MaterialDesignGroupBox}"> Style="{StaticResource MaterialDesignGroupBox}">
<Grid Height="50"> <Grid Height="50">
<TextBlock Text="GroupBox (with border) and elevation" VerticalAlignment="Center" /> <TextBlock VerticalAlignment="Center" Text="GroupBox (with border) and elevation" />
</Grid> </Grid>
</GroupBox> </GroupBox>
</smtx:XamlDisplay> </smtx:XamlDisplay>
...@@ -197,13 +197,13 @@ ...@@ -197,13 +197,13 @@
Grid.Column="1" Grid.Column="1"
UniqueKey="groupbox_10"> UniqueKey="groupbox_10">
<GroupBox Margin="16" <GroupBox Margin="16"
Header="Elevation (no border)"
Background="White"
materialDesign:ElevationAssist.Elevation="Dp6" materialDesign:ElevationAssist.Elevation="Dp6"
Background="White"
BorderThickness="0" BorderThickness="0"
Header="Elevation (no border)"
Style="{StaticResource MaterialDesignGroupBox}"> Style="{StaticResource MaterialDesignGroupBox}">
<Grid Height="50"> <Grid Height="50">
<TextBlock Text="GroupBox (without border) and elevation" VerticalAlignment="Center" /> <TextBlock VerticalAlignment="Center" Text="GroupBox (without border) and elevation" />
</Grid> </Grid>
</GroupBox> </GroupBox>
</smtx:XamlDisplay> </smtx:XamlDisplay>
...@@ -211,11 +211,11 @@ ...@@ -211,11 +211,11 @@
Grid.Column="2" Grid.Column="2"
UniqueKey="groupbox_11"> UniqueKey="groupbox_11">
<GroupBox Margin="16" <GroupBox Margin="16"
Header="Elevation on Card"
materialDesign:ElevationAssist.Elevation="Dp6" materialDesign:ElevationAssist.Elevation="Dp6"
Header="Elevation on Card"
Style="{StaticResource MaterialDesignCardGroupBox}"> Style="{StaticResource MaterialDesignCardGroupBox}">
<Grid Height="50"> <Grid Height="50">
<TextBlock Text="GroupBox (using Card style) and elevation" VerticalAlignment="Center" /> <TextBlock VerticalAlignment="Center" Text="GroupBox (using Card style) and elevation" />
</Grid> </Grid>
</GroupBox> </GroupBox>
</smtx:XamlDisplay> </smtx:XamlDisplay>
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
Height="32" Height="32"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Kind="{Binding Kind,Mode=OneTime}" /> Kind="{Binding Kind, Mode=OneTime}" />
</DockPanel> </DockPanel>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
......
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
materialDesign:TextFieldAssist.DecorationVisibility="Collapsed" materialDesign:TextFieldAssist.DecorationVisibility="Collapsed"
materialDesign:TextFieldAssist.HasClearButton="True" materialDesign:TextFieldAssist.HasClearButton="True"
DockPanel.Dock="Top" DockPanel.Dock="Top"
Text="{Binding SearchKeyword, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource MaterialDesignOutlinedTextBox}"
Style="{StaticResource MaterialDesignOutlinedTextBox}"/> Text="{Binding SearchKeyword, UpdateSourceTrigger=PropertyChanged}" />
<ListBox x:Name="DemoItemsListBox" <ListBox x:Name="DemoItemsListBox"
Margin="0,16,0,16" Margin="0,16,0,16"
......
...@@ -91,7 +91,7 @@ private static void ModifyTheme(bool isDarkTheme) ...@@ -91,7 +91,7 @@ private static void ModifyTheme(bool isDarkTheme)
var paletteHelper = new PaletteHelper(); var paletteHelper = new PaletteHelper();
var theme = paletteHelper.GetTheme(); var theme = paletteHelper.GetTheme();
theme.SetBaseTheme(isDarkTheme ? Theme.Dark : Theme.Light); theme.SetBaseTheme(isDarkTheme ? BaseTheme.Dark : BaseTheme.Light);
paletteHelper.SetTheme(theme); paletteHelper.SetTheme(theme);
} }
......
...@@ -170,9 +170,9 @@ ...@@ -170,9 +170,9 @@
Header="Item 3" /> Header="Item 3" />
</MenuItem> </MenuItem>
<MenuItem Foreground="Crimson" Header="(1) Important"> <MenuItem Foreground="Crimson" Header="(1) Important">
<MenuItem Foreground="{DynamicResource MaterialDesignLightForeground}" Header="Item 1" /> <MenuItem Foreground="{DynamicResource MaterialDesign.Brush.Foreground}" Header="Item 1" />
<MenuItem Foreground="Crimson" Header="(1) This is important" /> <MenuItem Foreground="Crimson" Header="(1) This is important" />
<MenuItem Foreground="{DynamicResource MaterialDesignLightForeground}" Header="Nothing here" /> <MenuItem Foreground="{DynamicResource MaterialDesign.Brush.Foreground}" Header="Nothing here" />
</MenuItem> </MenuItem>
</Menu> </Menu>
</smtx:XamlDisplay> </smtx:XamlDisplay>
......
using System.Windows.Media;
using MaterialDesignColors;
using MaterialDesignColors.ColorManipulation;
using MaterialDesignThemes.Wpf;
namespace MaterialDesignDemo
{
public static class PaletteHelperExtensions
{
public static void ChangePrimaryColor(this PaletteHelper paletteHelper, Color color)
{
ITheme theme = paletteHelper.GetTheme();
theme.PrimaryLight = new ColorPair(color.Lighten());
theme.PrimaryMid = new ColorPair(color);
theme.PrimaryDark = new ColorPair(color.Darken());
paletteHelper.SetTheme(theme);
}
public static void ChangeSecondaryColor(this PaletteHelper paletteHelper, Color color)
{
ITheme theme = paletteHelper.GetTheme();
theme.SecondaryLight = new ColorPair(color.Lighten());
theme.SecondaryMid = new ColorPair(color);
theme.SecondaryDark = new ColorPair(color.Darken());
paletteHelper.SetTheme(theme);
}
}
}
using System.Windows.Media;
using MaterialDesignColors;
using MaterialDesignColors.ColorManipulation;
using MaterialDesignThemes.Wpf;
namespace MaterialDesignDemo;
public static class PaletteHelperMixins
{
public static void ChangePrimaryColor(this PaletteHelper paletteHelper, Color color)
{
Theme theme = paletteHelper.GetTheme();
theme.PrimaryLight = new ColorPair(color.Lighten());
theme.PrimaryMid = new ColorPair(color);
theme.PrimaryDark = new ColorPair(color.Darken());
paletteHelper.SetTheme(theme);
}
public static void ChangeSecondaryColor(this PaletteHelper paletteHelper, Color color)
{
Theme theme = paletteHelper.GetTheme();
theme.SecondaryLight = new ColorPair(color.Lighten());
theme.SecondaryMid = new ColorPair(color);
theme.SecondaryDark = new ColorPair(color.Darken());
paletteHelper.SetTheme(theme);
}
}
<UserControl x:Class="MaterialDesignDemo.PopupBox" <UserControl x:Class="MaterialDesignDemo.PopupBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MaterialDesignDemo" xmlns:local="clr-namespace:MaterialDesignDemo"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=System.Runtime" xmlns:system="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d" d:DesignHeight="450"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignWidth="800"
mc:Ignorable="d">
<UserControl.Resources> <UserControl.Resources>
<ResourceDictionary> <ResourceDictionary>
<!-- This is needed to avoid runtime exceptions?! Seems like this might be a bug? --> <!-- This is needed to avoid runtime exceptions?! Seems like this might be a bug? -->
...@@ -16,14 +17,22 @@ ...@@ -16,14 +17,22 @@
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<DataTemplate x:Key="ContentTemplateGrid"> <DataTemplate x:Key="ContentTemplateGrid">
<Grid Width="200" Height="100" TextElement.Foreground="{DynamicResource MaterialDesignLightForeground}"> <Grid Width="200"
<TextBlock Text="Popup content in grid" HorizontalAlignment="Center" VerticalAlignment="Center" /> Height="100"
TextElement.Foreground="{DynamicResource MaterialDesign.Brush.Foreground}">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="Popup content in grid" />
</Grid> </Grid>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="ContentTemplateGridWithBackground"> <DataTemplate x:Key="ContentTemplateGridWithBackground">
<Grid Width="200" Height="100" Background="Fuchsia"> <Grid Width="200"
<TextBlock Text="Popup content in colored grid" HorizontalAlignment="Center" VerticalAlignment="Center" /> Height="100"
Background="Fuchsia">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="Popup content in colored grid" />
</Grid> </Grid>
</DataTemplate> </DataTemplate>
...@@ -51,12 +60,12 @@ ...@@ -51,12 +60,12 @@
</DataTemplate> </DataTemplate>
<x:Array x:Key="{x:Static local:PopupBox.DefaultStyleContentKey}" Type="ComboBoxItem"> <x:Array x:Key="{x:Static local:PopupBox.DefaultStyleContentKey}" Type="ComboBoxItem">
<ComboBoxItem Tag="{StaticResource ContentTemplateGrid}" materialDesign:HintAssist.HelperText="Selected content works best when used with the MaterialDesignPopupBox style">Grid</ComboBoxItem> <ComboBoxItem materialDesign:HintAssist.HelperText="Selected content works best when used with the MaterialDesignPopupBox style" Tag="{StaticResource ContentTemplateGrid}">Grid</ComboBoxItem>
<ComboBoxItem Tag="{StaticResource ContentTemplateGridWithBackground}">Colored grid</ComboBoxItem> <ComboBoxItem Tag="{StaticResource ContentTemplateGridWithBackground}">Colored grid</ComboBoxItem>
</x:Array> </x:Array>
<x:Array x:Key="{x:Static local:PopupBox.MultiFloatingActionStyleContentKey}" Type="ComboBoxItem"> <x:Array x:Key="{x:Static local:PopupBox.MultiFloatingActionStyleContentKey}" Type="ComboBoxItem">
<ComboBoxItem Tag="{StaticResource ContentTemplateButtonStack}" materialDesign:HintAssist.HelperText="Margin in the selected content (stack of buttons) needs to be compensated for in certain alignments (left/right)">Stack of buttons</ComboBoxItem> <ComboBoxItem materialDesign:HintAssist.HelperText="Margin in the selected content (stack of buttons) needs to be compensated for in certain alignments (left/right)" Tag="{StaticResource ContentTemplateButtonStack}">Stack of buttons</ComboBoxItem>
<ComboBoxItem Tag="{StaticResource ContentTemplateButtonStackWithBackground}">Stack of buttons in colored grid</ComboBoxItem> <ComboBoxItem Tag="{StaticResource ContentTemplateButtonStackWithBackground}">Stack of buttons in colored grid</ComboBoxItem>
</x:Array> </x:Array>
...@@ -78,31 +87,39 @@ ...@@ -78,31 +87,39 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" HorizontalAlignment="Center" Style="{StaticResource MaterialDesignSubtitle2TextBlock}" <TextBlock Grid.Row="0"
HorizontalAlignment="Center"
Style="{StaticResource MaterialDesignSubtitle2TextBlock}"
Text="{Binding ElementName=ContentComboBox, Path=SelectedItem, Converter={StaticResource ComboBoxItemToHelperTextConverter}}" /> Text="{Binding ElementName=ContentComboBox, Path=SelectedItem, Converter={StaticResource ComboBoxItemToHelperTextConverter}}" />
<materialDesign:PopupBox Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="True" Padding="0" <materialDesign:PopupBox Grid.Row="1"
Style="{Binding ElementName=StyleComboBox, Path=SelectedItem, Converter={StaticResource ComboBoxItemToStyleConverter}}" Padding="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
PlacementMode="{Binding ElementName=PopupBoxPlacementModeComboBox, Path=SelectedItem}"
PopupElevation="{Binding ElementName=ElevationComboBox, Path=SelectedItem}" PopupElevation="{Binding ElementName=ElevationComboBox, Path=SelectedItem}"
PopupUniformCornerRadius="{Binding ElementName=UniformCornerRadiusComboBox, Path=SelectedItem}"
PopupHorizontalOffset="{Binding ElementName=HorizontalOffsetComboBox, Path=SelectedItem}" PopupHorizontalOffset="{Binding ElementName=HorizontalOffsetComboBox, Path=SelectedItem}"
PopupUniformCornerRadius="{Binding ElementName=UniformCornerRadiusComboBox, Path=SelectedItem}"
PopupVerticalOffset="{Binding ElementName=VerticalOffsetComboBox, Path=SelectedItem}" PopupVerticalOffset="{Binding ElementName=VerticalOffsetComboBox, Path=SelectedItem}"
PlacementMode="{Binding ElementName=PopupBoxPlacementModeComboBox, Path=SelectedItem}"> SnapsToDevicePixels="True"
Style="{Binding ElementName=StyleComboBox, Path=SelectedItem, Converter={StaticResource ComboBoxItemToStyleConverter}}">
<ContentControl ContentTemplate="{Binding ElementName=ContentComboBox, Path=SelectedItem, Converter={StaticResource ComboBoxItemToDataTemplateConverter}}" /> <ContentControl ContentTemplate="{Binding ElementName=ContentComboBox, Path=SelectedItem, Converter={StaticResource ComboBoxItemToDataTemplateConverter}}" />
</materialDesign:PopupBox> </materialDesign:PopupBox>
</Grid> </Grid>
<StackPanel Grid.Column="1" Orientation="Vertical"> <StackPanel Grid.Column="1" Orientation="Vertical">
<GroupBox Header="Properties" Padding="10"> <GroupBox Padding="10" Header="Properties">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<TextBlock Text="Style:" Style="{StaticResource MaterialDesignSubtitle2TextBlock}" /> <TextBlock Style="{StaticResource MaterialDesignSubtitle2TextBlock}" Text="Style:" />
<ComboBox x:Name="StyleComboBox" SelectionChanged="StyleComboBox_OnSelectionChanged"> <ComboBox x:Name="StyleComboBox" SelectionChanged="StyleComboBox_OnSelectionChanged">
<ComboBoxItem Tag="{StaticResource MaterialDesignPopupBox}">MaterialDesignPopupBox</ComboBoxItem> <ComboBoxItem Tag="{StaticResource MaterialDesignPopupBox}">MaterialDesignPopupBox</ComboBoxItem>
<ComboBoxItem Tag="{StaticResource MaterialDesignMultiFloatingActionPopupBox}">MaterialDesignMultiFloatingActionPopupBox</ComboBoxItem> <ComboBoxItem Tag="{StaticResource MaterialDesignMultiFloatingActionPopupBox}">MaterialDesignMultiFloatingActionPopupBox</ComboBoxItem>
</ComboBox> </ComboBox>
<TextBlock Text="Elevation:" Margin="{StaticResource Spacer}" Style="{StaticResource MaterialDesignSubtitle2TextBlock}" /> <TextBlock Margin="{StaticResource Spacer}"
Style="{StaticResource MaterialDesignSubtitle2TextBlock}"
Text="Elevation:" />
<ComboBox x:Name="ElevationComboBox" SelectedIndex="6"> <ComboBox x:Name="ElevationComboBox" SelectedIndex="6">
<materialDesign:Elevation>Dp0</materialDesign:Elevation> <materialDesign:Elevation>Dp0</materialDesign:Elevation>
<materialDesign:Elevation>Dp1</materialDesign:Elevation> <materialDesign:Elevation>Dp1</materialDesign:Elevation>
...@@ -118,7 +135,9 @@ ...@@ -118,7 +135,9 @@
<materialDesign:Elevation>Dp24</materialDesign:Elevation> <materialDesign:Elevation>Dp24</materialDesign:Elevation>
</ComboBox> </ComboBox>
<TextBlock Text="PopupUniformCornerRadius:" Margin="{StaticResource Spacer}" Style="{StaticResource MaterialDesignSubtitle2TextBlock}" /> <TextBlock Margin="{StaticResource Spacer}"
Style="{StaticResource MaterialDesignSubtitle2TextBlock}"
Text="PopupUniformCornerRadius:" />
<ComboBox x:Name="UniformCornerRadiusComboBox" SelectedIndex="2"> <ComboBox x:Name="UniformCornerRadiusComboBox" SelectedIndex="2">
<system:Double>0</system:Double> <system:Double>0</system:Double>
<system:Double>2</system:Double> <system:Double>2</system:Double>
...@@ -129,7 +148,9 @@ ...@@ -129,7 +148,9 @@
<system:Double>20</system:Double> <system:Double>20</system:Double>
</ComboBox> </ComboBox>
<TextBlock Text="PopupHorizontalOffset:" Margin="{StaticResource Spacer}" Style="{StaticResource MaterialDesignSubtitle2TextBlock}" /> <TextBlock Margin="{StaticResource Spacer}"
Style="{StaticResource MaterialDesignSubtitle2TextBlock}"
Text="PopupHorizontalOffset:" />
<ComboBox x:Name="HorizontalOffsetComboBox" SelectedIndex="10"> <ComboBox x:Name="HorizontalOffsetComboBox" SelectedIndex="10">
<system:Double>-100</system:Double> <system:Double>-100</system:Double>
<system:Double>-50</system:Double> <system:Double>-50</system:Double>
...@@ -154,7 +175,9 @@ ...@@ -154,7 +175,9 @@
<system:Double>100</system:Double> <system:Double>100</system:Double>
</ComboBox> </ComboBox>
<TextBlock Text="PopupVerticalOffset:" Margin="{StaticResource Spacer}" Style="{StaticResource MaterialDesignSubtitle2TextBlock}" /> <TextBlock Margin="{StaticResource Spacer}"
Style="{StaticResource MaterialDesignSubtitle2TextBlock}"
Text="PopupVerticalOffset:" />
<ComboBox x:Name="VerticalOffsetComboBox" SelectedIndex="10"> <ComboBox x:Name="VerticalOffsetComboBox" SelectedIndex="10">
<system:Double>-100</system:Double> <system:Double>-100</system:Double>
<system:Double>-50</system:Double> <system:Double>-50</system:Double>
...@@ -179,7 +202,9 @@ ...@@ -179,7 +202,9 @@
<system:Double>100</system:Double> <system:Double>100</system:Double>
</ComboBox> </ComboBox>
<TextBlock Text="PopupBoxPlacementMode:" Margin="{StaticResource Spacer}" Style="{StaticResource MaterialDesignSubtitle2TextBlock}" /> <TextBlock Margin="{StaticResource Spacer}"
Style="{StaticResource MaterialDesignSubtitle2TextBlock}"
Text="PopupBoxPlacementMode:" />
<ComboBox x:Name="PopupBoxPlacementModeComboBox" SelectedIndex="1"> <ComboBox x:Name="PopupBoxPlacementModeComboBox" SelectedIndex="1">
<materialDesign:PopupBoxPlacementMode>BottomAndAlignCentres</materialDesign:PopupBoxPlacementMode> <materialDesign:PopupBoxPlacementMode>BottomAndAlignCentres</materialDesign:PopupBoxPlacementMode>
<materialDesign:PopupBoxPlacementMode>BottomAndAlignLeftEdges</materialDesign:PopupBoxPlacementMode> <materialDesign:PopupBoxPlacementMode>BottomAndAlignLeftEdges</materialDesign:PopupBoxPlacementMode>
...@@ -197,9 +222,11 @@ ...@@ -197,9 +222,11 @@
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
<GroupBox Header="Popup" Margin="{StaticResource Spacer}" Padding="10"> <GroupBox Margin="{StaticResource Spacer}"
Padding="10"
Header="Popup">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<TextBlock Text="Popup Content:" Style="{StaticResource MaterialDesignSubtitle2TextBlock}" /> <TextBlock Style="{StaticResource MaterialDesignSubtitle2TextBlock}" Text="Popup Content:" />
<ComboBox x:Name="ContentComboBox" /> <ComboBox x:Name="ContentComboBox" />
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
......
...@@ -205,10 +205,10 @@ ...@@ -205,10 +205,10 @@
VerticalContentAlignment="Top" VerticalContentAlignment="Top"
UniqueKey="fractionalPreviewRatingBar_3"> UniqueKey="fractionalPreviewRatingBar_3">
<materialDesign:RatingBar x:Name="BasicRatingBarFractionalPreview2" <materialDesign:RatingBar x:Name="BasicRatingBarFractionalPreview2"
InvertDirection="True"
IsPreviewValueEnabled="True" IsPreviewValueEnabled="True"
Max="5" Max="5"
Min="0" Min="0"
InvertDirection="True"
ValueIncrements="0.25" ValueIncrements="0.25"
Value="0" /> Value="0" />
</smtx:XamlDisplay> </smtx:XamlDisplay>
...@@ -219,11 +219,11 @@ ...@@ -219,11 +219,11 @@
<smtx:XamlDisplay Margin="24,0,0,5" UniqueKey="fractionalPreviewRatingBar_4"> <smtx:XamlDisplay Margin="24,0,0,5" UniqueKey="fractionalPreviewRatingBar_4">
<materialDesign:RatingBar x:Name="CustomRatingBarFractionalPreview2" <materialDesign:RatingBar x:Name="CustomRatingBarFractionalPreview2"
InvertDirection="True"
IsPreviewValueEnabled="True" IsPreviewValueEnabled="True"
Max="3" Max="3"
Min="0" Min="0"
Orientation="Vertical" Orientation="Vertical"
InvertDirection="True"
ValueIncrements="0.25" ValueIncrements="0.25"
Value="2"> Value="2">
<materialDesign:RatingBar.ValueItemTemplate> <materialDesign:RatingBar.ValueItemTemplate>
......
...@@ -69,10 +69,10 @@ ...@@ -69,10 +69,10 @@
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,16,0,0" UniqueKey="continuous_slider_h_5"> <smtx:XamlDisplay Margin="0,16,0,0" UniqueKey="continuous_slider_h_5">
<Slider Maximum="50" <Slider materialDesign:SliderAssist.HideActiveTrack="True"
Maximum="50"
Minimum="0" Minimum="0"
Value="35" Value="35" />
materialDesign:SliderAssist.HideActiveTrack="True" />
</smtx:XamlDisplay> </smtx:XamlDisplay>
</StackPanel> </StackPanel>
...@@ -119,11 +119,11 @@ ...@@ -119,11 +119,11 @@
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="16,0,0,0" UniqueKey="continuous_slider_v_5"> <smtx:XamlDisplay Margin="16,0,0,0" UniqueKey="continuous_slider_v_5">
<Slider Maximum="50" <Slider materialDesign:SliderAssist.HideActiveTrack="True"
Maximum="50"
Minimum="0" Minimum="0"
Orientation="Vertical" Orientation="Vertical"
Value="25" Value="25" />
materialDesign:SliderAssist.HideActiveTrack="True" />
</smtx:XamlDisplay> </smtx:XamlDisplay>
</StackPanel> </StackPanel>
...@@ -189,16 +189,16 @@ ...@@ -189,16 +189,16 @@
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,24,0,0" UniqueKey="discrete_slider_h_5"> <smtx:XamlDisplay Margin="0,24,0,0" UniqueKey="discrete_slider_h_5">
<Slider Maximum="{Binding DiscreteHorizontal.Maximum}" <Slider materialDesign:SliderAssist.HideActiveTrack="True"
Maximum="{Binding DiscreteHorizontal.Maximum}"
Minimum="0" Minimum="0"
Style="{StaticResource MaterialDesignDiscreteSlider}" Style="{StaticResource MaterialDesignDiscreteSlider}"
TickFrequency="{Binding DiscreteHorizontal.TickFrequency}" TickFrequency="{Binding DiscreteHorizontal.TickFrequency}"
TickPlacement="BottomRight" TickPlacement="BottomRight"
Value="40" Value="40" />
materialDesign:SliderAssist.HideActiveTrack="True" />
</smtx:XamlDisplay> </smtx:XamlDisplay>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
...@@ -297,14 +297,14 @@ ...@@ -297,14 +297,14 @@
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="20,0,0,0" UniqueKey="discrete_slider_v_7"> <smtx:XamlDisplay Margin="20,0,0,0" UniqueKey="discrete_slider_v_7">
<Slider Maximum="{Binding DiscreteVertical.Maximum}" <Slider materialDesign:SliderAssist.HideActiveTrack="True"
Maximum="{Binding DiscreteVertical.Maximum}"
Minimum="0" Minimum="0"
Orientation="Vertical" Orientation="Vertical"
Style="{StaticResource MaterialDesignDiscreteSlider}" Style="{StaticResource MaterialDesignDiscreteSlider}"
TickFrequency="{Binding DiscreteVertical.TickFrequency}" TickFrequency="{Binding DiscreteVertical.TickFrequency}"
TickPlacement="BottomRight" TickPlacement="BottomRight"
Value="70000" Value="70000" />
materialDesign:SliderAssist.HideActiveTrack="True" />
</smtx:XamlDisplay> </smtx:XamlDisplay>
</StackPanel> </StackPanel>
</Grid> </Grid>
......
此差异已折叠。
...@@ -316,17 +316,27 @@ ...@@ -316,17 +316,27 @@
Style="{StaticResource MaterialDesignHeadline5TextBlock}" Style="{StaticResource MaterialDesignHeadline5TextBlock}"
Text="Scrollable content" /> Text="Scrollable content" />
<smtx:XamlDisplay Margin="0,0,16,16" UniqueKey="tabs_scrollable_content" HorizontalAlignment="Left"> <smtx:XamlDisplay Margin="0,0,16,16"
<TabControl Width="500" HorizontalAlignment="Left"
Height="200"> UniqueKey="tabs_scrollable_content">
<TabControl Width="500" Height="200">
<TabItem Header="TAB 1"> <TabItem Header="TAB 1">
<ScrollViewer> <ScrollViewer>
<TextBlock Text="{Binding VeryLongText}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" TextWrapping="Wrap" /> <TextBlock HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Text="{Binding VeryLongText}"
TextWrapping="Wrap" />
</ScrollViewer> </ScrollViewer>
</TabItem> </TabItem>
<TabItem Header="TAB 2"> <TabItem Header="TAB 2">
<ScrollViewer> <ScrollViewer>
<TextBox Text="{Binding VeryLongText}" Style="{StaticResource MaterialDesignOutlinedTextBox}" AcceptsReturn="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" TextWrapping="Wrap" Margin="5" /> <TextBox Margin="5"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AcceptsReturn="True"
Style="{StaticResource MaterialDesignOutlinedTextBox}"
Text="{Binding VeryLongText}"
TextWrapping="Wrap" />
</ScrollViewer> </ScrollViewer>
</TabItem> </TabItem>
</TabControl> </TabControl>
...@@ -446,133 +456,132 @@ ...@@ -446,133 +456,132 @@
Text="Different sizes" /> Text="Different sizes" />
<StackPanel> <StackPanel>
<smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_19"> <smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_19">
<materialDesign:Card> <materialDesign:Card>
<TabControl HorizontalContentAlignment="Left"> <TabControl HorizontalContentAlignment="Left">
<TabItem Header="TAB1"> <TabItem Header="TAB1">
<TextBlock Margin="8" Text="Not filled, required width, tab 1" /> <TextBlock Margin="8" Text="Not filled, required width, tab 1" />
</TabItem> </TabItem>
<TabItem Header="TAB 2 Wide"> <TabItem Header="TAB 2 Wide">
<TextBlock Margin="8" Text="Not filled, required width, tab 2" /> <TextBlock Margin="8" Text="Not filled, required width, tab 2" />
</TabItem> </TabItem>
<TabItem Header="TAB 3 Extremely Wide"> <TabItem Header="TAB 3 Extremely Wide">
<TextBlock Margin="8" Text="Not filled, required width, tab 3" /> <TextBlock Margin="8" Text="Not filled, required width, tab 3" />
</TabItem> </TabItem>
<TabItem Header="TAB 4"> <TabItem Header="TAB 4">
<TextBlock Margin="8" Text="Not filled, required width, tab 4" /> <TextBlock Margin="8" Text="Not filled, required width, tab 4" />
</TabItem> </TabItem>
</TabControl> </TabControl>
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_20"> <smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_20">
<materialDesign:Card> <materialDesign:Card>
<TabControl HorizontalContentAlignment="Left" Style="{StaticResource MaterialDesignUniformTabControl}"> <TabControl HorizontalContentAlignment="Left" Style="{StaticResource MaterialDesignUniformTabControl}">
<TabItem Header="TAB1"> <TabItem Header="TAB1">
<TextBlock Margin="8" Text="Not filled, uniform width, tab 1" /> <TextBlock Margin="8" Text="Not filled, uniform width, tab 1" />
</TabItem> </TabItem>
<TabItem Header="TAB 2 Wide"> <TabItem Header="TAB 2 Wide">
<TextBlock Margin="8" Text="Not filled, uniform width, tab 2" /> <TextBlock Margin="8" Text="Not filled, uniform width, tab 2" />
</TabItem> </TabItem>
<TabItem Header="TAB 3 Extremely Wide"> <TabItem Header="TAB 3 Extremely Wide">
<TextBlock Margin="8" Text="Not filled, uniform width, tab 3" /> <TextBlock Margin="8" Text="Not filled, uniform width, tab 3" />
</TabItem> </TabItem>
<TabItem Header="TAB 4"> <TabItem Header="TAB 4">
<TextBlock Margin="8" Text="Not filled, uniform width, tab 4" /> <TextBlock Margin="8" Text="Not filled, uniform width, tab 4" />
</TabItem> </TabItem>
</TabControl> </TabControl>
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_21"> <smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_21">
<materialDesign:Card> <materialDesign:Card>
<TabControl HorizontalContentAlignment="Center" Style="{StaticResource MaterialDesignFilledTabControl}"> <TabControl HorizontalContentAlignment="Center" Style="{StaticResource MaterialDesignFilledTabControl}">
<TabItem Header="TAB1"> <TabItem Header="TAB1">
<TextBlock Margin="8" Text="Filled, centered, required width, tab 1" /> <TextBlock Margin="8" Text="Filled, centered, required width, tab 1" />
</TabItem> </TabItem>
<TabItem Header="TAB 2 Wide"> <TabItem Header="TAB 2 Wide">
<TextBlock Margin="8" Text="Filled, centered, required width, tab 2" /> <TextBlock Margin="8" Text="Filled, centered, required width, tab 2" />
</TabItem> </TabItem>
<TabItem Header="TAB 3 Extremely Wide"> <TabItem Header="TAB 3 Extremely Wide">
<TextBlock Margin="8" Text="Filled, centered, required width, tab 3" /> <TextBlock Margin="8" Text="Filled, centered, required width, tab 3" />
</TabItem> </TabItem>
<TabItem Header="TAB 4"> <TabItem Header="TAB 4">
<TextBlock Margin="8" Text="Filled, centered, required width, tab 4" /> <TextBlock Margin="8" Text="Filled, centered, required width, tab 4" />
</TabItem> </TabItem>
</TabControl> </TabControl>
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_22"> <smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_22">
<materialDesign:Card> <materialDesign:Card>
<TabControl HorizontalContentAlignment="Center" Style="{StaticResource MaterialDesignFilledUniformTabControl}"> <TabControl HorizontalContentAlignment="Center" Style="{StaticResource MaterialDesignFilledUniformTabControl}">
<TabItem Header="TAB1"> <TabItem Header="TAB1">
<TextBlock Margin="8" Text="Filled, centered, uniform width, tab 1" /> <TextBlock Margin="8" Text="Filled, centered, uniform width, tab 1" />
</TabItem> </TabItem>
<TabItem Header="TAB 2 Wide"> <TabItem Header="TAB 2 Wide">
<TextBlock Margin="8" Text="Filled, centered, uniform width, tab 2" /> <TextBlock Margin="8" Text="Filled, centered, uniform width, tab 2" />
</TabItem> </TabItem>
<TabItem Header="TAB 3 Extremely Wide"> <TabItem Header="TAB 3 Extremely Wide">
<TextBlock Margin="8" Text="Filled, centered, uniform width, tab 3" /> <TextBlock Margin="8" Text="Filled, centered, uniform width, tab 3" />
</TabItem> </TabItem>
<TabItem Header="TAB 4"> <TabItem Header="TAB 4">
<TextBlock Margin="8" Text="Filled, centered, uniform width, tab 4" /> <TextBlock Margin="8" Text="Filled, centered, uniform width, tab 4" />
</TabItem> </TabItem>
</TabControl> </TabControl>
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_23"> <smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_23">
<materialDesign:Card> <materialDesign:Card>
<TabControl HorizontalContentAlignment="Left" materialDesign:ColorZoneAssist.Mode="SecondaryMid"> <TabControl HorizontalContentAlignment="Left" materialDesign:ColorZoneAssist.Mode="SecondaryMid">
<TabItem Header="TAB1"> <TabItem Header="TAB1">
<TextBlock Margin="8" Text="Not filled secondary example tab 1" /> <TextBlock Margin="8" Text="Not filled secondary example tab 1" />
</TabItem> </TabItem>
<TabItem Header="TAB 2"> <TabItem Header="TAB 2">
<TextBlock Margin="8" Text="Not filled secondary example tab 2" /> <TextBlock Margin="8" Text="Not filled secondary example tab 2" />
</TabItem> </TabItem>
<TabItem Header="TAB 3333"> <TabItem Header="TAB 3333">
<TextBlock Margin="8" Text="Secondary example tab 3333" /> <TextBlock Margin="8" Text="Secondary example tab 3333" />
</TabItem> </TabItem>
<TabItem Header="TAB4 Wide"> <TabItem Header="TAB4 Wide">
<TextBlock Margin="8" Text="Secondary example tab 4 wide" /> <TextBlock Margin="8" Text="Secondary example tab 4 wide" />
</TabItem> </TabItem>
<TabItem Header="TABbbbbbbbbbbxxxxx 5"> <TabItem Header="TABbbbbbbbbbbxxxxx 5">
<TextBlock Margin="8" Text="Secondary example tab 5" /> <TextBlock Margin="8" Text="Secondary example tab 5" />
</TabItem> </TabItem>
<TabItem Header="TAB 6 Different Width"> <TabItem Header="TAB 6 Different Width">
<TextBlock Margin="8" Text="Secondary example tab 6 different width" /> <TextBlock Margin="8" Text="Secondary example tab 6 different width" />
</TabItem> </TabItem>
<TabItem Header="TAB 7 Looooong"> <TabItem Header="TAB 7 Looooong">
<TextBlock Margin="8" Text="Secondary example tab 7 looooong" /> <TextBlock Margin="8" Text="Secondary example tab 7 looooong" />
</TabItem> </TabItem>
<TabItem Header="TAB 8 Width"> <TabItem Header="TAB 8 Width">
<TextBlock Margin="8" Text="Secondary example tab 8 width" /> <TextBlock Margin="8" Text="Secondary example tab 8 width" />
</TabItem> </TabItem>
<TabItem Header="TAAX999"> <TabItem Header="TAAX999">
<TextBlock Margin="8" Text="Secondary example tab 9" /> <TextBlock Margin="8" Text="Secondary example tab 9" />
</TabItem> </TabItem>
<TabItem Header="Tab10"> <TabItem Header="Tab10">
<TextBlock Margin="8" Text="Secondary example tab 10" /> <TextBlock Margin="8" Text="Secondary example tab 10" />
</TabItem> </TabItem>
</TabControl> </TabControl>
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_24"> <smtx:XamlDisplay Margin="0,0,0,16" UniqueKey="tabs_24">
<materialDesign:Card> <materialDesign:Card>
<TabControl <TabControl HorizontalContentAlignment="Left"
HorizontalContentAlignment="Left" materialDesign:ColorZoneAssist.Mode="SecondaryMid"
materialDesign:ColorZoneAssist.Mode="SecondaryMid" Style="{StaticResource MaterialDesignFilledTabControl}">
Style="{StaticResource MaterialDesignFilledTabControl}"> <TabItem Header="TAB1">
<TabItem Header="TAB1"> <TextBlock Margin="8" Text="Secondary filled example tab 1" />
<TextBlock Margin="8" Text="Secondary filled example tab 1" /> </TabItem>
</TabItem> <TabItem Header="TAB 2">
<TabItem Header="TAB 2"> <TextBlock Margin="8" Text="Secondary filled example tab 2" />
<TextBlock Margin="8" Text="Secondary filled example tab 2" /> </TabItem>
</TabItem> </TabControl>
</TabControl> </materialDesign:Card>
</materialDesign:Card> </smtx:XamlDisplay>
</smtx:XamlDisplay> </StackPanel>
</StackPanel>
<TextBlock Margin="0,15,0,20" <TextBlock Margin="0,15,0,20"
Style="{StaticResource MaterialDesignHeadline5TextBlock}" Style="{StaticResource MaterialDesignHeadline5TextBlock}"
...@@ -584,17 +593,19 @@ ...@@ -584,17 +593,19 @@
ItemsSource="{Binding CustomTabs}" ItemsSource="{Binding CustomTabs}"
SelectedItem="{Binding SelectedTab}"> SelectedItem="{Binding SelectedTab}">
<!-- <!--
If you use DisplayMemberPath to bind to a simple auto property you can cause a binking leak. If you use DisplayMemberPath to bind to a simple auto property you can cause a binking leak.
See: https://blog.jetbrains.com/dotnet/2014/09/04/fighting-common-wpf-memory-leaks-with-dotmemory/ See: https://blog.jetbrains.com/dotnet/2014/09/04/fighting-common-wpf-memory-leaks-with-dotmemory/
--> -->
<TabControl.ItemTemplate> <TabControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding CustomHeader}"/> <TextBlock Text="{Binding CustomHeader}" />
<Button Command="{Binding CloseCommand}"> <Button Command="{Binding CloseCommand}">
<Button.Template> <Button.Template>
<ControlTemplate> <ControlTemplate>
<materialDesign:PackIcon Kind="Close" Foreground="Red" Background="Transparent"/> <materialDesign:PackIcon Background="Transparent"
Foreground="Red"
Kind="Close" />
</ControlTemplate> </ControlTemplate>
</Button.Template> </Button.Template>
</Button> </Button>
...@@ -605,7 +616,7 @@ ...@@ -605,7 +616,7 @@
<DataTemplate DataType="domain:CustomTab"> <DataTemplate DataType="domain:CustomTab">
<TextBlock Margin="10" <TextBlock Margin="10"
FontSize="18" FontSize="18"
Text="{Binding CustomContent, Mode=OneTime}" /> Text="{Binding CustomContent}" />
</DataTemplate> </DataTemplate>
</TabControl.ContentTemplate> </TabControl.ContentTemplate>
</TabControl> </TabControl>
......
<UserControl x:Class="MaterialDesignDemo.Toggles" <UserControl x:Class="MaterialDesignDemo.Toggles"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
...@@ -264,8 +264,8 @@ ...@@ -264,8 +264,8 @@
<smtx:XamlDisplay Margin="8,0,0,0" <smtx:XamlDisplay Margin="8,0,0,0"
VerticalAlignment="Center" VerticalAlignment="Center"
UniqueKey="buttons_64"> UniqueKey="buttons_64">
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" <ToggleButton Width="60"
Width="60" Style="{StaticResource MaterialDesignSwitchToggleButton}"
ToolTip="MaterialDesignSwitchToggleButton with Custom Track Background"> ToolTip="MaterialDesignSwitchToggleButton with Custom Track Background">
<materialDesign:ToggleButtonAssist.SwitchTrackOnBackground> <materialDesign:ToggleButtonAssist.SwitchTrackOnBackground>
<SolidColorBrush Color="Green" /> <SolidColorBrush Color="Green" />
...@@ -367,10 +367,10 @@ ...@@ -367,10 +367,10 @@
<TextBlock Text="ListBoxAssist.IsToggle allows more natural toggle behaviour" /> <TextBlock Text="ListBoxAssist.IsToggle allows more natural toggle behaviour" />
</StackPanel> </StackPanel>
</ListBox.ToolTip> </ListBox.ToolTip>
<ListBoxItem Content="{materialDesign:PackIcon Kind=FormatBold}" /> <ListBoxItem Content="{materialDesign:PackIcon Kind=FormatBold}" />
<ListBoxItem Content="{materialDesign:PackIcon Kind=FormatItalic}" /> <ListBoxItem Content="{materialDesign:PackIcon Kind=FormatItalic}" />
<ListBoxItem Content="{materialDesign:PackIcon Kind=FormatUnderline}" /> <ListBoxItem Content="{materialDesign:PackIcon Kind=FormatUnderline}" />
</ListBox> </ListBox>
</smtx:XamlDisplay> </smtx:XamlDisplay>
......
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
<materialDesign:TransitionerSlide> <materialDesign:TransitionerSlide>
<Border Background="#009688"> <Border Background="#009688">
<TextBlock Margin="24" <TextBlock Margin="24"
Foreground="Azure" Foreground="Azure"
TextWrapping="Wrap"> TextWrapping="Wrap">
You can set .DefaultTransitionOrigin, to help with transitions such as the circle wipe, which are triggered from code. You can set .DefaultTransitionOrigin, to help with transitions such as the circle wipe, which are triggered from code.
</TextBlock> </TextBlock>
</Border> </Border>
</materialDesign:TransitionerSlide> </materialDesign:TransitionerSlide>
......
...@@ -52,9 +52,9 @@ ...@@ -52,9 +52,9 @@
</materialDesign:TransitionerSlide> </materialDesign:TransitionerSlide>
<!-- now we are going to slide this in by combining some extra effects. the inner content slides in, so we'll set the outer background and clip, to keep things nice --> <!-- now we are going to slide this in by combining some extra effects. the inner content slides in, so we'll set the outer background and clip, to keep things nice -->
<materialDesign:TransitionerSlide Background="{DynamicResource MaterialDesignDarkBackground}" <materialDesign:TransitionerSlide Background="{DynamicResource MaterialDesign.Brush.Background}"
ClipToBounds="True" ClipToBounds="True"
Foreground="{DynamicResource MaterialDesignDarkForeground}"> Foreground="{DynamicResource MaterialDesign.Brush.Foreground}">
<materialDesign:TransitionerSlide.OpeningEffects> <materialDesign:TransitionerSlide.OpeningEffects>
<materialDesign:TransitionEffect Kind="SlideInFromLeft" Duration="0:0:0.8" /> <materialDesign:TransitionEffect Kind="SlideInFromLeft" Duration="0:0:0.8" />
<materialDesign:TransitionEffect Kind="SlideInFromBottom" <materialDesign:TransitionEffect Kind="SlideInFromBottom"
......
...@@ -134,8 +134,7 @@ ...@@ -134,8 +134,7 @@
<Setter Property="materialDesign:TreeViewAssist.ExpanderSize" Value="32" /> <Setter Property="materialDesign:TreeViewAssist.ExpanderSize" Value="32" />
<Setter Property="materialDesign:TreeViewAssist.ShowSelection" Value="False" /> <Setter Property="materialDesign:TreeViewAssist.ShowSelection" Value="False" />
</Style> </Style>
<HierarchicalDataTemplate DataType="{x:Type domain:MovieCategory}" <HierarchicalDataTemplate DataType="{x:Type domain:MovieCategory}" ItemsSource="{Binding Movies, Mode=OneTime}">
ItemsSource="{Binding Movies, Mode=OneTime}">
<TextBlock Margin="3,2" Text="{Binding Name, Mode=OneTime}" /> <TextBlock Margin="3,2" Text="{Binding Name, Mode=OneTime}" />
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
......
...@@ -137,7 +137,6 @@ ...@@ -137,7 +137,6 @@
<Setter Property="materialDesign:ElevationAssist.Elevation" Value="Dp0" /> <Setter Property="materialDesign:ElevationAssist.Elevation" Value="Dp0" />
<Setter Property="materialDesign:RippleAssist.Feedback" Value="LightGray" /> <Setter Property="materialDesign:RippleAssist.Feedback" Value="LightGray" />
<Setter Property="materialDesign:RippleAssist.RippleOnTop" Value="True" /> <Setter Property="materialDesign:RippleAssist.RippleOnTop" Value="True" />
<Setter Property="materialDesign:ShadowAssist.ShadowEdges" Value="All" />
</Style> </Style>
</Grid.Resources> </Grid.Resources>
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<DockPanel> <DockPanel>
<ToggleButton VerticalAlignment="Center" <ToggleButton VerticalAlignment="Center"
DockPanel.Dock="Right" DockPanel.Dock="Right"
Style="{StaticResource MaterialDesignSwitchAccentToggleButton}" /> Style="{StaticResource MaterialDesignSwitchSecondaryToggleButton}" />
<StackPanel materialDesign:RippleAssist.IsCentered="True" Orientation="Horizontal"> <StackPanel materialDesign:RippleAssist.IsCentered="True" Orientation="Horizontal">
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}" /> <ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}" />
......
...@@ -103,7 +103,6 @@ ...@@ -103,7 +103,6 @@
</StackPanel.Resources> </StackPanel.Resources>
<smtx:XamlDisplay Margin="0" UniqueKey="comboboxes_9"> <smtx:XamlDisplay Margin="0" UniqueKey="comboboxes_9">
<StackPanel> <StackPanel>
<CheckBox x:Name="DisplaySelectedItemCheckBox" <CheckBox x:Name="DisplaySelectedItemCheckBox"
Margin="0,8,0,0" Margin="0,8,0,0"
...@@ -118,23 +117,6 @@ ...@@ -118,23 +117,6 @@
</ComboBox> </ComboBox>
</StackPanel> </StackPanel>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay UniqueKey="comboboxes_10">
<StackPanel>
<CheckBox x:Name="ClassicModeCheckBox"
Content="Use classic mode"
IsChecked="True"
IsThreeState="False" />
<ComboBox materialDesign:ComboBoxAssist.ClassicMode="{Binding ElementName=ClassicModeCheckBox, Path=IsChecked}">
<ComboBoxItem Content="Apple" IsSelected="True" />
<ComboBoxItem Content="Banana" />
<ComboBoxItem Content="Pear" />
<ComboBoxItem Content="Orange" />
</ComboBox>
</StackPanel>
</smtx:XamlDisplay>
</StackPanel> </StackPanel>
<Rectangle Height="1" <Rectangle Height="1"
...@@ -338,4 +320,4 @@ ...@@ -338,4 +320,4 @@
</smtx:XamlDisplay> </smtx:XamlDisplay>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</UserControl> </UserControl>
\ No newline at end of file
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<StackPanel> <StackPanel>
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="Custom Columns" /> <TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="Custom Columns" />
<FrameworkElement x:Name="DataContextProxy" DataContext="{Binding}"/> <FrameworkElement x:Name="DataContextProxy" DataContext="{Binding}" />
<smtx:XamlDisplay UniqueKey="grids_1"> <smtx:XamlDisplay UniqueKey="grids_1">
<DataGrid AutoGenerateColumns="False" <DataGrid AutoGenerateColumns="False"
......
...@@ -2,199 +2,197 @@ ...@@ -2,199 +2,197 @@
using MaterialDesignColors; using MaterialDesignColors;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
namespace MaterialDesign3Demo.Domain namespace MaterialDesign3Demo.Domain;
internal class ColorToolViewModel : ViewModelBase
{ {
internal class ColorToolViewModel : ViewModelBase private readonly PaletteHelper _paletteHelper = new PaletteHelper();
{
private readonly PaletteHelper _paletteHelper = new PaletteHelper();
private ColorScheme _activeScheme; private ColorScheme _activeScheme;
public ColorScheme ActiveScheme public ColorScheme ActiveScheme
{
get => _activeScheme;
set
{ {
get => _activeScheme; if (_activeScheme != value)
set
{ {
if (_activeScheme != value) _activeScheme = value;
{ OnPropertyChanged();
_activeScheme = value;
OnPropertyChanged();
}
} }
} }
}
private Color? _selectedColor; private Color? _selectedColor;
public Color? SelectedColor public Color? SelectedColor
{
get => _selectedColor;
set
{ {
get => _selectedColor; if (_selectedColor != value)
set
{ {
if (_selectedColor != value) _selectedColor = value;
OnPropertyChanged();
// if we are triggering a change internally its a hue change and the colors will match
// so we don't want to trigger a custom color change.
var currentSchemeColor = ActiveScheme switch
{ {
_selectedColor = value; ColorScheme.Primary => _primaryColor,
OnPropertyChanged(); ColorScheme.Secondary => _secondaryColor,
ColorScheme.PrimaryForeground => _primaryForegroundColor,
// if we are triggering a change internally its a hue change and the colors will match ColorScheme.SecondaryForeground => _secondaryForegroundColor,
// so we don't want to trigger a custom color change. _ => throw new NotSupportedException($"{ActiveScheme} is not a handled ColorScheme.. Ye daft programmer!")
var currentSchemeColor = ActiveScheme switch };
{
ColorScheme.Primary => _primaryColor, if (_selectedColor != currentSchemeColor && value is Color color)
ColorScheme.Secondary => _secondaryColor, {
ColorScheme.PrimaryForeground => _primaryForegroundColor, ChangeCustomColor(color);
ColorScheme.SecondaryForeground => _secondaryForegroundColor,
_ => throw new NotSupportedException($"{ActiveScheme} is not a handled ColorScheme.. Ye daft programmer!")
};
if (_selectedColor != currentSchemeColor && value is Color color)
{
ChangeCustomColor(color);
}
} }
} }
} }
}
public IEnumerable<ISwatch> Swatches { get; } = SwatchHelper.Swatches; public IEnumerable<ISwatch> Swatches { get; } = SwatchHelper.Swatches;
public ICommand ChangeCustomHueCommand { get; } public ICommand ChangeCustomHueCommand { get; }
public ICommand ChangeHueCommand { get; } public ICommand ChangeHueCommand { get; }
public ICommand ChangeToPrimaryCommand { get; } public ICommand ChangeToPrimaryCommand { get; }
public ICommand ChangeToSecondaryCommand { get; } public ICommand ChangeToSecondaryCommand { get; }
public ICommand ChangeToPrimaryForegroundCommand { get; } public ICommand ChangeToPrimaryForegroundCommand { get; }
public ICommand ChangeToSecondaryForegroundCommand { get; } public ICommand ChangeToSecondaryForegroundCommand { get; }
public ICommand ToggleBaseCommand { get; } public ICommand ToggleBaseCommand { get; }
private void ApplyBase(bool isDark) private void ApplyBase(bool isDark)
{ {
ITheme theme = _paletteHelper.GetTheme(); Theme theme = _paletteHelper.GetTheme();
IBaseTheme baseTheme = isDark ? new MaterialDesignDarkTheme() : new MaterialDesignLightTheme(); theme.SetBaseTheme(isDark ? BaseTheme.Dark : BaseTheme.Light);
theme.SetBaseTheme(baseTheme); _paletteHelper.SetTheme(theme);
_paletteHelper.SetTheme(theme); }
}
public ColorToolViewModel() public ColorToolViewModel()
{ {
ToggleBaseCommand = new AnotherCommandImplementation(o => ApplyBase((bool)o!)); ToggleBaseCommand = new AnotherCommandImplementation(o => ApplyBase((bool)o!));
ChangeHueCommand = new AnotherCommandImplementation(ChangeHue); ChangeHueCommand = new AnotherCommandImplementation(ChangeHue);
ChangeCustomHueCommand = new AnotherCommandImplementation(ChangeCustomColor); ChangeCustomHueCommand = new AnotherCommandImplementation(ChangeCustomColor);
ChangeToPrimaryCommand = new AnotherCommandImplementation(o => ChangeScheme(ColorScheme.Primary)); ChangeToPrimaryCommand = new AnotherCommandImplementation(o => ChangeScheme(ColorScheme.Primary));
ChangeToSecondaryCommand = new AnotherCommandImplementation(o => ChangeScheme(ColorScheme.Secondary)); ChangeToSecondaryCommand = new AnotherCommandImplementation(o => ChangeScheme(ColorScheme.Secondary));
ChangeToPrimaryForegroundCommand = new AnotherCommandImplementation(o => ChangeScheme(ColorScheme.PrimaryForeground)); ChangeToPrimaryForegroundCommand = new AnotherCommandImplementation(o => ChangeScheme(ColorScheme.PrimaryForeground));
ChangeToSecondaryForegroundCommand = new AnotherCommandImplementation(o => ChangeScheme(ColorScheme.SecondaryForeground)); ChangeToSecondaryForegroundCommand = new AnotherCommandImplementation(o => ChangeScheme(ColorScheme.SecondaryForeground));
ITheme theme = _paletteHelper.GetTheme(); Theme theme = _paletteHelper.GetTheme();
_primaryColor = theme.PrimaryMid.Color; _primaryColor = theme.PrimaryMid.Color;
_secondaryColor = theme.SecondaryMid.Color; _secondaryColor = theme.SecondaryMid.Color;
SelectedColor = _primaryColor; SelectedColor = _primaryColor;
} }
private void ChangeCustomColor(object? obj) private void ChangeCustomColor(object? obj)
{ {
var color = (Color)obj!; var color = (Color)obj!;
if (ActiveScheme == ColorScheme.Primary) if (ActiveScheme == ColorScheme.Primary)
{ {
_paletteHelper.ChangePrimaryColor(color); _paletteHelper.ChangePrimaryColor(color);
_primaryColor = color; _primaryColor = color;
}
else if (ActiveScheme == ColorScheme.Secondary)
{
_paletteHelper.ChangeSecondaryColor(color);
_secondaryColor = color;
}
else if (ActiveScheme == ColorScheme.PrimaryForeground)
{
SetPrimaryForegroundToSingleColor(color);
_primaryForegroundColor = color;
}
else if (ActiveScheme == ColorScheme.SecondaryForeground)
{
SetSecondaryForegroundToSingleColor(color);
_secondaryForegroundColor = color;
}
} }
else if (ActiveScheme == ColorScheme.Secondary)
{
_paletteHelper.ChangeSecondaryColor(color);
_secondaryColor = color;
}
else if (ActiveScheme == ColorScheme.PrimaryForeground)
{
SetPrimaryForegroundToSingleColor(color);
_primaryForegroundColor = color;
}
else if (ActiveScheme == ColorScheme.SecondaryForeground)
{
SetSecondaryForegroundToSingleColor(color);
_secondaryForegroundColor = color;
}
}
private void ChangeScheme(ColorScheme scheme) private void ChangeScheme(ColorScheme scheme)
{
ActiveScheme = scheme;
if (ActiveScheme == ColorScheme.Primary)
{ {
ActiveScheme = scheme; SelectedColor = _primaryColor;
if (ActiveScheme == ColorScheme.Primary) }
{ else if (ActiveScheme == ColorScheme.Secondary)
SelectedColor = _primaryColor; {
} SelectedColor = _secondaryColor;
else if (ActiveScheme == ColorScheme.Secondary) }
{ else if (ActiveScheme == ColorScheme.PrimaryForeground)
SelectedColor = _secondaryColor; {
} SelectedColor = _primaryForegroundColor;
else if (ActiveScheme == ColorScheme.PrimaryForeground) }
{ else if (ActiveScheme == ColorScheme.SecondaryForeground)
SelectedColor = _primaryForegroundColor; {
} SelectedColor = _secondaryForegroundColor;
else if (ActiveScheme == ColorScheme.SecondaryForeground)
{
SelectedColor = _secondaryForegroundColor;
}
} }
}
private Color? _primaryColor; private Color? _primaryColor;
private Color? _secondaryColor; private Color? _secondaryColor;
private Color? _primaryForegroundColor; private Color? _primaryForegroundColor;
private Color? _secondaryForegroundColor; private Color? _secondaryForegroundColor;
private void ChangeHue(object? obj) private void ChangeHue(object? obj)
{ {
var hue = (Color)obj!; var hue = (Color)obj!;
SelectedColor = hue; SelectedColor = hue;
if (ActiveScheme == ColorScheme.Primary) if (ActiveScheme == ColorScheme.Primary)
{ {
_paletteHelper.ChangePrimaryColor(hue); _paletteHelper.ChangePrimaryColor(hue);
_primaryColor = hue; _primaryColor = hue;
_primaryForegroundColor = _paletteHelper.GetTheme().PrimaryMid.GetForegroundColor(); _primaryForegroundColor = _paletteHelper.GetTheme().PrimaryMid.GetForegroundColor();
}
else if (ActiveScheme == ColorScheme.Secondary)
{
_paletteHelper.ChangeSecondaryColor(hue);
_secondaryColor = hue;
_secondaryForegroundColor = _paletteHelper.GetTheme().SecondaryMid.GetForegroundColor();
}
else if (ActiveScheme == ColorScheme.PrimaryForeground)
{
SetPrimaryForegroundToSingleColor(hue);
_primaryForegroundColor = hue;
}
else if (ActiveScheme == ColorScheme.SecondaryForeground)
{
SetSecondaryForegroundToSingleColor(hue);
_secondaryForegroundColor = hue;
}
} }
else if (ActiveScheme == ColorScheme.Secondary)
private void SetPrimaryForegroundToSingleColor(Color color) {
_paletteHelper.ChangeSecondaryColor(hue);
_secondaryColor = hue;
_secondaryForegroundColor = _paletteHelper.GetTheme().SecondaryMid.GetForegroundColor();
}
else if (ActiveScheme == ColorScheme.PrimaryForeground)
{
SetPrimaryForegroundToSingleColor(hue);
_primaryForegroundColor = hue;
}
else if (ActiveScheme == ColorScheme.SecondaryForeground)
{ {
ITheme theme = _paletteHelper.GetTheme(); SetSecondaryForegroundToSingleColor(hue);
_secondaryForegroundColor = hue;
}
}
theme.PrimaryLight = new ColorPair(theme.PrimaryLight.Color, color); private void SetPrimaryForegroundToSingleColor(Color color)
theme.PrimaryMid = new ColorPair(theme.PrimaryMid.Color, color); {
theme.PrimaryDark = new ColorPair(theme.PrimaryDark.Color, color); Theme theme = _paletteHelper.GetTheme();
_paletteHelper.SetTheme(theme); theme.PrimaryLight = new ColorPair(theme.PrimaryLight.Color, color);
} theme.PrimaryMid = new ColorPair(theme.PrimaryMid.Color, color);
theme.PrimaryDark = new ColorPair(theme.PrimaryDark.Color, color);
private void SetSecondaryForegroundToSingleColor(Color color) _paletteHelper.SetTheme(theme);
{ }
ITheme theme = _paletteHelper.GetTheme();
private void SetSecondaryForegroundToSingleColor(Color color)
{
Theme theme = _paletteHelper.GetTheme();
theme.SecondaryLight = new ColorPair(theme.SecondaryLight.Color, color); theme.SecondaryLight = new ColorPair(theme.SecondaryLight.Color, color);
theme.SecondaryMid = new ColorPair(theme.SecondaryMid.Color, color); theme.SecondaryMid = new ColorPair(theme.SecondaryMid.Color, color);
theme.SecondaryDark = new ColorPair(theme.SecondaryDark.Color, color); theme.SecondaryDark = new ColorPair(theme.SecondaryDark.Color, color);
_paletteHelper.SetTheme(theme); _paletteHelper.SetTheme(theme);
}
} }
} }
...@@ -4,177 +4,176 @@ ...@@ -4,177 +4,176 @@
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using Microsoft.Win32; using Microsoft.Win32;
namespace MaterialDesign3Demo.Domain namespace MaterialDesign3Demo.Domain;
public class IconPackViewModel : ViewModelBase
{ {
public class IconPackViewModel : ViewModelBase private readonly Lazy<IEnumerable<PackIconKindGroup>> _packIconKinds;
{ private readonly ISnackbarMessageQueue _snackbarMessageQueue;
private readonly Lazy<IEnumerable<PackIconKindGroup>> _packIconKinds;
private readonly ISnackbarMessageQueue _snackbarMessageQueue;
public IconPackViewModel(ISnackbarMessageQueue snackbarMessageQueue) public IconPackViewModel(ISnackbarMessageQueue snackbarMessageQueue)
{ {
_snackbarMessageQueue = snackbarMessageQueue ?? throw new ArgumentNullException(nameof(snackbarMessageQueue)); _snackbarMessageQueue = snackbarMessageQueue ?? throw new ArgumentNullException(nameof(snackbarMessageQueue));
OpenDotComCommand = new AnotherCommandImplementation(OpenDotCom); OpenDotComCommand = new AnotherCommandImplementation(OpenDotCom);
SearchCommand = new AnotherCommandImplementation(Search); SearchCommand = new AnotherCommandImplementation(Search);
CopyToClipboardCommand = new AnotherCommandImplementation(CopyToClipboard); CopyToClipboardCommand = new AnotherCommandImplementation(CopyToClipboard);
_packIconKinds = new Lazy<IEnumerable<PackIconKindGroup>>(() => _packIconKinds = new Lazy<IEnumerable<PackIconKindGroup>>(() =>
Enum.GetNames(typeof(PackIconKind)) Enum.GetNames(typeof(PackIconKind))
.GroupBy(k => (PackIconKind)Enum.Parse(typeof(PackIconKind), k)) .GroupBy(k => (PackIconKind)Enum.Parse(typeof(PackIconKind), k))
.Select(g => new PackIconKindGroup(g)) .Select(g => new PackIconKindGroup(g))
.OrderBy(x => x.Kind) .OrderBy(x => x.Kind)
.ToList()); .ToList());
var helper = new PaletteHelper(); var helper = new PaletteHelper();
if (helper.GetThemeManager() is { } themeManager) if (helper.GetThemeManager() is { } themeManager)
{ {
themeManager.ThemeChanged += ThemeManager_ThemeChanged; themeManager.ThemeChanged += ThemeManager_ThemeChanged;
}
SetDefaultIconColors();
} }
SetDefaultIconColors();
}
private void ThemeManager_ThemeChanged(object? sender, ThemeChangedEventArgs e) private void ThemeManager_ThemeChanged(object? sender, ThemeChangedEventArgs e)
=> SetDefaultIconColors(); => SetDefaultIconColors();
public ICommand OpenDotComCommand { get; } public ICommand OpenDotComCommand { get; }
public ICommand SearchCommand { get; } public ICommand SearchCommand { get; }
public ICommand CopyToClipboardCommand { get; } public ICommand CopyToClipboardCommand { get; }
private IEnumerable<PackIconKindGroup>? _kinds; private IEnumerable<PackIconKindGroup>? _kinds;
private PackIconKindGroup? _group; private PackIconKindGroup? _group;
private string? _kind; private string? _kind;
private PackIconKind _packIconKind; private PackIconKind _packIconKind;
public IEnumerable<PackIconKindGroup> Kinds public IEnumerable<PackIconKindGroup> Kinds
{ {
get => _kinds ??= _packIconKinds.Value; get => _kinds ??= _packIconKinds.Value;
set => SetProperty(ref _kinds, value); set => SetProperty(ref _kinds, value);
} }
public PackIconKindGroup? Group public PackIconKindGroup? Group
{
get => _group;
set
{ {
get => _group; if (SetProperty(ref _group, value))
set
{ {
if (SetProperty(ref _group, value)) Kind = value?.Kind;
{
Kind = value?.Kind;
}
} }
} }
}
public string? Kind public string? Kind
{
get => _kind;
set
{ {
get => _kind; if (SetProperty(ref _kind, value))
set
{ {
if (SetProperty(ref _kind, value)) PackIconKind = value != null ? (PackIconKind)Enum.Parse(typeof(PackIconKind), value) : default;
{
PackIconKind = value != null ? (PackIconKind)Enum.Parse(typeof(PackIconKind), value) : default;
}
} }
} }
}
public PackIconKind PackIconKind public PackIconKind PackIconKind
{ {
get => _packIconKind; get => _packIconKind;
set => SetProperty(ref _packIconKind, value); set => SetProperty(ref _packIconKind, value);
} }
private void OpenDotCom(object? _) private void OpenDotCom(object? _)
=> Link.OpenInBrowser("https://materialdesignicons.com/"); => Link.OpenInBrowser("https://materialdesignicons.com/");
private async void Search(object? obj) private async void Search(object? obj)
{
var text = obj as string;
if (string.IsNullOrWhiteSpace(text))
{ {
var text = obj as string; Kinds = _packIconKinds.Value;
if (string.IsNullOrWhiteSpace(text))
{
Kinds = _packIconKinds.Value;
}
else
{
Kinds = await Task.Run(() => _packIconKinds.Value
.Where(x => x.Aliases.Any(a => a.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0))
.ToList());
}
} }
else
private void CopyToClipboard(object? obj)
{ {
var toBeCopied = $"<materialDesign:PackIcon Kind=\"{obj}\" />"; Kinds = await Task.Run(() => _packIconKinds.Value
Clipboard.SetDataObject(toBeCopied); .Where(x => x.Aliases.Any(a => a.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0))
_snackbarMessageQueue.Enqueue(toBeCopied + " copied to clipboard"); .ToList());
} }
}
private void SetDefaultIconColors() private void CopyToClipboard(object? obj)
{ {
var helper = new PaletteHelper(); var toBeCopied = $"<materialDesign:PackIcon Kind=\"{obj}\" />";
ITheme theme = helper.GetTheme(); Clipboard.SetDataObject(toBeCopied);
GeneratedIconBackground = theme.Paper; _snackbarMessageQueue.Enqueue(toBeCopied + " copied to clipboard");
GeneratedIconForeground = theme.PrimaryMid.Color; }
}
private Color _generatedIconBackground; private void SetDefaultIconColors()
public Color GeneratedIconBackground {
{ var helper = new PaletteHelper();
get => _generatedIconBackground; Theme theme = helper.GetTheme();
set => SetProperty(ref _generatedIconBackground, value); GeneratedIconBackground = theme.Background;
} GeneratedIconForeground = theme.PrimaryMid.Color;
}
private Color _generatedIconBackground;
public Color GeneratedIconBackground
{
get => _generatedIconBackground;
set => SetProperty(ref _generatedIconBackground, value);
}
private Color _generatedIconForeground; private Color _generatedIconForeground;
public Color GeneratedIconForeground public Color GeneratedIconForeground
{
get => _generatedIconForeground;
set => SetProperty(ref _generatedIconForeground, value);
}
private ICommand? _saveIconCommand;
public ICommand SaveIconCommand => _saveIconCommand ??= new AnotherCommandImplementation(OnSaveIcon);
private void OnSaveIcon(object? _)
{
var saveDialog = new SaveFileDialog
{
DefaultExt = ".ico",
Title = "Save Icon (.ico)",
Filter = "Icon Files|*.ico|All Files|*",
CheckPathExists = true,
OverwritePrompt = true,
RestoreDirectory = true
};
if (saveDialog.ShowDialog() != true) return;
var icon = new Icon();
//TODO: Make this size list configurable
foreach (var size in new[] { 256, 128, 64, 48, 32, 24, 16 })
{ {
get => _generatedIconForeground; RenderTargetBitmap bmp = RenderImage(size);
set => SetProperty(ref _generatedIconForeground, value); icon.Images.Add(new BmpIconImage(bmp));
} }
private ICommand? _saveIconCommand; icon.Save(saveDialog.FileName);
public ICommand SaveIconCommand => _saveIconCommand ??= new AnotherCommandImplementation(OnSaveIcon);
private void OnSaveIcon(object? _) RenderTargetBitmap RenderImage(int size)
{ {
var saveDialog = new SaveFileDialog var packIcon = new PackIcon
{ {
DefaultExt = ".ico", Kind = PackIconKind,
Title = "Save Icon (.ico)", Background = new SolidColorBrush(GeneratedIconBackground),
Filter = "Icon Files|*.ico|All Files|*", Foreground = new SolidColorBrush(GeneratedIconForeground),
CheckPathExists = true, Width = size,
OverwritePrompt = true, Height = size,
RestoreDirectory = true Style = (Style)Application.Current.FindResource(typeof(PackIcon))
}; };
if (saveDialog.ShowDialog() != true) return; packIcon.Measure(new Size(size, size));
packIcon.Arrange(new Rect(0, 0, size, size));
var icon = new Icon(); packIcon.UpdateLayout();
//TODO: Make this size list configurable RenderTargetBitmap bmp = new(size, size, 96, 96, PixelFormats.Pbgra32);
foreach (var size in new[] { 256, 128, 64, 48, 32, 24, 16 }) bmp.Render(packIcon);
{ return bmp;
RenderTargetBitmap bmp = RenderImage(size);
icon.Images.Add(new BmpIconImage(bmp));
}
icon.Save(saveDialog.FileName);
RenderTargetBitmap RenderImage(int size)
{
var packIcon = new PackIcon
{
Kind = PackIconKind,
Background = new SolidColorBrush(GeneratedIconBackground),
Foreground = new SolidColorBrush(GeneratedIconForeground),
Width = size,
Height = size,
Style = (Style)Application.Current.FindResource(typeof(PackIcon))
};
packIcon.Measure(new Size(size, size));
packIcon.Arrange(new Rect(0, 0, size, size));
packIcon.UpdateLayout();
RenderTargetBitmap bmp = new(size, size, 96, 96, PixelFormats.Pbgra32);
bmp.Render(packIcon);
return bmp;
}
} }
} }
} }
using MaterialDesignColors; using MaterialDesignColors;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
namespace MaterialDesign3Demo.Domain namespace MaterialDesign3Demo.Domain;
public class PaletteSelectorViewModel : ViewModelBase
{ {
public class PaletteSelectorViewModel : ViewModelBase public PaletteSelectorViewModel()
{ {
public PaletteSelectorViewModel() Swatches = new SwatchesProvider().Swatches;
{ }
Swatches = new SwatchesProvider().Swatches;
}
public IEnumerable<Swatch> Swatches { get; } public IEnumerable<Swatch> Swatches { get; }
public ICommand ApplyPrimaryCommand { get; } = new AnotherCommandImplementation(o => ApplyPrimary((Swatch)o!)); public ICommand ApplyPrimaryCommand { get; } = new AnotherCommandImplementation(o => ApplyPrimary((Swatch)o!));
private static void ApplyPrimary(Swatch swatch) private static void ApplyPrimary(Swatch swatch)
=> ModifyTheme(theme => theme.SetPrimaryColor(swatch.ExemplarHue.Color)); => ModifyTheme(theme => theme.SetPrimaryColor(swatch.ExemplarHue.Color));
public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o!)); public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o!));
private static void ApplyAccent(Swatch swatch) private static void ApplyAccent(Swatch swatch)
{
if (swatch is { AccentExemplarHue: not null })
{ {
if (swatch is { AccentExemplarHue: not null }) ModifyTheme(theme => theme.SetSecondaryColor(swatch.AccentExemplarHue.Color));
{
ModifyTheme(theme => theme.SetSecondaryColor(swatch.AccentExemplarHue.Color));
}
} }
}
private static void ModifyTheme(Action<ITheme> modificationAction) private static void ModifyTheme(Action<Theme> modificationAction)
{ {
var paletteHelper = new PaletteHelper(); var paletteHelper = new PaletteHelper();
ITheme theme = paletteHelper.GetTheme(); Theme theme = paletteHelper.GetTheme();
modificationAction?.Invoke(theme); modificationAction?.Invoke(theme);
paletteHelper.SetTheme(theme); paletteHelper.SetTheme(theme);
}
} }
} }
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
namespace MaterialDesign3Demo.Domain namespace MaterialDesign3Demo.Domain;
public class ThemeSettingsViewModel : ViewModelBase
{ {
public class ThemeSettingsViewModel : ViewModelBase public ThemeSettingsViewModel()
{ {
public ThemeSettingsViewModel() var paletteHelper = new PaletteHelper();
{ Theme theme = paletteHelper.GetTheme();
var paletteHelper = new PaletteHelper();
ITheme theme = paletteHelper.GetTheme();
IsDarkTheme = theme.GetBaseTheme() == BaseTheme.Dark; IsDarkTheme = theme.GetBaseTheme() == BaseTheme.Dark;
if (theme is Theme internalTheme) if (theme is Theme internalTheme)
{ {
_isColorAdjusted = internalTheme.ColorAdjustment is not null; _isColorAdjusted = internalTheme.ColorAdjustment is not null;
var colorAdjustment = internalTheme.ColorAdjustment ?? new ColorAdjustment(); var colorAdjustment = internalTheme.ColorAdjustment ?? new ColorAdjustment();
_desiredContrastRatio = colorAdjustment.DesiredContrastRatio; _desiredContrastRatio = colorAdjustment.DesiredContrastRatio;
_contrastValue = colorAdjustment.Contrast; _contrastValue = colorAdjustment.Contrast;
_colorSelectionValue = colorAdjustment.Colors; _colorSelectionValue = colorAdjustment.Colors;
} }
if (paletteHelper.GetThemeManager() is { } themeManager) if (paletteHelper.GetThemeManager() is { } themeManager)
{
themeManager.ThemeChanged += (_, e) =>
{ {
themeManager.ThemeChanged += (_, e) => IsDarkTheme = e.NewTheme?.GetBaseTheme() == BaseTheme.Dark;
{ };
IsDarkTheme = e.NewTheme?.GetBaseTheme() == BaseTheme.Dark;
};
}
} }
}
private bool _isDarkTheme; private bool _isDarkTheme;
public bool IsDarkTheme public bool IsDarkTheme
{
get => _isDarkTheme;
set
{ {
get => _isDarkTheme; if (SetProperty(ref _isDarkTheme, value))
set
{ {
if (SetProperty(ref _isDarkTheme, value)) ModifyTheme(theme => theme.SetBaseTheme(value ? BaseTheme.Dark : BaseTheme.Light));
{
ModifyTheme(theme => theme.SetBaseTheme(value ? Theme.Dark : Theme.Light));
}
} }
} }
}
private bool _isColorAdjusted; private bool _isColorAdjusted;
public bool IsColorAdjusted public bool IsColorAdjusted
{
get => _isColorAdjusted;
set
{ {
get => _isColorAdjusted; if (SetProperty(ref _isColorAdjusted, value))
set
{ {
if (SetProperty(ref _isColorAdjusted, value)) ModifyTheme(theme =>
{ {
ModifyTheme(theme => if (theme is Theme internalTheme)
{ {
if (theme is Theme internalTheme) internalTheme.ColorAdjustment = value
{ ? new ColorAdjustment
internalTheme.ColorAdjustment = value {
? new ColorAdjustment DesiredContrastRatio = DesiredContrastRatio,
{ Contrast = ContrastValue,
DesiredContrastRatio = DesiredContrastRatio, Colors = ColorSelectionValue
Contrast = ContrastValue, }
Colors = ColorSelectionValue : null;
} }
: null; });
}
});
}
} }
} }
}
private float _desiredContrastRatio = 4.5f; private float _desiredContrastRatio = 4.5f;
public float DesiredContrastRatio public float DesiredContrastRatio
{
get => _desiredContrastRatio;
set
{ {
get => _desiredContrastRatio; if (SetProperty(ref _desiredContrastRatio, value))
set
{ {
if (SetProperty(ref _desiredContrastRatio, value)) ModifyTheme(theme =>
{ {
ModifyTheme(theme => if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null)
{ internalTheme.ColorAdjustment.DesiredContrastRatio = value;
if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null) });
internalTheme.ColorAdjustment.DesiredContrastRatio = value;
});
}
} }
} }
}
public IEnumerable<Contrast> ContrastValues => Enum.GetValues(typeof(Contrast)).Cast<Contrast>(); public IEnumerable<Contrast> ContrastValues => Enum.GetValues(typeof(Contrast)).Cast<Contrast>();
private Contrast _contrastValue; private Contrast _contrastValue;
public Contrast ContrastValue public Contrast ContrastValue
{
get => _contrastValue;
set
{ {
get => _contrastValue; if (SetProperty(ref _contrastValue, value))
set
{ {
if (SetProperty(ref _contrastValue, value)) ModifyTheme(theme =>
{ {
ModifyTheme(theme => if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null)
{ internalTheme.ColorAdjustment.Contrast = value;
if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null) });
internalTheme.ColorAdjustment.Contrast = value;
});
}
} }
} }
}
public IEnumerable<ColorSelection> ColorSelectionValues => Enum.GetValues(typeof(ColorSelection)).Cast<ColorSelection>(); public IEnumerable<ColorSelection> ColorSelectionValues => Enum.GetValues(typeof(ColorSelection)).Cast<ColorSelection>();
private ColorSelection _colorSelectionValue; private ColorSelection _colorSelectionValue;
public ColorSelection ColorSelectionValue public ColorSelection ColorSelectionValue
{
get => _colorSelectionValue;
set
{ {
get => _colorSelectionValue; if (SetProperty(ref _colorSelectionValue, value))
set
{ {
if (SetProperty(ref _colorSelectionValue, value)) ModifyTheme(theme =>
{ {
ModifyTheme(theme => if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null)
{ internalTheme.ColorAdjustment.Colors = value;
if (theme is Theme internalTheme && internalTheme.ColorAdjustment != null) });
internalTheme.ColorAdjustment.Colors = value;
});
}
} }
} }
}
private static void ModifyTheme(Action<ITheme> modificationAction) private static void ModifyTheme(Action<Theme> modificationAction)
{ {
var paletteHelper = new PaletteHelper(); var paletteHelper = new PaletteHelper();
ITheme theme = paletteHelper.GetTheme(); Theme theme = paletteHelper.GetTheme();
modificationAction?.Invoke(theme); modificationAction?.Invoke(theme);
paletteHelper.SetTheme(theme); paletteHelper.SetTheme(theme);
}
} }
} }
...@@ -133,17 +133,17 @@ ...@@ -133,17 +133,17 @@
</Style> </Style>
</WrapPanel.Resources> </WrapPanel.Resources>
<smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_26"> <smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_26">
<materialDesign:Card materialDesign:ShadowAssist.ShadowEdges="Bottom,Right"> <materialDesign:Card>
<TextBlock Text="Custom shadow clip&#10;Bottom, Right" /> <TextBlock Text="Custom shadow clip&#10;Bottom, Right" />
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_27"> <smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_27">
<materialDesign:Card materialDesign:ShadowAssist.ShadowEdges="Top"> <materialDesign:Card>
<TextBlock Text="Custom shadow clip&#10;Top" /> <TextBlock Text="Custom shadow clip&#10;Top" />
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_28"> <smtx:XamlDisplay Margin="0,0,16,32" UniqueKey="shadow_28">
<materialDesign:Card materialDesign:ShadowAssist.ShadowEdges="Bottom,Left"> <materialDesign:Card>
<TextBlock Text="Custom shadow clip&#10;Bottom, Left" /> <TextBlock Text="Custom shadow clip&#10;Bottom, Left" />
</materialDesign:Card> </materialDesign:Card>
</smtx:XamlDisplay> </smtx:XamlDisplay>
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
Height="56" Height="56"
Click="MenuOpen_Click" Click="MenuOpen_Click"
DockPanel.Dock="Right" DockPanel.Dock="Right"
Foreground="{StaticResource MaterialDesignBody}" Foreground="{DynamicResource MaterialDesign.Brush.Foreground}"
Style="{StaticResource MaterialDesignIconForegroundButton}"> Style="{StaticResource MaterialDesignIconForegroundButton}">
<materialDesign:PackIcon Width="36" <materialDesign:PackIcon Width="36"
Height="36" Height="36"
...@@ -113,8 +113,8 @@ ...@@ -113,8 +113,8 @@
materialDesign:TextFieldAssist.HasClearButton="True" materialDesign:TextFieldAssist.HasClearButton="True"
materialDesign:TextFieldAssist.TextFieldCornerRadius="8" materialDesign:TextFieldAssist.TextFieldCornerRadius="8"
DockPanel.Dock="Top" DockPanel.Dock="Top"
Text="{Binding SearchKeyword, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource MaterialDesignOutlinedTextBox}"
Style="{StaticResource MaterialDesignOutlinedTextBox}"/> Text="{Binding SearchKeyword, UpdateSourceTrigger=PropertyChanged}" />
<ListBox x:Name="DemoItemsListBox" <ListBox x:Name="DemoItemsListBox"
Margin="12,16,12,16" Margin="12,16,12,16"
AutomationProperties.Name="DemoPagesListBox" AutomationProperties.Name="DemoPagesListBox"
......
...@@ -99,7 +99,7 @@ private static void ModifyTheme(bool isDarkTheme) ...@@ -99,7 +99,7 @@ private static void ModifyTheme(bool isDarkTheme)
var paletteHelper = new PaletteHelper(); var paletteHelper = new PaletteHelper();
var theme = paletteHelper.GetTheme(); var theme = paletteHelper.GetTheme();
theme.SetBaseTheme(isDarkTheme ? Theme.Dark : Theme.Light); theme.SetBaseTheme(isDarkTheme ? BaseTheme.Dark : BaseTheme.Light);
paletteHelper.SetTheme(theme); paletteHelper.SetTheme(theme);
} }
......
using System.Windows.Media;
using MaterialDesignColors;
using MaterialDesignColors.ColorManipulation;
using MaterialDesignThemes.Wpf;
namespace MaterialDesign3Demo
{
public static class PaletteHelperExtensions
{
public static void ChangePrimaryColor(this PaletteHelper paletteHelper, Color color)
{
ITheme theme = paletteHelper.GetTheme();
theme.PrimaryLight = new ColorPair(color.Lighten());
theme.PrimaryMid = new ColorPair(color);
theme.PrimaryDark = new ColorPair(color.Darken());
paletteHelper.SetTheme(theme);
}
public static void ChangeSecondaryColor(this PaletteHelper paletteHelper, Color color)
{
ITheme theme = paletteHelper.GetTheme();
theme.SecondaryLight = new ColorPair(color.Lighten());
theme.SecondaryMid = new ColorPair(color);
theme.SecondaryDark = new ColorPair(color.Darken());
paletteHelper.SetTheme(theme);
}
}
}
using System.Windows.Media;
using MaterialDesignColors;
using MaterialDesignColors.ColorManipulation;
using MaterialDesignThemes.Wpf;
namespace MaterialDesign3Demo;
public static class PaletteHelperExtensions
{
public static void ChangePrimaryColor(this PaletteHelper paletteHelper, Color color)
{
Theme theme = paletteHelper.GetTheme();
theme.PrimaryLight = new ColorPair(color.Lighten());
theme.PrimaryMid = new ColorPair(color);
theme.PrimaryDark = new ColorPair(color.Darken());
paletteHelper.SetTheme(theme);
}
public static void ChangeSecondaryColor(this PaletteHelper paletteHelper, Color color)
{
Theme theme = paletteHelper.GetTheme();
theme.SecondaryLight = new ColorPair(color.Lighten());
theme.SecondaryMid = new ColorPair(color);
theme.SecondaryDark = new ColorPair(color.Darken());
paletteHelper.SetTheme(theme);
}
}
...@@ -60,8 +60,8 @@ ...@@ -60,8 +60,8 @@
<smtx:XamlDisplay Margin="0,5,8,8" UniqueKey="buttons_36"> <smtx:XamlDisplay Margin="0,5,8,8" UniqueKey="buttons_36">
<ToggleButton Content="C" <ToggleButton Content="C"
IsChecked="True" IsChecked="True"
Style="{StaticResource MaterialDesignActionAccentToggleButton}" Style="{StaticResource MaterialDesignActionSecondaryToggleButton}"
ToolTip="MaterialDesignActionAccentToggleButton" /> ToolTip="MaterialDesignActionSecondaryToggleButton" />
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="0,5,8,8" UniqueKey="buttons_37"> <smtx:XamlDisplay Margin="0,5,8,8" UniqueKey="buttons_37">
...@@ -241,8 +241,8 @@ ...@@ -241,8 +241,8 @@
VerticalAlignment="Center" VerticalAlignment="Center"
UniqueKey="buttons_51"> UniqueKey="buttons_51">
<ToggleButton IsChecked="True" <ToggleButton IsChecked="True"
Style="{StaticResource MaterialDesignSwitchAccentToggleButton}" Style="{StaticResource MaterialDesignSwitchSecondaryToggleButton}"
ToolTip="MaterialDesignSwitchAccentToggleButton" /> ToolTip="MaterialDesignSwitchSecondaryToggleButton" />
</smtx:XamlDisplay> </smtx:XamlDisplay>
<smtx:XamlDisplay Margin="8,0,0,0" <smtx:XamlDisplay Margin="8,0,0,0"
......
...@@ -52,9 +52,9 @@ ...@@ -52,9 +52,9 @@
</materialDesign:TransitionerSlide> </materialDesign:TransitionerSlide>
<!-- now we are going to slide this in by combining some extra effects. the inner content slides in, so we'll set the outer background and clip, to keep things nice --> <!-- now we are going to slide this in by combining some extra effects. the inner content slides in, so we'll set the outer background and clip, to keep things nice -->
<materialDesign:TransitionerSlide Background="{DynamicResource MaterialDesignDarkBackground}" <materialDesign:TransitionerSlide Background="{DynamicResource MaterialDesign.Brush.Background}"
ClipToBounds="True" ClipToBounds="True"
Foreground="{DynamicResource MaterialDesignDarkForeground}"> Foreground="{DynamicResource MaterialDesign.Brush.Foreground}">
<materialDesign:TransitionerSlide.OpeningEffects> <materialDesign:TransitionerSlide.OpeningEffects>
<materialDesign:TransitionEffect Kind="SlideInFromLeft" Duration="0:0:0.8" /> <materialDesign:TransitionEffect Kind="SlideInFromLeft" Duration="0:0:0.8" />
<materialDesign:TransitionEffect Kind="SlideInFromBottom" <materialDesign:TransitionEffect Kind="SlideInFromBottom"
......
using System.Windows.Media; using System.Windows.Media;
namespace MaterialDesignColors.ColorManipulation namespace MaterialDesignColors.ColorManipulation;
public static class ColorAssist
{ {
public static class ColorAssist /// <summary>
/// The relative brightness of any point in a color space, normalized to 0 for darkest black and 1 for lightest white
/// For the sRGB color space, the relative luminance of a color is defined as L = 0.2126 * R + 0.7152 * G + 0.0722 * B where R, G and B are defined as:
/// if RsRGB <= 0.03928 then R = RsRGB / 12.92 else R = ((RsRGB+0.055)/1.055) ^ 2.4
/// if GsRGB <= 0.03928 then G = GsRGB / 12.92 else G = ((GsRGB+0.055)/1.055) ^ 2.4
/// if BsRGB <= 0.03928 then B = BsRGB / 12.92 else B = ((BsRGB+0.055)/1.055) ^ 2.4
/// and RsRGB, GsRGB, and BsRGB are defined as:
/// RsRGB = R8bit/255
/// GsRGB = G8bit/255
/// BsRGB = B8bit/255
/// Based on https://www.w3.org/TR/WCAG21/#dfn-relative-luminance
/// </summary>
/// <param name="color"></param>
/// <returns></returns>
public static float RelativeLuminance(this Color color)
{ {
/// <summary> return
/// The relative brightness of any point in a color space, normalized to 0 for darkest black and 1 for lightest white 0.2126f * Calc(color.R / 255f) +
/// For the sRGB color space, the relative luminance of a color is defined as L = 0.2126 * R + 0.7152 * G + 0.0722 * B where R, G and B are defined as: 0.7152f * Calc(color.G / 255f) +
/// if RsRGB <= 0.03928 then R = RsRGB / 12.92 else R = ((RsRGB+0.055)/1.055) ^ 2.4 0.0722f * Calc(color.B / 255f);
/// if GsRGB <= 0.03928 then G = GsRGB / 12.92 else G = ((GsRGB+0.055)/1.055) ^ 2.4
/// if BsRGB <= 0.03928 then B = BsRGB / 12.92 else B = ((BsRGB+0.055)/1.055) ^ 2.4
/// and RsRGB, GsRGB, and BsRGB are defined as:
/// RsRGB = R8bit/255
/// GsRGB = G8bit/255
/// BsRGB = B8bit/255
/// Based on https://www.w3.org/TR/WCAG21/#dfn-relative-luminance
/// </summary>
/// <param name="color"></param>
/// <returns></returns>
public static float RelativeLuminance(this Color color)
{
return
0.2126f * Calc(color.R / 255f) +
0.7152f * Calc(color.G / 255f) +
0.0722f * Calc(color.B / 255f);
static float Calc(float colorValue) static float Calc(float colorValue)
=> colorValue <= 0.03928f ? colorValue / 12.92f : (float)Math.Pow((colorValue + 0.055f) / 1.055f, 2.4); => colorValue <= 0.03928f ? colorValue / 12.92f : (float)Math.Pow((colorValue + 0.055f) / 1.055f, 2.4);
} }
[Obsolete("Use RelativeLuminance instead")] /// <summary>
public static float RelativeLuninance(this Color color) => RelativeLuminance(color); /// The contrast ratio is calculated as (L1 + 0.05) / (L2 + 0.05), where
/// L1 is the: relative luminance of the lighter of the colors, and
/// <summary> /// L2 is the relative luminance of the darker of the colors.
/// The contrast ratio is calculated as (L1 + 0.05) / (L2 + 0.05), where /// Based on https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast%20ratio
/// L1 is the: relative luminance of the lighter of the colors, and /// </summary>
/// L2 is the relative luminance of the darker of the colors. /// <param name="color"></param>
/// Based on https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast%20ratio /// <param name="color2"></param>
/// </summary> /// <returns></returns>
/// <param name="color"></param> public static float ContrastRatio(this Color color, Color color2)
/// <param name="color2"></param> {
/// <returns></returns> float l1 = color.RelativeLuminance();
public static float ContrastRatio(this Color color, Color color2) float l2 = color2.RelativeLuminance();
if (l2 > l1)
{ {
float l1 = color.RelativeLuminance(); float temp = l1;
float l2 = color2.RelativeLuminance(); l1 = l2;
if (l2 > l1) l2 = temp;
{
float temp = l1;
l1 = l2;
l2 = temp;
}
return (l1 + 0.05f) / (l2 + 0.05f);
} }
return (l1 + 0.05f) / (l2 + 0.05f);
}
/// <summary> /// <summary>
/// Adjust the foreground color to have an acceptable contrast ratio. /// Adjust the foreground color to have an acceptable contrast ratio.
/// </summary> /// </summary>
/// <param name="foreground">The foreground color</param> /// <param name="foreground">The foreground color</param>
/// <param name="background">The background color</param> /// <param name="background">The background color</param>
/// <param name="targetRatio">The target contrast ratio</param> /// <param name="targetRatio">The target contrast ratio</param>
/// <param name="tolerance">The tolerance to the contrast ratio needs to be within</param> /// <param name="tolerance">The tolerance to the contrast ratio needs to be within</param>
/// <returns>The updated foreground color with the target contrast ratio with the background</returns> /// <returns>The updated foreground color with the target contrast ratio with the background</returns>
public static Color EnsureContrastRatio(this Color foreground, Color background, float targetRatio, float tolerance = 0.1f) public static Color EnsureContrastRatio(this Color foreground, Color background, float targetRatio, float tolerance = 0.1f)
=> EnsureContrastRatio(foreground, background, targetRatio, out _, tolerance); => EnsureContrastRatio(foreground, background, targetRatio, out _, tolerance);
/// <summary> /// <summary>
/// Adjust the foreground color to have an acceptable contrast ratio. /// Adjust the foreground color to have an acceptable contrast ratio.
/// </summary> /// </summary>
/// <param name="foreground">The foreground color</param> /// <param name="foreground">The foreground color</param>
/// <param name="background">The background color</param> /// <param name="background">The background color</param>
/// <param name="targetRatio">The target contrast ratio</param> /// <param name="targetRatio">The target contrast ratio</param>
/// <param name="offset">The offset that was applied</param> /// <param name="offset">The offset that was applied</param>
/// <param name="tolerance">The tolerance to the contrast ratio needs to be within</param> /// <param name="tolerance">The tolerance to the contrast ratio needs to be within</param>
/// <returns>The updated foreground color with the target contrast ratio with the background</returns> /// <returns>The updated foreground color with the target contrast ratio with the background</returns>
public static Color EnsureContrastRatio(this Color foreground, Color background, float targetRatio, out double offset, float tolerance = 0.1f) public static Color EnsureContrastRatio(this Color foreground, Color background, float targetRatio, out double offset, float tolerance = 0.1f)
{ {
offset = 0.0f; offset = 0.0f;
float ratio = foreground.ContrastRatio(background); float ratio = foreground.ContrastRatio(background);
if (ratio > targetRatio) return foreground; if (ratio > targetRatio) return foreground;
var contrastWithWhite = background.ContrastRatio(Colors.White); float contrastWithWhite = background.ContrastRatio(Colors.White);
var contrastWithBlack = background.ContrastRatio(Colors.Black); float contrastWithBlack = background.ContrastRatio(Colors.Black);
var shouldDarken = contrastWithBlack > contrastWithWhite; bool shouldDarken = contrastWithBlack > contrastWithWhite;
//Lighten is negative //Lighten is negative
Color finalColor = foreground; Color finalColor = foreground;
double? adjust = null; double? adjust = null;
while ((ratio < targetRatio - tolerance || ratio > targetRatio + tolerance) && while ((ratio < targetRatio - tolerance || ratio > targetRatio + tolerance) &&
finalColor != Colors.White && finalColor != Colors.White &&
finalColor != Colors.Black) finalColor != Colors.Black)
{
if (ratio - targetRatio < 0.0)
{ {
if (ratio - targetRatio < 0.0) //Move offset of foreground further away from background
if (shouldDarken)
{ {
//Move offset of foreground further away from background if (adjust < 0)
if (shouldDarken)
{ {
if (adjust < 0) adjust /= -2;
{
adjust /= -2;
}
else if (adjust == null)
{
adjust = 1.0f;
}
} }
else else
{ {
if (adjust > 0) adjust ??= 1.0f;
{
adjust /= -2;
}
else if (adjust == null)
{
adjust = -1.0f;
}
} }
} }
else else
{ {
//Move offset of foreground closer to background if (adjust > 0)
if (shouldDarken)
{ {
if (adjust > 0) adjust /= -2;
{
adjust /= -2;
}
else if (adjust == null)
{
adjust = -1.0f;
}
} }
else else
{ {
if (adjust < 0) adjust ??= -1.0f;
{
adjust /= -2;
}
else if (adjust == null)
{
adjust = 1.0f;
}
} }
} }
offset += adjust.Value;
finalColor = foreground.ShiftLightness(offset);
ratio = finalColor.ContrastRatio(background);
} }
return finalColor; else
}
public static Color ContrastingForegroundColor(this Color color)
=> color.IsLightColor() ? Colors.Black : Colors.White;
public static bool IsLightColor(this Color color)
{
double rgb_srgb(double d)
{ {
d /= 255.0; //Move offset of foreground closer to background
return (d > 0.03928) if (shouldDarken)
? Math.Pow((d + 0.055) / 1.055, 2.4) {
: d / 12.92; if (adjust > 0)
{
adjust /= -2;
}
else
{
adjust ??= -1.0f;
}
}
else
{
if (adjust < 0)
{
adjust /= -2;
}
else
{
adjust ??= 1.0f;
}
}
} }
var r = rgb_srgb(color.R);
var g = rgb_srgb(color.G);
var b = rgb_srgb(color.B);
var luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b; offset += adjust.Value;
return luminance > 0.179;
}
public static bool IsDarkColor(this Color color) => !IsLightColor(color); finalColor = foreground.ShiftLightness(offset);
public static Color ShiftLightness(this Color color, double amount = 1.0f) ratio = finalColor.ContrastRatio(background);
{
var lab = color.ToLab();
var shifted = new Lab(lab.L - LabConstants.Kn * amount, lab.A, lab.B);
return shifted.ToColor();
} }
return finalColor;
}
public static Color ContrastingForegroundColor(this Color color)
=> color.IsLightColor() ? Colors.Black : Colors.White;
public static Color ShiftLightness(this Color color, int amount = 1) public static bool IsLightColor(this Color color)
{
static double rgb_srgb(double d)
{ {
var lab = color.ToLab(); d /= 255.0;
var shifted = new Lab(lab.L - LabConstants.Kn * amount, lab.A, lab.B); return (d > 0.03928)
return shifted.ToColor(); ? Math.Pow((d + 0.055) / 1.055, 2.4)
: d / 12.92;
} }
double r = rgb_srgb(color.R);
double g = rgb_srgb(color.G);
double b = rgb_srgb(color.B);
public static Color Darken(this Color color, int amount = 1) => color.ShiftLightness(amount); double luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
return luminance > 0.179;
}
public static bool IsDarkColor(this Color color)
=> !IsLightColor(color);
public static Color Lighten(this Color color, int amount = 1) => color.ShiftLightness(-amount); public static Color ShiftLightness(this Color color, double amount = 1.0f)
{
var lab = color.ToLab();
var shifted = new Lab(lab.L - LabConstants.Kn * amount, lab.A, lab.B);
return shifted.ToColor();
} }
public static Color ShiftLightness(this Color color, int amount = 1)
{
var lab = color.ToLab();
var shifted = new Lab(lab.L - LabConstants.Kn * amount, lab.A, lab.B);
return shifted.ToColor();
}
public static Color Darken(this Color color, int amount = 1)
=> color.ShiftLightness(amount);
public static Color Lighten(this Color color, int amount = 1)
=> color.ShiftLightness(-amount);
} }
namespace MaterialDesignColors.ColorManipulation namespace MaterialDesignColors.ColorManipulation;
{
public struct Hsb
{
public double Hue { get; }
public double Saturation { get; }
public double Brightness { get; }
public Hsb(double hue, double saturation, double brightness) public record struct Hsb(double Hue, double Saturation, double Brightness);
{
Hue = hue;
Saturation = saturation;
Brightness = brightness;
}
}
}
using System.Windows.Media;
namespace MaterialDesignColors.ColorManipulation
{
public static class HsbConverter
{
public static Color ToColor(this Hsb hsv)
{
var h = hsv.Hue;
var s = hsv.Saturation;
var b = hsv.Brightness;
b *= 255;
if (s.IsCloseTo(0)) return Color.FromRgb((byte)b, (byte)b, (byte)b);
if (h.IsCloseTo(360)) h = 0;
while (h > 360) h -= 360;
while (h < 0) h += 360;
h /= 60;
var i = (int)Math.Floor(h);
var f = h - i;
var p = b * (1 - s);
var q = b * (1 - s * f);
var t = b * (1 - s * (1 - f));
if (i == 0) return Color.FromRgb((byte)b, (byte)t, (byte)p);
if (i == 1) return Color.FromRgb((byte)q, (byte)b, (byte)p);
if (i == 2) return Color.FromRgb((byte)p, (byte)b, (byte)t);
if (i == 3) return Color.FromRgb((byte)p, (byte)q, (byte)b);
if (i == 4) return Color.FromRgb((byte)t, (byte)p, (byte)b);
if (i == 5) return Color.FromRgb((byte)b, (byte)p, (byte)q);
throw new Exception("Invalid HSB values");
}
public static Hsb ToHsb(this Color color)
{
double r = color.R;
double g = color.G;
double b = color.B;
r = r / 255;
g = g / 255;
b = b / 255;
var rgb = new[] { r, g, b };
var max = rgb.Max();
var min = rgb.Min();
double v = max;
double h = max;
var d = max - min;
var s = max.IsCloseTo(0) ? 0 : d / max;
if (max.IsCloseTo(min))
{
h = 0; // achromatic
}
else
{
if (max.IsCloseTo(r))
{
h = (g - b) / d + (g < b ? 6 : 0);
}
else if (max.IsCloseTo(g))
{
h = (b - r) / d + 2;
}
else if (max.IsCloseTo(b))
{
h = (r - g) / d + 4;
}
h *= 60;
}
return new Hsb(h, s, v);
}
private static bool IsCloseTo(this double value, double target, double tolerance = double.Epsilon)
=> Math.Abs(value - target) < tolerance;
}
}
using System.Windows.Media;
namespace MaterialDesignColors.ColorManipulation;
public static class HsbExtensions
{
public static Color ToColor(this Hsb hsv)
{
double h = hsv.Hue;
double s = hsv.Saturation;
double b = hsv.Brightness;
b *= 255;
if (s.IsCloseTo(0)) return Color.FromRgb((byte)b, (byte)b, (byte)b);
if (h.IsCloseTo(360)) h = 0;
while (h > 360) h -= 360;
while (h < 0) h += 360;
h /= 60;
int i = (int)Math.Floor(h);
double f = h - i;
double p = b * (1 - s);
double q = b * (1 - s * f);
double t = b * (1 - s * (1 - f));
return i switch
{
0 => Color.FromRgb((byte)b, (byte)t, (byte)p),
1 => Color.FromRgb((byte)q, (byte)b, (byte)p),
2 => Color.FromRgb((byte)p, (byte)b, (byte)t),
3 => Color.FromRgb((byte)p, (byte)q, (byte)b),
4 => Color.FromRgb((byte)t, (byte)p, (byte)b),
5 => Color.FromRgb((byte)b, (byte)p, (byte)q),
_ => throw new InvalidOperationException("Invalid HSB values"),
};
}
public static Hsb ToHsb(this Color color)
{
double r = color.R;
double g = color.G;
double b = color.B;
r /= 255;
g /= 255;
b /= 255;
double[] rgb = new[] { r, g, b };
double max = rgb.Max();
double min = rgb.Min();
double v = max;
double h = max;
double d = max - min;
double s = max.IsCloseTo(0) ? 0 : d / max;
if (max.IsCloseTo(min))
{
h = 0; // achromatic
}
else
{
if (max.IsCloseTo(r))
{
h = (g - b) / d + (g < b ? 6 : 0);
}
else if (max.IsCloseTo(g))
{
h = (b - r) / d + 2;
}
else if (max.IsCloseTo(b))
{
h = (r - g) / d + 4;
}
h *= 60;
}
return new Hsb(h, s, v);
}
private static bool IsCloseTo(this double value, double target, double tolerance = double.Epsilon)
=> Math.Abs(value - target) < tolerance;
}
namespace MaterialDesignColors.ColorManipulation namespace MaterialDesignColors.ColorManipulation;
{
internal struct Hsl
{
public double H { get; }
public double S { get; }
public double L { get; }
public Hsl(double h, double s, double l) internal record struct Hsl(double H, double S, double L);
{
H = h;
S = s;
L = l;
}
}
}
using System.Windows.Media;
namespace MaterialDesignColors.ColorManipulation
{
internal static class HslConverter
{
public static Color ToColor(this Hsl hsl)
{
double hsv_rbg(double v1, double v2, double vH)
{
if (vH < 0) vH += 1;
if (vH > 1) vH -= 1;
if ((6 * vH) < 1) return (v1 + (v2 - v1) * 6 * vH);
if ((2 * vH) < 1) return (v2);
if ((3 * vH) < 2) return (v1 + (v2 - v1) * ((2.0 / 3) - vH) * 6);
return (v1);
}
var h = hsl.H * (1.0 / 360);
var s = hsl.S * (1.0 / 100);
var l = hsl.L * (1.0 / 100);
double r, g, b;
if (s == 0)
{
r = l * 255;
g = l * 255;
b = l * 255;
}
else
{
double var_2;
if (l < 0.5) var_2 = l * (1 + s);
else var_2 = (l + s) - (s * l);
var var_1 = 2 * l - var_2;
r = 255 * hsv_rbg(var_1, var_2, h + (1.0 / 3));
g = 255 * hsv_rbg(var_1, var_2, h);
b = 255 * hsv_rbg(var_1, var_2, h - (1.0 / 3));
}
return Color.FromRgb((byte)Math.Round(r), (byte)Math.Round(g), (byte)Math.Round(b));
}
}
}
using System.Windows.Media;
namespace MaterialDesignColors.ColorManipulation;
internal static class HslExtensions
{
public static Color ToColor(this Hsl hsl)
{
double hsv_rbg(double v1, double v2, double vH)
{
if (vH < 0) vH += 1;
if (vH > 1) vH -= 1;
if ((6 * vH) < 1) return (v1 + (v2 - v1) * 6 * vH);
if ((2 * vH) < 1) return (v2);
if ((3 * vH) < 2) return (v1 + (v2 - v1) * ((2.0 / 3) - vH) * 6);
return (v1);
}
var h = hsl.H * (1.0 / 360);
var s = hsl.S * (1.0 / 100);
var l = hsl.L * (1.0 / 100);
double r, g, b;
if (s == 0)
{
r = l * 255;
g = l * 255;
b = l * 255;
}
else
{
double var_2;
if (l < 0.5) var_2 = l * (1 + s);
else var_2 = (l + s) - (s * l);
var var_1 = 2 * l - var_2;
r = 255 * hsv_rbg(var_1, var_2, h + (1.0 / 3));
g = 255 * hsv_rbg(var_1, var_2, h);
b = 255 * hsv_rbg(var_1, var_2, h - (1.0 / 3));
}
return Color.FromRgb((byte)Math.Round(r), (byte)Math.Round(g), (byte)Math.Round(b));
}
}
namespace MaterialDesignColors.ColorManipulation namespace MaterialDesignColors.ColorManipulation;
{
internal struct Lab
{
public double L { get; }
public double A { get; }
public double B { get; }
public Lab(double l, double a, double b) internal record struct Lab(double L, double A, double B);
{
L = l;
A = a;
B = b;
}
}
internal class LabConstants internal class LabConstants
{ {
public const double Kn = 18; public const double Kn = 18;
public const double WhitePointX = 0.95047; public const double WhitePointX = 0.95047;
public const double WhitePointY = 1; public const double WhitePointY = 1;
public const double WhitePointZ = 1.08883; public const double WhitePointZ = 1.08883;
public static readonly double eCubedRoot = Math.Pow(e, 1.0 / 3); public static readonly double eCubedRoot = Math.Pow(e, 1.0 / 3);
public const double k = 24389 / 27.0; public const double k = 24389 / 27.0;
public const double e = 216 / 24389.0; public const double e = 216 / 24389.0;
}
} }
using System.Windows.Media;
namespace MaterialDesignColors.ColorManipulation
{
internal static class LabConverter
{
public static Lab ToLab(this Color c)
{
var xyz = c.ToXyz();
return xyz.ToLab();
}
public static Lab ToLab(this Xyz xyz)
{
double xyz_lab(double v)
{
if (v > LabConstants.e)
return Math.Pow(v, 1 / 3.0);
else
return (v * LabConstants.k + 16) / 116;
}
var fx = xyz_lab(xyz.X / LabConstants.WhitePointX);
var fy = xyz_lab(xyz.Y / LabConstants.WhitePointY);
var fz = xyz_lab(xyz.Z / LabConstants.WhitePointZ);
var l = 116 * fy - 16;
var a = 500 * (fx - fy);
var b = 200 * (fy - fz);
return new Lab(l, a, b);
}
public static Color ToColor(this Lab lab)
{
var xyz = lab.ToXyz();
return xyz.ToColor();
}
}
}
using System.Windows.Media;
namespace MaterialDesignColors.ColorManipulation;
internal static class LabExtensions
{
public static Lab ToLab(this Color c)
=> c.ToXyz().ToLab();
public static Lab ToLab(this Xyz xyz)
{
double xyz_lab(double v)
{
if (v > LabConstants.e)
return Math.Pow(v, 1 / 3.0);
else
return (v * LabConstants.k + 16) / 116;
}
double fx = xyz_lab(xyz.X / LabConstants.WhitePointX);
double fy = xyz_lab(xyz.Y / LabConstants.WhitePointY);
double fz = xyz_lab(xyz.Z / LabConstants.WhitePointZ);
double l = 116 * fy - 16;
double a = 500 * (fx - fy);
double b = 200 * (fy - fz);
return new Lab(l, a, b);
}
public static Color ToColor(this Lab lab)
=> lab.ToXyz().ToColor();
}
namespace MaterialDesignColors.ColorManipulation namespace MaterialDesignColors.ColorManipulation;
{
internal struct Xyz
{
public double X { get; }
public double Y { get; }
public double Z { get; }
public Xyz(double x, double y, double z) internal record struct Xyz(double X, double Y, double Z);
{
X = x;
Y = y;
Z = z;
}
}
}
using System.Windows.Media;
namespace MaterialDesignColors.ColorManipulation
{
internal static class XyzConverter
{
public static Color ToColor(this Xyz xyz)
{
double xyz_rgb(double d)
{
if (d > 0.0031308)
return 255.0 * (1.055 * Math.Pow(d, 1.0 / 2.4) - 0.055);
else
return 255.0 * (12.92 * d);
}
byte clip(double d)
{
if (d < 0) return 0;
if (d > 255) return 255;
return (byte)Math.Round(d);
}
var r = xyz_rgb(3.2404542 * xyz.X - 1.5371385 * xyz.Y - 0.4985314 * xyz.Z);
var g = xyz_rgb(-0.9692660 * xyz.X + 1.8760108 * xyz.Y + 0.0415560 * xyz.Z);
var b = xyz_rgb(0.0556434 * xyz.X - 0.2040259 * xyz.Y + 1.0572252 * xyz.Z);
return Color.FromRgb(clip(r), clip(g), clip(b));
}
public static Xyz ToXyz(this Color c)
{
double rgb_xyz(double v)
{
v /= 255;
if (v > 0.04045)
return Math.Pow((v + 0.055) / 1.055, 2.4);
else
return v / 12.92;
}
var r = rgb_xyz(c.R);
var g = rgb_xyz(c.G);
var b = rgb_xyz(c.B);
var x = 0.4124564 * r + 0.3575761 * g + 0.1804375 * b;
var y = 0.2126729 * r + 0.7151522 * g + 0.0721750 * b;
var z = 0.0193339 * r + 0.1191920 * g + 0.9503041 * b;
return new Xyz(x, y, z);
}
public static Xyz ToXyz(this Lab lab)
{
double lab_xyz(double d)
{
if (d > LabConstants.eCubedRoot)
return d * d * d;
else
return (116 * d - 16) / LabConstants.k;
}
var y = (lab.L + 16.0) / 116.0;
var x = double.IsNaN(lab.A) ? y : y + lab.A / 500.0;
var z = double.IsNaN(lab.B) ? y : y - lab.B / 200.0;
y = LabConstants.WhitePointY * lab_xyz(y);
x = LabConstants.WhitePointX * lab_xyz(x);
z = LabConstants.WhitePointZ * lab_xyz(z);
return new Xyz(x, y, z);
}
}
}
using System.Windows.Media;
namespace MaterialDesignColors.ColorManipulation;
internal static class XyzExtensions
{
public static Color ToColor(this Xyz xyz)
{
double xyz_rgb(double d)
{
if (d > 0.0031308)
return 255.0 * (1.055 * Math.Pow(d, 1.0 / 2.4) - 0.055);
else
return 255.0 * (12.92 * d);
}
byte clip(double d)
{
if (d < 0) return 0;
if (d > 255) return 255;
return (byte)Math.Round(d);
}
var r = xyz_rgb(3.2404542 * xyz.X - 1.5371385 * xyz.Y - 0.4985314 * xyz.Z);
var g = xyz_rgb(-0.9692660 * xyz.X + 1.8760108 * xyz.Y + 0.0415560 * xyz.Z);
var b = xyz_rgb(0.0556434 * xyz.X - 0.2040259 * xyz.Y + 1.0572252 * xyz.Z);
return Color.FromRgb(clip(r), clip(g), clip(b));
}
public static Xyz ToXyz(this Color c)
{
double rgb_xyz(double v)
{
v /= 255;
if (v > 0.04045)
return Math.Pow((v + 0.055) / 1.055, 2.4);
else
return v / 12.92;
}
var r = rgb_xyz(c.R);
var g = rgb_xyz(c.G);
var b = rgb_xyz(c.B);
var x = 0.4124564 * r + 0.3575761 * g + 0.1804375 * b;
var y = 0.2126729 * r + 0.7151522 * g + 0.0721750 * b;
var z = 0.0193339 * r + 0.1191920 * g + 0.9503041 * b;
return new Xyz(x, y, z);
}
public static Xyz ToXyz(this Lab lab)
{
double lab_xyz(double d)
{
if (d > LabConstants.eCubedRoot)
return d * d * d;
else
return (116 * d - 16) / LabConstants.k;
}
var y = (lab.L + 16.0) / 116.0;
var x = double.IsNaN(lab.A) ? y : y + lab.A / 500.0;
var z = double.IsNaN(lab.B) ? y : y - lab.B / 200.0;
y = LabConstants.WhitePointY * lab_xyz(y);
x = LabConstants.WhitePointX * lab_xyz(x);
z = LabConstants.WhitePointZ * lab_xyz(z);
return new Xyz(x, y, z);
}
}
using System.Windows.Media; using System.Diagnostics;
using System.Windows.Media;
using MaterialDesignColors.ColorManipulation; using MaterialDesignColors.ColorManipulation;
namespace MaterialDesignColors namespace MaterialDesignColors;
{
public struct ColorPair
{
public Color Color { get; set; }
/// <summary> [DebuggerDisplay($"Color: {{{nameof(Color)}}}; Foreground: {{{nameof(ForegroundColor)}}}")]
/// The foreground or opposite color. If left null, this will be calculated for you. public struct ColorPair
/// Calculated by calling ColorAssist.ContrastingForegroundColor() {
/// </summary> public Color Color { get; set; }
public Color? ForegroundColor { get; set; }
public static implicit operator ColorPair(Color color) => new ColorPair(color); /// <summary>
/// The foreground or opposite color. If left null, this will be calculated for you.
/// Calculated by calling ColorAssist.ContrastingForegroundColor()
/// </summary>
public Color? ForegroundColor { get; set; }
public ColorPair(Color color) public static implicit operator ColorPair(Color color) => new ColorPair(color);
{
Color = color;
ForegroundColor = null;
}
public ColorPair(Color color, Color? foreground) public ColorPair(Color color)
{ {
Color = color; Color = color;
ForegroundColor = foreground; ForegroundColor = null;
} }
public Color GetForegroundColor() => ForegroundColor ?? Color.ContrastingForegroundColor(); public ColorPair(Color color, Color? foreground)
{
Color = color;
ForegroundColor = foreground;
} }
public Color GetForegroundColor() => ForegroundColor ?? Color.ContrastingForegroundColor();
} }
using System.Windows.Media; using System.Windows.Media;
namespace MaterialDesignColors namespace MaterialDesignColors;
public class Hue
{ {
public class Hue public Hue(string name, Color color, Color foreground)
{ {
public Hue(string name, Color color, Color foreground) if (name is null) throw new ArgumentNullException(nameof(name));
{
if (name is null) throw new ArgumentNullException(nameof(name));
Name = name; Name = name;
Color = color; Color = color;
Foreground = foreground; Foreground = foreground;
} }
public string Name { get; } public string Name { get; }
public Color Color { get; } public Color Color { get; }
public Color Foreground { get; } public Color Foreground { get; }
public override string ToString() => Name; public override string ToString() => Name;
}
} }
using System.Windows.Media; using System.Windows.Media;
namespace MaterialDesignColors namespace MaterialDesignColors;
public interface ISwatch
{ {
public interface ISwatch string Name { get; }
{ IEnumerable<Color> Hues { get; }
string Name { get; } IDictionary<MaterialDesignColor, Color> Lookup { get; }
IEnumerable<Color> Hues { get; }
IDictionary<MaterialDesignColor, Color> Lookup { get; }
}
} }
...@@ -8,19 +8,18 @@ ...@@ -8,19 +8,18 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace MaterialDesignColors.Properties { namespace MaterialDesignColors.Properties;
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public static Settings Default {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")] get {
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { return defaultInstance;
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
} }
} }
} }
using System.Windows.Media; using System.Windows.Media;
namespace MaterialDesignColors.Recommended namespace MaterialDesignColors.Recommended;
public class BlueGreySwatch : ISwatch
{ {
public class BlueGreySwatch : ISwatch public static Color BlueGrey50 { get; } = (Color)ColorConverter.ConvertFromString("#ECEFF1");
{ public static Color BlueGrey100 { get; } = (Color)ColorConverter.ConvertFromString("#CFD8DC");
public static Color BlueGrey50 { get; } = (Color)ColorConverter.ConvertFromString("#ECEFF1"); public static Color BlueGrey200 { get; } = (Color)ColorConverter.ConvertFromString("#B0BEC5");
public static Color BlueGrey100 { get; } = (Color)ColorConverter.ConvertFromString("#CFD8DC"); public static Color BlueGrey300 { get; } = (Color)ColorConverter.ConvertFromString("#90A4AE");
public static Color BlueGrey200 { get; } = (Color)ColorConverter.ConvertFromString("#B0BEC5"); public static Color BlueGrey400 { get; } = (Color)ColorConverter.ConvertFromString("#78909C");
public static Color BlueGrey300 { get; } = (Color)ColorConverter.ConvertFromString("#90A4AE"); public static Color BlueGrey500 { get; } = (Color)ColorConverter.ConvertFromString("#607D8B");
public static Color BlueGrey400 { get; } = (Color)ColorConverter.ConvertFromString("#78909C"); public static Color BlueGrey600 { get; } = (Color)ColorConverter.ConvertFromString("#546E7A");
public static Color BlueGrey500 { get; } = (Color)ColorConverter.ConvertFromString("#607D8B"); public static Color BlueGrey700 { get; } = (Color)ColorConverter.ConvertFromString("#455A64");
public static Color BlueGrey600 { get; } = (Color)ColorConverter.ConvertFromString("#546E7A"); public static Color BlueGrey800 { get; } = (Color)ColorConverter.ConvertFromString("#37474F");
public static Color BlueGrey700 { get; } = (Color)ColorConverter.ConvertFromString("#455A64"); public static Color BlueGrey900 { get; } = (Color)ColorConverter.ConvertFromString("#263238");
public static Color BlueGrey800 { get; } = (Color)ColorConverter.ConvertFromString("#37474F");
public static Color BlueGrey900 { get; } = (Color)ColorConverter.ConvertFromString("#263238");
public string Name { get; } = "Blue Grey"; public string Name { get; } = "Blue Grey";
public IDictionary<MaterialDesignColor, Color> Lookup { get; } = new Dictionary<MaterialDesignColor, Color> public IDictionary<MaterialDesignColor, Color> Lookup { get; } = new Dictionary<MaterialDesignColor, Color>
{ {
{ MaterialDesignColor.BlueGrey50, BlueGrey50 }, { MaterialDesignColor.BlueGrey50, BlueGrey50 },
{ MaterialDesignColor.BlueGrey100, BlueGrey100 }, { MaterialDesignColor.BlueGrey100, BlueGrey100 },
{ MaterialDesignColor.BlueGrey200, BlueGrey200 }, { MaterialDesignColor.BlueGrey200, BlueGrey200 },
{ MaterialDesignColor.BlueGrey300, BlueGrey300 }, { MaterialDesignColor.BlueGrey300, BlueGrey300 },
{ MaterialDesignColor.BlueGrey400, BlueGrey400 }, { MaterialDesignColor.BlueGrey400, BlueGrey400 },
{ MaterialDesignColor.BlueGrey500, BlueGrey500 }, { MaterialDesignColor.BlueGrey500, BlueGrey500 },
{ MaterialDesignColor.BlueGrey600, BlueGrey600 }, { MaterialDesignColor.BlueGrey600, BlueGrey600 },
{ MaterialDesignColor.BlueGrey700, BlueGrey700 }, { MaterialDesignColor.BlueGrey700, BlueGrey700 },
{ MaterialDesignColor.BlueGrey800, BlueGrey800 }, { MaterialDesignColor.BlueGrey800, BlueGrey800 },
{ MaterialDesignColor.BlueGrey900, BlueGrey900 }, { MaterialDesignColor.BlueGrey900, BlueGrey900 },
}; };
public IEnumerable<Color> Hues => Lookup.Values; public IEnumerable<Color> Hues => Lookup.Values;
}
} }
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册