From 6587c4b7b524f9a6600385c1748e5b6ef2fb634b Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Fri, 19 Jun 2020 21:45:59 +0800 Subject: [PATCH] add obsoleted props --- src/Avalonia.Controls/ProgressBar.cs | 73 +++++++++++++++------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/src/Avalonia.Controls/ProgressBar.cs b/src/Avalonia.Controls/ProgressBar.cs index 2a732e9d90..e904957429 100644 --- a/src/Avalonia.Controls/ProgressBar.cs +++ b/src/Avalonia.Controls/ProgressBar.cs @@ -1,3 +1,4 @@ +using System; using Avalonia.Controls.Primitives; using Avalonia.Layout; using Avalonia.Media; @@ -8,7 +9,7 @@ namespace Avalonia.Controls /// A control used to indicate the progress of an operation. /// public class ProgressBar : RangeBase - { + { public class ProgressBarTemplateProperties : AvaloniaObject { private double _container2Width; @@ -17,8 +18,6 @@ namespace Avalonia.Controls private double _containerAnimationEndPosition; private double _container2AnimationStartPosition; private double _container2AnimationEndPosition; - private double _indeterminateStartingOffset; - private double _indeterminateEndingOffset; public static readonly DirectProperty ContainerAnimationStartPositionProperty = AvaloniaProperty.RegisterDirect( @@ -56,18 +55,6 @@ namespace Avalonia.Controls p => p.ContainerWidth, (p, o) => p.ContainerWidth = o); - public static readonly DirectProperty IndeterminateStartingOffsetProperty = - AvaloniaProperty.RegisterDirect( - nameof(IndeterminateStartingOffset), - p => p.IndeterminateStartingOffset, - (p, o) => p.IndeterminateStartingOffset = o); - - public static readonly DirectProperty IndeterminateEndingOffsetProperty = - AvaloniaProperty.RegisterDirect( - nameof(IndeterminateEndingOffset), - p => p.IndeterminateEndingOffset, - (p, o) => p.IndeterminateEndingOffset = o); - public double ContainerAnimationStartPosition { get => _containerAnimationStartPosition; @@ -103,20 +90,10 @@ namespace Avalonia.Controls get => _container2AnimationEndPosition; set => SetAndRaise(Container2AnimationEndPositionProperty, ref _container2AnimationEndPosition, value); } - - public double IndeterminateStartingOffset - { - get => _indeterminateStartingOffset; - set => SetAndRaise(IndeterminateStartingOffsetProperty, ref _indeterminateStartingOffset, value); - } - - public double IndeterminateEndingOffset - { - get => _indeterminateEndingOffset; - set => SetAndRaise(IndeterminateEndingOffsetProperty, ref _indeterminateEndingOffset, value); - } } - + + private double _indeterminateStartingOffset; + private double _indeterminateEndingOffset; private Border _indicator; public static readonly StyledProperty IsIndeterminateProperty = @@ -126,7 +103,35 @@ namespace Avalonia.Controls AvaloniaProperty.Register(nameof(ShowProgressText)); public static readonly StyledProperty OrientationProperty = - AvaloniaProperty.Register(nameof(Orientation), Orientation.Horizontal); + AvaloniaProperty.Register(nameof(Orientation), Orientation.Horizontal); + + [Obsolete("To be removed when Avalonia.Themes.Default is discontinued.")] + public static readonly DirectProperty IndeterminateStartingOffsetProperty = + AvaloniaProperty.RegisterDirect( + nameof(IndeterminateStartingOffset), + p => p.IndeterminateStartingOffset, + (p, o) => p.IndeterminateStartingOffset = o); + + [Obsolete("To be removed when Avalonia.Themes.Default is discontinued.")] + public static readonly DirectProperty IndeterminateEndingOffsetProperty = + AvaloniaProperty.RegisterDirect( + nameof(IndeterminateEndingOffset), + p => p.IndeterminateEndingOffset, + (p, o) => p.IndeterminateEndingOffset = o); + + [Obsolete("To be removed when Avalonia.Themes.Default is discontinued.")] + public double IndeterminateStartingOffset + { + get => _indeterminateStartingOffset; + set => SetAndRaise(IndeterminateStartingOffsetProperty, ref _indeterminateStartingOffset, value); + } + + [Obsolete("To be removed when Avalonia.Themes.Default is discontinued.")] + public double IndeterminateEndingOffset + { + get => _indeterminateEndingOffset; + set => SetAndRaise(IndeterminateEndingOffsetProperty, ref _indeterminateEndingOffset, value); + } static ProgressBar() { @@ -157,7 +162,7 @@ namespace Avalonia.Controls { get => GetValue(OrientationProperty); set => SetValue(OrientationProperty, value); - } + } /// protected override Size ArrangeOverride(Size finalSize) @@ -208,10 +213,10 @@ namespace Avalonia.Controls TemplateProperties.Container2AnimationStartPosition = barIndicatorWidth2 * -1.5; // Position at -150% TemplateProperties.Container2AnimationEndPosition = barIndicatorWidth2 * 1.66; // Position at 166% - + // Remove these properties when we switch to fluent as default and removed the old one. - TemplateProperties.IndeterminateStartingOffset = -dim; - TemplateProperties.IndeterminateEndingOffset = dim * 2; + IndeterminateStartingOffset = -(dim / 5d); + IndeterminateEndingOffset = dim; var padding = Padding; var rectangle = new RectangleGeometry( @@ -220,7 +225,7 @@ namespace Avalonia.Controls padding.Top, bounds.Width - (padding.Right + padding.Left), bounds.Height - (padding.Bottom + padding.Top) - )); + )); } else {