Refactor ProgressBar

This commit is contained in:
chinboy
2025-03-05 17:18:55 +08:00
parent c8bd3c244f
commit 27bca294d0
4 changed files with 12 additions and 18 deletions
@@ -233,10 +233,10 @@ public abstract class AbstractCircleProgress : AbstractProgressBar
protected override void NotifyPropertyChanged(AvaloniaPropertyChangedEventArgs e)
{
base.NotifyPropertyChanged(e);
if (e.Property == WidthProperty || e.Property == HeightProperty)
if (this.IsAttachedToVisualTree())
{
if (this.IsAttachedToVisualTree())
if (e.Property == WidthProperty || e.Property == HeightProperty)
{
CalculateStrokeThickness();
SetupExtraInfoFontSize();
@@ -1,7 +1,5 @@
using AtomUI.IconPkg;
using AtomUI.IconPkg.AntDesign;
using AtomUI.Theme;
using AtomUI.Theme.Data;
using AtomUI.Theme.Styling;
using Avalonia;
using Avalonia.Controls;
@@ -1,5 +1,4 @@
using System.Reactive.Disposables;
using AtomUI.Controls.Utils;
using AtomUI.IconPkg;
using AtomUI.Media;
using AtomUI.Theme;
@@ -438,6 +437,15 @@ public abstract class AbstractProgressBar : RangeBase,
{
EffectiveSizeType = e.GetNewValue<SizeType>();
}
else if (e.Property == ValueProperty)
{
IsCompleted = MathUtils.AreClose(Value, Maximum);
UpdatePseudoClasses();
}
else if (e.Property == IsCompletedProperty)
{
InvalidateMeasure();
}
if (this.IsAttachedToVisualTree())
{
@@ -450,17 +458,6 @@ public abstract class AbstractProgressBar : RangeBase,
NotifyEffectSizeTypeChanged();
}
}
if (e.Property == ValueProperty)
{
IsCompleted = MathUtils.AreClose(Value, Maximum);
UpdatePseudoClasses();
}
else if (e.Property == IsCompletedProperty)
{
InvalidateMeasure();
}
NotifyPropertyChanged(e);
}
@@ -7,7 +7,6 @@ using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Styling;
namespace AtomUI.Controls;