From 39730bbd362d9a70491e999ac05079311a661581 Mon Sep 17 00:00:00 2001 From: Bastian Schmidt Date: Fri, 18 Dec 2020 15:26:00 +0100 Subject: [PATCH 01/14] Fixing documentation --- src/MahApps.Metro/Theming/MahAppsLibraryThemeProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MahApps.Metro/Theming/MahAppsLibraryThemeProvider.cs b/src/MahApps.Metro/Theming/MahAppsLibraryThemeProvider.cs index 7ec4f8f0b6..39e706da7f 100644 --- a/src/MahApps.Metro/Theming/MahAppsLibraryThemeProvider.cs +++ b/src/MahApps.Metro/Theming/MahAppsLibraryThemeProvider.cs @@ -8,7 +8,7 @@ namespace MahApps.Metro.Theming { /// - /// Provides theme resources from Fluent.Ribbon. + /// Provides theme resources from MahApps.Metro. /// public class MahAppsLibraryThemeProvider : LibraryThemeProvider { @@ -32,4 +32,4 @@ public override void FillColorSchemeValues(Dictionary values, Ru values.Add("MahApps.Colors.IdealForeground", colorValues.IdealForegroundColor.ToString()); } } -} \ No newline at end of file +} From 4c3b39e007be96bf75293c63744c7662995d547d Mon Sep 17 00:00:00 2001 From: punker76 Date: Tue, 23 Feb 2021 23:23:17 +0100 Subject: [PATCH 02/14] Fix HorizontalAlignment of ContextMenu Icon --- src/MahApps.Metro/Styles/Controls.MenuItem.xaml | 7 ++++--- src/MahApps.Metro/Styles/VS/MenuItem.xaml | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/MahApps.Metro/Styles/Controls.MenuItem.xaml b/src/MahApps.Metro/Styles/Controls.MenuItem.xaml index e9f49a48a4..c63db939eb 100644 --- a/src/MahApps.Metro/Styles/Controls.MenuItem.xaml +++ b/src/MahApps.Metro/Styles/Controls.MenuItem.xaml @@ -361,7 +361,7 @@ Margin="5 0 0 0" HorizontalAlignment="Center" VerticalAlignment="Center" - Data="{StaticResource Checkmark}" + Data="{DynamicResource Checkmark}" Fill="{DynamicResource MahApps.Brushes.CheckmarkFill}" FlowDirection="LeftToRight" Visibility="Collapsed" /> @@ -377,7 +377,7 @@ @@ -454,6 +454,7 @@ @@ -461,7 +462,7 @@ Margin="5 0 0 0" HorizontalAlignment="Center" VerticalAlignment="Center" - Data="{StaticResource Checkmark}" + Data="{DynamicResource Checkmark}" Fill="{DynamicResource MahApps.Brushes.CheckmarkFill}" FlowDirection="LeftToRight" Visibility="Collapsed" /> diff --git a/src/MahApps.Metro/Styles/VS/MenuItem.xaml b/src/MahApps.Metro/Styles/VS/MenuItem.xaml index 5c24b8afa3..e4b84915c0 100644 --- a/src/MahApps.Metro/Styles/VS/MenuItem.xaml +++ b/src/MahApps.Metro/Styles/VS/MenuItem.xaml @@ -48,12 +48,13 @@ Width="16" Height="16" Margin="1 1 0 0" - Data="{StaticResource Checkmark}" + Data="{DynamicResource Checkmark}" Fill="{DynamicResource MahApps.Brushes.Menu.Checkmark.Fill}" FlowDirection="LeftToRight" /> Date: Wed, 24 Feb 2021 00:09:47 +0100 Subject: [PATCH 03/14] Pin cake and dependencies --- .gitignore | 3 ++- build.cake | 12 ++++++------ tools/packages.config | 4 ++++ 3 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 tools/packages.config diff --git a/.gitignore b/.gitignore index abb90a6008..4125fd8eba 100644 --- a/.gitignore +++ b/.gitignore @@ -264,7 +264,8 @@ src/MahApps.Metro/Styles/Themes/*.xaml !src/MahApps.Metro/Styles/Themes/Theme.Template.xaml # cake -tools/ +tools/* +!tools/packages.config # XamlStyler !XamlStyler/ diff --git a/build.cake b/build.cake index 4a176bf6d7..a516d64913 100644 --- a/build.cake +++ b/build.cake @@ -2,15 +2,15 @@ // TOOLS / ADDINS /////////////////////////////////////////////////////////////////////////////// -#module nuget:?package=Cake.DotNetTool.Module +#module nuget:?package=Cake.DotNetTool.Module&version=0.5.0 #tool "dotnet:?package=NuGetKeyVaultSignTool&version=1.2.28" #tool "dotnet:?package=AzureSignTool&version=2.0.17" -#tool GitVersion.CommandLine&version=5.5.1 -#tool gitreleasemanager -#tool xunit.runner.console -#tool vswhere -#addin Cake.Figlet +#tool GitVersion.CommandLine&version=5.6.6 +#tool gitreleasemanager&version=0.11.0 +#tool xunit.runner.console&version=2.4.1 +#tool vswhere&version=2.8.4 +#addin nuget:?package=Cake.Figlet&version=1.4.0 /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS diff --git a/tools/packages.config b/tools/packages.config new file mode 100644 index 0000000000..007f90a29a --- /dev/null +++ b/tools/packages.config @@ -0,0 +1,4 @@ + + + + From bfdb221556a5274afc56a2110b736696ab1257e1 Mon Sep 17 00:00:00 2001 From: punker76 Date: Wed, 24 Feb 2021 14:35:58 +0100 Subject: [PATCH 04/14] Use global .NET tools --- build.cake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.cake b/build.cake index a516d64913..2cfa5c103e 100644 --- a/build.cake +++ b/build.cake @@ -3,11 +3,11 @@ /////////////////////////////////////////////////////////////////////////////// #module nuget:?package=Cake.DotNetTool.Module&version=0.5.0 -#tool "dotnet:?package=NuGetKeyVaultSignTool&version=1.2.28" -#tool "dotnet:?package=AzureSignTool&version=2.0.17" +#tool dotnet:?package=NuGetKeyVaultSignTool&version=1.2.28 +#tool dotnet:?package=AzureSignTool&version=2.0.17 +#tool dotnet:?package=GitReleaseManager.Tool&version=0.11.0 +#tool dotnet:?package=GitVersion.Tool&version=5.6.6 -#tool GitVersion.CommandLine&version=5.6.6 -#tool gitreleasemanager&version=0.11.0 #tool xunit.runner.console&version=2.4.1 #tool vswhere&version=2.8.4 #addin nuget:?package=Cake.Figlet&version=1.4.0 From da7f97305fa35396ac2498d348490555d0c00b1d Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 8 Jan 2021 18:42:19 +0100 Subject: [PATCH 05/14] (GH-4019) Implement ColorToSolidColorBrushConverter This should resolve the binding issues. --- .../ColorToSolidColorBrushConverter.cs | 56 +++++++++++++++++++ .../Themes/ColorPicker/ColorCanvas.xaml | 6 +- .../Themes/ColorPicker/ColorPalette.xaml | 6 +- .../Themes/ColorPicker/ColorPicker.xaml | 12 +--- 4 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 src/MahApps.Metro/Converters/ColorToSolidColorBrushConverter.cs diff --git a/src/MahApps.Metro/Converters/ColorToSolidColorBrushConverter.cs b/src/MahApps.Metro/Converters/ColorToSolidColorBrushConverter.cs new file mode 100644 index 0000000000..de39855f76 --- /dev/null +++ b/src/MahApps.Metro/Converters/ColorToSolidColorBrushConverter.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace MahApps.Metro.Converters +{ + /// + /// Converts a given into a . + /// + [ValueConversion (typeof(Color), typeof(SolidColorBrush)) ] + public class ColorToSolidColorBrushConverter : MarkupConverter + { + static ColorToSolidColorBrushConverter _DefaultInstance; + + /// + /// returns a static instance if needed. + /// + public static ColorToSolidColorBrushConverter DefaultInstance => _DefaultInstance ??= new ColorToSolidColorBrushConverter(); + + /// + /// Gets or Sets the FallbackBrush which should be used if the conversion fails. + /// + public SolidColorBrush FallbackBrush { get; set; } + + protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is Color color) + { + var brush = new SolidColorBrush(color); + brush.Freeze(); + return brush; + } + else + { + return FallbackBrush; + } + } + + protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is SolidColorBrush brush) + { + return brush.Color; + } + else + { + return null; + } + } + } +} diff --git a/src/MahApps.Metro/Themes/ColorPicker/ColorCanvas.xaml b/src/MahApps.Metro/Themes/ColorPicker/ColorCanvas.xaml index 0abe35aca7..2249d70308 100644 --- a/src/MahApps.Metro/Themes/ColorPicker/ColorCanvas.xaml +++ b/src/MahApps.Metro/Themes/ColorPicker/ColorCanvas.xaml @@ -187,11 +187,7 @@ Background="{DynamicResource MahApps.Brushes.Tile}" BorderBrush="{DynamicResource MahApps.Brushes.ThemeForeground}" BorderThickness="1"> - - - - - + - - - - - + diff --git a/src/MahApps.Metro/Themes/ColorPicker/ColorPicker.xaml b/src/MahApps.Metro/Themes/ColorPicker/ColorPicker.xaml index e9cfdd7b36..7de8ca3c4d 100644 --- a/src/MahApps.Metro/Themes/ColorPicker/ColorPicker.xaml +++ b/src/MahApps.Metro/Themes/ColorPicker/ColorPicker.xaml @@ -22,11 +22,7 @@ Background="{DynamicResource MahApps.Brushes.Tile.Small}" BorderBrush="{DynamicResource MahApps.Brushes.Control.Border}" BorderThickness="1"> - - - - - + - - - - - + From 12c11cbad6d126340bb7c52e81c41d3b6a919070 Mon Sep 17 00:00:00 2001 From: punker76 Date: Thu, 25 Feb 2021 10:13:54 +0100 Subject: [PATCH 06/14] (GH-4019) Implement IValueConverter directly --- .../ColorToSolidColorBrushConverter.cs | 45 +++++++++---------- .../Themes/ColorPicker/ColorCanvas.xaml | 2 +- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/MahApps.Metro/Converters/ColorToSolidColorBrushConverter.cs b/src/MahApps.Metro/Converters/ColorToSolidColorBrushConverter.cs index de39855f76..41802e8a4f 100644 --- a/src/MahApps.Metro/Converters/ColorToSolidColorBrushConverter.cs +++ b/src/MahApps.Metro/Converters/ColorToSolidColorBrushConverter.cs @@ -1,33 +1,37 @@ using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Data; using System.Windows.Media; +using JetBrains.Annotations; namespace MahApps.Metro.Converters { /// /// Converts a given into a . /// - [ValueConversion (typeof(Color), typeof(SolidColorBrush)) ] - public class ColorToSolidColorBrushConverter : MarkupConverter + [ValueConversion(typeof(Color), typeof(SolidColorBrush))] + public class ColorToSolidColorBrushConverter : IValueConverter { - static ColorToSolidColorBrushConverter _DefaultInstance; + private static ColorToSolidColorBrushConverter defaultInstance; /// - /// returns a static instance if needed. + /// Gets a static instance of the converter if needed. /// - public static ColorToSolidColorBrushConverter DefaultInstance => _DefaultInstance ??= new ColorToSolidColorBrushConverter(); + public static ColorToSolidColorBrushConverter DefaultInstance => defaultInstance ??= new ColorToSolidColorBrushConverter(); /// - /// Gets or Sets the FallbackBrush which should be used if the conversion fails. + /// Gets or Sets the brush which will be used if the conversion fails. /// + [CanBeNull] public SolidColorBrush FallbackBrush { get; set; } - protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture) + /// + /// Gets or Sets the color which will be used if the conversion fails. + /// + [CanBeNull] + public Color? FallbackColor { get; set; } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is Color color) { @@ -35,22 +39,13 @@ protected override object Convert(object value, Type targetType, object paramete brush.Freeze(); return brush; } - else - { - return FallbackBrush; - } + + return this.FallbackBrush; } - protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - if (value is SolidColorBrush brush) - { - return brush.Color; - } - else - { - return null; - } + return value is SolidColorBrush brush ? brush.Color : this.FallbackColor; } } -} +} \ No newline at end of file diff --git a/src/MahApps.Metro/Themes/ColorPicker/ColorCanvas.xaml b/src/MahApps.Metro/Themes/ColorPicker/ColorCanvas.xaml index 2249d70308..ca94e51cd9 100644 --- a/src/MahApps.Metro/Themes/ColorPicker/ColorCanvas.xaml +++ b/src/MahApps.Metro/Themes/ColorPicker/ColorCanvas.xaml @@ -187,7 +187,7 @@ Background="{DynamicResource MahApps.Brushes.Tile}" BorderBrush="{DynamicResource MahApps.Brushes.ThemeForeground}" BorderThickness="1"> - + Date: Thu, 21 Jan 2021 19:09:10 +0900 Subject: [PATCH 07/14] Keep SelectedItemProperty Binding for ClearTextButton in ComboBox Use the SetCurrentValue method to prevent the binding from being released. --- src/MahApps.Metro/Controls/Helper/TextBoxHelper.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MahApps.Metro/Controls/Helper/TextBoxHelper.cs b/src/MahApps.Metro/Controls/Helper/TextBoxHelper.cs index e27211a1ce..d4f3cda5cf 100644 --- a/src/MahApps.Metro/Controls/Helper/TextBoxHelper.cs +++ b/src/MahApps.Metro/Controls/Helper/TextBoxHelper.cs @@ -931,11 +931,11 @@ public static void ButtonClicked(object sender, RoutedEventArgs e) { if (comboBox.IsEditable) { - comboBox.Text = string.Empty; + comboBox.SetCurrentValue(ComboBox.TextProperty, string.Empty); comboBox.GetBindingExpression(ComboBox.TextProperty)?.UpdateSource(); } - comboBox.SelectedItem = null; + comboBox.SetCurrentValue(ComboBox.SelectedItemProperty, null); comboBox.GetBindingExpression(ComboBox.SelectedItemProperty)?.UpdateSource(); } else if (parent is ColorPickerBase colorPicker) @@ -1020,4 +1020,4 @@ private static void ComboBoxLoaded(object sender, RoutedEventArgs e) } } } -} \ No newline at end of file +} From 039988cb01e2d60182d8365aad39147c20961858 Mon Sep 17 00:00:00 2001 From: punker76 Date: Thu, 25 Feb 2021 18:37:14 +0100 Subject: [PATCH 08/14] (GH-4030) Fix ToggleSwitch Right Alignment --- src/MahApps.Metro/Styles/Controls.ContextMenu.xaml | 4 +++- src/MahApps.Metro/Styles/VS/ContextMenu.xaml | 4 +++- src/MahApps.Metro/Themes/ToggleSwitch.xaml | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/MahApps.Metro/Styles/Controls.ContextMenu.xaml b/src/MahApps.Metro/Styles/Controls.ContextMenu.xaml index 6498042b63..13bc87f9b5 100644 --- a/src/MahApps.Metro/Styles/Controls.ContextMenu.xaml +++ b/src/MahApps.Metro/Styles/Controls.ContextMenu.xaml @@ -55,7 +55,9 @@ - + diff --git a/src/MahApps.Metro/Styles/VS/ContextMenu.xaml b/src/MahApps.Metro/Styles/VS/ContextMenu.xaml index c9fb349002..7f3385518d 100644 --- a/src/MahApps.Metro/Styles/VS/ContextMenu.xaml +++ b/src/MahApps.Metro/Styles/VS/ContextMenu.xaml @@ -55,7 +55,9 @@ - + diff --git a/src/MahApps.Metro/Themes/ToggleSwitch.xaml b/src/MahApps.Metro/Themes/ToggleSwitch.xaml index ae6c0993c5..128515f428 100644 --- a/src/MahApps.Metro/Themes/ToggleSwitch.xaml +++ b/src/MahApps.Metro/Themes/ToggleSwitch.xaml @@ -22,6 +22,7 @@ + @@ -55,8 +56,8 @@ TextElement.Foreground="{TemplateBinding mah:HeaderedControlHelper.HeaderForeground}" Visibility="Collapsed" /> - @@ -345,6 +346,7 @@ + From 5e17639978ae1dcf02307b16c165d80165227f3b Mon Sep 17 00:00:00 2001 From: punker76 Date: Sat, 27 Feb 2021 13:26:31 +0100 Subject: [PATCH 09/14] (GH-4012) Fix FlipView SelectionChanged event firing twice The SelectionChanged event is a bubbling event, so if the ListBox inside the FlipView fires the event, all other events in the same container will be fired. --- src/MahApps.Metro/Controls/FlipView.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/MahApps.Metro/Controls/FlipView.cs b/src/MahApps.Metro/Controls/FlipView.cs index 35b2960a99..fb6e4aa412 100644 --- a/src/MahApps.Metro/Controls/FlipView.cs +++ b/src/MahApps.Metro/Controls/FlipView.cs @@ -26,6 +26,7 @@ namespace MahApps.Metro.Controls [TemplatePart(Name = PART_DownButton, Type = typeof(Button))] [TemplatePart(Name = PART_BannerGrid, Type = typeof(Grid))] [TemplatePart(Name = PART_BannerLabel, Type = typeof(Label))] + [TemplatePart(Name = PART_Index, Type = typeof(ListBox))] [StyleTypedProperty(Property = nameof(NavigationButtonStyle), StyleTargetType = typeof(Button))] [StyleTypedProperty(Property = nameof(IndexItemContainerStyle), StyleTargetType = typeof(ListBoxItem))] public class FlipView : Selector @@ -696,6 +697,7 @@ public string ButtonDownContentStringFormat private const string PART_ForwardButton = "PART_ForwardButton"; private const string PART_Presenter = "PART_Presenter"; private const string PART_UpButton = "PART_UpButton"; + private const string PART_Index = "PART_Index"; /// /// To counteract the double Loaded event issue. /// @@ -911,6 +913,20 @@ public override void OnApplyTemplate() { this.bannerLabel.Opacity = this.IsBannerEnabled ? 1d : 0d; } + + this.ExecuteWhenLoaded(() => + { + if (this.GetTemplateChild(PART_Index) is ListBox listBox) + { + listBox.SelectionChanged += (sender, e) => + { + if (ReferenceEquals(e.OriginalSource, listBox)) + { + e.Handled = true; + } + }; + } + }); } protected override DependencyObject GetContainerForItemOverride() From b204632ea9cdaec7923999bc17b8832da0754f4a Mon Sep 17 00:00:00 2001 From: punker76 Date: Sun, 28 Feb 2021 12:43:03 +0100 Subject: [PATCH 10/14] (GH-4050) Add CornerRadiusFilterConverter Filters a CornerRadius by the given Filter property. Result can be a new CornerRadius or a value of it's 4 corners. --- .../Converters/CornerRadiusFilterConverter.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/MahApps.Metro/Converters/CornerRadiusFilterConverter.cs diff --git a/src/MahApps.Metro/Converters/CornerRadiusFilterConverter.cs b/src/MahApps.Metro/Converters/CornerRadiusFilterConverter.cs new file mode 100644 index 0000000000..14c1da0935 --- /dev/null +++ b/src/MahApps.Metro/Converters/CornerRadiusFilterConverter.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace MahApps.Metro.Converters +{ + /// + /// Filters a CornerRadius by the given Filter property. Result can be a new CornerRadius or a value of it's 4 corners. + /// + public class CornerRadiusFilterConverter : IValueConverter + { + public RadiusType Filter { get; set; } = RadiusType.None; + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is CornerRadius cornerRadius) + { + var filter = this.Filter; + + // yes, we can override it with the parameter value + if (parameter is RadiusType radiusType) + { + filter = radiusType; + } + + switch (filter) + { + default: + return cornerRadius; + case RadiusType.Left: + return new CornerRadius(cornerRadius.TopLeft, 0, 0, cornerRadius.BottomLeft); + case RadiusType.Top: + return new CornerRadius(cornerRadius.TopLeft, cornerRadius.TopRight, 0, 0); + case RadiusType.Right: + return new CornerRadius(0, cornerRadius.TopRight, cornerRadius.BottomRight, 0); + case RadiusType.Bottom: + return new CornerRadius(0, 0, cornerRadius.BottomRight, cornerRadius.BottomLeft); + case RadiusType.TopLeft: + return cornerRadius.TopLeft; + case RadiusType.TopRight: + return cornerRadius.TopRight; + case RadiusType.BottomRight: + return cornerRadius.BottomRight; + case RadiusType.BottomLeft: + return cornerRadius.BottomLeft; + } + } + + return Binding.DoNothing; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + // for now no back converting + return DependencyProperty.UnsetValue; + } + } +} \ No newline at end of file From 0c7ac72f578c2adf69c8cc53c9729da6dd0cf0b9 Mon Sep 17 00:00:00 2001 From: punker76 Date: Sun, 28 Feb 2021 12:47:01 +0100 Subject: [PATCH 11/14] (GH-4050) Add new CheckCornerRadius to CheckBoxHelper The CheckCornerRadius property allows users to control the roundness of the CheckBox corners independently by setting a radius value for each corner. --- .../ExampleViews/ButtonsExample.xaml | 2 +- .../Controls/Helper/CheckBoxHelper.cs | 30 +++++++++++++++++++ .../Styles/Controls.CheckBox.xaml | 7 ++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/ButtonsExample.xaml b/src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/ButtonsExample.xaml index f458486a20..1a42f74022 100644 --- a/src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/ButtonsExample.xaml +++ b/src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/ButtonsExample.xaml @@ -321,7 +321,7 @@