From f391c61869442c8032f10adf98305cb8b36a5e26 Mon Sep 17 00:00:00 2001 From: mOlDaViA Date: Mon, 10 Jun 2024 10:36:30 +0200 Subject: [PATCH 1/4] Added the HorizontalIconAlignment property. You can now choose, if you want to show the icon left or right to the content. --- src/Wpf.Ui/Controls/Button/Button.cs | 34 ++- src/Wpf.Ui/Controls/Button/Button.xaml | 285 +++++++++++++++---------- 2 files changed, 201 insertions(+), 118 deletions(-) diff --git a/src/Wpf.Ui/Controls/Button/Button.cs b/src/Wpf.Ui/Controls/Button/Button.cs index fd14c98fa..f59fccf74 100644 --- a/src/Wpf.Ui/Controls/Button/Button.cs +++ b/src/Wpf.Ui/Controls/Button/Button.cs @@ -13,16 +13,16 @@ namespace Wpf.Ui.Controls; /// /// /// -/// <ui:Button +/// /// /// -/// <ui:Button +/// /// /// /// @@ -100,6 +100,13 @@ public class Button : System.Windows.Controls.Button, IAppearanceControl, IIconC ) ); + /// Identifies the dependency property. + public static readonly DependencyProperty HorizontalIconAlignmentProperty = DependencyProperty.Register( + nameof(HorizontalIconAlignment), + typeof(HorizontalIconAlignments), + typeof(Button), + new PropertyMetadata(HorizontalIconAlignments.Left)); + /// /// Gets or sets displayed . /// @@ -181,6 +188,21 @@ public Brush PressedBorderBrush public CornerRadius CornerRadius { get => (CornerRadius)GetValue(CornerRadiusProperty); - set => SetValue(CornerRadiusProperty, (object)value); + set => SetValue(CornerRadiusProperty, value); + } + + /// + /// Gets or sets whether the icon should be shown left or right from the content. + /// + public HorizontalIconAlignments HorizontalIconAlignment + { + get => (HorizontalIconAlignments)GetValue(HorizontalIconAlignmentProperty); + set => SetValue(HorizontalIconAlignmentProperty, value); + } + + public enum HorizontalIconAlignments + { + Left, + Right } -} +} \ No newline at end of file diff --git a/src/Wpf.Ui/Controls/Button/Button.xaml b/src/Wpf.Ui/Controls/Button/Button.xaml index 7214b0114..e52790206 100644 --- a/src/Wpf.Ui/Controls/Button/Button.xaml +++ b/src/Wpf.Ui/Controls/Button/Button.xaml @@ -11,30 +11,34 @@ + xmlns:controls="clr-namespace:Wpf.Ui.Controls" + > 11,5,11,6 1 - 0,0,8,0 + - - - - - - - + - - - + + + - - - + + + + + + + + + + + + + + - + - + - + - + - + - + - - + + - - + + - + - - - + + + - - - - + + + + + + + + + + + + + + - + - + - + - + - + - + - - + + - - + + - + \ No newline at end of file diff --git a/src/Wpf.Ui/Controls/Slider/SliderThumbPositionConverter.cs b/src/Wpf.Ui/Controls/Slider/SliderThumbPositionConverter.cs new file mode 100644 index 000000000..40c1d441f --- /dev/null +++ b/src/Wpf.Ui/Controls/Slider/SliderThumbPositionConverter.cs @@ -0,0 +1,22 @@ +using System.Windows.Data; + +// ReSharper disable once CheckNamespace +namespace Wpf.Ui.Controls; + +public class SliderThumbPositionConverter : IMultiValueConverter +{ + public object Convert(object[]? values, Type targetType, object parameter, CultureInfo culture) + { + if (values is [double trackActualDimension, double trackValue, double trackMinimum, double trackMaximum]) + { + return trackActualDimension * (trackValue - trackMinimum) / (trackMaximum - trackMinimum); + } + + return Binding.DoNothing; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/Wpf.Ui/Markup/FontIconExtension.cs b/src/Wpf.Ui/Markup/FontIconExtension.cs index 448ea33a6..6be6cc6e4 100644 --- a/src/Wpf.Ui/Markup/FontIconExtension.cs +++ b/src/Wpf.Ui/Markup/FontIconExtension.cs @@ -3,6 +3,7 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using System.Windows.Controls; using System.Windows.Markup; using Wpf.Ui.Controls; @@ -39,33 +40,86 @@ public FontIconExtension(string glyph) Glyph = glyph; } + public FontIconExtension(string glyph, double fontSize) + : this(glyph) + { + FontSize = fontSize; + } + + public FontIconExtension(string glyph, FontFamily fontFamily, double fontSize) + : this(glyph, fontSize) + { + FontFamily = fontFamily; + } + [ConstructorArgument("glyph")] - public string? Glyph { get; set; } + public required string Glyph { get; set; } [ConstructorArgument("fontFamily")] public FontFamily FontFamily { get; set; } = new("FluentSystemIcons"); - public double FontSize { get; set; } + [ConstructorArgument("fontSize")] + public double? FontSize { get; set; } public override object ProvideValue(IServiceProvider serviceProvider) { - if ( - serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget + if (serviceProvider.GetService(typeof(IProvideValueTarget)) is not IProvideValueTarget provideValueTarget) + { + return new FontIcon { - TargetObject: Setter - } - ) + FontFamily = FontFamily, + Glyph = Glyph, + FontSize = FontSize ?? SystemFonts.MessageFontSize + }; + } + + if (provideValueTarget.TargetObject is Setter) { return this; } - FontIcon fontIcon = new() { Glyph = Glyph, FontFamily = FontFamily }; + FontIcon fontIcon = new() + { + FontFamily = FontFamily, + Glyph = Glyph, + }; + + if (FontSize.HasValue) + { + fontIcon.FontSize = FontSize.Value; + } - if (FontSize > 0) + if (provideValueTarget.TargetObject is not FrameworkElement targetElement) { - fontIcon.FontSize = FontSize; + return fontIcon; } + targetElement.Loaded += (_, _) => + { + UpdateFontSize(fontIcon, targetElement); + }; + + targetElement.LayoutUpdated += (_, _) => + { + UpdateFontSize(fontIcon, targetElement); + }; + return fontIcon; } -} + + private void UpdateFontSize(FontIcon fontIcon, FrameworkElement targetElement) + { + if (FontSize.HasValue) + { + fontIcon.SetCurrentValue(FontIcon.FontSizeProperty, FontSize.Value); + } + else if (targetElement is Control control) + { + fontIcon.SetCurrentValue(FontIcon.FontSizeProperty, control.FontSize); + } + else + { + fontIcon.SetCurrentValue(FontIcon.FontSizeProperty, SystemFonts.MessageFontSize); + } + } +} \ No newline at end of file diff --git a/src/Wpf.Ui/Markup/SymbolIconExtension.cs b/src/Wpf.Ui/Markup/SymbolIconExtension.cs index 754706976..c2cf86c7a 100644 --- a/src/Wpf.Ui/Markup/SymbolIconExtension.cs +++ b/src/Wpf.Ui/Markup/SymbolIconExtension.cs @@ -3,6 +3,7 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using System.Windows.Controls; using System.Windows.Markup; using Wpf.Ui.Controls; @@ -50,33 +51,66 @@ public SymbolIconExtension(SymbolRegular symbol, bool filled) Filled = filled; } + public SymbolIconExtension(SymbolRegular symbol, bool filled, double fontSize) + : this(symbol, filled) + { + FontSize = fontSize; + } + [ConstructorArgument("symbol")] public SymbolRegular Symbol { get; set; } [ConstructorArgument("filled")] public bool Filled { get; set; } + [ConstructorArgument("fontSize")] public double FontSize { get; set; } public override object ProvideValue(IServiceProvider serviceProvider) { - if ( - serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget - { - TargetObject: Setter - } - ) + if (serviceProvider.GetService(typeof(IProvideValueTarget)) is not IProvideValueTarget provideValueTarget) + { + return new SymbolIcon { Symbol = Symbol, Filled = Filled, FontSize = FontSize > 0 ? FontSize : SystemFonts.MessageFontSize }; + } + + if (provideValueTarget.TargetObject is Setter) { return this; } - SymbolIcon symbolIcon = new() { Symbol = Symbol, Filled = Filled }; + SymbolIcon symbolIcon = new () + { + Symbol = Symbol, + Filled = Filled + }; - if (FontSize > 0) + if (provideValueTarget.TargetObject is not FrameworkElement targetElement) { - symbolIcon.FontSize = FontSize; + return symbolIcon; } + targetElement.Loaded += (_, _) => + { + UpdateFontSize(symbolIcon, targetElement); + }; + + targetElement.LayoutUpdated += (_, _) => + { + UpdateFontSize(symbolIcon, targetElement); + }; + return symbolIcon; } -} + + private void UpdateFontSize(SymbolIcon symbolIcon, FrameworkElement targetElement) + { + if (FontSize > 0) + { + symbolIcon.SetCurrentValue(FontIcon.FontSizeProperty, FontSize); + } + else if (targetElement is Control control) + { + symbolIcon.SetCurrentValue(FontIcon.FontSizeProperty, control.FontSize); + } + } +} \ No newline at end of file From ee5b3c355ce333242d5fdfe020957635fd3ec062 Mon Sep 17 00:00:00 2001 From: mOlDaViA Date: Mon, 24 Jun 2024 07:03:51 +0200 Subject: [PATCH 3/4] Rewrite of the TitleBar class: 1. Added AdditionalControls property: You can now add additional buttons with the same default size or add customizied controls. Button default style example: ```csharp ``` 2. Header remains the same. 3. Window is now resizable if you use a TitleBar: You can now (finally!) resize the window if you use the TitleBar! This was the most reason why i switched here from messages to events. Messages are basically not necsassary for the titlebar. 4. ActionsOverride: You can now override every default button (Help, Minimize, Maximize and Close) contained in the TitleBar. Before you could create a RoutedEvent for the close event and performe actions in there but you could never cancel the close method as it was a seperated event inside the TitleBar called after the override action. Now you can! 4. Added boolean UseTrayMenu: If UseTrayMenu on close click the application now hides instead the window of closing it. Add your tray menu and your boolean and you are good to go. 5. DragMove from maximized window is now smoother. --- .../Controls/AccessText/AccessText.xaml | 28 +- src/Wpf.Ui/Controls/Anchor/Anchor.xaml | 22 +- .../AutoSuggestBox/AutoSuggestBox.xaml | 212 +-- src/Wpf.Ui/Controls/Badge/Badge.xaml | 68 +- .../Controls/BreadcrumbBar/BreadcrumbBar.xaml | 128 +- src/Wpf.Ui/Controls/Calendar/Calendar.xaml | 640 ++++---- .../CalendarDatePicker.xaml | 24 +- src/Wpf.Ui/Controls/Card/Card.xaml | 98 +- .../Controls/CardAction/CardAction.xaml | 166 +- src/Wpf.Ui/Controls/CardColor/CardColor.xaml | 66 +- .../Controls/CardControl/CardControl.xaml | 166 +- .../Controls/CardExpander/CardExpander.xaml | 314 ++-- src/Wpf.Ui/Controls/CheckBox/CheckBox.xaml | 180 +- .../Controls/ColorPicker/ColorPicker.xaml | 12 +- src/Wpf.Ui/Controls/ComboBox/ComboBox.xaml | 504 +++--- .../Controls/ContentDialog/ContentDialog.xaml | 298 ++-- .../Controls/ContextMenu/ContextMenu.xaml | 78 +- .../ContextMenu/ContextMenuLoader.xaml | 8 +- src/Wpf.Ui/Controls/DataGrid/DataGrid.xaml | 843 +++++----- .../Controls/DatePicker/DatePicker.xaml | 246 +-- .../DropDownButton/DropDownButton.xaml | 142 +- .../DynamicScrollBar/DynamicScrollBar.xaml | 562 ++++--- .../DynamicScrollViewer.xaml | 88 +- src/Wpf.Ui/Controls/Expander/Expander.xaml | 278 ++-- .../Controls/FluentWindow/FluentWindow.xaml | 60 +- src/Wpf.Ui/Controls/Flyout/Flyout.xaml | 104 +- src/Wpf.Ui/Controls/Frame/Frame.xaml | 16 +- .../GridView/GridViewColumnHeader.xaml | 116 +- .../HyperlinkButton/HyperlinkButton.xaml | 136 +- src/Wpf.Ui/Controls/Image/Image.xaml | 54 +- src/Wpf.Ui/Controls/InfoBadge/InfoBadge.xaml | 188 ++- src/Wpf.Ui/Controls/InfoBar/InfoBar.xaml | 160 +- .../Controls/ItemsControl/ItemsControl.xaml | 4 +- src/Wpf.Ui/Controls/Label/Label.xaml | 12 +- src/Wpf.Ui/Controls/ListBox/ListBox.xaml | 58 +- src/Wpf.Ui/Controls/ListBox/ListBoxItem.xaml | 54 +- src/Wpf.Ui/Controls/ListView/ListView.xaml | 240 +-- .../Controls/ListView/ListViewItem.xaml | 152 +- .../Controls/LoadingScreen/LoadingScreen.xaml | 40 +- src/Wpf.Ui/Controls/Menu/Menu.xaml | 44 +- src/Wpf.Ui/Controls/Menu/MenuItem.xaml | 1058 ++++++------ src/Wpf.Ui/Controls/Menu/MenuLoader.xaml | 10 +- .../Controls/MessageBox/MessageBox.xaml | 210 +-- .../NavigationView/NavigationLeftFluent.xaml | 210 +-- .../NavigationView/NavigationView.xaml | 80 +- .../NavigationViewBasePaneButtonStyle.xaml | 128 +- .../NavigationView/NavigationViewBottom.xaml | 256 +-- .../NavigationViewBreadcrumbItem.xaml | 16 +- .../NavigationView/NavigationViewCompact.xaml | 618 +++---- .../NavigationViewConstants.xaml | 16 +- .../NavigationViewContentPresenter.xaml | 54 +- .../NavigationViewItemDefaultStyle.xaml | 40 +- .../NavigationViewItemHeader.xaml | 66 +- .../NavigationViewItemSeparator.xaml | 32 +- .../NavigationViewLeftMinimalCompact.xaml | 276 ++-- .../NavigationView/NavigationViewTop.xaml | 476 +++--- src/Wpf.Ui/Controls/NumberBox/NumberBox.xaml | 390 ++--- src/Wpf.Ui/Controls/Page/Page.xaml | 32 +- .../Controls/PasswordBox/PasswordBox.xaml | 448 ++--- .../Controls/ProgressBar/ProgressBar.xaml | 116 +- .../Controls/ProgressRing/ProgressRing.xaml | 114 +- .../Controls/RadioButton/RadioButton.xaml | 220 +-- .../Controls/RatingControl/RatingControl.xaml | 132 +- .../Controls/RichTextBox/RichTextBox.xaml | 108 +- src/Wpf.Ui/Controls/ScrollBar/ScrollBar.xaml | 516 +++--- .../Controls/ScrollViewer/ScrollViewer.xaml | 84 +- src/Wpf.Ui/Controls/Separator/Separator.xaml | 30 +- src/Wpf.Ui/Controls/Snackbar/Snackbar.xaml | 278 ++-- .../Controls/SplitButton/SplitButton.xaml | 238 +-- src/Wpf.Ui/Controls/StatusBar/StatusBar.xaml | 44 +- .../Controls/TabControl/TabControl.xaml | 152 +- src/Wpf.Ui/Controls/TextBlock/TextBlock.xaml | 18 +- src/Wpf.Ui/Controls/TextBox/TextBox.xaml | 508 +++--- src/Wpf.Ui/Controls/ThumbRate/ThumbRate.xaml | 82 +- .../Controls/TimePicker/TimePicker.xaml | 156 +- src/Wpf.Ui/Controls/TitleBar/TitleBar.cs | 748 ++++----- src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml | 395 ++--- .../Controls/TitleBar/TitleBarButton.cs | 237 --- .../Controls/TitleBar/TitleBarButtonType.cs | 43 - .../Controls/ToggleButton/ToggleButton.xaml | 144 +- .../Controls/ToggleSwitch/ToggleSwitch.xaml | 390 ++--- src/Wpf.Ui/Controls/ToolBar/ToolBar.xaml | 318 ++-- src/Wpf.Ui/Controls/ToolTip/ToolTip.xaml | 78 +- src/Wpf.Ui/Controls/TreeGrid/TreeGrid.xaml | 98 +- src/Wpf.Ui/Controls/TreeView/TreeView.xaml | 70 +- .../Controls/TreeView/TreeViewItem.xaml | 358 ++-- .../VirtualizingGridView.xaml | 62 +- .../VirtualizingItemsControl.xaml | 50 +- .../VirtualizingWrapPanel.xaml | 20 +- src/Wpf.Ui/Controls/Window/Window.xaml | 72 +- src/Wpf.Ui/Resources/Accent.xaml | 64 +- src/Wpf.Ui/Resources/DefaultContextMenu.xaml | 10 +- .../Resources/DefaultFocusVisualStyle.xaml | 20 +- .../DefaultTextBoxScrollViewerStyle.xaml | 29 +- src/Wpf.Ui/Resources/Fonts.xaml | 4 +- src/Wpf.Ui/Resources/Palette.xaml | 84 +- src/Wpf.Ui/Resources/StaticColors.xaml | 60 +- src/Wpf.Ui/Resources/Theme/Dark.xaml | 1450 ++++++++++++----- src/Wpf.Ui/Resources/Typography.xaml | 108 +- src/Wpf.Ui/Resources/Variables.xaml | 8 +- src/Wpf.Ui/Resources/Wpf.Ui.xaml | 182 +-- 101 files changed, 10051 insertions(+), 8872 deletions(-) delete mode 100644 src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs delete mode 100644 src/Wpf.Ui/Controls/TitleBar/TitleBarButtonType.cs diff --git a/src/Wpf.Ui/Controls/AccessText/AccessText.xaml b/src/Wpf.Ui/Controls/AccessText/AccessText.xaml index 3e8dde99c..b39cfa8ae 100644 --- a/src/Wpf.Ui/Controls/AccessText/AccessText.xaml +++ b/src/Wpf.Ui/Controls/AccessText/AccessText.xaml @@ -5,20 +5,24 @@ All Rights Reserved. --> - + - - - - - - - - - - - - - - - - - - - - - + + - - + - - - - - + + + + + - + - + - + @@ -176,26 +194,26 @@ - + - - + + - - + + - + - + - + diff --git a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml index d627afdcb..ce7659288 100644 --- a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml +++ b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml @@ -5,55 +5,57 @@ All Rights Reserved. --> - + - - - - - - - - - - - - - - + #FFFF0000 @@ -771,133 +818,143 @@ 22 22 - - - - - - - - - - + - - - + + + - - - + + + - + - + - + - + - - - - + + + + - - - - + + + + @@ -224,24 +236,24 @@ - + - + @@ -249,59 +261,65 @@ - + - - - + + + - + - + - + - + - + - + - + @@ -309,60 +327,60 @@ - - - - + + + + - - - - + + + + @@ -371,24 +389,24 @@ - + - + @@ -396,26 +414,30 @@ - - - - - - diff --git a/src/Wpf.Ui/Controls/GridView/GridViewColumnHeader.xaml b/src/Wpf.Ui/Controls/GridView/GridViewColumnHeader.xaml index 8881c5acf..84549094d 100644 --- a/src/Wpf.Ui/Controls/GridView/GridViewColumnHeader.xaml +++ b/src/Wpf.Ui/Controls/GridView/GridViewColumnHeader.xaml @@ -5,23 +5,25 @@ All Rights Reserved. --> - + - - - - - - diff --git a/src/Wpf.Ui/Controls/ListBox/ListBox.xaml b/src/Wpf.Ui/Controls/ListBox/ListBox.xaml index de1b16ee2..37e5749ff 100644 --- a/src/Wpf.Ui/Controls/ListBox/ListBox.xaml +++ b/src/Wpf.Ui/Controls/ListBox/ListBox.xaml @@ -5,28 +5,32 @@ All Rights Reserved. --> - + - - - - - - - - - + + - - + + - - + + - - + + - + - + - + - - + + - + @@ -118,19 +126,19 @@ - + - - + + - + - + @@ -138,14 +146,14 @@ - + - + @@ -156,48 +164,50 @@ - - + + - - + + - - + + - + - + - - + + - + @@ -205,170 +215,182 @@ - - + + - - - - + + + + - - + Background="{DynamicResource CheckBoxBackground}" + BorderBrush="{DynamicResource CheckBoxBorderBrush}" + BorderThickness="1" + CornerRadius="4" + Visibility="Collapsed" + > + - - - - - + + + + + - + - + - + - + - + - + - + - - + + - - + + - - - + + + - - - + + + - + - + - + - + - - + + - + @@ -376,11 +398,11 @@ - - + + - + - - + + - - + + - - - + + + - - - + + + - + - + - + - - + + - + @@ -530,20 +560,20 @@ - - + + - - + + - + - + @@ -551,14 +581,14 @@ - + - + @@ -569,53 +599,55 @@ - - + + - - - + + + - - - + + + - + - - + + - - + + - + @@ -623,177 +655,189 @@ - - + + - - - - - + + + + + - - + Background="{DynamicResource CheckBoxBackground}" + BorderBrush="{DynamicResource CheckBoxBorderBrush}" + BorderThickness="1" + CornerRadius="4" + Visibility="Collapsed" + > + - - - - - + + + + + - + - - + + - - + + - + - + - + - + - - + + - - + + - - - - + + + + - - - + + + - + - + - + - + - - + + - + @@ -801,11 +845,11 @@ - - + + - + - - - + - - - - - + + + + + - + - + - + @@ -131,29 +145,29 @@ - + - + - - + + - + - - + + - + - + @@ -161,8 +175,8 @@ - - + + diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationLeftFluent.xaml b/src/Wpf.Ui/Controls/NavigationView/NavigationLeftFluent.xaml index c0b6265d6..b82cebad3 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationLeftFluent.xaml +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationLeftFluent.xaml @@ -1,145 +1,149 @@ - + - + - - + + - + - + - - + + - + - - + + - + - - - - + + + + - - - + + + - - - + + + - + - - + + - + - - + + - - + + - + - - - - - + + + + + - - - - - - + + + + - + - + - + - + - - + + - + - + - + - - diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.xaml b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.xaml index cd6aba954..486050fc9 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.xaml +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.xaml @@ -5,51 +5,51 @@ All Rights Reserved. --> - + - - - - - - - + + + @@ -65,42 +75,50 @@ - - - - - + + + + + diff --git a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.xaml b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.xaml index 6dc7b15a6..f2466720c 100644 --- a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.xaml +++ b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.xaml @@ -5,37 +5,39 @@ All Rights Reserved. --> - + - + - - - - - - + - - - + + + - - - + + + - + - + - + - + - - - - + + + + - - - - + + + + @@ -231,117 +243,123 @@ - + - - - + + + - + - - + + - + - + - + - + - - - - + + + + - - - - + + + + @@ -349,26 +367,30 @@ - - - - + - - + - + @@ -121,50 +127,58 @@ - + - - + + - - + + - - - + + + - + - - - + + + - + @@ -175,124 +189,124 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/src/Wpf.Ui/Controls/SplitButton/SplitButton.xaml b/src/Wpf.Ui/Controls/SplitButton/SplitButton.xaml index 609d86275..f78bcc010 100644 --- a/src/Wpf.Ui/Controls/SplitButton/SplitButton.xaml +++ b/src/Wpf.Ui/Controls/SplitButton/SplitButton.xaml @@ -8,133 +8,139 @@ Copyright (c) Microsoft Corporation. All Rights Reserved. --> - + - + 8,0,0,0 - - - - + + + + - - - diff --git a/src/Wpf.Ui/Controls/TabControl/TabControl.xaml b/src/Wpf.Ui/Controls/TabControl/TabControl.xaml index 4d18232f2..845101edb 100644 --- a/src/Wpf.Ui/Controls/TabControl/TabControl.xaml +++ b/src/Wpf.Ui/Controls/TabControl/TabControl.xaml @@ -5,51 +5,53 @@ All Rights Reserved. --> - + diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.xaml b/src/Wpf.Ui/Controls/TextBox/TextBox.xaml index 4fc1e5940..da34b71c1 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.xaml +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.xaml @@ -8,11 +8,11 @@ Copyright (c) Microsoft Corporation. All Rights Reserved. --> - + 1,1,1,1 0,0,0,1 @@ -22,94 +22,98 @@ 0,0,0,0 24 - - - - - + + + + - - - - + + + + - + - - - + + + - + - + - + - + - + - - + + - - + + - - + + - - + + - - - - + + + + - - - + + + - - - + + + - + - - + + - + - - - - - - - - + + + + + + + + - - - - + + + + - + - - - - + + + - - + \ No newline at end of file diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs deleted file mode 100644 index e87f3352f..000000000 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs +++ /dev/null @@ -1,237 +0,0 @@ -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. -// Copyright (C) Leszek Pomianowski and WPF UI Contributors. -// All Rights Reserved. - -using System.Windows.Automation.Peers; -using System.Windows.Automation.Provider; -using Wpf.Ui.Extensions; -using Wpf.Ui.Interop; - -// ReSharper disable once CheckNamespace -namespace Wpf.Ui.Controls; - -public class TitleBarButton : Wpf.Ui.Controls.Button -{ - /// Identifies the dependency property. - public static readonly DependencyProperty ButtonTypeProperty = DependencyProperty.Register( - nameof(ButtonType), - typeof(TitleBarButtonType), - typeof(TitleBarButton), - new PropertyMetadata(TitleBarButtonType.Unknown, OnButtonTypeChanged) - ); - - /// Identifies the dependency property. - public static readonly DependencyProperty ButtonsForegroundProperty = DependencyProperty.Register( - nameof(ButtonsForeground), - typeof(Brush), - typeof(TitleBarButton), - new FrameworkPropertyMetadata( - SystemColors.ControlTextBrush, - FrameworkPropertyMetadataOptions.Inherits - ) - ); - - /// Identifies the dependency property. - public static readonly DependencyProperty MouseOverButtonsForegroundProperty = - DependencyProperty.Register( - nameof(MouseOverButtonsForeground), - typeof(Brush), - typeof(TitleBarButton), - new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits) - ); - - /// Identifies the dependency property. - public static readonly DependencyProperty RenderButtonsForegroundProperty = DependencyProperty.Register( - nameof(RenderButtonsForeground), - typeof(Brush), - typeof(TitleBarButton), - new FrameworkPropertyMetadata( - SystemColors.ControlTextBrush, - FrameworkPropertyMetadataOptions.Inherits - ) - ); - - /// - /// Gets or sets the type of the button. - /// - public TitleBarButtonType ButtonType - { - get => (TitleBarButtonType)GetValue(ButtonTypeProperty); - set => SetValue(ButtonTypeProperty, value); - } - - /// - /// Gets or sets the foreground of the navigation buttons. - /// - public Brush ButtonsForeground - { - get => (Brush)GetValue(ButtonsForegroundProperty); - set => SetValue(ButtonsForegroundProperty, value); - } - - /// - /// Gets or sets the foreground of the navigation buttons when moused over. - /// - public Brush? MouseOverButtonsForeground - { - get => (Brush?)GetValue(MouseOverButtonsForegroundProperty); - set => SetValue(MouseOverButtonsForegroundProperty, value); - } - - public Brush RenderButtonsForeground - { - get => (Brush)GetValue(RenderButtonsForegroundProperty); - set => SetValue(RenderButtonsForegroundProperty, value); - } - - public bool IsHovered { get; private set; } - - private readonly Brush _defaultBackgroundBrush = Brushes.Transparent; // REVIEW: Should it be transparent? - private User32.WM_NCHITTEST _returnValue; - - private bool _isClickedDown; - - public TitleBarButton() - { - Loaded += TitleBarButton_Loaded; - Unloaded += TitleBarButton_Unloaded; - } - - private void TitleBarButton_Unloaded(object sender, RoutedEventArgs e) - { - DependencyPropertyDescriptor - .FromProperty(ButtonsForegroundProperty, typeof(Brush)) - .RemoveValueChanged(this, OnButtonsForegroundChanged); - } - - private void TitleBarButton_Loaded(object sender, RoutedEventArgs e) - { - SetCurrentValue(RenderButtonsForegroundProperty, ButtonsForeground); - DependencyPropertyDescriptor - .FromProperty(ButtonsForegroundProperty, typeof(Brush)) - .AddValueChanged(this, OnButtonsForegroundChanged); - } - - private void OnButtonsForegroundChanged(object? sender, EventArgs e) - { - SetCurrentValue( - RenderButtonsForegroundProperty, - IsHovered ? MouseOverButtonsForeground : ButtonsForeground - ); - } - - /// - /// Forces button background to change. - /// - public void Hover() - { - if (IsHovered) - { - return; - } - - SetCurrentValue(BackgroundProperty, MouseOverBackground); - if (MouseOverButtonsForeground != null) - { - SetCurrentValue(RenderButtonsForegroundProperty, MouseOverButtonsForeground); - } - - IsHovered = true; - } - - /// - /// Forces button background to change. - /// - public void RemoveHover() - { - if (!IsHovered) - { - return; - } - - SetCurrentValue(BackgroundProperty, _defaultBackgroundBrush); - SetCurrentValue(RenderButtonsForegroundProperty, ButtonsForeground); - - IsHovered = false; - _isClickedDown = false; - } - - /// - /// Invokes click on the button. - /// - public void InvokeClick() - { - if ( - new ButtonAutomationPeer(this).GetPattern(PatternInterface.Invoke) - is IInvokeProvider invokeProvider - ) - { - invokeProvider.Invoke(); - } - - _isClickedDown = false; - } - - internal bool ReactToHwndHook(User32.WM msg, IntPtr lParam, out IntPtr returnIntPtr) - { - returnIntPtr = IntPtr.Zero; - - switch (msg) - { - case User32.WM.NCHITTEST: - if (this.IsMouseOverElement(lParam)) - { - /*Debug.WriteLine($"Hitting {ButtonType} | return code {_returnValue}");*/ - Hover(); - returnIntPtr = (IntPtr)_returnValue; - return true; - } - - RemoveHover(); - return false; - case User32.WM.NCMOUSELEAVE: // Mouse leaves the window - RemoveHover(); - return false; - case User32.WM.NCLBUTTONDOWN when this.IsMouseOverElement(lParam): // Left button clicked down - _isClickedDown = true; - return true; - case User32.WM.NCLBUTTONUP when _isClickedDown && this.IsMouseOverElement(lParam): // Left button clicked up - InvokeClick(); - return true; - default: - return false; - } - } - - private static void OnButtonTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - if (d is not TitleBarButton titleBarButton) - { - return; - } - - titleBarButton.OnButtonTypeChanged(e); - } - - protected void OnButtonTypeChanged(DependencyPropertyChangedEventArgs e) - { - var buttonType = (TitleBarButtonType)e.NewValue; - - _returnValue = buttonType switch - { - TitleBarButtonType.Unknown => User32.WM_NCHITTEST.HTNOWHERE, - TitleBarButtonType.Help => User32.WM_NCHITTEST.HTHELP, - TitleBarButtonType.Minimize => User32.WM_NCHITTEST.HTMINBUTTON, - TitleBarButtonType.Close => User32.WM_NCHITTEST.HTCLOSE, - TitleBarButtonType.Restore => User32.WM_NCHITTEST.HTMAXBUTTON, - TitleBarButtonType.Maximize => User32.WM_NCHITTEST.HTMAXBUTTON, - _ - => throw new ArgumentOutOfRangeException( - "e.NewValue", - buttonType, - $"Unsupported button type: {buttonType}." - ) - }; - } -} diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBarButtonType.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBarButtonType.cs deleted file mode 100644 index da560e0d6..000000000 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBarButtonType.cs +++ /dev/null @@ -1,43 +0,0 @@ -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. -// Copyright (C) Leszek Pomianowski and WPF UI Contributors. -// All Rights Reserved. - -// ReSharper disable once CheckNamespace -namespace Wpf.Ui.Controls; - -/// -/// Type of the Title Bar button. -/// -public enum TitleBarButtonType -{ - /// - /// Unknown button. - /// - Unknown, - - /// - /// Maximize button. - /// - Minimize, - - /// - /// Close button. - /// - Close, - - /// - /// Maximize button. - /// - Maximize, - - /// - /// Restore button. - /// - Restore, - - /// - /// Help button. - /// - Help -} diff --git a/src/Wpf.Ui/Controls/ToggleButton/ToggleButton.xaml b/src/Wpf.Ui/Controls/ToggleButton/ToggleButton.xaml index 04af06574..65d781c16 100644 --- a/src/Wpf.Ui/Controls/ToggleButton/ToggleButton.xaml +++ b/src/Wpf.Ui/Controls/ToggleButton/ToggleButton.xaml @@ -8,113 +8,117 @@ Copyright (c) Microsoft Corporation. All Rights Reserved. --> - + 11,5,11,6 1 0,0,8,0 - - - - - - - - diff --git a/src/Wpf.Ui/Controls/ToolTip/ToolTip.xaml b/src/Wpf.Ui/Controls/ToolTip/ToolTip.xaml index bf9bd19e5..dbe6be937 100644 --- a/src/Wpf.Ui/Controls/ToolTip/ToolTip.xaml +++ b/src/Wpf.Ui/Controls/ToolTip/ToolTip.xaml @@ -5,49 +5,53 @@ All Rights Reserved. --> - + - @@ -57,6 +61,8 @@ - - - - - diff --git a/src/Wpf.Ui/Controls/Window/Window.xaml b/src/Wpf.Ui/Controls/Window/Window.xaml index a4493d605..23149f063 100644 --- a/src/Wpf.Ui/Controls/Window/Window.xaml +++ b/src/Wpf.Ui/Controls/Window/Window.xaml @@ -5,51 +5,53 @@ All Rights Reserved. --> - + - - - - - - - - - - diff --git a/src/Wpf.Ui/Resources/Variables.xaml b/src/Wpf.Ui/Resources/Variables.xaml index 45a927342..767369b56 100644 --- a/src/Wpf.Ui/Resources/Variables.xaml +++ b/src/Wpf.Ui/Resources/Variables.xaml @@ -7,10 +7,10 @@ Based on Microsoft XAML for Win UI Copyright (c) Microsoft Corporation. All Rights Reserved. --> - + 16 diff --git a/src/Wpf.Ui/Resources/Wpf.Ui.xaml b/src/Wpf.Ui/Resources/Wpf.Ui.xaml index b52f501d3..44168b591 100644 --- a/src/Wpf.Ui/Resources/Wpf.Ui.xaml +++ b/src/Wpf.Ui/Resources/Wpf.Ui.xaml @@ -6,97 +6,97 @@ --> - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 12d2818be0abda0da261f66b592157299a735fc6 Mon Sep 17 00:00:00 2001 From: mOlDaViA Date: Thu, 27 Jun 2024 02:16:50 +0200 Subject: [PATCH 4/4] Forgot you had a seperate place for converters, so the SliderThumbPositionConverter is now in the right place. --- src/Wpf.Ui/Controls/Slider/Slider.xaml | 4 ++-- .../Slider => Converters}/SliderThumbPositionConverter.cs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) rename src/Wpf.Ui/{Controls/Slider => Converters}/SliderThumbPositionConverter.cs (81%) diff --git a/src/Wpf.Ui/Controls/Slider/Slider.xaml b/src/Wpf.Ui/Controls/Slider/Slider.xaml index d5a742daf..e3bff3004 100644 --- a/src/Wpf.Ui/Controls/Slider/Slider.xaml +++ b/src/Wpf.Ui/Controls/Slider/Slider.xaml @@ -7,9 +7,9 @@ - +