From abf17e6a68650b935cf0433ed425f7973c94dcc5 Mon Sep 17 00:00:00 2001 From: Marek Jurczyga Date: Fri, 5 Apr 2024 11:47:43 +0200 Subject: [PATCH 1/6] Added DrawingBrushIcone element --- .../Views/Pages/BasicInput/ButtonPage.xaml | 42 +++++++++++++++++ .../Controls/IconElement/DrawingBrushIcon.cs | 45 +++++++++++++++++++ .../Markup/DrawingBrushIconExtension.cs | 30 +++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs create mode 100644 src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml index 91d6247fe..cfb1309d1 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml @@ -94,6 +94,48 @@ Icon="{ui:SymbolIcon Fluent24}" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Date: Fri, 5 Apr 2024 11:50:05 +0200 Subject: [PATCH 2/6] Uncommented NavigationView.Base OnLoaded refresh state --- src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs index 4ee6f9920..91aa4faba 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs @@ -94,7 +94,7 @@ protected override void OnInitialized(EventArgs e) private void OnLoaded(object sender, RoutedEventArgs e) { // TODO: Refresh - //UpdateVisualState((NavigationView)sender); + UpdateVisualState((NavigationView)sender); } /// From 9281c437958833dee6a850f317af44eb4a3c0c9f Mon Sep 17 00:00:00 2001 From: Marek Jurczyga Date: Tue, 9 Apr 2024 09:36:53 +0200 Subject: [PATCH 3/6] DrawingBrushIcon --- .../Views/Pages/BasicInput/ButtonPage.xaml | 2 +- .../Controls/IconElement/DrawingBrushIcon.cs | 35 ++++++++++++++++--- .../Markup/DrawingBrushIconExtension.cs | 11 ++++-- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml index cfb1309d1..a9c60b1e5 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml @@ -132,7 +132,7 @@ + Icon="{ui:DrawingBrushIcon {StaticResource StatusCriticalError}, Size=24}"> diff --git a/src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs b/src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs index c4ef8b822..00d23ad80 100644 --- a/src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs @@ -27,19 +27,44 @@ private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedE self.Border.Background = e.NewValue as DrawingBrush; } + public double Size + { + get { return (double)GetValue(SizeProperty); } + set { SetValue(SizeProperty, value); } + } + + // Using a DependencyProperty as the backing store for IconSize. This enables animation, styling, binding, etc... + public static readonly DependencyProperty SizeProperty = + DependencyProperty.Register("Size", typeof(double), typeof(DrawingBrushIcon), new PropertyMetadata(16.0, OnIconSizeChanged)); + + private static void OnIconSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var self = (DrawingBrushIcon)d; + if (self.Border is null) + return; + + if (double.TryParse(e.NewValue?.ToString(), out double dblValue)) + { + self.Border.Width = dblValue; + self.Border.Height = dblValue; + } + } + protected Border? Border; protected override UIElement InitializeChildren() { Border = new Border() { - Background = Icon, HorizontalAlignment = HorizontalAlignment.Stretch, - VerticalAlignment = VerticalAlignment.Stretch, + Background = Icon, + Width = Size, + Height = Size }; - Grid grid = new Grid(); - grid.Children.Add(Border); - return grid; + Viewbox viewbox = new Viewbox(); + viewbox.Child = Border; + + return viewbox; } } diff --git a/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs b/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs index 2425e7a3e..ef5ec4bca 100644 --- a/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs +++ b/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs @@ -16,14 +16,21 @@ public DrawingBrushIconExtension(DrawingBrush icon) { Icon = icon; } - + public DrawingBrushIconExtension(DrawingBrush icon, double size) + : this(icon) + { + Size = size; + } [ConstructorArgument("icon")] public DrawingBrush Icon { get; set; } + [ConstructorArgument("Size")] + public double Size { get; set; } = 16; + public override object ProvideValue(IServiceProvider serviceProvider) { - var drawingBrushIcon = new DrawingBrushIcon { Icon = Icon }; + var drawingBrushIcon = new DrawingBrushIcon { Icon = Icon, Size = Size }; return drawingBrushIcon; } From 7d1a0f219aff18cc602aac7cd26ada1aba89086f Mon Sep 17 00:00:00 2001 From: Marek Jurczyga Date: Tue, 9 Apr 2024 11:03:54 +0200 Subject: [PATCH 4/6] added some style settings to NavigationLeftTemplate --- src/Wpf.Ui.Gallery/App.xaml | 3 ++ .../NavigationView/NavigationViewCompact.xaml | 54 ++++++++++++------- .../NavigationViewConstants.xaml | 11 ++++ 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/Wpf.Ui.Gallery/App.xaml b/src/Wpf.Ui.Gallery/App.xaml index 1c2e59256..2bbbc20fc 100644 --- a/src/Wpf.Ui.Gallery/App.xaml +++ b/src/Wpf.Ui.Gallery/App.xaml @@ -7,6 +7,7 @@ xmlns:syntax="http://schemas.lepo.co/wpfui/2022/xaml/syntax" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" DispatcherUnhandledException="OnDispatcherUnhandledException" + xmlns:system="clr-namespace:System;assembly=mscorlib" Exit="OnExit" Startup="OnStartup"> @@ -28,6 +29,8 @@ + + diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewCompact.xaml b/src/Wpf.Ui/Controls/NavigationView/NavigationViewCompact.xaml index 29b31e856..6793d420c 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewCompact.xaml +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewCompact.xaml @@ -17,8 +17,8 @@ - + - - + + + @@ -211,7 +213,7 @@ - + @@ -307,6 +309,8 @@ Grid.Row="0" Margin="0,5,0,5" HorizontalAlignment="Left" + Width="{DynamicResource PaneLeftButtonWidth}" + Height="{DynamicResource PaneLeftButtonHeight}" IsEnabled="{TemplateBinding IsBackEnabled}" Style="{StaticResource BasePaneButtonStyle}" Visibility="{TemplateBinding IsBackButtonVisible, @@ -316,20 +320,30 @@ - + + + + + + + - - - - - - - + + + + + + + + @@ -461,7 +475,7 @@ Storyboard.TargetName="PaneGrid" Storyboard.TargetProperty="Width" From="{TemplateBinding OpenPaneLength}" - To="40" + To="{DynamicResource PaneLeftButtonWidth}" Duration="0:0:.16" /> @@ -474,6 +488,7 @@ + @@ -481,6 +496,7 @@ + diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml b/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml index 5c396e733..c083c91a8 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml @@ -4,6 +4,15 @@ xmlns:converters="clr-namespace:Wpf.Ui.Converters" xmlns:system="clr-namespace:System;assembly=mscorlib"> + + + 12 + 16 + 40 + 40 + + 24 40 40 @@ -11,6 +20,8 @@ 60 12 1,1,1,1 + + From 5aa126ef2c7788093c961afd8d811b8e7030d68d Mon Sep 17 00:00:00 2001 From: Marek Jurczyga Date: Fri, 19 Apr 2024 09:03:09 +0200 Subject: [PATCH 5/6] [#890 - bugfix] - comment default textblock style font size --- src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml | 8 +++++--- src/Wpf.Ui/Controls/TextBlock/TextBlock.xaml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml index a9c60b1e5..d13e0ae02 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml @@ -128,12 +128,14 @@ + - - + + - + From e90f5f0aca979bbf76f362d7aad5fcd3d256d22f Mon Sep 17 00:00:00 2001 From: Marek Jurczyga Date: Sun, 21 Apr 2024 14:02:13 +0200 Subject: [PATCH 6/6] Addressed requested changes --- src/Wpf.Ui.Gallery/App.xaml | 2 -- .../Controls/IconElement/DrawingBrushIcon.cs | 29 +++++++++++++++---- .../NavigationViewConstants.xaml | 6 +--- .../Markup/DrawingBrushIconExtension.cs | 5 ++-- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/Wpf.Ui.Gallery/App.xaml b/src/Wpf.Ui.Gallery/App.xaml index 2bbbc20fc..1088a5938 100644 --- a/src/Wpf.Ui.Gallery/App.xaml +++ b/src/Wpf.Ui.Gallery/App.xaml @@ -29,8 +29,6 @@ - - diff --git a/src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs b/src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs index 00d23ad80..c63736ab0 100644 --- a/src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs +++ b/src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs @@ -7,16 +7,27 @@ using System.Windows.Controls; namespace Wpf.Ui.Controls; + +/// +/// Represents an icon that uses an DrawingBrush as its content. +/// public class DrawingBrushIcon : IconElement { + /// + /// Gets or sets + /// public DrawingBrush Icon { get { return (DrawingBrush)GetValue(IconProperty); } set { SetValue(IconProperty, value); } } - public static readonly DependencyProperty IconProperty = - DependencyProperty.Register("Icon", typeof(DrawingBrush), typeof(DrawingBrushIcon), new PropertyMetadata(default(DrawingBrush), OnIconChanged)); + /// Identifies the dependency property. + public static readonly DependencyProperty IconProperty = DependencyProperty.Register( + nameof(Icon), + typeof(DrawingBrush), + typeof(DrawingBrushIcon), + new PropertyMetadata(default(DrawingBrush), OnIconChanged)); private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { @@ -27,21 +38,29 @@ private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedE self.Border.Background = e.NewValue as DrawingBrush; } + /// + /// Gets or sets + /// public double Size { get { return (double)GetValue(SizeProperty); } set { SetValue(SizeProperty, value); } } - // Using a DependencyProperty as the backing store for IconSize. This enables animation, styling, binding, etc... - public static readonly DependencyProperty SizeProperty = - DependencyProperty.Register("Size", typeof(double), typeof(DrawingBrushIcon), new PropertyMetadata(16.0, OnIconSizeChanged)); + /// Identifies the dependency property. + public static readonly DependencyProperty SizeProperty = DependencyProperty.Register( + nameof(Size), + typeof(double), + typeof(DrawingBrushIcon), + new PropertyMetadata(16.0, OnIconSizeChanged)); private static void OnIconSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var self = (DrawingBrushIcon)d; if (self.Border is null) + { return; + } if (double.TryParse(e.NewValue?.ToString(), out double dblValue)) { diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml b/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml index c083c91a8..cd2e6a63b 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml @@ -4,15 +4,11 @@ xmlns:converters="clr-namespace:Wpf.Ui.Converters" xmlns:system="clr-namespace:System;assembly=mscorlib"> - - 12 16 40 40 - - + 24 40 40 diff --git a/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs b/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs index ef5ec4bca..a1de2ce49 100644 --- a/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs +++ b/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs @@ -16,8 +16,9 @@ public DrawingBrushIconExtension(DrawingBrush icon) { Icon = icon; } + public DrawingBrushIconExtension(DrawingBrush icon, double size) - : this(icon) + : this(icon) { Size = size; } @@ -25,7 +26,7 @@ public DrawingBrushIconExtension(DrawingBrush icon, double size) [ConstructorArgument("icon")] public DrawingBrush Icon { get; set; } - [ConstructorArgument("Size")] + [ConstructorArgument("size")] public double Size { get; set; } = 16; public override object ProvideValue(IServiceProvider serviceProvider)