From a253702bcf8bb30af1be5d819df3e834357bc4a5 Mon Sep 17 00:00:00 2001 From: Difegue <8237712+Difegue@users.noreply.github.com> Date: Tue, 16 Apr 2024 11:37:46 +0200 Subject: [PATCH 01/36] Prevent icons in MenuItems from being tabstops Fix for #1054 --- src/Wpf.Ui/Controls/Menu/MenuItem.xaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Wpf.Ui/Controls/Menu/MenuItem.xaml b/src/Wpf.Ui/Controls/Menu/MenuItem.xaml index a22e0ee1f..14d59b749 100644 --- a/src/Wpf.Ui/Controls/Menu/MenuItem.xaml +++ b/src/Wpf.Ui/Controls/Menu/MenuItem.xaml @@ -172,6 +172,7 @@ Grid.Column="0" Margin="0,0,6,0" VerticalAlignment="Center" + KeyboardNavigation.IsTabStop="False" Content="{TemplateBinding Icon}" /> @@ -583,6 +587,7 @@ Grid.Column="0" Margin="0,0,6,0" VerticalAlignment="Center" + KeyboardNavigation.IsTabStop="False" Content="{TemplateBinding Icon}" FontSize="{TemplateBinding FontSize}" /> @@ -660,6 +665,7 @@ Grid.Column="1" Margin="0,0,6,0" VerticalAlignment="Center" + KeyboardNavigation.IsTabStop="False" Content="{TemplateBinding Icon}" FontSize="16" /> @@ -735,6 +741,7 @@ Grid.Column="0" Margin="0,0,6,0" VerticalAlignment="Center" + KeyboardNavigation.IsTabStop="False" Content="{TemplateBinding Icon}" FontSize="16" /> From d73377660c0df092396e77e680b383f4af8b9b83 Mon Sep 17 00:00:00 2001 From: Difegue <8237712+Difegue@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:35:52 +0200 Subject: [PATCH 02/36] Fix incorrectly refactored High Contrast theme dictionary selection This was broken in c0ace5b18648a2f7ccc77eff388cae1fa6ef8555 --- src/Wpf.Ui/Appearance/ApplicationThemeManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs b/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs index 69bcbc136..226be0fcc 100644 --- a/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs +++ b/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs @@ -97,7 +97,7 @@ public static void Apply( SystemTheme.HC1 => "HC1", SystemTheme.HC2 => "HC2", SystemTheme.HCBlack => "HCBlack", - SystemTheme.HCWhite => "HCBlack", + SystemTheme.HCWhite => "HCWhite", _ => "HCWhite", }; break; From d33ecf33cfb52661962555138020b766266437c7 Mon Sep 17 00:00:00 2001 From: mOlDaViA <37399229+m0lDaViA@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:32:09 +0200 Subject: [PATCH 03/36] Fixed the markup extension for the SymbolIcon and FontIcon class not working at all. --- src/Wpf.Ui/Markup/FontIconExtension.cs | 22 ++++++++++++---------- src/Wpf.Ui/Markup/SymbolIconExtension.cs | 12 +++++++++++- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/Wpf.Ui/Markup/FontIconExtension.cs b/src/Wpf.Ui/Markup/FontIconExtension.cs index f190ee91c..57a81ace5 100644 --- a/src/Wpf.Ui/Markup/FontIconExtension.cs +++ b/src/Wpf.Ui/Markup/FontIconExtension.cs @@ -32,29 +32,31 @@ namespace Wpf.Ui.Markup; [MarkupExtensionReturnType(typeof(FontIcon))] public class FontIconExtension : MarkupExtension { - public FontIconExtension(string glyph) + public FontIconExtension() { - Glyph = glyph; - FontFamily = new FontFamily("FluentSystemIcons"); } - public FontIconExtension(string glyph, FontFamily fontFamily) - : this(glyph) + public FontIconExtension(string glyph) { - FontFamily = fontFamily; + Glyph = glyph; } [ConstructorArgument("glyph")] - public string Glyph { get; set; } + public string? Glyph { get; set; } [ConstructorArgument("fontFamily")] - public FontFamily FontFamily { get; set; } + public FontFamily FontFamily { get; set; } = new("FluentSystemIcons"); public double FontSize { get; set; } public override object ProvideValue(IServiceProvider serviceProvider) { - var fontIcon = new FontIcon { Glyph = Glyph, FontFamily = FontFamily }; + if (serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget { TargetObject: Setter }) + { + return this; + } + + FontIcon fontIcon = new() { Glyph = Glyph, FontFamily = FontFamily }; if (FontSize > 0) { @@ -63,4 +65,4 @@ public override object ProvideValue(IServiceProvider serviceProvider) return fontIcon; } -} +} \ No newline at end of file diff --git a/src/Wpf.Ui/Markup/SymbolIconExtension.cs b/src/Wpf.Ui/Markup/SymbolIconExtension.cs index 90ae2ea86..48c9a3801 100644 --- a/src/Wpf.Ui/Markup/SymbolIconExtension.cs +++ b/src/Wpf.Ui/Markup/SymbolIconExtension.cs @@ -32,6 +32,11 @@ namespace Wpf.Ui.Markup; [MarkupExtensionReturnType(typeof(SymbolIcon))] public class SymbolIconExtension : MarkupExtension { + + public SymbolIconExtension() + { + } + public SymbolIconExtension(SymbolRegular symbol) { Symbol = symbol; @@ -58,7 +63,12 @@ public SymbolIconExtension(SymbolRegular symbol, bool filled) public override object ProvideValue(IServiceProvider serviceProvider) { - var symbolIcon = new SymbolIcon { Symbol = Symbol, Filled = Filled }; + if (serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget { TargetObject: Setter }) + { + return this; + } + + SymbolIcon symbolIcon = new() { Symbol = Symbol, Filled = Filled }; if (FontSize > 0) { From 5525c2b1b831d21a5c68a4fc5e5b8d55182a80bd Mon Sep 17 00:00:00 2001 From: mOlDaViA <37399229+m0lDaViA@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:03:37 +0200 Subject: [PATCH 04/36] Rewrite of the arc class. Added SweepDirection as property, viewbox to easier scale the arc aswell as a new startpoint at 12am and refactoring of the code. --- src/Wpf.Ui/Controls/Arc/Arc.cs | 201 ++++++++++++++++++++++++--------- 1 file changed, 147 insertions(+), 54 deletions(-) diff --git a/src/Wpf.Ui/Controls/Arc/Arc.cs b/src/Wpf.Ui/Controls/Arc/Arc.cs index 4d14713a8..f10e7c331 100644 --- a/src/Wpf.Ui/Controls/Arc/Arc.cs +++ b/src/Wpf.Ui/Controls/Arc/Arc.cs @@ -3,27 +3,24 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using System.Windows.Controls; +using System.Windows.Shapes; using Point = System.Windows.Point; using Size = System.Windows.Size; +#pragma warning disable SA1124 -// ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; -/// -/// Control that draws a symmetrical arc with rounded edges. -/// -/// -/// -/// <ui:Arc -/// EndAngle="359" -/// StartAngle="0" -/// Stroke="{ui:ThemeResource SystemAccentColorSecondaryBrush}" -/// StrokeThickness="2" -/// Visibility="Visible" /> -/// -/// -public class Arc : System.Windows.Shapes.Shape +public class Arc : Shape { + #region Declarations + + private Viewbox? _rootLayout; + + #endregion + + #region Static Properties + /// Identifies the dependency property. public static readonly DependencyProperty StartAngleProperty = DependencyProperty.Register( nameof(StartAngle), @@ -40,6 +37,28 @@ public class Arc : System.Windows.Shapes.Shape new PropertyMetadata(0.0d, PropertyChangedCallback) ); + /// Identifies the dependency property. + public static readonly DependencyProperty SweepDirectionProperty = + DependencyProperty.Register( + nameof(SweepDirection), + typeof(SweepDirection), + typeof(Arc), + new PropertyMetadata(SweepDirection.Clockwise, PropertyChangedCallback) + ); + + /// Identifies the dependency property. + public static new readonly DependencyProperty StrokeStartLineCapProperty = + DependencyProperty.Register( + nameof(StrokeStartLineCap), + typeof(PenLineCap), + typeof(Arc), + new PropertyMetadata(PenLineCap.Round, PropertyChangedCallback) + ); + + #endregion + + #region Public Properties + /// /// Gets or sets the initial angle from which the arc will be drawn. /// @@ -59,37 +78,52 @@ public double EndAngle } /// - /// Gets a value indicating whether one of the two larger arc sweeps is chosen; otherwise, if is , one of the smaller arc sweeps is chosen. + /// Gets or sets the direction to where the arc will be drawn. /// - public bool IsLargeArc { get; internal set; } = false; + public SweepDirection SweepDirection + { + get => (SweepDirection)GetValue(SweepDirectionProperty); + set => SetValue(SweepDirectionProperty, value); + } - /// - protected override Geometry DefiningGeometry => GetDefiningGeometry(); + public new PenLineCap StrokeStartLineCap + { + get { return (PenLineCap)GetValue(StrokeStartLineCapProperty); } + set { SetValue(StrokeStartLineCapProperty, value); } + } /// - /// Initializes static members of the class. + /// Gets a value indicating whether one of the two larger arc sweeps is chosen; otherwise, if is , one of the smaller arc sweeps is chosen. /// - /// - /// Overrides default properties. - /// - static Arc() + public bool IsLargeArc { get; internal set; } = false; + + #endregion + + #region Private Methods + + private void EnsureRootLayout() { - StrokeStartLineCapProperty.OverrideMetadata( - typeof(Arc), - new FrameworkPropertyMetadata(PenLineCap.Round) - ); + if (_rootLayout != null) + { + return; + } - StrokeEndLineCapProperty.OverrideMetadata( - typeof(Arc), - new FrameworkPropertyMetadata(PenLineCap.Round) - ); + _rootLayout = new Viewbox { SnapsToDevicePixels = true }; + AddVisualChild(_rootLayout); } + #endregion + + #region Protected Methods + + /// + protected override Geometry DefiningGeometry => DefinedGeometry(); + /// /// Get the geometry that defines this shape. /// Based on Mark Feldman implementation. /// - protected Geometry GetDefiningGeometry() + protected Geometry DefinedGeometry() { var geometryStream = new StreamGeometry(); var arcSize = new Size( @@ -97,20 +131,18 @@ protected Geometry GetDefiningGeometry() Math.Max(0, (RenderSize.Height - StrokeThickness) / 2) ); - using (StreamGeometryContext context = geometryStream.Open()) - { - context.BeginFigure(PointAtAngle(Math.Min(StartAngle, EndAngle)), false, false); - - context.ArcTo( - PointAtAngle(Math.Max(StartAngle, EndAngle)), - arcSize, - 0, - IsLargeArc, - SweepDirection.Counterclockwise, - true, - false - ); - } + using StreamGeometryContext context = geometryStream.Open(); + context.BeginFigure(PointAtAngle(Math.Min(StartAngle, EndAngle)), false, false); + + context.ArcTo( + PointAtAngle(Math.Max(StartAngle, EndAngle)), + arcSize, + 0, + IsLargeArc, + SweepDirection, + true, + false + ); geometryStream.Transform = new TranslateTransform(StrokeThickness / 2, StrokeThickness / 2); @@ -124,11 +156,36 @@ protected Geometry GetDefiningGeometry() /// The angle at which to create the point. protected Point PointAtAngle(double angle) { - var radAngle = angle * (Math.PI / 180); - var xRadius = (RenderSize.Width - StrokeThickness) / 2; - var yRadius = (RenderSize.Height - StrokeThickness) / 2; - - return new Point(xRadius + (xRadius * Math.Cos(radAngle)), yRadius - (yRadius * Math.Sin(radAngle))); + if (SweepDirection == SweepDirection.Counterclockwise) + { + angle += 90; + angle %= 360; + if (angle < 0) + { + angle += 360; + } + + var radAngle = angle * (Math.PI / 180); + var xRadius = (RenderSize.Width - StrokeThickness) / 2; + var yRadius = (RenderSize.Height - StrokeThickness) / 2; + + return new Point(xRadius + (xRadius * Math.Cos(radAngle)), yRadius - (yRadius * Math.Sin(radAngle))); + } + else + { + angle -= 90; + angle %= 360; + if (angle < 0) + { + angle += 360; + } + + var radAngle = angle * (Math.PI / 180); + var xRadius = (RenderSize.Width - StrokeThickness) / 2; + var yRadius = (RenderSize.Height - StrokeThickness) / 2; + + return new Point(xRadius + (xRadius * Math.Cos(-radAngle)), yRadius - (yRadius * Math.Sin(-radAngle))); + } } /// @@ -142,8 +199,44 @@ protected static void PropertyChangedCallback(DependencyObject d, DependencyProp } control.IsLargeArc = Math.Abs(control.EndAngle - control.StartAngle) > 180; - - // Force complete new layout pass control.InvalidateVisual(); } + + protected override Visual? GetVisualChild(int index) + { + if (index != 0) + { + throw new ArgumentOutOfRangeException(nameof(index), "Arc should have only 1 child"); + } + + EnsureRootLayout(); + + return _rootLayout; + } + + protected override Size MeasureOverride(Size availableSize) + { + EnsureRootLayout(); + + _rootLayout!.Measure(availableSize); + return _rootLayout.DesiredSize; + } + + protected override Size ArrangeOverride(Size finalSize) + { + EnsureRootLayout(); + + _rootLayout!.Arrange(new Rect(default, finalSize)); + return finalSize; + } + + /// Overrides the default OnRender method to draw the element. + /// A object that is drawn during the rendering pass of this . + protected override void OnRender(DrawingContext drawingContext) + { + base.OnRender(drawingContext); + drawingContext.DrawGeometry(Stroke, new Pen(Stroke, StrokeThickness), DefinedGeometry()); + } + + #endregion } From a35eb010f6c7fdae279b5b85609e76253de58559 Mon Sep 17 00:00:00 2001 From: mOlDaViA <37399229+m0lDaViA@users.noreply.github.com> Date: Thu, 2 May 2024 01:32:16 +0200 Subject: [PATCH 05/36] Fixed the PenLineCap property. --- src/Wpf.Ui/Controls/Arc/Arc.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Wpf.Ui/Controls/Arc/Arc.cs b/src/Wpf.Ui/Controls/Arc/Arc.cs index f10e7c331..eee288735 100644 --- a/src/Wpf.Ui/Controls/Arc/Arc.cs +++ b/src/Wpf.Ui/Controls/Arc/Arc.cs @@ -8,6 +8,7 @@ using Point = System.Windows.Point; using Size = System.Windows.Size; #pragma warning disable SA1124 +#pragma warning disable CS0108 namespace Wpf.Ui.Controls; @@ -47,7 +48,7 @@ public class Arc : Shape ); /// Identifies the dependency property. - public static new readonly DependencyProperty StrokeStartLineCapProperty = + public static readonly DependencyProperty StrokeStartLineCapProperty = DependencyProperty.Register( nameof(StrokeStartLineCap), typeof(PenLineCap), @@ -86,7 +87,7 @@ public SweepDirection SweepDirection set => SetValue(SweepDirectionProperty, value); } - public new PenLineCap StrokeStartLineCap + public PenLineCap StrokeStartLineCap { get { return (PenLineCap)GetValue(StrokeStartLineCapProperty); } set { SetValue(StrokeStartLineCapProperty, value); } @@ -235,7 +236,13 @@ protected override Size ArrangeOverride(Size finalSize) protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); - drawingContext.DrawGeometry(Stroke, new Pen(Stroke, StrokeThickness), DefinedGeometry()); + Pen pen = new(Stroke, StrokeThickness) + { + StartLineCap = StrokeStartLineCap, + EndLineCap = StrokeStartLineCap + }; + + drawingContext.DrawGeometry(Stroke, pen, DefinedGeometry()); } #endregion From 4471cb90d3d66ee655ab6eb96cc77dc477c3265d Mon Sep 17 00:00:00 2001 From: mOlDaViA <37399229+m0lDaViA@users.noreply.github.com> Date: Sat, 4 May 2024 22:15:19 +0200 Subject: [PATCH 06/36] Added back doc and removed regions. --- src/Wpf.Ui/Controls/Arc/Arc.cs | 35 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/Wpf.Ui/Controls/Arc/Arc.cs b/src/Wpf.Ui/Controls/Arc/Arc.cs index eee288735..5168c5563 100644 --- a/src/Wpf.Ui/Controls/Arc/Arc.cs +++ b/src/Wpf.Ui/Controls/Arc/Arc.cs @@ -7,21 +7,28 @@ using System.Windows.Shapes; using Point = System.Windows.Point; using Size = System.Windows.Size; -#pragma warning disable SA1124 +// ReSharper disable CheckNamespace #pragma warning disable CS0108 namespace Wpf.Ui.Controls; +/// +/// Control that draws a symmetrical arc with rounded edges. +/// +/// +/// +/// <ui:Arc +/// EndAngle="359" +/// StartAngle="0" +/// Stroke="{ui:ThemeResource SystemAccentColorSecondaryBrush}" +/// StrokeThickness="2" +/// Visibility="Visible" /> +/// +/// public class Arc : Shape { - #region Declarations - private Viewbox? _rootLayout; - #endregion - - #region Static Properties - /// Identifies the dependency property. public static readonly DependencyProperty StartAngleProperty = DependencyProperty.Register( nameof(StartAngle), @@ -56,10 +63,6 @@ public class Arc : Shape new PropertyMetadata(PenLineCap.Round, PropertyChangedCallback) ); - #endregion - - #region Public Properties - /// /// Gets or sets the initial angle from which the arc will be drawn. /// @@ -98,10 +101,6 @@ public PenLineCap StrokeStartLineCap /// public bool IsLargeArc { get; internal set; } = false; - #endregion - - #region Private Methods - private void EnsureRootLayout() { if (_rootLayout != null) @@ -113,10 +112,6 @@ private void EnsureRootLayout() AddVisualChild(_rootLayout); } - #endregion - - #region Protected Methods - /// protected override Geometry DefiningGeometry => DefinedGeometry(); @@ -244,6 +239,4 @@ protected override void OnRender(DrawingContext drawingContext) drawingContext.DrawGeometry(Stroke, pen, DefinedGeometry()); } - - #endregion } From 8ebf43ec565a0bd28e1dbb66a89c68038d353787 Mon Sep 17 00:00:00 2001 From: pomianowski <13592821+pomianowski@users.noreply.github.com> Date: Sun, 5 May 2024 11:00:14 +0200 Subject: [PATCH 07/36] Well, it can be null --- src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs index 94acd6c1f..fb8a326dc 100644 --- a/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs +++ b/src/Wpf.Ui/Controls/AutoSuggestBox/AutoSuggestBox.cs @@ -270,7 +270,12 @@ public override void OnApplyTemplate() /// public new bool Focus() { - return TextBox!.Focus(); + if (TextBox is null) + { + return false; + } + + return TextBox.Focus(); } protected T GetTemplateChild(string name) From ef742b512bd25696aca589a07ce4b15dd8fd11ea Mon Sep 17 00:00:00 2001 From: pomianowski <13592821+pomianowski@users.noreply.github.com> Date: Sun, 5 May 2024 11:01:47 +0200 Subject: [PATCH 08/36] Format code --- src/Wpf.Ui/Controls/Arc/Arc.cs | 53 +++++++++++++----------- src/Wpf.Ui/Markup/FontIconExtension.cs | 13 +++--- src/Wpf.Ui/Markup/SymbolIconExtension.cs | 12 +++--- 3 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/Wpf.Ui/Controls/Arc/Arc.cs b/src/Wpf.Ui/Controls/Arc/Arc.cs index 5168c5563..c668584a7 100644 --- a/src/Wpf.Ui/Controls/Arc/Arc.cs +++ b/src/Wpf.Ui/Controls/Arc/Arc.cs @@ -7,9 +7,8 @@ using System.Windows.Shapes; using Point = System.Windows.Point; using Size = System.Windows.Size; -// ReSharper disable CheckNamespace -#pragma warning disable CS0108 +// ReSharper disable CheckNamespace namespace Wpf.Ui.Controls; /// @@ -46,22 +45,20 @@ public class Arc : Shape ); /// Identifies the dependency property. - public static readonly DependencyProperty SweepDirectionProperty = - DependencyProperty.Register( - nameof(SweepDirection), - typeof(SweepDirection), - typeof(Arc), - new PropertyMetadata(SweepDirection.Clockwise, PropertyChangedCallback) - ); + public static readonly DependencyProperty SweepDirectionProperty = DependencyProperty.Register( + nameof(SweepDirection), + typeof(SweepDirection), + typeof(Arc), + new PropertyMetadata(SweepDirection.Clockwise, PropertyChangedCallback) + ); /// Identifies the dependency property. - public static readonly DependencyProperty StrokeStartLineCapProperty = - DependencyProperty.Register( - nameof(StrokeStartLineCap), - typeof(PenLineCap), - typeof(Arc), - new PropertyMetadata(PenLineCap.Round, PropertyChangedCallback) - ); + public static readonly DependencyProperty StrokeStartLineCapProperty = DependencyProperty.Register( + nameof(StrokeStartLineCap), + typeof(PenLineCap), + typeof(Arc), + new PropertyMetadata(PenLineCap.Round, PropertyChangedCallback) + ); /// /// Gets or sets the initial angle from which the arc will be drawn. @@ -90,7 +87,8 @@ public SweepDirection SweepDirection set => SetValue(SweepDirectionProperty, value); } - public PenLineCap StrokeStartLineCap + // TODO: Should we? + public new PenLineCap StrokeStartLineCap { get { return (PenLineCap)GetValue(StrokeStartLineCapProperty); } set { SetValue(StrokeStartLineCapProperty, value); } @@ -165,7 +163,10 @@ protected Point PointAtAngle(double angle) var xRadius = (RenderSize.Width - StrokeThickness) / 2; var yRadius = (RenderSize.Height - StrokeThickness) / 2; - return new Point(xRadius + (xRadius * Math.Cos(radAngle)), yRadius - (yRadius * Math.Sin(radAngle))); + return new Point( + xRadius + (xRadius * Math.Cos(radAngle)), + yRadius - (yRadius * Math.Sin(radAngle)) + ); } else { @@ -180,7 +181,10 @@ protected Point PointAtAngle(double angle) var xRadius = (RenderSize.Width - StrokeThickness) / 2; var yRadius = (RenderSize.Height - StrokeThickness) / 2; - return new Point(xRadius + (xRadius * Math.Cos(-radAngle)), yRadius - (yRadius * Math.Sin(-radAngle))); + return new Point( + xRadius + (xRadius * Math.Cos(-radAngle)), + yRadius - (yRadius * Math.Sin(-radAngle)) + ); } } @@ -231,11 +235,12 @@ protected override Size ArrangeOverride(Size finalSize) protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); - Pen pen = new(Stroke, StrokeThickness) - { - StartLineCap = StrokeStartLineCap, - EndLineCap = StrokeStartLineCap - }; + Pen pen = + new(Stroke, StrokeThickness) + { + StartLineCap = StrokeStartLineCap, + EndLineCap = StrokeStartLineCap + }; drawingContext.DrawGeometry(Stroke, pen, DefinedGeometry()); } diff --git a/src/Wpf.Ui/Markup/FontIconExtension.cs b/src/Wpf.Ui/Markup/FontIconExtension.cs index 57a81ace5..448ea33a6 100644 --- a/src/Wpf.Ui/Markup/FontIconExtension.cs +++ b/src/Wpf.Ui/Markup/FontIconExtension.cs @@ -32,9 +32,7 @@ namespace Wpf.Ui.Markup; [MarkupExtensionReturnType(typeof(FontIcon))] public class FontIconExtension : MarkupExtension { - public FontIconExtension() - { - } + public FontIconExtension() { } public FontIconExtension(string glyph) { @@ -51,7 +49,12 @@ public FontIconExtension(string glyph) public override object ProvideValue(IServiceProvider serviceProvider) { - if (serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget { TargetObject: Setter }) + if ( + serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget + { + TargetObject: Setter + } + ) { return this; } @@ -65,4 +68,4 @@ public override object ProvideValue(IServiceProvider serviceProvider) return fontIcon; } -} \ No newline at end of file +} diff --git a/src/Wpf.Ui/Markup/SymbolIconExtension.cs b/src/Wpf.Ui/Markup/SymbolIconExtension.cs index 48c9a3801..754706976 100644 --- a/src/Wpf.Ui/Markup/SymbolIconExtension.cs +++ b/src/Wpf.Ui/Markup/SymbolIconExtension.cs @@ -32,10 +32,7 @@ namespace Wpf.Ui.Markup; [MarkupExtensionReturnType(typeof(SymbolIcon))] public class SymbolIconExtension : MarkupExtension { - - public SymbolIconExtension() - { - } + public SymbolIconExtension() { } public SymbolIconExtension(SymbolRegular symbol) { @@ -63,7 +60,12 @@ public SymbolIconExtension(SymbolRegular symbol, bool filled) public override object ProvideValue(IServiceProvider serviceProvider) { - if (serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget { TargetObject: Setter }) + if ( + serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget + { + TargetObject: Setter + } + ) { return this; } From a0aae10cb09160477f71bf8b9297d7826cfa5ee9 Mon Sep 17 00:00:00 2001 From: JonAdamsFromNC Date: Thu, 9 May 2024 11:26:43 -0400 Subject: [PATCH 09/36] Update themes.md --- docs/documentation/themes.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/documentation/themes.md b/docs/documentation/themes.md index 4fa255169..16ad1d59a 100644 --- a/docs/documentation/themes.md +++ b/docs/documentation/themes.md @@ -37,10 +37,10 @@ Or, you can add **WPF UI** resources manually. If you want to change the theme while the application is running, you can call the static `Apply` method of the `Theme` class. ```csharp -Wpf.Ui.Appearance.Theme.Apply( - Wpf.Ui.Appearance.ThemeType.Light, // Theme type - Wpf.Ui.Appearance.BackgroundType.Mica, // Background type - true // Whether to change accents automatically +Wpf.Ui.Appearance.ApplicationThemeManager.Apply( + Wpf.Ui.Appearance.ApplicationTheme.Light, // Theme type + Wpf.Ui.Controls.WindowBackdropType.Mica, // Background type + true // Whether to change accents automatically ); ``` @@ -59,10 +59,10 @@ public partial class MainWindow : Window Loaded += (sender, args) => { - Wpf.Ui.Appearance.Watcher.Watch( - this, // Window class - Wpf.Ui.Appearance.BackgroundType.Mica, // Background type - true // Whether to change accents automatically + Wpf.Ui.Appearance.SystemThemeWatcher.Watch( + this, // Window class + Wpf.Ui.Controls.WindowBackdropType.Mica, // Background type + true // Whether to change accents automatically ); }; } From 77b0c26c4b17d50855097ddba98e03e7107f9893 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Thu, 9 May 2024 19:47:30 -0300 Subject: [PATCH 10/36] Update UiApplication.cs Ignore `Application` without LibraryResources --- src/Wpf.Ui/UiApplication.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Wpf.Ui/UiApplication.cs b/src/Wpf.Ui/UiApplication.cs index 0cfbe47f4..263925fd9 100644 --- a/src/Wpf.Ui/UiApplication.cs +++ b/src/Wpf.Ui/UiApplication.cs @@ -23,7 +23,22 @@ public class UiApplication /// public UiApplication(Application application) { - _application = application; + if (application is not null) + { + var hasLibraryResources = application.Resources.MergedDictionaries + .Where(e => e.Source is not null) + .Any(e => e.Source.ToString().ToLower().Contains(Appearance.ApplicationThemeManager.LibraryNamespace)); + + if (hasLibraryResources) + { + _application = application; + } + } + + System.Diagnostics.Debug.WriteLine( + $"INFO | {typeof(UiApplication)} application is {_application}", + "Wpf.Ui" + ); } /// From 2f51370db222fa1e1bbcee843049e70d6d8bca6b Mon Sep 17 00:00:00 2001 From: pomian <13592821+pomianowski@users.noreply.github.com> Date: Sun, 12 May 2024 10:39:45 +0200 Subject: [PATCH 11/36] Update UiApplication.cs --- src/Wpf.Ui/UiApplication.cs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Wpf.Ui/UiApplication.cs b/src/Wpf.Ui/UiApplication.cs index 263925fd9..108ecbbcf 100644 --- a/src/Wpf.Ui/UiApplication.cs +++ b/src/Wpf.Ui/UiApplication.cs @@ -23,18 +23,18 @@ public class UiApplication /// public UiApplication(Application application) { - if (application is not null) + if (application is null) { - var hasLibraryResources = application.Resources.MergedDictionaries - .Where(e => e.Source is not null) - .Any(e => e.Source.ToString().ToLower().Contains(Appearance.ApplicationThemeManager.LibraryNamespace)); + return; + } - if (hasLibraryResources) - { - _application = application; - } + if (!ApplicationHasResources(application) + { + return; } + _application = application; + System.Diagnostics.Debug.WriteLine( $"INFO | {typeof(UiApplication)} application is {_application}", "Wpf.Ui" @@ -126,4 +126,11 @@ public void Shutdown() { _application?.Shutdown(); } + + private static bool ApplicationHasResources(Application application) + { + return application.Resources.MergedDictionaries + .Where(e => e.Source is not null) + .Any(e => e.Source.ToString().ToLower().Contains(Appearance.ApplicationThemeManager.LibraryNamespace)); + } } From 7a958785c101f702b6637fd74c9ea2dfeaacdc67 Mon Sep 17 00:00:00 2001 From: pomian <13592821+pomianowski@users.noreply.github.com> Date: Sun, 12 May 2024 10:42:19 +0200 Subject: [PATCH 12/36] Update UiApplication.cs --- src/Wpf.Ui/UiApplication.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wpf.Ui/UiApplication.cs b/src/Wpf.Ui/UiApplication.cs index 108ecbbcf..c985373ec 100644 --- a/src/Wpf.Ui/UiApplication.cs +++ b/src/Wpf.Ui/UiApplication.cs @@ -28,7 +28,7 @@ public UiApplication(Application application) return; } - if (!ApplicationHasResources(application) + if (!ApplicationHasResources(application)) { return; } From 303c7bb201e9f1b978fa6c5d9685c77e06b721d1 Mon Sep 17 00:00:00 2001 From: JulesDebeaumont Date: Sun, 2 Jun 2024 13:05:54 +0200 Subject: [PATCH 13/36] [TYPO] link to 404 (#1102) --- docs/documentation/nuget.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/documentation/nuget.md b/docs/documentation/nuget.md index f6e53308f..cb0881512 100644 --- a/docs/documentation/nuget.md +++ b/docs/documentation/nuget.md @@ -28,4 +28,4 @@ NuGet is a free, open-source package management system for the Microsoft .NET pl # Done! -Package installed, to learn more, go to the [**Getting started**](/tutorial/getting-started.html) page. +Package installed, to learn more, go to the [**Getting started**](/documentation/getting-started.html) page. From 334ded5a5fa282c1b341024fb4c3640972c65674 Mon Sep 17 00:00:00 2001 From: Andrij Abyzov Date: Sun, 2 Jun 2024 13:11:16 +0200 Subject: [PATCH 14/36] Fix warnings (#1104) * Fix IDE0073 and inherent SA1512 static analyzer issues. IDE0073 is caused by setting file_header_template and having more lines in the header comment than specified in the template. SA1512 is caused by having an empty line between a single-line comment and following code. * Fix more formatting-related build warnings --- src/Wpf.Ui.Demo.Simple/AssemblyInfo.cs | 5 +++++ src/Wpf.Ui.FontMapper/FontSource.cs | 5 +++++ src/Wpf.Ui.FontMapper/GitTag.cs | 7 ++++++- .../Views/Pages/Layout/ExpanderPage.xaml.cs | 7 ++++++- src/Wpf.Ui.SyntaxHighlight/Highlighter.cs | 2 +- src/Wpf.Ui.Tray/Hicon.cs | 2 +- src/Wpf.Ui/Controls/Anchor/Anchor.cs | 2 +- src/Wpf.Ui/Controls/Badge/Badge.cs | 2 +- .../Controls/BreadcrumbBar/BreadcrumbBar.cs | 6 +++--- .../BreadcrumbBar/BreadcrumbBarItem.cs | 4 ++-- .../BreadcrumbBarItemClickedEventArgs.cs | 2 +- .../ContextMenu/ContextMenuLoader.xaml.cs | 4 ++-- src/Wpf.Ui/Controls/DateTimeHelper.cs | 8 ++++---- .../Controls/GridView/GridViewRowPresenter.cs | 5 +++++ src/Wpf.Ui/Controls/ItemRange.cs | 12 ++++++------ src/Wpf.Ui/Controls/ListView/ListView.cs | 5 +++++ .../Controls/NavigationView/INavigationView.cs | 6 +++--- .../NavigationView/INavigationViewItem.cs | 6 +++--- .../NavigationView/NavigatedEventArgs.cs | 6 +++--- .../NavigatingCancelEventArgs.cs | 2 +- .../Controls/NavigationView/NavigationCache.cs | 2 +- .../NavigationView/NavigationCacheMode.cs | 2 +- .../NavigationView/NavigationView.Base.cs | 4 ++-- .../NavigationView/NavigationView.Events.cs | 2 +- .../NavigationView.Navigation.cs | 4 ++-- .../NavigationView.TemplateParts.cs | 2 +- .../NavigationViewBackButtonVisible.cs | 2 +- .../NavigationViewBreadcrumbItem.cs | 2 +- .../NavigationViewContentPresenter.cs | 4 ++-- .../NavigationView/NavigationViewItem.cs | 4 ++-- .../NavigationView/NavigationViewItemHeader.cs | 2 +- .../NavigationViewItemSeparator.cs | 2 +- .../NavigationViewPaneDisplayMode.cs | 2 +- .../Controls/NumberBox/INumberFormatter.cs | 2 +- src/Wpf.Ui/Controls/NumberBox/INumberParser.cs | 2 +- src/Wpf.Ui/Controls/NumberBox/NumberBox.cs | 12 ++++++------ .../NumberBoxSpinButtonPlacementMode.cs | 2 +- .../NumberBox/NumberBoxValidationMode.cs | 2 +- .../NumberBox/ValidateNumberFormatter.cs | 2 +- src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs | 8 ++++---- .../Controls/ProgressRing/ProgressRing.cs | 4 ++-- src/Wpf.Ui/Controls/ScrollDirection.cs | 12 ++++++------ src/Wpf.Ui/Controls/Snackbar/Snackbar.cs | 4 ++-- src/Wpf.Ui/Controls/SpacingMode.cs | 10 +++++----- src/Wpf.Ui/Controls/TypedEventHandler.cs | 6 +++--- .../VirtualizingGridView.cs | 12 ++++++------ .../VirtualizingItemsControl.cs | 10 +++++----- .../VirtualizingUniformGrid.cs | 12 ++++++------ .../VirtualizingPanelBase.cs | 13 +++++-------- .../VirtualizingWrapPanel.cs | 16 ++++++---------- .../Converters/ProgressThicknessConverter.cs | 4 ++-- src/Wpf.Ui/Hardware/DisplayDpi.cs | 4 ++-- src/Wpf.Ui/Input/IRelayCommand.cs | 8 ++++---- src/Wpf.Ui/Input/IRelayCommand{T}.cs | 8 ++++---- src/Wpf.Ui/Input/RelayCommand{T}.cs | 12 ++++++------ src/Wpf.Ui/Interop/Dwmapi.cs | 10 +++++----- src/Wpf.Ui/Interop/Kernel32.cs | 7 +++---- src/Wpf.Ui/Interop/ShObjIdl.cs | 9 ++++----- src/Wpf.Ui/Interop/Shell32.cs | 12 ++++++------ src/Wpf.Ui/Interop/UnsafeNativeMethods.cs | 12 +++++++----- src/Wpf.Ui/Interop/UnsafeReflection.cs | 8 ++++---- src/Wpf.Ui/Interop/User32.cs | 18 +++++++++--------- src/Wpf.Ui/Interop/UxTheme.cs | 18 +++++++++--------- src/Wpf.Ui/Interop/WinDef/POINT.cs | 8 ++++---- src/Wpf.Ui/Interop/WinDef/POINTL.cs | 8 ++++---- src/Wpf.Ui/Interop/WinDef/RECT.cs | 8 ++++---- src/Wpf.Ui/Interop/WinDef/RECTL.cs | 8 ++++---- src/Wpf.Ui/Interop/WinDef/SIZE.cs | 8 ++++---- src/Wpf.Ui/Markup/Design.cs | 6 ++---- src/Wpf.Ui/UiApplication.cs | 5 ++++- src/Wpf.Ui/Win32/Utilities.cs | 8 ++++---- tests/Wpf.Ui.Gallery.UnitTests/UnitTest1.cs | 5 +++++ tests/Wpf.Ui.Gallery.UnitTests/Usings.cs | 5 +++++ 73 files changed, 247 insertions(+), 213 deletions(-) diff --git a/src/Wpf.Ui.Demo.Simple/AssemblyInfo.cs b/src/Wpf.Ui.Demo.Simple/AssemblyInfo.cs index 273de9fbc..b8f7eb71b 100644 --- a/src/Wpf.Ui.Demo.Simple/AssemblyInfo.cs +++ b/src/Wpf.Ui.Demo.Simple/AssemblyInfo.cs @@ -1,3 +1,8 @@ +// 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; [assembly: ThemeInfo( diff --git a/src/Wpf.Ui.FontMapper/FontSource.cs b/src/Wpf.Ui.FontMapper/FontSource.cs index 07f91a684..ef82fed41 100644 --- a/src/Wpf.Ui.FontMapper/FontSource.cs +++ b/src/Wpf.Ui.FontMapper/FontSource.cs @@ -1,3 +1,8 @@ +// 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. + namespace Wpf.Ui.FontMapper; class FontSource diff --git a/src/Wpf.Ui.FontMapper/GitTag.cs b/src/Wpf.Ui.FontMapper/GitTag.cs index b05c52d12..a31b1015d 100644 --- a/src/Wpf.Ui.FontMapper/GitTag.cs +++ b/src/Wpf.Ui.FontMapper/GitTag.cs @@ -1,3 +1,8 @@ -namespace Wpf.Ui.FontMapper; +// 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. + +namespace Wpf.Ui.FontMapper; record GitTag(string Ref, string Node_Id, string Url); diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Layout/ExpanderPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/Layout/ExpanderPage.xaml.cs index 89af1d655..5dbf69feb 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Layout/ExpanderPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/Layout/ExpanderPage.xaml.cs @@ -1,4 +1,9 @@ -using Wpf.Ui.Controls; +// 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 Wpf.Ui.Controls; using Wpf.Ui.Gallery.ControlsLookup; using Wpf.Ui.Gallery.ViewModels.Pages.Layout; diff --git a/src/Wpf.Ui.SyntaxHighlight/Highlighter.cs b/src/Wpf.Ui.SyntaxHighlight/Highlighter.cs index a9912099f..73d4391be 100644 --- a/src/Wpf.Ui.SyntaxHighlight/Highlighter.cs +++ b/src/Wpf.Ui.SyntaxHighlight/Highlighter.cs @@ -2,7 +2,7 @@ // 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. -// + // TODO: This class is work in progress. using System; diff --git a/src/Wpf.Ui.Tray/Hicon.cs b/src/Wpf.Ui.Tray/Hicon.cs index f86466243..5d3d492fb 100644 --- a/src/Wpf.Ui.Tray/Hicon.cs +++ b/src/Wpf.Ui.Tray/Hicon.cs @@ -2,7 +2,7 @@ // 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. -// + // TODO: This class is the only reason for using System.Drawing.Common. // It is worth looking for a way to get hIcon without using it. diff --git a/src/Wpf.Ui/Controls/Anchor/Anchor.cs b/src/Wpf.Ui/Controls/Anchor/Anchor.cs index 032009df4..bc3bdedbe 100644 --- a/src/Wpf.Ui/Controls/Anchor/Anchor.cs +++ b/src/Wpf.Ui/Controls/Anchor/Anchor.cs @@ -2,7 +2,7 @@ // 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. -// + // https://docs.microsoft.com/en-us/fluent-ui/web-components/components/anchor // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/Badge/Badge.cs b/src/Wpf.Ui/Controls/Badge/Badge.cs index cebd04cdb..2106341f9 100644 --- a/src/Wpf.Ui/Controls/Badge/Badge.cs +++ b/src/Wpf.Ui/Controls/Badge/Badge.cs @@ -2,7 +2,7 @@ // 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. -// + // https://docs.microsoft.com/en-us/fluent-ui/web-components/components/badge // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs index 4f0fa361d..d0d701788 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs @@ -2,9 +2,9 @@ // 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. -// -// Based on Windows UI Library -// Copyright(c) Microsoft Corporation.All rights reserved. + +/* Based on Windows UI Library + Copyright(c) Microsoft Corporation.All rights reserved. */ using System.Collections.Specialized; using System.Windows.Controls.Primitives; diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs index ea6d82561..6f4164cba 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItem.cs @@ -2,8 +2,8 @@ // 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. -// -// Based on Windows UI Library + +/* Based on Windows UI Library */ using Wpf.Ui.Converters; diff --git a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItemClickedEventArgs.cs b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItemClickedEventArgs.cs index ba3efbb22..f680d12c4 100644 --- a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItemClickedEventArgs.cs +++ b/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBarItemClickedEventArgs.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/ContextMenu/ContextMenuLoader.xaml.cs b/src/Wpf.Ui/Controls/ContextMenu/ContextMenuLoader.xaml.cs index 57ef7e0db..46ce1a442 100644 --- a/src/Wpf.Ui/Controls/ContextMenu/ContextMenuLoader.xaml.cs +++ b/src/Wpf.Ui/Controls/ContextMenu/ContextMenuLoader.xaml.cs @@ -2,8 +2,8 @@ // 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. -// -// This Code is based on a StackOverflow-Answer: https://stackoverflow.com/a/56736232/9759874 + +/* This Code is based on a StackOverflow-Answer: https://stackoverflow.com/a/56736232/9759874 */ using System.Reflection; using System.Windows.Threading; diff --git a/src/Wpf.Ui/Controls/DateTimeHelper.cs b/src/Wpf.Ui/Controls/DateTimeHelper.cs index 7bfd09025..1590305ad 100644 --- a/src/Wpf.Ui/Controls/DateTimeHelper.cs +++ b/src/Wpf.Ui/Controls/DateTimeHelper.cs @@ -2,13 +2,13 @@ // 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. -// + // 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. -// -// NOTE: This date time helper assumes it is working in a Gregorian calendar -// If we ever support non Gregorian calendars this class would need to be redesigned + +/* NOTE: This date time helper assumes it is working in a Gregorian calendar + If we ever support non-Gregorian calendars this class would need to be redesigned */ using System.Diagnostics; using System.Windows.Controls; diff --git a/src/Wpf.Ui/Controls/GridView/GridViewRowPresenter.cs b/src/Wpf.Ui/Controls/GridView/GridViewRowPresenter.cs index 0ba3e9334..f6be31290 100644 --- a/src/Wpf.Ui/Controls/GridView/GridViewRowPresenter.cs +++ b/src/Wpf.Ui/Controls/GridView/GridViewRowPresenter.cs @@ -1,3 +1,8 @@ +// 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.Reflection; using System.Windows.Controls; diff --git a/src/Wpf.Ui/Controls/ItemRange.cs b/src/Wpf.Ui/Controls/ItemRange.cs index 7719de53c..96f4e646d 100644 --- a/src/Wpf.Ui/Controls/ItemRange.cs +++ b/src/Wpf.Ui/Controls/ItemRange.cs @@ -2,12 +2,12 @@ // 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. -// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel -// -// Copyright (C) S. Bäumlisberger -// All Rights Reserved. + +/* Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. + https://github.com/sbaeumlisberger/VirtualizingWrapPanel + + Copyright (C) S. Bäumlisberger + All Rights Reserved. */ namespace Wpf.Ui.Controls; diff --git a/src/Wpf.Ui/Controls/ListView/ListView.cs b/src/Wpf.Ui/Controls/ListView/ListView.cs index 31e0237be..ef2b44a30 100644 --- a/src/Wpf.Ui/Controls/ListView/ListView.cs +++ b/src/Wpf.Ui/Controls/ListView/ListView.cs @@ -1,3 +1,8 @@ +// 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. + namespace Wpf.Ui.Controls; /// diff --git a/src/Wpf.Ui/Controls/NavigationView/INavigationView.cs b/src/Wpf.Ui/Controls/NavigationView/INavigationView.cs index 74d21ccc0..b279b20b2 100644 --- a/src/Wpf.Ui/Controls/NavigationView/INavigationView.cs +++ b/src/Wpf.Ui/Controls/NavigationView/INavigationView.cs @@ -2,9 +2,9 @@ // 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. -// -// Based on Windows UI Library -// Copyright(c) Microsoft Corporation.All rights reserved. + +/* Based on Windows UI Library + Copyright(c) Microsoft Corporation.All rights reserved. */ using System.Collections; using System.Windows.Controls; diff --git a/src/Wpf.Ui/Controls/NavigationView/INavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/INavigationViewItem.cs index 9ff7e0d3c..1bdddbee3 100644 --- a/src/Wpf.Ui/Controls/NavigationView/INavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/INavigationViewItem.cs @@ -2,9 +2,9 @@ // 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. -// -// Based on Windows UI Library -// Copyright(c) Microsoft Corporation.All rights reserved. + +/* Based on Windows UI Library + Copyright(c) Microsoft Corporation.All rights reserved. */ using System.Collections; using System.Windows.Controls; diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigatedEventArgs.cs b/src/Wpf.Ui/Controls/NavigationView/NavigatedEventArgs.cs index ac0a304de..5521c782e 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigatedEventArgs.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigatedEventArgs.cs @@ -2,9 +2,9 @@ // 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. -// -// Based on Windows UI Library -// Copyright(c) Microsoft Corporation.All rights reserved. + +/* Based on Windows UI Library + Copyright(c) Microsoft Corporation.All rights reserved. */ // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigatingCancelEventArgs.cs b/src/Wpf.Ui/Controls/NavigationView/NavigatingCancelEventArgs.cs index 2db4e2bec..7ec4b4cd3 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigatingCancelEventArgs.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigatingCancelEventArgs.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationCache.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationCache.cs index 4d33f1939..98c20c7d5 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationCache.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationCache.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationCacheMode.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationCacheMode.cs index 64b0099b5..2bd38c327 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationCacheMode.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationCacheMode.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs index 5859b1666..0beabb6ba 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs @@ -2,8 +2,8 @@ // 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. -// -// Based on Windows UI Library https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.navigationview?view=winrt-22621 + +/* Based on Windows UI Library https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.navigationview?view=winrt-22621 */ using System.Collections; using System.Collections.ObjectModel; diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Events.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Events.cs index ba6c0fcfe..ef2af06f2 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Events.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Events.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs index 77474ba14..29d3084ec 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Navigation.cs @@ -2,8 +2,8 @@ // 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. -// -// Based on Windows UI Library + +/* Based on Windows UI Library */ using System.Collections.ObjectModel; using System.Diagnostics; diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs index 548abff07..b0aa2436f 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.TemplateParts.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewBackButtonVisible.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewBackButtonVisible.cs index 329fb5e3b..2b9b91c25 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewBackButtonVisible.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewBackButtonVisible.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewBreadcrumbItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewBreadcrumbItem.cs index 1a4bdad8e..b5be596db 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewBreadcrumbItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewBreadcrumbItem.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs index fbd3625d3..636c530c2 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs @@ -2,8 +2,8 @@ // 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. -// -// Based on Windows UI Library + +/* Based on Windows UI Library */ using System.Windows.Controls; using System.Windows.Input; diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs index 5acda7583..e85c80677 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItem.cs @@ -2,8 +2,8 @@ // 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. -// -// Based on Windows UI Library https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.navigationviewitem?view=winrt-22621 + +/* Based on Windows UI Library https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.navigationviewitem?view=winrt-22621 */ using System.Collections; using System.Collections.ObjectModel; diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs index df000c1f0..a8e2a666d 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemHeader.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. // diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs index d94a9c7c4..ce89f6513 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewItemSeparator.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewPaneDisplayMode.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewPaneDisplayMode.cs index 78a7cb597..ae511fe9b 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewPaneDisplayMode.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewPaneDisplayMode.cs @@ -2,7 +2,7 @@ // 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. -// + // Based on Windows UI Library // Copyright(c) Microsoft Corporation.All rights reserved. diff --git a/src/Wpf.Ui/Controls/NumberBox/INumberFormatter.cs b/src/Wpf.Ui/Controls/NumberBox/INumberFormatter.cs index de20f3878..bfcb91cc6 100644 --- a/src/Wpf.Ui/Controls/NumberBox/INumberFormatter.cs +++ b/src/Wpf.Ui/Controls/NumberBox/INumberFormatter.cs @@ -2,7 +2,7 @@ // 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. -// + // This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs b/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs index 2c7837127..ea472467f 100644 --- a/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs +++ b/src/Wpf.Ui/Controls/NumberBox/INumberParser.cs @@ -2,7 +2,7 @@ // 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. -// + // This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs index bc167220b..8c188d1cc 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBox.cs @@ -2,13 +2,13 @@ // 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. -// + // This Source Code is partially based on the source code provided by the .NET Foundation. -// -// TODO: Mask (with placeholder); Clipboard paste; -// TODO: Constant decimals when formatting. Although this can actually be done with NumberFormatter. -// TODO: Disable expression by default -// TODO: Lock to digit characters only by property + +/* TODO: Mask (with placeholder); Clipboard paste; */ +/* TODO: Constant decimals when formatting. Although this can actually be done with NumberFormatter. */ +/* TODO: Disable expression by default */ +/* TODO: Lock to digit characters only by property */ using System.Windows.Data; using System.Windows.Input; diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBoxSpinButtonPlacementMode.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBoxSpinButtonPlacementMode.cs index 752068831..17c88f42a 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBoxSpinButtonPlacementMode.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBoxSpinButtonPlacementMode.cs @@ -2,7 +2,7 @@ // 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. -// + // This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBoxValidationMode.cs b/src/Wpf.Ui/Controls/NumberBox/NumberBoxValidationMode.cs index f99a5d741..4dfe465a1 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBoxValidationMode.cs +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBoxValidationMode.cs @@ -2,7 +2,7 @@ // 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. -// + // This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs b/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs index 8963a305d..19873b87f 100644 --- a/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs +++ b/src/Wpf.Ui/Controls/NumberBox/ValidateNumberFormatter.cs @@ -2,7 +2,7 @@ // 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. -// + // This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index 2d7be4f91..d888b18f8 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -2,11 +2,11 @@ // 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. -// + // TODO: This is an initial implementation and requires the necessary corrections, tests and adjustments. -// -// TextProperty contains asterisks OR raw password if IsPasswordRevealed is set to true -// PasswordProperty always contains raw password + +/* TextProperty contains asterisks OR raw password if IsPasswordRevealed is set to true + PasswordProperty always contains raw password */ using System.Windows.Controls; diff --git a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs index 8c5e79bef..0e4399e5c 100644 --- a/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs +++ b/src/Wpf.Ui/Controls/ProgressRing/ProgressRing.cs @@ -2,8 +2,8 @@ // 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. -// -// https://docs.microsoft.com/en-us/fluent-ui/web-components/components/progress-ring + +/* https://docs.microsoft.com/en-us/fluent-ui/web-components/components/progress-ring */ using Brush = System.Windows.Media.Brush; using Brushes = System.Windows.Media.Brushes; diff --git a/src/Wpf.Ui/Controls/ScrollDirection.cs b/src/Wpf.Ui/Controls/ScrollDirection.cs index 70a555837..c9008cbe9 100644 --- a/src/Wpf.Ui/Controls/ScrollDirection.cs +++ b/src/Wpf.Ui/Controls/ScrollDirection.cs @@ -2,12 +2,12 @@ // 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. -// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel -// -// Copyright (C) S. Bäumlisberger -// All Rights Reserved. + +/* Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. + https://github.com/sbaeumlisberger/VirtualizingWrapPanel + + Copyright (C) S. Bäumlisberger + All Rights Reserved. */ namespace Wpf.Ui.Controls; diff --git a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs index 123ba8915..9050723bd 100644 --- a/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs +++ b/src/Wpf.Ui/Controls/Snackbar/Snackbar.cs @@ -2,8 +2,8 @@ // 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. -// -// TODO: Refactor as popup, detach from the window renderer + +/* TODO: Refactor as popup, detach from the window renderer */ using System.Windows.Controls; using Wpf.Ui.Input; diff --git a/src/Wpf.Ui/Controls/SpacingMode.cs b/src/Wpf.Ui/Controls/SpacingMode.cs index 81f5b7d2c..154af3605 100644 --- a/src/Wpf.Ui/Controls/SpacingMode.cs +++ b/src/Wpf.Ui/Controls/SpacingMode.cs @@ -2,11 +2,11 @@ // 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. -// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel -// Copyright (C) S. Bäumlisberger -// All Rights Reserved. + +/* Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. + https://github.com/sbaeumlisberger/VirtualizingWrapPanel + Copyright (C) S. Bäumlisberger + All Rights Reserved. */ namespace Wpf.Ui.Controls; diff --git a/src/Wpf.Ui/Controls/TypedEventHandler.cs b/src/Wpf.Ui/Controls/TypedEventHandler.cs index a7cd6a7d4..bc8e6e587 100644 --- a/src/Wpf.Ui/Controls/TypedEventHandler.cs +++ b/src/Wpf.Ui/Controls/TypedEventHandler.cs @@ -2,9 +2,9 @@ // 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. -// -// Based on Windows UI Library -// Copyright(c) Microsoft Corporation.All rights reserved. + +/* Based on Windows UI Library + Copyright(c) Microsoft Corporation.All rights reserved. */ namespace Wpf.Ui.Controls; diff --git a/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs b/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs index 9512b5656..b3acc4f57 100644 --- a/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs +++ b/src/Wpf.Ui/Controls/VirtualizingGridView/VirtualizingGridView.cs @@ -2,12 +2,12 @@ // 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. -// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel -// -// Copyright (C) S. Bäumlisberger -// All Rights Reserved. + +/* Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. + https://github.com/sbaeumlisberger/VirtualizingWrapPanel + + Copyright (C) S. Bäumlisberger + All Rights Reserved. */ using System.Windows.Controls; using System.Windows.Data; diff --git a/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs b/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs index 2123737b9..0b42e64fd 100644 --- a/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs +++ b/src/Wpf.Ui/Controls/VirtualizingItemsControl/VirtualizingItemsControl.cs @@ -2,11 +2,11 @@ // 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. -// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel -// Copyright (C) S. Bäumlisberger -// All Rights Reserved. + +/* Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. + https://github.com/sbaeumlisberger/VirtualizingWrapPanel + Copyright (C) S. Bäumlisberger + All Rights Reserved. */ using System.Windows.Controls; diff --git a/src/Wpf.Ui/Controls/VirtualizingUniformGrid/VirtualizingUniformGrid.cs b/src/Wpf.Ui/Controls/VirtualizingUniformGrid/VirtualizingUniformGrid.cs index 143558c92..3b2d8ffd4 100644 --- a/src/Wpf.Ui/Controls/VirtualizingUniformGrid/VirtualizingUniformGrid.cs +++ b/src/Wpf.Ui/Controls/VirtualizingUniformGrid/VirtualizingUniformGrid.cs @@ -2,12 +2,12 @@ // 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. -// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel -// -// Copyright (C) S. Bäumlisberger -// All Rights Reserved. + +/* Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. + https://github.com/sbaeumlisberger/VirtualizingWrapPanel + + Copyright (C) S. Bäumlisberger + All Rights Reserved. */ // ReSharper disable once CheckNamespace namespace Wpf.Ui.Controls; diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs index db85b66fc..6e6bb58bc 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingPanelBase.cs @@ -2,14 +2,11 @@ // 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. -// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel -// Copyright (C) S. Bäumlisberger -// All Rights Reserved. -// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel + +/* Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. + https://github.com/sbaeumlisberger/VirtualizingWrapPanel + Copyright (C) S. Bäumlisberger + All Rights Reserved. */ using System.Collections.ObjectModel; using System.Collections.Specialized; diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index 6ace09392..0507f36ea 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -2,14 +2,11 @@ // 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. -// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel -// Copyright (C) S. Bäumlisberger -// All Rights Reserved. -// -// Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. -// https://github.com/sbaeumlisberger/VirtualizingWrapPanel + +/* Based on VirtualizingWrapPanel created by S. Bäumlisberger licensed under MIT license. + https://github.com/sbaeumlisberger/VirtualizingWrapPanel + Copyright (C) S. Bäumlisberger + All Rights Reserved. */ using System.Windows.Controls; using System.Windows.Controls.Primitives; @@ -428,8 +425,7 @@ protected override ItemRange UpdateItemRange() int rowCountInCacheBefore = (int)(cacheBeforeInPixel / GetHeight(ChildSize)); int rowCountInCacheAfter = ( - (int) - Math.Ceiling( + (int)Math.Ceiling( (offsetInPixel + viewportHeight + cacheAfterInPixel) / GetHeight(ChildSize) ) ) - (int)Math.Ceiling((offsetInPixel + viewportHeight) / GetHeight(ChildSize)); diff --git a/src/Wpf.Ui/Converters/ProgressThicknessConverter.cs b/src/Wpf.Ui/Converters/ProgressThicknessConverter.cs index cc10cc0e4..f0880ee0d 100644 --- a/src/Wpf.Ui/Converters/ProgressThicknessConverter.cs +++ b/src/Wpf.Ui/Converters/ProgressThicknessConverter.cs @@ -2,8 +2,8 @@ // 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. -// -// TODO: It's too hardcoded, we should define better formula. + +/* TODO: It's too hardcoded, we should define better formula. */ using System.Windows.Data; diff --git a/src/Wpf.Ui/Hardware/DisplayDpi.cs b/src/Wpf.Ui/Hardware/DisplayDpi.cs index 8ea68b963..88d8d3f9a 100644 --- a/src/Wpf.Ui/Hardware/DisplayDpi.cs +++ b/src/Wpf.Ui/Hardware/DisplayDpi.cs @@ -2,8 +2,8 @@ // 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. -// -// This Source Code is partially based on the source code provided by the .NET Foundation. + +/* This Source Code is partially based on the source code provided by the .NET Foundation. */ namespace Wpf.Ui.Hardware; diff --git a/src/Wpf.Ui/Input/IRelayCommand.cs b/src/Wpf.Ui/Input/IRelayCommand.cs index 0bbd4de35..cf7e75ec5 100644 --- a/src/Wpf.Ui/Input/IRelayCommand.cs +++ b/src/Wpf.Ui/Input/IRelayCommand.cs @@ -2,10 +2,10 @@ // 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. -// -// 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. + +/* 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.Windows.Input; diff --git a/src/Wpf.Ui/Input/IRelayCommand{T}.cs b/src/Wpf.Ui/Input/IRelayCommand{T}.cs index ae93e1dd6..9e5b23513 100644 --- a/src/Wpf.Ui/Input/IRelayCommand{T}.cs +++ b/src/Wpf.Ui/Input/IRelayCommand{T}.cs @@ -2,10 +2,10 @@ // 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. -// -// 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. + +/* 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.Windows.Input; diff --git a/src/Wpf.Ui/Input/RelayCommand{T}.cs b/src/Wpf.Ui/Input/RelayCommand{T}.cs index 6fd4ff9b3..5cf365d67 100644 --- a/src/Wpf.Ui/Input/RelayCommand{T}.cs +++ b/src/Wpf.Ui/Input/RelayCommand{T}.cs @@ -2,12 +2,12 @@ // 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. -// -// 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. -// -// This file is inspired from the MvvmLight library (lbugnion/MvvmLight) + +/* 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. + + This file is inspired by the MvvmLight library (lbugnion/MvvmLight) */ using System.Runtime.CompilerServices; diff --git a/src/Wpf.Ui/Interop/Dwmapi.cs b/src/Wpf.Ui/Interop/Dwmapi.cs index 8bb49b605..f1a090711 100644 --- a/src/Wpf.Ui/Interop/Dwmapi.cs +++ b/src/Wpf.Ui/Interop/Dwmapi.cs @@ -2,7 +2,7 @@ // 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. -// + // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. @@ -14,14 +14,14 @@ // // Windows Kits\10\Include\10.0.22000.0\um\dwmapi.h -using System.Runtime.InteropServices; - -namespace Wpf.Ui.Interop; - // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming #pragma warning disable SA1307 // Accessible fields should begin with upper-case letter +using System.Runtime.InteropServices; + +namespace Wpf.Ui.Interop; + /// /// Desktop Window Manager (DWM). /// diff --git a/src/Wpf.Ui/Interop/Kernel32.cs b/src/Wpf.Ui/Interop/Kernel32.cs index 02b2d75e0..d66562109 100644 --- a/src/Wpf.Ui/Interop/Kernel32.cs +++ b/src/Wpf.Ui/Interop/Kernel32.cs @@ -2,7 +2,7 @@ // 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. -// + // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. @@ -12,13 +12,12 @@ // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods +// ReSharper disable IdentifierTypo +// ReSharper disable InconsistentNaming using System.Runtime.InteropServices; namespace Wpf.Ui.Interop; -// ReSharper disable IdentifierTypo -// ReSharper disable InconsistentNaming - /// /// Used by multiple technologies. /// diff --git a/src/Wpf.Ui/Interop/ShObjIdl.cs b/src/Wpf.Ui/Interop/ShObjIdl.cs index d1774844d..cc334f43e 100644 --- a/src/Wpf.Ui/Interop/ShObjIdl.cs +++ b/src/Wpf.Ui/Interop/ShObjIdl.cs @@ -2,7 +2,7 @@ // 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. -// + // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. @@ -12,13 +12,12 @@ // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods -using System.Runtime.InteropServices; - -namespace Wpf.Ui.Interop; - // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming #pragma warning disable SA1307 // Accessible fields should begin with upper-case letter +using System.Runtime.InteropServices; + +namespace Wpf.Ui.Interop; /// /// Exposes methods that enumerate the contents of a view and receive notification from callback upon enumeration completion. diff --git a/src/Wpf.Ui/Interop/Shell32.cs b/src/Wpf.Ui/Interop/Shell32.cs index 3a571041f..9b1a4de70 100644 --- a/src/Wpf.Ui/Interop/Shell32.cs +++ b/src/Wpf.Ui/Interop/Shell32.cs @@ -2,7 +2,7 @@ // 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. -// + // This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. @@ -12,16 +12,16 @@ // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods -using System.Runtime.InteropServices; -using System.Runtime.InteropServices.ComTypes; - -namespace Wpf.Ui.Interop; - // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming #pragma warning disable SA1307 // Accessible fields should begin with upper-case letter #pragma warning disable SA1401 // Fields should be private +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.ComTypes; + +namespace Wpf.Ui.Interop; + /// /// The Windows UI provides users with access to a wide variety of objects necessary to run applications and manage the operating system. /// diff --git a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs index ce4cf4653..a3fc2421a 100644 --- a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs +++ b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs @@ -2,10 +2,10 @@ // 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. -// -// This Source Code is partially based on reverse engineering of the Windows Operating System, -// and is intended for use on Windows systems only. -// This Source Code is partially based on the source code provided by the .NET Foundation. + +/* This Source Code is partially based on reverse engineering of the Windows Operating System, + and is intended for use on Windows systems only. + This Source Code is partially based on the source code provided by the .NET Foundation. */ using System.Runtime.InteropServices; using Microsoft.Win32; @@ -376,7 +376,9 @@ public static Color GetDwmColor() return Color.FromArgb(255, values[2], values[1], values[0]); } - catch { } + catch + { + } } } diff --git a/src/Wpf.Ui/Interop/UnsafeReflection.cs b/src/Wpf.Ui/Interop/UnsafeReflection.cs index 891cfc77f..cb9ff3b05 100644 --- a/src/Wpf.Ui/Interop/UnsafeReflection.cs +++ b/src/Wpf.Ui/Interop/UnsafeReflection.cs @@ -2,10 +2,10 @@ // 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. -// -// This Source Code is partially based on reverse engineering of the Windows Operating System, -// and is intended for use on Windows systems only. -// This Source Code is partially based on the source code provided by the .NET Foundation. + +/* This Source Code is partially based on reverse engineering of the Windows Operating System, + and is intended for use on Windows systems only. + This Source Code is partially based on the source code provided by the .NET Foundation. */ using Wpf.Ui.Controls; using Wpf.Ui.TaskBar; diff --git a/src/Wpf.Ui/Interop/User32.cs b/src/Wpf.Ui/Interop/User32.cs index cf16f0e45..d2d7e10cc 100644 --- a/src/Wpf.Ui/Interop/User32.cs +++ b/src/Wpf.Ui/Interop/User32.cs @@ -2,15 +2,15 @@ // 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. -// -// This Source Code is partially based on reverse engineering of the Windows Operating System, -// and is intended for use on Windows systems only. -// This Source Code is partially based on the source code provided by the .NET Foundation. -// -// NOTE: -// I split unmanaged code stuff into the NativeMethods library. -// If you have suggestions for the code below, please submit your changes there. -// https://github.com/lepoco/nativemethods + +/* This Source Code is partially based on reverse engineering of the Windows Operating System, + and is intended for use on Windows systems only. + This Source Code is partially based on the source code provided by the .NET Foundation. + + NOTE: + I split unmanaged code stuff into the NativeMethods library. + If you have suggestions for the code below, please submit your changes there. + https://github.com/lepoco/nativemethods */ using System.Runtime.InteropServices; diff --git a/src/Wpf.Ui/Interop/UxTheme.cs b/src/Wpf.Ui/Interop/UxTheme.cs index 9eb0f7be4..479e01915 100644 --- a/src/Wpf.Ui/Interop/UxTheme.cs +++ b/src/Wpf.Ui/Interop/UxTheme.cs @@ -2,15 +2,15 @@ // 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. -// -// This Source Code is partially based on reverse engineering of the Windows Operating System, -// and is intended for use on Windows systems only. -// This Source Code is partially based on the source code provided by the .NET Foundation. -// -// NOTE: -// I split unmanaged code stuff into the NativeMethods library. -// If you have suggestions for the code below, please submit your changes there. -// https://github.com/lepoco/nativemethods + +/* This Source Code is partially based on reverse engineering of the Windows Operating System, + and is intended for use on Windows systems only. + This Source Code is partially based on the source code provided by the .NET Foundation. + + NOTE: + I split unmanaged code stuff into the NativeMethods library. + If you have suggestions for the code below, please submit your changes there. + https://github.com/lepoco/nativemethods */ using System.Runtime.InteropServices; using System.Text; diff --git a/src/Wpf.Ui/Interop/WinDef/POINT.cs b/src/Wpf.Ui/Interop/WinDef/POINT.cs index 567aa6423..4aa0fd702 100644 --- a/src/Wpf.Ui/Interop/WinDef/POINT.cs +++ b/src/Wpf.Ui/Interop/WinDef/POINT.cs @@ -2,10 +2,10 @@ // 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. -// -// This Source Code is partially based on reverse engineering of the Windows Operating System, -// and is intended for use on Windows systems only. -// This Source Code is partially based on the source code provided by the .NET Foundation. + +/* This Source Code is partially based on reverse engineering of the Windows Operating System, + and is intended for use on Windows systems only. + This Source Code is partially based on the source code provided by the .NET Foundation. */ using System.Runtime.InteropServices; diff --git a/src/Wpf.Ui/Interop/WinDef/POINTL.cs b/src/Wpf.Ui/Interop/WinDef/POINTL.cs index d595be474..d85aa49b5 100644 --- a/src/Wpf.Ui/Interop/WinDef/POINTL.cs +++ b/src/Wpf.Ui/Interop/WinDef/POINTL.cs @@ -2,10 +2,10 @@ // 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. -// -// This Source Code is partially based on reverse engineering of the Windows Operating System, -// and is intended for use on Windows systems only. -// This Source Code is partially based on the source code provided by the .NET Foundation. + +/* This Source Code is partially based on reverse engineering of the Windows Operating System, + and is intended for use on Windows systems only. + This Source Code is partially based on the source code provided by the .NET Foundation. */ using System.Runtime.InteropServices; diff --git a/src/Wpf.Ui/Interop/WinDef/RECT.cs b/src/Wpf.Ui/Interop/WinDef/RECT.cs index 6b9e27dd8..57ade04eb 100644 --- a/src/Wpf.Ui/Interop/WinDef/RECT.cs +++ b/src/Wpf.Ui/Interop/WinDef/RECT.cs @@ -2,10 +2,10 @@ // 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. -// -// This Source Code is partially based on reverse engineering of the Windows Operating System, -// and is intended for use on Windows systems only. -// This Source Code is partially based on the source code provided by the .NET Foundation. + +/* This Source Code is partially based on reverse engineering of the Windows Operating System, + and is intended for use on Windows systems only. + This Source Code is partially based on the source code provided by the .NET Foundation. */ using System.Runtime.InteropServices; diff --git a/src/Wpf.Ui/Interop/WinDef/RECTL.cs b/src/Wpf.Ui/Interop/WinDef/RECTL.cs index 2df49831f..614f69671 100644 --- a/src/Wpf.Ui/Interop/WinDef/RECTL.cs +++ b/src/Wpf.Ui/Interop/WinDef/RECTL.cs @@ -2,10 +2,10 @@ // 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. -// -// This Source Code is partially based on reverse engineering of the Windows Operating System, -// and is intended for use on Windows systems only. -// This Source Code is partially based on the source code provided by the .NET Foundation. + +/* This Source Code is partially based on reverse engineering of the Windows Operating System, + and is intended for use on Windows systems only. + This Source Code is partially based on the source code provided by the .NET Foundation. */ using System.Runtime.InteropServices; diff --git a/src/Wpf.Ui/Interop/WinDef/SIZE.cs b/src/Wpf.Ui/Interop/WinDef/SIZE.cs index 6e77f4304..a0a2aa48d 100644 --- a/src/Wpf.Ui/Interop/WinDef/SIZE.cs +++ b/src/Wpf.Ui/Interop/WinDef/SIZE.cs @@ -2,10 +2,10 @@ // 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. -// -// This Source Code is partially based on reverse engineering of the Windows Operating System, -// and is intended for use on Windows systems only. -// This Source Code is partially based on the source code provided by the .NET Foundation. + +/* This Source Code is partially based on reverse engineering of the Windows Operating System, + and is intended for use on Windows systems only. + This Source Code is partially based on the source code provided by the .NET Foundation. */ using System.Runtime.InteropServices; diff --git a/src/Wpf.Ui/Markup/Design.cs b/src/Wpf.Ui/Markup/Design.cs index 6a6966659..5dbb316f1 100644 --- a/src/Wpf.Ui/Markup/Design.cs +++ b/src/Wpf.Ui/Markup/Design.cs @@ -28,12 +28,10 @@ public static class Design /// private static bool InDesignMode => _inDesignMode ??= - (bool) - DependencyPropertyDescriptor + (bool)DependencyPropertyDescriptor .FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)) .Metadata.DefaultValue - || System - .Diagnostics.Process.GetCurrentProcess() + || System.Diagnostics.Process.GetCurrentProcess() .ProcessName.StartsWith(DesignProcessName, StringComparison.Ordinal); public static readonly DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached( diff --git a/src/Wpf.Ui/UiApplication.cs b/src/Wpf.Ui/UiApplication.cs index c985373ec..4ec6f2cea 100644 --- a/src/Wpf.Ui/UiApplication.cs +++ b/src/Wpf.Ui/UiApplication.cs @@ -95,11 +95,14 @@ public ResourceDictionary Resources _resources.MergedDictionaries.Add(themesDictionary); _resources.MergedDictionaries.Add(controlsDictionary); } - catch { } + catch + { + } } return _application?.Resources ?? _resources; } + set { if (_application is not null) diff --git a/src/Wpf.Ui/Win32/Utilities.cs b/src/Wpf.Ui/Win32/Utilities.cs index f07dea80f..a90e9df70 100644 --- a/src/Wpf.Ui/Win32/Utilities.cs +++ b/src/Wpf.Ui/Win32/Utilities.cs @@ -140,8 +140,8 @@ out var majorObj major = (int)majorObj; } - // When the 'CurrentMajorVersionNumber' value is not present we fallback to reading the previous key used for this: 'CurrentVersion' - else if ( + else // When the 'CurrentMajorVersionNumber' value is not present we fallback to reading the previous key used for this: 'CurrentVersion' + if ( TryGetRegistryKey( @"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion", @@ -176,8 +176,8 @@ out var minorObj minor = (int)minorObj; } - // When the 'CurrentMinorVersionNumber' value is not present we fallback to reading the previous key used for this: 'CurrentVersion' - else if ( + else // When the 'CurrentMinorVersionNumber' value is not present we fallback to reading the previous key used for this: 'CurrentVersion' + if ( TryGetRegistryKey( @"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion", diff --git a/tests/Wpf.Ui.Gallery.UnitTests/UnitTest1.cs b/tests/Wpf.Ui.Gallery.UnitTests/UnitTest1.cs index e1c337693..dbdc4b17e 100644 --- a/tests/Wpf.Ui.Gallery.UnitTests/UnitTest1.cs +++ b/tests/Wpf.Ui.Gallery.UnitTests/UnitTest1.cs @@ -1,3 +1,8 @@ +// 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. + namespace Wpf.Ui.Gallery.UnitTests; public class UnitTest1 diff --git a/tests/Wpf.Ui.Gallery.UnitTests/Usings.cs b/tests/Wpf.Ui.Gallery.UnitTests/Usings.cs index c802f4480..d5bf6204c 100644 --- a/tests/Wpf.Ui.Gallery.UnitTests/Usings.cs +++ b/tests/Wpf.Ui.Gallery.UnitTests/Usings.cs @@ -1 +1,6 @@ +// 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. + global using Xunit; From 232b9c6c5a102d4052f428b327a8eb920a7682b8 Mon Sep 17 00:00:00 2001 From: Muniwedesu <32552380+Muniwedesu@users.noreply.github.com> Date: Sun, 2 Jun 2024 04:12:14 -0700 Subject: [PATCH 15/36] fix non-legacy backdrop when switching themes (#1094) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Антонов Семен Викторович --- src/Wpf.Ui/Appearance/WindowBackgroundManager.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs b/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs index 4425f68c9..84f9bc8da 100644 --- a/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs +++ b/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs @@ -91,10 +91,14 @@ WindowBackdropType backdrop } // This was required to update the background when moving from a HC theme to light/dark theme. However, this breaks theme proper light/dark theme changing on Windows 10. - // else - // { - // _ = WindowBackdrop.RemoveBackground(window); - // } + // But window backdrop effects are not applied when it has an opaque (or any) background on W11 (so removing this breaks backdrop effects when switching themes), however, for legacy MICA it may not be required + // using existing variable, though the OS build which (officially) supports setting DWM_SYSTEMBACKDROP_TYPE attribute is build 22621 + // source: https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type + if (Win32.Utilities.IsOSWindows11Insider1OrNewer && backdrop is not WindowBackdropType.None) + { + _ = WindowBackdrop.RemoveBackground(window); + } + _ = WindowBackdrop.ApplyBackdrop(window, backdrop); if (applicationTheme is ApplicationTheme.Dark) { From 259faf2baea61a2eb71d7e207833d0c754049089 Mon Sep 17 00:00:00 2001 From: textGamex Date: Sun, 2 Jun 2024 19:12:37 +0800 Subject: [PATCH 16/36] fix: possible null reference exceptions in PasswordBox (#1091) --- src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index d888b18f8..d49a0d341 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -237,7 +237,7 @@ private void UpdateTextContents(bool isTriggeredByTextInput) var caretIndex = CaretIndex; var selectionIndex = SelectionStart; - var currentPassword = Password; + var currentPassword = Password ?? string.Empty; var newPasswordValue = currentPassword; if (isTriggeredByTextInput) From 00a4c0c5ec95f41f5864567108cb4baa7b6eacbe Mon Sep 17 00:00:00 2001 From: textGamex Date: Wed, 5 Jun 2024 04:16:55 +0800 Subject: [PATCH 17/36] fix: TextBox, NumberBox, PasswordBox Placeholder Not Working Properly. (#1109) --- src/Wpf.Ui/Controls/NumberBox/NumberBox.xaml | 18 +++---- .../Controls/PasswordBox/PasswordBox.cs | 12 +---- .../Controls/PasswordBox/PasswordBox.xaml | 10 ++-- src/Wpf.Ui/Controls/TextBox/TextBox.cs | 47 +++++++++++++++---- src/Wpf.Ui/Controls/TextBox/TextBox.xaml | 2 +- 5 files changed, 55 insertions(+), 34 deletions(-) diff --git a/src/Wpf.Ui/Controls/NumberBox/NumberBox.xaml b/src/Wpf.Ui/Controls/NumberBox/NumberBox.xaml index 361a9bb5b..58f36f9a1 100644 --- a/src/Wpf.Ui/Controls/NumberBox/NumberBox.xaml +++ b/src/Wpf.Ui/Controls/NumberBox/NumberBox.xaml @@ -54,10 +54,10 @@ + Foreground="{TemplateBinding Foreground}" + IsTabStop="False" /> + Foreground="{DynamicResource TextControlButtonForeground}" + IsTabStop="False"> @@ -178,8 +178,8 @@ VerticalAlignment="Top" Content="{TemplateBinding Icon}" FontSize="16" - IsTabStop="False" - Foreground="{TemplateBinding Foreground}" /> + Foreground="{TemplateBinding Foreground}" + IsTabStop="False" /> @@ -192,7 +192,7 @@ CornerRadius="{TemplateBinding Border.CornerRadius}" /> - + diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index d49a0d341..e4be9da26 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -88,7 +88,7 @@ public bool IsPasswordRevealed } /// - /// Gets or sets a value indicating whether whether to display the password reveal button. + /// Gets or sets a value indicating whether to display the password reveal button. /// public bool RevealButtonEnabled { @@ -125,15 +125,7 @@ protected override void OnTextChanged(TextChangedEventArgs e) } else { - if (PlaceholderEnabled && Text.Length > 0) - { - SetCurrentValue(PlaceholderEnabledProperty, false); - } - - if (!PlaceholderEnabled && Text.Length < 1) - { - SetCurrentValue(PlaceholderEnabledProperty, true); - } + SetPlaceholderTextVisibility(); RevealClearButton(); } diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.xaml b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.xaml index 871698bba..346b8a68d 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.xaml +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.xaml @@ -204,8 +204,8 @@ Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}" CommandParameter="clear" Cursor="Arrow" - IsTabStop="False" - Foreground="{DynamicResource TextControlButtonForeground}"> + Foreground="{DynamicResource TextControlButtonForeground}" + IsTabStop="False"> @@ -228,8 +228,8 @@ Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}" CommandParameter="reveal" Cursor="Arrow" - IsTabStop="False" - Foreground="{DynamicResource TextControlButtonForeground}"> + Foreground="{DynamicResource TextControlButtonForeground}" + IsTabStop="False"> @@ -256,7 +256,7 @@ CornerRadius="{TemplateBinding Border.CornerRadius}" /> - + diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.cs b/src/Wpf.Ui/Controls/TextBox/TextBox.cs index e33781008..befd9169f 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.cs +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.cs @@ -48,6 +48,13 @@ public class TextBox : System.Windows.Controls.TextBox new PropertyMetadata(true) ); + /// Identifies the dependency property. + public static readonly DependencyProperty CurrentPlaceholderEnabledProperty = DependencyProperty.Register( + nameof(CurrentPlaceholderEnabled), + typeof(bool), + typeof(TextBox), + new PropertyMetadata(true)); + /// Identifies the dependency property. public static readonly DependencyProperty ClearButtonEnabledProperty = DependencyProperty.Register( nameof(ClearButtonEnabled), @@ -99,7 +106,7 @@ public ElementPlacement IconPlacement } /// - /// Gets or sets numbers pattern. + /// Gets or sets placeholder text. /// public string PlaceholderText { @@ -108,7 +115,7 @@ public string PlaceholderText } /// - /// Gets or sets a value indicating whether to display the placeholder text. + /// Gets or sets a value indicating whether to enable the placeholder text. /// public bool PlaceholderEnabled { @@ -116,6 +123,15 @@ public bool PlaceholderEnabled set => SetValue(PlaceholderEnabledProperty, value); } + /// + /// Gets or sets a value indicating whether to display the placeholder text. + /// + public bool CurrentPlaceholderEnabled + { + get => (bool)GetValue(CurrentPlaceholderEnabledProperty); + protected set => SetValue(CurrentPlaceholderEnabledProperty, value); + } + /// /// Gets or sets a value indicating whether to enable the clear button. /// @@ -154,6 +170,7 @@ public bool IsTextSelectionEnabled public TextBox() { SetValue(TemplateButtonCommandProperty, new RelayCommand(OnTemplateButtonClick)); + CurrentPlaceholderEnabled = PlaceholderEnabled; } /// @@ -161,17 +178,29 @@ protected override void OnTextChanged(TextChangedEventArgs e) { base.OnTextChanged(e); - if (PlaceholderEnabled && Text.Length > 0) + SetPlaceholderTextVisibility(); + + RevealClearButton(); + } + + protected void SetPlaceholderTextVisibility() + { + if (PlaceholderEnabled) { - SetCurrentValue(PlaceholderEnabledProperty, false); + if (CurrentPlaceholderEnabled && Text.Length > 0) + { + SetCurrentValue(CurrentPlaceholderEnabledProperty, false); + } + + if (!CurrentPlaceholderEnabled && Text.Length < 1) + { + SetCurrentValue(CurrentPlaceholderEnabledProperty, true); + } } - - if (!PlaceholderEnabled && Text.Length < 1) + else { - SetCurrentValue(PlaceholderEnabledProperty, true); + SetCurrentValue(CurrentPlaceholderEnabledProperty, false); } - - RevealClearButton(); } /// diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.xaml b/src/Wpf.Ui/Controls/TextBox/TextBox.xaml index 8e197b9c0..4fc1e5940 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.xaml +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.xaml @@ -214,7 +214,7 @@ CornerRadius="{TemplateBinding Border.CornerRadius}" /> - + From 150e05d2610c17d62d87c7ae54a39220fc1441bd Mon Sep 17 00:00:00 2001 From: textGamex Date: Sun, 9 Jun 2024 05:44:24 +0800 Subject: [PATCH 18/36] fix: PlaceholderText may not display promptly under certain circumstances (#1115) --- src/Wpf.Ui/Controls/TextBox/TextBox.cs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Wpf.Ui/Controls/TextBox/TextBox.cs b/src/Wpf.Ui/Controls/TextBox/TextBox.cs index befd9169f..25b2f8ffc 100644 --- a/src/Wpf.Ui/Controls/TextBox/TextBox.cs +++ b/src/Wpf.Ui/Controls/TextBox/TextBox.cs @@ -45,7 +45,7 @@ public class TextBox : System.Windows.Controls.TextBox nameof(PlaceholderEnabled), typeof(bool), typeof(TextBox), - new PropertyMetadata(true) + new PropertyMetadata(true, OnPlaceholderEnabledChanged) ); /// Identifies the dependency property. @@ -53,7 +53,8 @@ public class TextBox : System.Windows.Controls.TextBox nameof(CurrentPlaceholderEnabled), typeof(bool), typeof(TextBox), - new PropertyMetadata(true)); + new PropertyMetadata(true) + ); /// Identifies the dependency property. public static readonly DependencyProperty ClearButtonEnabledProperty = DependencyProperty.Register( @@ -197,7 +198,7 @@ protected void SetPlaceholderTextVisibility() SetCurrentValue(CurrentPlaceholderEnabledProperty, true); } } - else + else if (CurrentPlaceholderEnabled) { SetCurrentValue(CurrentPlaceholderEnabledProperty, false); } @@ -263,4 +264,19 @@ protected virtual void OnTemplateButtonClick(string? parameter) OnClearButtonClick(); } + + private static void OnPlaceholderEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is not TextBox control) + { + return; + } + + control.OnPlaceholderEnabledChanged(); + } + + protected virtual void OnPlaceholderEnabledChanged() + { + SetPlaceholderTextVisibility(); + } } From ba8a24146844c127373526236e3c647240c177b9 Mon Sep 17 00:00:00 2001 From: jm <107654654+jm6271@users.noreply.github.com> Date: Sat, 8 Jun 2024 17:45:05 -0400 Subject: [PATCH 19/36] Update themes.md (#1114) Change the Watcher class to SystemThemeWatcher in the docs --- docs/documentation/themes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/documentation/themes.md b/docs/documentation/themes.md index 16ad1d59a..218b02e1b 100644 --- a/docs/documentation/themes.md +++ b/docs/documentation/themes.md @@ -46,7 +46,7 @@ Wpf.Ui.Appearance.ApplicationThemeManager.Apply( ### Automatic change -The theme can be changed automatically when the operating system changes its background or accent using the [Watcher](https://github.com/lepoco/wpfui/blob/main/src/Wpf.Ui/Appearance/Watcher.cs) class. +The theme can be changed automatically when the operating system changes its background or accent using the [SystemThemeWatcher](https://github.com/lepoco/wpfui/blob/main/src/Wpf.Ui/Appearance/SystemThemeWatcher.cs) class. ```csharp namespace MyApp; From cc35ab2da15ed329feb74ec3703f59d68e5c95df Mon Sep 17 00:00:00 2001 From: pomian <13592821+pomianowski@users.noreply.github.com> Date: Tue, 11 Jun 2024 01:49:20 +0200 Subject: [PATCH 20/36] Update window titlebar color (#1122) --- .../Appearance/WindowBackgroundManager.cs | 5 +++ .../Controls/FluentWindow/FluentWindow.cs | 2 + .../VirtualizingWrapPanel.cs | 3 +- src/Wpf.Ui/Controls/Window/WindowBackdrop.cs | 38 ++++++++++++++++++- src/Wpf.Ui/Interop/Dwmapi.cs | 16 ++++++++ src/Wpf.Ui/Interop/UnsafeNativeMethods.cs | 4 +- src/Wpf.Ui/Markup/Design.cs | 6 ++- src/Wpf.Ui/UiApplication.cs | 17 ++++----- 8 files changed, 74 insertions(+), 17 deletions(-) diff --git a/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs b/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs index 84f9bc8da..769e888bc 100644 --- a/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs +++ b/src/Wpf.Ui/Appearance/WindowBackgroundManager.cs @@ -100,6 +100,7 @@ WindowBackdropType backdrop } _ = WindowBackdrop.ApplyBackdrop(window, backdrop); + if (applicationTheme is ApplicationTheme.Dark) { ApplyDarkThemeToWindow(window); @@ -109,6 +110,8 @@ WindowBackdropType backdrop RemoveDarkThemeFromWindow(window); } + _ = WindowBackdrop.RemoveTitlebarBackground(window); + foreach (object? subWindow in window.OwnedWindows) { if (subWindow is Window windowSubWindow) @@ -123,6 +126,8 @@ WindowBackdropType backdrop { RemoveDarkThemeFromWindow(windowSubWindow); } + + _ = WindowBackdrop.RemoveTitlebarBackground(window); } } } diff --git a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs b/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs index c8cc3bea8..9d4905211 100644 --- a/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs +++ b/src/Wpf.Ui/Controls/FluentWindow/FluentWindow.cs @@ -199,6 +199,8 @@ protected virtual void OnBackdropTypeChanged(WindowBackdropType oldValue, Window if (WindowBackdrop.IsSupported(newValue) && WindowBackdrop.RemoveBackground(this)) { _ = WindowBackdrop.ApplyBackdrop(this, newValue); + + _ = WindowBackdrop.RemoveTitlebarBackground(this); } } diff --git a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs index 0507f36ea..1a58d4723 100644 --- a/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs +++ b/src/Wpf.Ui/Controls/VirtualizingWrapPanel/VirtualizingWrapPanel.cs @@ -425,7 +425,8 @@ protected override ItemRange UpdateItemRange() int rowCountInCacheBefore = (int)(cacheBeforeInPixel / GetHeight(ChildSize)); int rowCountInCacheAfter = ( - (int)Math.Ceiling( + (int) + Math.Ceiling( (offsetInPixel + viewportHeight + cacheAfterInPixel) / GetHeight(ChildSize) ) ) - (int)Math.Ceiling((offsetInPixel + viewportHeight) / GetHeight(ChildSize)); diff --git a/src/Wpf.Ui/Controls/Window/WindowBackdrop.cs b/src/Wpf.Ui/Controls/Window/WindowBackdrop.cs index 582d03cd7..a1cc1c2d2 100644 --- a/src/Wpf.Ui/Controls/Window/WindowBackdrop.cs +++ b/src/Wpf.Ui/Controls/Window/WindowBackdrop.cs @@ -38,7 +38,7 @@ public static bool IsSupported(WindowBackdropType backdropType) /// The window to which the backdrop effect will be applied. /// The type of backdrop effect to apply. Determines the visual appearance of the window's backdrop. /// if the operation was successful; otherwise, . - public static bool ApplyBackdrop(System.Windows.Window window, WindowBackdropType backdropType) + public static bool ApplyBackdrop(System.Windows.Window? window, WindowBackdropType backdropType) { if (window is null) { @@ -216,6 +216,40 @@ public static bool RemoveBackground(System.Windows.Window? window) return true; } + public static bool RemoveTitlebarBackground(System.Windows.Window? window) + { + if (window is null) + { + return false; + } + + IntPtr windowHandle = new WindowInteropHelper(window).Handle; + + if (windowHandle == IntPtr.Zero) + { + return false; + } + + HwndSource? windowSource = HwndSource.FromHwnd(windowHandle); + + // Remove background from client area + if (windowSource?.Handle != IntPtr.Zero && windowSource?.CompositionTarget != null) + { + // NOTE: https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute + // Specifying DWMWA_COLOR_DEFAULT (value 0xFFFFFFFF) for the color will reset the window back to using the system's default behavior for the caption color. + uint titlebarPvAttribute = 0xFFFFFFFE; + + Dwmapi.DwmSetWindowAttribute( + windowSource.Handle, + Dwmapi.DWMWINDOWATTRIBUTE.DWMWA_CAPTION_COLOR, + ref titlebarPvAttribute, + Marshal.SizeOf(typeof(uint)) + ); + } + + return true; + } + private static bool ApplyDwmwWindowAttrubute(IntPtr hWnd, Dwmapi.DWMSBT dwmSbt) { if (hWnd == IntPtr.Zero) @@ -228,7 +262,7 @@ private static bool ApplyDwmwWindowAttrubute(IntPtr hWnd, Dwmapi.DWMSBT dwmSbt) return false; } - var backdropPvAttribute = (int)dwmSbt; + int backdropPvAttribute = (int)dwmSbt; var dwmApiResult = Dwmapi.DwmSetWindowAttribute( hWnd, diff --git a/src/Wpf.Ui/Interop/Dwmapi.cs b/src/Wpf.Ui/Interop/Dwmapi.cs index f1a090711..adf6a9618 100644 --- a/src/Wpf.Ui/Interop/Dwmapi.cs +++ b/src/Wpf.Ui/Interop/Dwmapi.cs @@ -619,6 +619,22 @@ public static extern int DwmSetWindowAttribute( [In] int cbAttribute ); + /// + /// Sets the value of Desktop Window Manager (DWM) non-client rendering attributes for a window. + /// + /// The handle to the window for which the attribute value is to be set. + /// A flag describing which value to set, specified as a value of the DWMWINDOWATTRIBUTE enumeration. + /// A pointer to an object containing the attribute value to set. + /// The size, in bytes, of the attribute value being set via the pvAttribute parameter. + /// If the function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + [DllImport(Libraries.Dwmapi)] + public static extern int DwmSetWindowAttribute( + [In] IntPtr hWnd, + [In] DWMWINDOWATTRIBUTE dwAttribute, + [In] ref uint pvAttribute, + [In] int cbAttribute + ); + /// /// Retrieves the current value of a specified Desktop Window Manager (DWM) attribute applied to a window. For programming guidance, and code examples, see Controlling non-client region rendering. /// diff --git a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs index a3fc2421a..e73401cca 100644 --- a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs +++ b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs @@ -376,9 +376,7 @@ public static Color GetDwmColor() return Color.FromArgb(255, values[2], values[1], values[0]); } - catch - { - } + catch { } } } diff --git a/src/Wpf.Ui/Markup/Design.cs b/src/Wpf.Ui/Markup/Design.cs index 5dbb316f1..6a6966659 100644 --- a/src/Wpf.Ui/Markup/Design.cs +++ b/src/Wpf.Ui/Markup/Design.cs @@ -28,10 +28,12 @@ public static class Design /// private static bool InDesignMode => _inDesignMode ??= - (bool)DependencyPropertyDescriptor + (bool) + DependencyPropertyDescriptor .FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)) .Metadata.DefaultValue - || System.Diagnostics.Process.GetCurrentProcess() + || System + .Diagnostics.Process.GetCurrentProcess() .ProcessName.StartsWith(DesignProcessName, StringComparison.Ordinal); public static readonly DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached( diff --git a/src/Wpf.Ui/UiApplication.cs b/src/Wpf.Ui/UiApplication.cs index 4ec6f2cea..b12c0b7a9 100644 --- a/src/Wpf.Ui/UiApplication.cs +++ b/src/Wpf.Ui/UiApplication.cs @@ -36,8 +36,8 @@ public UiApplication(Application application) _application = application; System.Diagnostics.Debug.WriteLine( - $"INFO | {typeof(UiApplication)} application is {_application}", - "Wpf.Ui" + $"INFO | {typeof(UiApplication)} application is {_application}", + "Wpf.Ui" ); } @@ -95,14 +95,11 @@ public ResourceDictionary Resources _resources.MergedDictionaries.Add(themesDictionary); _resources.MergedDictionaries.Add(controlsDictionary); } - catch - { - } + catch { } } return _application?.Resources ?? _resources; } - set { if (_application is not null) @@ -132,8 +129,10 @@ public void Shutdown() private static bool ApplicationHasResources(Application application) { - return application.Resources.MergedDictionaries - .Where(e => e.Source is not null) - .Any(e => e.Source.ToString().ToLower().Contains(Appearance.ApplicationThemeManager.LibraryNamespace)); + return application + .Resources.MergedDictionaries.Where(e => e.Source is not null) + .Any(e => + e.Source.ToString().ToLower().Contains(Appearance.ApplicationThemeManager.LibraryNamespace) + ); } } From 9c55f379bb1ea3bcb59d3b2faabcf577131699ed Mon Sep 17 00:00:00 2001 From: textGamex Date: Tue, 11 Jun 2024 07:57:58 +0800 Subject: [PATCH 21/36] fix: possible multiple invocations of the INavigationAware interface methods. (#1116) Co-authored-by: pomian <13592821+pomianowski@users.noreply.github.com> --- .../NavigationViewContentPresenter.cs | 52 ++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs index 636c530c2..d35cb52b7 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs @@ -183,47 +183,39 @@ private void ApplyTransitionEffectToNavigatedPage(object content) private static void NotifyContentAboutNavigatingTo(object content) { - if (content is INavigationAware navigationAwareNavigationContent) + switch (content) { - navigationAwareNavigationContent.OnNavigatedTo(); - } - - if ( - content is INavigableView + case INavigationAware navigationAwareNavigationContent: + navigationAwareNavigationContent.OnNavigatedTo(); + break; + case INavigableView { ViewModel: INavigationAware navigationAwareNavigableViewViewModel - } - ) - { - navigationAwareNavigableViewViewModel.OnNavigatedTo(); - } - - if (content is FrameworkElement { DataContext: INavigationAware navigationAwareCurrentContent }) - { - navigationAwareCurrentContent.OnNavigatedTo(); + }: + navigationAwareNavigableViewViewModel.OnNavigatedTo(); + break; + case FrameworkElement { DataContext: INavigationAware navigationAwareCurrentContent }: + navigationAwareCurrentContent.OnNavigatedTo(); + break; } } private static void NotifyContentAboutNavigatingFrom(object content) { - if (content is INavigationAware navigationAwareNavigationContent) + switch (content) { - navigationAwareNavigationContent.OnNavigatedFrom(); - } - - if ( - content is INavigableView + case INavigationAware navigationAwareNavigationContent: + navigationAwareNavigationContent.OnNavigatedFrom(); + break; + case INavigableView { ViewModel: INavigationAware navigationAwareNavigableViewViewModel - } - ) - { - navigationAwareNavigableViewViewModel.OnNavigatedFrom(); - } - - if (content is FrameworkElement { DataContext: INavigationAware navigationAwareCurrentContent }) - { - navigationAwareCurrentContent.OnNavigatedFrom(); + }: + navigationAwareNavigableViewViewModel.OnNavigatedFrom(); + break; + case FrameworkElement { DataContext: INavigationAware navigationAwareCurrentContent }: + navigationAwareCurrentContent.OnNavigatedFrom(); + break; } } } From 7db4af29d7464236eab90940b159112e0a2e2ef4 Mon Sep 17 00:00:00 2001 From: ioswald Date: Mon, 10 Jun 2024 19:00:39 -0500 Subject: [PATCH 22/36] Update `INotifyCollectionChanged` events in `MenuItems` and `FooterMenuItems` of the `NavigationView` (#1098) * - added source source binding list change event handling for navigationview menu/footer items. - Fixed menu/footer items not updating with databinding source if items modified post init. * Fixed stackoverflow due to recursive call from collection change event when updating from binding source * Update NavigationView.Properties.cs * Update NavigationView.Properties.cs --------- Co-authored-by: pomian <13592821+pomianowski@users.noreply.github.com> --- .../NavigationView.Properties.cs | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs index 2f714bcfa..746899a80 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs @@ -450,6 +450,49 @@ public Thickness FrameMargin set => SetValue(FrameMarginProperty, value); } + private void OnMenuItemsSource_CollectionChanged(object? sender, IList collection, NotifyCollectionChangedEventArgs e) + { + if (ReferenceEquals(sender, collection)) + { + return; + } + + switch (e.Action) + { + case NotifyCollectionChangedAction.Add: + foreach (var item in e.NewItems) + { + collection.Add(item); + } + break; + + case NotifyCollectionChangedAction.Remove: + foreach (var item in e.OldItems) + { + if (!e.NewItems.Contains(item)) + { + collection.Remove(item); + } + } + break; + + case NotifyCollectionChangedAction.Move: + var moveItem = MenuItems[e.OldStartingIndex]; + collection.RemoveAt(e.OldStartingIndex); + collection.Insert(e.NewStartingIndex, moveItem); + break; + + case NotifyCollectionChangedAction.Replace: + collection.RemoveAt(e.OldStartingIndex); + collection.Insert(e.OldStartingIndex, e.NewItems[0]); + break; + + case NotifyCollectionChangedAction.Reset: + collection.Clear(); + break; + } + } + private void OnMenuItems_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { if (e.NewItems is null) @@ -481,6 +524,11 @@ private static void OnMenuItemsSourceChanged(DependencyObject? d, DependencyProp { navigationView.MenuItems.Add(e.NewValue); } + + if (e.NewValue is INotifyCollectionChanged oc) + { + oc.CollectionChanged += (s, e) => navigationView.OnMenuItemsSource_CollectionChanged(oc, navigationView.MenuItems, e); + } } private void OnFooterMenuItems_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) @@ -517,6 +565,11 @@ DependencyPropertyChangedEventArgs e { navigationView.FooterMenuItems.Add(e.NewValue); } + + if (e.NewValue is INotifyCollectionChanged oc) + { + oc.CollectionChanged += (s, e) => navigationView.OnMenuItemsSource_CollectionChanged(oc, navigationView.FooterMenuItems, e); + } } private static void OnPaneDisplayModeChanged(DependencyObject? d, DependencyPropertyChangedEventArgs e) From f340d47a48dff798fb7bf8b86111b53e853a3708 Mon Sep 17 00:00:00 2001 From: pomianowski <13592821+pomianowski@users.noreply.github.com> Date: Tue, 11 Jun 2024 02:01:15 +0200 Subject: [PATCH 23/36] Format code --- .../NavigationView/NavigationView.Properties.cs | 12 +++++++++--- .../NavigationView/NavigationViewContentPresenter.cs | 10 ++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs index 746899a80..ea3716c88 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs @@ -450,7 +450,11 @@ public Thickness FrameMargin set => SetValue(FrameMarginProperty, value); } - private void OnMenuItemsSource_CollectionChanged(object? sender, IList collection, NotifyCollectionChangedEventArgs e) + private void OnMenuItemsSource_CollectionChanged( + object? sender, + IList collection, + NotifyCollectionChangedEventArgs e + ) { if (ReferenceEquals(sender, collection)) { @@ -527,7 +531,8 @@ private static void OnMenuItemsSourceChanged(DependencyObject? d, DependencyProp if (e.NewValue is INotifyCollectionChanged oc) { - oc.CollectionChanged += (s, e) => navigationView.OnMenuItemsSource_CollectionChanged(oc, navigationView.MenuItems, e); + oc.CollectionChanged += (s, e) => + navigationView.OnMenuItemsSource_CollectionChanged(oc, navigationView.MenuItems, e); } } @@ -568,7 +573,8 @@ DependencyPropertyChangedEventArgs e if (e.NewValue is INotifyCollectionChanged oc) { - oc.CollectionChanged += (s, e) => navigationView.OnMenuItemsSource_CollectionChanged(oc, navigationView.FooterMenuItems, e); + oc.CollectionChanged += (s, e) => + navigationView.OnMenuItemsSource_CollectionChanged(oc, navigationView.FooterMenuItems, e); } } diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs index d35cb52b7..b1bbe2cf4 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewContentPresenter.cs @@ -188,10 +188,7 @@ private static void NotifyContentAboutNavigatingTo(object content) case INavigationAware navigationAwareNavigationContent: navigationAwareNavigationContent.OnNavigatedTo(); break; - case INavigableView - { - ViewModel: INavigationAware navigationAwareNavigableViewViewModel - }: + case INavigableView { ViewModel: INavigationAware navigationAwareNavigableViewViewModel }: navigationAwareNavigableViewViewModel.OnNavigatedTo(); break; case FrameworkElement { DataContext: INavigationAware navigationAwareCurrentContent }: @@ -207,10 +204,7 @@ private static void NotifyContentAboutNavigatingFrom(object content) case INavigationAware navigationAwareNavigationContent: navigationAwareNavigationContent.OnNavigatedFrom(); break; - case INavigableView - { - ViewModel: INavigationAware navigationAwareNavigableViewViewModel - }: + case INavigableView { ViewModel: INavigationAware navigationAwareNavigableViewViewModel }: navigationAwareNavigableViewViewModel.OnNavigatedFrom(); break; case FrameworkElement { DataContext: INavigationAware navigationAwareCurrentContent }: From 09eeabd684f2e8f242ceff6deb60e1546d2a7bbf Mon Sep 17 00:00:00 2001 From: getup700 <93909149+getup700@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:33:22 +0800 Subject: [PATCH 24/36] Update themes.md (#1124) --- docs/documentation/themes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/documentation/themes.md b/docs/documentation/themes.md index 218b02e1b..e98eb724e 100644 --- a/docs/documentation/themes.md +++ b/docs/documentation/themes.md @@ -24,8 +24,8 @@ Or, you can add **WPF UI** resources manually. - - + + From 305ee5794009667dbdfb3f75deb66ac28cdceef4 Mon Sep 17 00:00:00 2001 From: Difegue <8237712+Difegue@users.noreply.github.com> Date: Wed, 24 Jul 2024 21:13:11 +0200 Subject: [PATCH 25/36] Revert changes that make it impossible to use {ui:SymbolIcon} as the Value of a Setter (#1159) --- src/Wpf.Ui/Markup/FontIconExtension.cs | 10 ---------- src/Wpf.Ui/Markup/SymbolIconExtension.cs | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/src/Wpf.Ui/Markup/FontIconExtension.cs b/src/Wpf.Ui/Markup/FontIconExtension.cs index 448ea33a6..c0e1bf655 100644 --- a/src/Wpf.Ui/Markup/FontIconExtension.cs +++ b/src/Wpf.Ui/Markup/FontIconExtension.cs @@ -49,16 +49,6 @@ public FontIconExtension(string glyph) public override object ProvideValue(IServiceProvider serviceProvider) { - if ( - serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget - { - TargetObject: Setter - } - ) - { - return this; - } - FontIcon fontIcon = new() { Glyph = Glyph, FontFamily = FontFamily }; if (FontSize > 0) diff --git a/src/Wpf.Ui/Markup/SymbolIconExtension.cs b/src/Wpf.Ui/Markup/SymbolIconExtension.cs index 754706976..98bcd335a 100644 --- a/src/Wpf.Ui/Markup/SymbolIconExtension.cs +++ b/src/Wpf.Ui/Markup/SymbolIconExtension.cs @@ -60,16 +60,6 @@ public SymbolIconExtension(SymbolRegular symbol, bool filled) public override object ProvideValue(IServiceProvider serviceProvider) { - if ( - serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget - { - TargetObject: Setter - } - ) - { - return this; - } - SymbolIcon symbolIcon = new() { Symbol = Symbol, Filled = Filled }; if (FontSize > 0) From 19790710bc961547efa165fbce7cdfb007449de3 Mon Sep 17 00:00:00 2001 From: Difegue <8237712+Difegue@users.noreply.github.com> Date: Wed, 24 Jul 2024 21:14:34 +0200 Subject: [PATCH 26/36] Fix DynamicScrollViewer not responding to touch events (#1154) --- .../Controls/DynamicScrollViewer/DynamicScrollViewer.xaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.xaml b/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.xaml index 91c377518..201647a79 100644 --- a/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.xaml +++ b/src/Wpf.Ui/Controls/DynamicScrollViewer/DynamicScrollViewer.xaml @@ -1,4 +1,4 @@ - + - + Date: Wed, 24 Jul 2024 21:17:20 +0200 Subject: [PATCH 30/36] Workaround for touch input triggering alongside the hwnd hook on titlebar (#1153) * Workaround for touch input triggering alongside the hwndhook on titlebar Fixes #1126 Setting hittest to false disables touch input on the button, which was firing alongside WM_NCLBUTTONUP in the hwndhook, resulting in the command being fired twice. * Update TitleBar.xaml --------- Co-authored-by: pomian <13592821+pomianowski@users.noreply.github.com> --- src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml b/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml index 8af4ccca0..5ab185e5c 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml @@ -177,7 +177,8 @@ + ButtonType="Maximize" + IsHitTestVisible="False"/> Date: Thu, 25 Jul 2024 03:17:43 +0800 Subject: [PATCH 31/36] fix: setting NotifyIcon.TooltipText at runtime doesn't work (#1132) --- src/Wpf.Ui.Tray/Controls/NotifyIcon.cs | 2 ++ src/Wpf.Ui.Tray/INotifyIcon.cs | 5 +++++ .../Internal/InternalNotifyIconManager.cs | 6 ++++++ src/Wpf.Ui.Tray/TrayManager.cs | 13 +++++++++++++ 4 files changed, 26 insertions(+) diff --git a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs index 7bc0fcac7..7f6b86889 100644 --- a/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs +++ b/src/Wpf.Ui.Tray/Controls/NotifyIcon.cs @@ -388,6 +388,8 @@ private static void OnTooltipTextChanged(DependencyObject d, DependencyPropertyC } notifyIcon.TooltipText = e.NewValue as string ?? string.Empty; + notifyIcon.internalNotifyIconManager.TooltipText = notifyIcon.TooltipText; + _ = notifyIcon.internalNotifyIconManager.ModifyToolTip(); } private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) diff --git a/src/Wpf.Ui.Tray/INotifyIcon.cs b/src/Wpf.Ui.Tray/INotifyIcon.cs index 13108eab4..1fceb7515 100644 --- a/src/Wpf.Ui.Tray/INotifyIcon.cs +++ b/src/Wpf.Ui.Tray/INotifyIcon.cs @@ -82,6 +82,11 @@ internal interface INotifyIcon /// bool ModifyIcon(); + /// + /// Tries to modify the tooltip of the in the shell. + /// + bool ModifyToolTip(); + /// /// Tries to remove the from the shell. /// diff --git a/src/Wpf.Ui.Tray/Internal/InternalNotifyIconManager.cs b/src/Wpf.Ui.Tray/Internal/InternalNotifyIconManager.cs index f3e0abe4d..9a1faab92 100644 --- a/src/Wpf.Ui.Tray/Internal/InternalNotifyIconManager.cs +++ b/src/Wpf.Ui.Tray/Internal/InternalNotifyIconManager.cs @@ -104,6 +104,12 @@ public virtual bool ModifyIcon() return TrayManager.ModifyIcon(this); } + /// + public virtual bool ModifyToolTip() + { + return TrayManager.ModifyToolTip(this); + } + /// public virtual bool Unregister() { diff --git a/src/Wpf.Ui.Tray/TrayManager.cs b/src/Wpf.Ui.Tray/TrayManager.cs index 5635947bc..161cf9223 100644 --- a/src/Wpf.Ui.Tray/TrayManager.cs +++ b/src/Wpf.Ui.Tray/TrayManager.cs @@ -124,6 +124,19 @@ public static bool ModifyIcon(INotifyIcon notifyIcon) return Interop.Shell32.Shell_NotifyIcon(Interop.Shell32.NIM.MODIFY, notifyIcon.ShellIconData); } + public static bool ModifyToolTip(INotifyIcon notifyIcon) + { + if (!notifyIcon.IsRegistered) + { + return true; + } + + notifyIcon.ShellIconData.szTip = notifyIcon.TooltipText; + notifyIcon.ShellIconData.uFlags |= Interop.Shell32.NIF.TIP; + + return Interop.Shell32.Shell_NotifyIcon(Interop.Shell32.NIM.MODIFY, notifyIcon.ShellIconData); + } + /// /// Tries to remove the from the shell. /// From c2afe6c467e123612e571f436245846e25e1ac0b Mon Sep 17 00:00:00 2001 From: textGamex Date: Thu, 25 Jul 2024 03:18:22 +0800 Subject: [PATCH 32/36] Doc: supplement the document content. (#1119) * doc: add navigation set initial page doc * doc: add NavigationView with MVVM Pattern Explanation --- docs/documentation/navigation-view.md | 154 ++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/docs/documentation/navigation-view.md b/docs/documentation/navigation-view.md index 2020474a2..8dd2408c6 100644 --- a/docs/documentation/navigation-view.md +++ b/docs/documentation/navigation-view.md @@ -69,3 +69,157 @@ RootNavigation.Navigate(2); ``` ## Pane display mode + +## Set initial page + +NavigationPage.xaml + +```xml + +``` + +NavigationPage.xaml.cs + +```csharp +public partial class NavigationPage : Page +{ + public NavigationPage(NavigationPageModel model) + { + InitializeComponent(); + + DataContext = model; + Loaded += (_, _) => RootNavigation.Navigate(type(MyDashboardClass)); + } +} +``` + +## Using Navigation in the MVVM + +Firstly, you need to implement the `IPageService` interface + +```csharp +// from src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs +public class PageService : IPageService +{ + /// + /// Service which provides the instances of pages. + /// + private readonly IServiceProvider _serviceProvider; + + /// + /// Initializes a new instance of the class and attaches the . + /// + public PageService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + /// + public T? GetPage() + where T : class + { + if (!typeof(FrameworkElement).IsAssignableFrom(typeof(T))) + { + throw new InvalidOperationException("The page should be a WPF control."); + } + + return (T?)_serviceProvider.GetService(typeof(T)); + } + + /// + public FrameworkElement? GetPage(Type pageType) + { + if (!typeof(FrameworkElement).IsAssignableFrom(pageType)) + { + throw new InvalidOperationException("The page should be a WPF control."); + } + + return _serviceProvider.GetService(pageType) as FrameworkElement; + } +} +``` + +Then, inject it into the IoC container. + +```csharp +var services = new ServiceCollection(); + +services.AddSingleton(); +services.AddSingleton(); +services.AddSingleton(); + +// inject View and ViewModel +services.AddSingleton(); +services.AddSingleton(); +services.AddSingleton(); +services.AddSingleton(); +services.AddSingleton(); +services.AddSingleton(); +``` + +Lastly, adjust the code for the navigation window. + +```xml + + + + +``` + +```csharp +using System.Collections.ObjectModel; +using System.Windows; +using CommunityToolkit.Mvvm.ComponentModel; +using Wpf.Ui; +using Wpf.Ui.Controls; + +public partial class MainWindow : Window +{ + public MainWindow(IPageService pageService, MainWindowViewModel model) + { + DataContext = model; + InitializeComponent(); + + // Set the page service for the navigation control. + RootNavigationView.SetPageService(pageService); + } +} + +public partial class MainWindowViewModel : ObservableObject +{ + [ObservableProperty] + private ObservableCollection _navigationItems = []; + + public MainWindowViewModel() + { + NavigationItems = + [ + new NavigationViewItem() + { + Content = "Home", + Icon = new SymbolIcon { Symbol = SymbolRegular.Home24 }, + TargetPageType = typeof(HomePage) + }, + new NavigationViewItem() + { + Content = "Counter", + TargetPageType = typeof(CounterPage) + }, + ]; + } +} +``` + +Alternatively, you can use the **WPF UI** Visual Studio Extension that includes a project template for MVVM pattern. From ecd36c1bb3b6f5019300807cedb916767afef5e8 Mon Sep 17 00:00:00 2001 From: textGamex Date: Thu, 25 Jul 2024 03:18:59 +0800 Subject: [PATCH 33/36] Fix: MessageBox does not support WindowStartupLocation (#1130) * fix: MessageBox does not support WindowStartupLocation * fix: MessageBox defaults to being displayed in the center of the screen. * MessageBox add comment --- src/Wpf.Ui/Controls/MessageBox/MessageBox.cs | 54 +++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs index 2844254af..579fc5a97 100644 --- a/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs +++ b/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs @@ -3,6 +3,10 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using System.Reflection; +#if NET8_0_OR_GREATER +using System.Runtime.CompilerServices; +#endif using Wpf.Ui.Input; using Wpf.Ui.Interop; using Size = System.Windows.Size; @@ -232,6 +236,9 @@ public bool IsPrimaryButtonEnabled /// public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty); + private static readonly PropertyInfo CanCenterOverWPFOwnerPropertyInfo = + typeof(Window).GetProperty("CanCenterOverWPFOwner", BindingFlags.NonPublic | BindingFlags.Instance)!; + /// /// Initializes a new instance of the class. /// @@ -318,9 +325,44 @@ protected virtual void OnLoaded() var rootElement = (UIElement)GetVisualChild(0)!; ResizeToContentSize(rootElement); - CenterWindowOnScreen(); + + switch (WindowStartupLocation) + { + case WindowStartupLocation.Manual: + case WindowStartupLocation.CenterScreen: + CenterWindowOnScreen(); + break; + case WindowStartupLocation.CenterOwner: + if (!CanCenterOverWPFOwner() || + Owner.WindowState is WindowState.Maximized or WindowState.Minimized) + { + CenterWindowOnScreen(); + } + else + { + CenterWindowOnOwner(); + } + + break; + default: throw new InvalidOperationException(); + } + } + + // CanCenterOverWPFOwner property see https://source.dot.net/#PresentationFramework/System/Windows/Window.cs,e679e433777b21b8 + private bool CanCenterOverWPFOwner() + { +#if NET8_0_OR_GREATER + return CanCenterOverWPFOwnerAccessor(this); +#else + return (bool)CanCenterOverWPFOwnerPropertyInfo.GetValue(this)!; +#endif } +#if NET8_0_OR_GREATER + [UnsafeAccessor(UnsafeAccessorKind.Method, Name = "get_CanCenterOverWPFOwner")] + private static extern bool CanCenterOverWPFOwnerAccessor(Window w); +#endif + /// /// Resizes the MessageBox to fit the content's size, including margins. /// @@ -353,7 +395,6 @@ protected override void OnClosing(CancelEventArgs e) protected virtual void CenterWindowOnScreen() { - // TODO: MessageBox should be displayed on the window on which the application double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; @@ -361,6 +402,15 @@ protected virtual void CenterWindowOnScreen() SetCurrentValue(TopProperty, (screenHeight / 2) - (Height / 2)); } + private void CenterWindowOnOwner() + { + double left = Owner.Left + ((Owner.Width - Width) / 2); + double top = Owner.Top + ((Owner.Height - Height) / 2); + + SetCurrentValue(LeftProperty, left); + SetCurrentValue(TopProperty, top); + } + /// /// Occurs after the is clicked /// From a4078704f6d7379f0cd2c05231f0de79b967eb01 Mon Sep 17 00:00:00 2001 From: Taein KIM Date: Thu, 25 Jul 2024 04:27:00 +0900 Subject: [PATCH 34/36] Replace Assembly.Location to AppContext.BaseDirectory (#1149) https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/warnings/il3000 https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli#api-incompatibility https://github.com/dotnet/corert/issues/5467 --- src/Wpf.Ui.Extension.Template.Blank/App.xaml.cs | 2 +- src/Wpf.Ui.Extension.Template.Compact/App.xaml.cs | 2 +- src/Wpf.Ui.Extension.Template.Fluent/App.xaml.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Wpf.Ui.Extension.Template.Blank/App.xaml.cs b/src/Wpf.Ui.Extension.Template.Blank/App.xaml.cs index 12f11be2c..2f88101a2 100644 --- a/src/Wpf.Ui.Extension.Template.Blank/App.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Blank/App.xaml.cs @@ -20,7 +20,7 @@ public partial class App // https://docs.microsoft.com/dotnet/core/extensions/logging private static readonly IHost _host = Host .CreateDefaultBuilder() - .ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)); }) + .ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); }) .ConfigureServices((context, services) => { throw new NotImplementedException("No service or window was registered."); diff --git a/src/Wpf.Ui.Extension.Template.Compact/App.xaml.cs b/src/Wpf.Ui.Extension.Template.Compact/App.xaml.cs index bcedf63e4..5e3346fdd 100644 --- a/src/Wpf.Ui.Extension.Template.Compact/App.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Compact/App.xaml.cs @@ -25,7 +25,7 @@ public partial class App // https://docs.microsoft.com/dotnet/core/extensions/logging private static readonly IHost _host = Host .CreateDefaultBuilder() - .ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)); }) + .ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); }) .ConfigureServices((context, services) => { services.AddHostedService(); diff --git a/src/Wpf.Ui.Extension.Template.Fluent/App.xaml.cs b/src/Wpf.Ui.Extension.Template.Fluent/App.xaml.cs index bcedf63e4..5e3346fdd 100644 --- a/src/Wpf.Ui.Extension.Template.Fluent/App.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Fluent/App.xaml.cs @@ -25,7 +25,7 @@ public partial class App // https://docs.microsoft.com/dotnet/core/extensions/logging private static readonly IHost _host = Host .CreateDefaultBuilder() - .ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)); }) + .ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); }) .ConfigureServices((context, services) => { services.AddHostedService(); From 4aeb0bf9d3c3aa630f18e215e9998ee63a4e7566 Mon Sep 17 00:00:00 2001 From: textGamex Date: Thu, 25 Jul 2024 03:33:42 +0800 Subject: [PATCH 35/36] Fix: PasswordBox does not accept PasswordChar as input (#1141) * fix: PasswordBox does not accept PasswordChar as input * refactor PasswordBox * fix: PasswordBox bug When the character to be replaced is a PasswordChar, it fails to substitute correctly * Format code * add PasswordHelper --------- Co-authored-by: pomian <13592821+pomianowski@users.noreply.github.com> --- .../Controls/PasswordBox/PasswordBox.cs | 44 +------ .../Controls/PasswordBox/PasswordHelper.cs | 118 ++++++++++++++++++ 2 files changed, 123 insertions(+), 39 deletions(-) create mode 100644 src/Wpf.Ui/Controls/PasswordBox/PasswordHelper.cs diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs index e4be9da26..e802d3796 100644 --- a/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordBox.cs @@ -16,8 +16,9 @@ namespace Wpf.Ui.Controls; /// /// The modified password control. /// -public class PasswordBox : Wpf.Ui.Controls.TextBox +public partial class PasswordBox : Wpf.Ui.Controls.TextBox { + private readonly PasswordHelper _passwordHelper; private bool _lockUpdatingContents; /// Identifies the dependency property. @@ -112,6 +113,7 @@ public event RoutedEventHandler PasswordChanged public PasswordBox() { _lockUpdatingContents = false; + _passwordHelper = new PasswordHelper(this); } /// @@ -228,47 +230,11 @@ private void UpdateTextContents(bool isTriggeredByTextInput) } var caretIndex = CaretIndex; - var selectionIndex = SelectionStart; - var currentPassword = Password ?? string.Empty; - var newPasswordValue = currentPassword; + var newPasswordValue = _passwordHelper.GetPassword(); if (isTriggeredByTextInput) { - var currentText = Text; - var newCharacters = currentText.Replace(PasswordChar.ToString(), string.Empty); - - if (currentText.Length < currentPassword.Length) - { - newPasswordValue = currentPassword.Remove( - selectionIndex, - currentPassword.Length - currentText.Length - ); - } - - if (newCharacters.Length > 1) - { - var index = currentText.IndexOf(newCharacters[0]); - - newPasswordValue = - index > newPasswordValue.Length - 1 - ? newPasswordValue + newCharacters - : newPasswordValue.Insert(index, newCharacters); - } - else - { - for (int i = 0; i < currentText.Length; i++) - { - if (currentText[i] == PasswordChar) - { - continue; - } - - newPasswordValue = - currentText.Length == newPasswordValue.Length - ? newPasswordValue.Remove(i, 1).Insert(i, currentText[i].ToString()) - : newPasswordValue.Insert(i, currentText[i].ToString()); - } - } + newPasswordValue = _passwordHelper.GetNewPassword(); } _lockUpdatingContents = true; diff --git a/src/Wpf.Ui/Controls/PasswordBox/PasswordHelper.cs b/src/Wpf.Ui/Controls/PasswordBox/PasswordHelper.cs new file mode 100644 index 000000000..64ed3fa0d --- /dev/null +++ b/src/Wpf.Ui/Controls/PasswordBox/PasswordHelper.cs @@ -0,0 +1,118 @@ +// 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.Diagnostics; + +// ReSharper disable once CheckNamespace +namespace Wpf.Ui.Controls; + +#pragma warning disable SA1601 + +public partial class PasswordBox +{ + private class PasswordHelper + { + private readonly PasswordBox _passwordBox; + private string _currentText; + private string _newPasswordValue; + private string _currentPassword; + + public PasswordHelper(PasswordBox passwordBox) + { + _passwordBox = passwordBox; + _currentText = string.Empty; + _newPasswordValue = string.Empty; + _currentPassword = string.Empty; + } + + public string GetNewPassword() + { + _currentPassword = GetPassword(); + _newPasswordValue = _currentPassword; + _currentText = _passwordBox.Text; + var selectionIndex = _passwordBox.SelectionStart; + var passwordChar = _passwordBox.PasswordChar; + var newCharacters = _currentText.Replace(passwordChar.ToString(), string.Empty); + bool isDeleted = false; + + if (IsDeleteOption()) + { + _newPasswordValue = _currentPassword.Remove( + selectionIndex, + _currentPassword.Length - _currentText.Length + ); + isDeleted = true; + } + + switch (newCharacters.Length) + { + case > 1: + { + var index = _currentText.IndexOf(newCharacters[0]); + + _newPasswordValue = + index > _newPasswordValue.Length - 1 + ? _newPasswordValue + newCharacters + : _newPasswordValue.Insert(index, newCharacters); + break; + } + + case 1: + { + for (int i = 0; i < _currentText.Length; i++) + { + if (_currentText[i] == passwordChar) + { + continue; + } + + UpdatePasswordWithInputCharacter(i, _currentText[i].ToString()); + break; + } + + break; + } + + case 0 when !isDeleted: + { + // The input is a PasswordChar, which is to be inserted at the designated position. + int insertIndex = selectionIndex - 1; + UpdatePasswordWithInputCharacter(insertIndex, passwordChar.ToString()); + break; + } + } + + return _newPasswordValue; + } + + private void UpdatePasswordWithInputCharacter(int insertIndex, string insertValue) + { + Debug.Assert(_currentText == _passwordBox.Text, "_currentText == _passwordBox.Text"); + + if (_currentText.Length == _newPasswordValue.Length) + { + // If it's a direct character replacement, remove the existing one before inserting the new one. + _newPasswordValue = _newPasswordValue.Remove(insertIndex, 1).Insert(insertIndex, insertValue); + } + else + { + _newPasswordValue = _newPasswordValue.Insert(insertIndex, insertValue); + } + } + + private bool IsDeleteOption() + { + Debug.Assert(_currentText == _passwordBox.Text, "_currentText == _passwordBox.Text"); + Debug.Assert( + _currentPassword == _passwordBox.Password, + "_currentPassword == _passwordBox.Password" + ); + + return _currentText.Length < _currentPassword.Length; + } + + public string GetPassword() => _passwordBox.Password ?? string.Empty; + } +} From 63f0f0ce75e2b45a4c7489b5675c5009da37b30a Mon Sep 17 00:00:00 2001 From: pomianowski <13592821+pomianowski@users.noreply.github.com> Date: Wed, 24 Jul 2024 21:34:50 +0200 Subject: [PATCH 36/36] Bump version --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index c6aabc6b9..452a106b7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 3.0.4 + 3.0.5 12.0 true