Refactor IsMotionEnabledProperty

This commit is contained in:
chinboy
2025-03-07 14:17:01 +08:00
parent 08b24b1e47
commit cc5c8f1db1
34 changed files with 149 additions and 315 deletions
@@ -98,10 +98,8 @@ internal class CountBadgeAdorner : TemplatedControl
AvaloniaProperty.Register<CountBadgeAdorner, double>(
nameof(BadgeShadowSize));
internal static readonly DirectProperty<CountBadgeAdorner, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<CountBadgeAdorner, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<CountBadgeAdorner>();
private bool _isAdornerMode;
@@ -147,12 +145,10 @@ internal class CountBadgeAdorner : TemplatedControl
set => SetValue(BadgeShadowSizeProperty, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
#endregion
+4 -8
View File
@@ -82,10 +82,8 @@ internal class DotBadgeAdorner : TemplatedControl
AvaloniaProperty.Register<DotBadgeAdorner, TimeSpan>(
nameof(MotionDuration));
internal static readonly DirectProperty<DotBadgeAdorner, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<DotBadgeAdorner, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<DotBadgeAdorner>();
internal TimeSpan MotionDuration
{
@@ -93,12 +91,10 @@ internal class DotBadgeAdorner : TemplatedControl
set => SetValue(MotionDurationProperty, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
#endregion
@@ -19,21 +19,17 @@ namespace AtomUI.Controls;
[PseudoClasses(StdPseudoClass.Selected, StdPseudoClass.InActive, BtnFocusedPC)]
internal class BaseCalendarButton : AvaloniaButton
{
internal static readonly DirectProperty<BaseCalendarButton, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<BaseCalendarButton, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
private bool _isMotionEnabled;
private const string BtnFocusedPC = ":btnfocused";
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<BaseCalendarButton>();
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
private const string BtnFocusedPC = ":btnfocused";
/// <summary>
/// A value indicating whether the button is focused.
/// </summary>
@@ -32,19 +32,15 @@ internal class BaseCalendarDayButton : AvaloniaButton,
internal const string BlackoutPC = ":blackout";
internal const string DayfocusedPC = ":dayfocused";
internal static readonly DirectProperty<BaseCalendarDayButton, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<BaseCalendarDayButton, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
private bool _isMotionEnabled;
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<BaseCalendarDayButton>();
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
private CompositeDisposable? _tokenBindingsDisposable;
@@ -12,17 +12,14 @@ using AvaloniaButton = Avalonia.Controls.Button;
internal class HeadTextButton : AvaloniaButton
{
internal static readonly DirectProperty<HeadTextButton, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<HeadTextButton, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
private bool _isMotionEnabled;
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<HeadTextButton>();
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
@@ -116,22 +116,18 @@ internal class CheckBoxIndicator : Control,
#region 内部属性定义
internal static readonly DirectProperty<CheckBoxIndicator, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<CheckBoxIndicator, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<CheckBoxIndicator>();
internal static readonly DirectProperty<CheckBoxIndicator, bool> IsWaveAnimationEnabledProperty
= AvaloniaProperty.RegisterDirect<CheckBoxIndicator, bool>(nameof(IsWaveAnimationEnabled),
o => o.IsWaveAnimationEnabled,
(o, v) => o.IsWaveAnimationEnabled = v);
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
private bool _isWaveAnimationEnabled = true;
+6 -10
View File
@@ -109,10 +109,8 @@ public class CollapseItem : HeaderedContentControl,
o => o.MotionDuration,
(o, v) => o.MotionDuration = v);
internal static readonly DirectProperty<CollapseItem, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<CollapseItem, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<CollapseItem>();
private SizeType _sizeType;
@@ -178,12 +176,10 @@ public class CollapseItem : HeaderedContentControl,
set => SetAndRaise(MotionDurationProperty, ref _motionDuration, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
#endregion
@@ -301,7 +297,7 @@ public class CollapseItem : HeaderedContentControl,
return;
}
if (!_isMotionEnabled || _tempAnimationDisabled)
if (!IsMotionEnabled || _tempAnimationDisabled)
{
_motionActor.IsVisible = true;
return;
@@ -320,7 +316,7 @@ public class CollapseItem : HeaderedContentControl,
return;
}
if (!_isMotionEnabled || _tempAnimationDisabled)
if (!IsMotionEnabled || _tempAnimationDisabled)
{
_motionActor.IsVisible = false;
return;
+4 -8
View File
@@ -21,17 +21,13 @@ public class ComboBoxItem : AvaloniaComboBoxItem
set => SetAndRaise(SizeTypeProperty, ref _sizeType, value);
}
internal static readonly DirectProperty<ComboBoxItem, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<ComboBoxItem, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
private bool _isMotionEnabled;
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<ComboBoxItem>();
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
#endregion
}
@@ -271,17 +271,13 @@ internal class Calendar : TemplatedControl
#region 内部属性定义
internal static readonly DirectProperty<Calendar, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<Calendar, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<Calendar>();
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
internal CalendarDayButton? FocusButton { get; set; }
@@ -22,17 +22,13 @@ internal sealed class CalendarButton : AvaloniaButton
{
internal const string BtnFocusedPC = ":btnfocused";
internal static readonly DirectProperty<CalendarButton, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<CalendarButton, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
private bool _isMotionEnabled;
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<CalendarButton>();
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
/// <summary>
@@ -32,17 +32,13 @@ internal sealed class CalendarDayButton : AvaloniaButton,
internal const string BlackoutPC = ":blackout";
internal const string DayfocusedPC = ":dayfocused";
internal static readonly DirectProperty<CalendarDayButton, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<CalendarDayButton, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
private bool _isMotionEnabled;
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<CalendarDayButton>();
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
@@ -69,10 +69,8 @@ internal class CalendarItem : TemplatedControl,
o => o.IsMonthViewMode,
(o, v) => o.IsMonthViewMode = v);
internal static readonly DirectProperty<CalendarItem, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<CalendarItem, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<CalendarItem>();
private bool _isMonthViewMode = true;
@@ -85,12 +83,10 @@ internal class CalendarItem : TemplatedControl,
set => SetAndRaise(IsMonthViewModeProperty, ref _isMonthViewMode, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
/// <summary>
@@ -86,17 +86,13 @@ internal class DatePickerPresenter : PickerPresenterBase,
public static readonly StyledProperty<TimeSpan?> TempSelectedTimeProperty =
AvaloniaProperty.Register<DatePickerPresenter, TimeSpan?>(nameof(TempSelectedTime));
internal static readonly DirectProperty<DatePickerPresenter, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<DatePickerPresenter, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
private bool _isMotionEnabled;
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<MenuItem>();
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
private bool _buttonsPanelVisible = true;
+5 -12
View File
@@ -1,8 +1,6 @@
using System.Diagnostics;
using System.Reactive.Disposables;
using AtomUI.Controls.Primitives;
using AtomUI.MotionScene;
using AtomUI.Theme;
using Avalonia;
using Avalonia.Animation;
using Avalonia.Animation.Easings;
@@ -12,7 +10,6 @@ using Avalonia.Controls.Templates;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.LogicalTree;
using Avalonia.Media;
using Avalonia.Media.Transformation;
using Avalonia.Threading;
@@ -68,10 +65,8 @@ internal class DrawerContainer : ContentControl
o => o.DialogSize,
(o, v) => o.DialogSize = v);
internal static readonly DirectProperty<DrawerContainer, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<DrawerContainer, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<DrawerContainer>();
internal static readonly DirectProperty<DrawerContainer, bool> CloseWhenClickOnMaskProperty
= AvaloniaProperty.RegisterDirect<DrawerContainer, bool>(nameof(CloseWhenClickOnMask),
@@ -165,14 +160,12 @@ internal class DrawerContainer : ContentControl
set => SetAndRaise(DialogSizeProperty, ref _dialogSize, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
private bool _closeWhenClickOnMask;
internal bool CloseWhenClickOnMask
@@ -64,10 +64,8 @@ internal class DrawerInfoContainer : HeaderedContentControl
o => o.HasExtra,
(o, v) => o.HasExtra = v);
internal static readonly DirectProperty<DrawerInfoContainer, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<DrawerInfoContainer, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<DrawerInfoContainer>();
private DrawerPlacement _placement = DrawerPlacement.Right;
@@ -149,12 +147,10 @@ internal class DrawerInfoContainer : HeaderedContentControl
set => SetAndRaise(HasExtraProperty, ref _hasExtra, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
#endregion
@@ -151,10 +151,8 @@ public abstract class PopupFlyoutBase : FlyoutBase,
internal static readonly StyledProperty<bool> IsDetectMouseClickEnabledProperty =
AvaloniaProperty.Register<PopupFlyoutBase, bool>(nameof(IsDetectMouseClickEnabled), true);
internal static readonly DirectProperty<PopupFlyoutBase, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<PopupFlyoutBase, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<PopupFlyoutBase>();
internal bool IsDetectMouseClickEnabled
{
@@ -162,12 +160,10 @@ public abstract class PopupFlyoutBase : FlyoutBase,
set => SetValue(IsDetectMouseClickEnabledProperty, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
#endregion
+4 -8
View File
@@ -17,10 +17,8 @@ public class ListBoxItem : AvaloniaListBoxItem
o => o.SizeType,
(o, v) => o.SizeType = v);
internal static readonly DirectProperty<ListBoxItem, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<ListBoxItem, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<ListBoxItem>();
internal static readonly DirectProperty<ListBoxItem, bool> DisabledItemHoverEffectProperty =
AvaloniaProperty.RegisterDirect<ListBoxItem, bool>(nameof(DisabledItemHoverEffect),
@@ -35,12 +33,10 @@ public class ListBoxItem : AvaloniaListBoxItem
set => SetAndRaise(SizeTypeProperty, ref _sizeType, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
private bool _disabledItemHoverEffect;
+4 -8
View File
@@ -43,17 +43,13 @@ public class MenuItem : AvaloniaMenuItem,
#region 内部属性定义
internal static readonly DirectProperty<MenuItem, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<MenuItem, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
private bool _isMotionEnabled;
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<MenuItem>();
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
+5 -9
View File
@@ -23,18 +23,14 @@ public class MenuScrollViewer : AvaloniaScrollViewer,
private IconButton? _scrollDownButton;
#region 内部属性定义
internal static readonly DirectProperty<MenuScrollViewer, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<MenuScrollViewer, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
private bool _isMotionEnabled;
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<MenuScrollViewer>();
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
+5 -11
View File
@@ -1,12 +1,10 @@
using System.Reactive.Disposables;
using System.Windows.Input;
using System.Windows.Input;
using AtomUI.Controls.Utils;
using AtomUI.Data;
using AtomUI.IconPkg;
using AtomUI.Input;
using AtomUI.Media;
using AtomUI.MotionScene;
using AtomUI.Theme;
using Avalonia;
using Avalonia.Animation;
using Avalonia.Animation.Easings;
@@ -288,10 +286,8 @@ public class NavMenuItem : HeaderedSelectingItemsControl,
o => o.IsDarkStyle,
(o, v) => o.IsDarkStyle = v);
internal static readonly DirectProperty<NavMenuItem, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<NavMenuItem, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<NavMenuItem>();
internal double ActiveBarWidth
{
@@ -361,12 +357,10 @@ public class NavMenuItem : HeaderedSelectingItemsControl,
set => SetAndRaise(IsDarkStyleProperty, ref _isDarkStyle, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
#endregion
@@ -83,22 +83,18 @@ public class OptionButton : AvaloniaRadioButton,
(o, v) => o.GroupPositionTrait = v,
OptionButtonPositionTrait.OnlyOne);
internal static readonly DirectProperty<OptionButton, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<OptionButton, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<OptionButton>();
internal static readonly DirectProperty<OptionButton, bool> IsWaveAnimationEnabledProperty
= AvaloniaProperty.RegisterDirect<OptionButton, bool>(nameof(IsWaveAnimationEnabled),
o => o.IsWaveAnimationEnabled,
(o, v) => o.IsWaveAnimationEnabled = v);
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
private bool _isWaveAnimationEnabled = true;
@@ -117,22 +117,18 @@ internal class RadioIndicator : Control,
#region 内部属性定义
internal static readonly DirectProperty<RadioIndicator, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<RadioIndicator, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<RadioIndicator>();
internal static readonly DirectProperty<RadioIndicator, bool> IsWaveAnimationEnabledProperty
= AvaloniaProperty.RegisterDirect<RadioIndicator, bool>(nameof(IsWaveAnimationEnabled),
o => o.IsWaveAnimationEnabled,
(o, v) => o.IsWaveAnimationEnabled = v);
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
private bool _isWaveAnimationEnabled = true;
+5 -11
View File
@@ -4,8 +4,6 @@ using AtomUI.Controls.Utils;
using AtomUI.IconPkg;
using AtomUI.Media;
using AtomUI.Theme;
using AtomUI.Theme.Data;
using AtomUI.Theme.Styling;
using Avalonia;
using Avalonia.Animation;
using Avalonia.Controls;
@@ -49,11 +47,9 @@ public class SegmentedItem : ContentControl,
internal static readonly StyledProperty<SizeType> SizeTypeProperty =
SizeTypeAwareControlProperty.SizeTypeProperty.AddOwner<SegmentedItem>();
internal static readonly DirectProperty<SegmentedItem, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<SegmentedItem, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<SegmentedItem>();
internal SizeType SizeType
{
@@ -61,12 +57,10 @@ public class SegmentedItem : ContentControl,
set => SetValue(SizeTypeProperty, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
+4 -9
View File
@@ -8,7 +8,6 @@ using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.LogicalTree;
using Avalonia.Media;
using Avalonia.VisualTree;
@@ -44,17 +43,13 @@ public class SliderThumb : TemplatedControl
#region 内部属性定义
internal static readonly DirectProperty<SliderThumb, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<SliderThumb, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<SliderThumb>();
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
#endregion
+4 -8
View File
@@ -231,10 +231,8 @@ public class SliderTrack : Control,
internal static readonly RoutedEvent<PointerReleasedEventArgs> TrailReleasedEvent =
RoutedEvent.Register<SliderTrack, PointerReleasedEventArgs>(nameof(TrailReleased), RoutingStrategies.Bubble);
internal static readonly DirectProperty<SliderTrack, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<SliderTrack, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<SliderTrack>();
internal double SliderTrackSize
{
@@ -284,12 +282,10 @@ public class SliderTrack : Control,
set => SetValue(MarkBorderThicknessProperty, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
+4 -8
View File
@@ -64,10 +64,8 @@ internal class SwitchKnob : Control,
internal static readonly StyledProperty<double> KnobRenderWidthProperty
= AvaloniaProperty.Register<SwitchKnob, double>(nameof(KnobRenderWidth));
internal static readonly DirectProperty<SwitchKnob, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<SwitchKnob, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<SwitchKnob>();
internal static readonly StyledProperty<TimeSpan> LoadingAnimationDurationProperty
= AvaloniaProperty.Register<SwitchKnob, TimeSpan>(nameof(LoadingAnimationDuration));
@@ -101,12 +99,10 @@ internal class SwitchKnob : Control,
set => SetValue(KnobRenderWidthProperty, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
internal TimeSpan LoadingAnimationDuration
+5 -9
View File
@@ -63,10 +63,8 @@ public class TabItem : AvaloniaTabItem,
internal static readonly StyledProperty<TabSharp> ShapeProperty =
AvaloniaProperty.Register<TabItem, TabSharp>(nameof(Shape));
internal static readonly DirectProperty<TabItem, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<TabItem, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<TabItem>();
public SizeType SizeType
{
@@ -79,13 +77,11 @@ public class TabItem : AvaloniaTabItem,
get => GetValue(ShapeProperty);
set => SetValue(ShapeProperty, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
@@ -86,10 +86,8 @@ public class TabStripItem : AvaloniaTabStripItem,
internal static readonly StyledProperty<TabSharp> ShapeProperty =
AvaloniaProperty.Register<TabStripItem, TabSharp>(nameof(Shape));
internal static readonly DirectProperty<TabStripItem, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<TabStripItem, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<TabStripItem>();
public TabSharp Shape
{
@@ -97,12 +95,10 @@ public class TabStripItem : AvaloniaTabStripItem,
set => SetValue(ShapeProperty, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
@@ -1,7 +1,6 @@
using System.Diagnostics;
using System.Reactive.Disposables;
using AtomUI.Controls.TimePickerLang;
using AtomUI.Controls.Utils;
using AtomUI.Theme;
using AtomUI.Theme.Data;
using AtomUI.Theme.Styling;
@@ -68,62 +67,37 @@ internal class DateTimePickerPanel : Panel,
ITokenResourceConsumer
{
#region 公共属性定义
/// <summary>
/// Defines the <see cref="ItemHeight" /> property
/// </summary>
public static readonly StyledProperty<double> ItemHeightProperty =
AvaloniaProperty.Register<DateTimePickerPanel, double>(nameof(ItemHeight), 40.0);
/// <summary>
/// Defines the <see cref="PanelType" /> property
/// </summary>
public static readonly StyledProperty<DateTimePickerPanelType> PanelTypeProperty =
AvaloniaProperty.Register<DateTimePickerPanel, DateTimePickerPanelType>(nameof(PanelType));
/// <summary>
/// Defines the <see cref="ItemFormat" /> property
/// </summary>
public static readonly StyledProperty<string> ItemFormatProperty =
AvaloniaProperty.Register<DateTimePickerPanel, string>(nameof(ItemFormat), "yyyy");
/// <summary>
/// Defines the <see cref="ShouldLoop" /> property
/// </summary>
public static readonly StyledProperty<bool> ShouldLoopProperty =
AvaloniaProperty.Register<DateTimePickerPanel, bool>(nameof(ShouldLoop));
/// <summary>
/// Gets or sets the height of each item
/// </summary>
public double ItemHeight
{
get => GetValue(ItemHeightProperty);
set => SetValue(ItemHeightProperty, value);
}
/// <summary>
/// Gets or sets what this panel displays in date or time units
/// </summary>
public DateTimePickerPanelType PanelType
{
get => GetValue(PanelTypeProperty);
set => SetValue(PanelTypeProperty, value);
}
/// <summary>
/// Gets or sets the string format for the items, using standard
/// .net DateTime or TimeSpan formatting. Format must match panel type
/// </summary>
public string ItemFormat
{
get => GetValue(ItemFormatProperty);
set => SetValue(ItemFormatProperty, value);
}
/// <summary>
/// Gets or sets whether the panel should loop
/// </summary>
public bool ShouldLoop
{
get => GetValue(ShouldLoopProperty);
@@ -134,17 +108,13 @@ internal class DateTimePickerPanel : Panel,
#region 内部属性定义
internal static readonly DirectProperty<DateTimePickerPanel, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<DateTimePickerPanel, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
private bool _isMotionEnabled;
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<DateTimePickerPanel>();
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
@@ -99,17 +99,13 @@ internal class TimePickerPresenter : PickerPresenterBase,
set => SetValue(TempSelectedTimeProperty, value);
}
internal static readonly DirectProperty<TimePickerPresenter, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<TimePickerPresenter, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<TimePickerPresenter>();
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
@@ -115,10 +115,8 @@ internal class TimeView : TemplatedControl,
internal static readonly StyledProperty<bool> IsPointerInSelectorProperty =
AvaloniaProperty.Register<TimeView, bool>(nameof(IsPointerInSelector), false);
internal static readonly DirectProperty<TimeView, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<TimeView, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<TimeView>();
private double _spacerWidth;
@@ -142,12 +140,10 @@ internal class TimeView : TemplatedControl,
set => SetAndRaise(ItemHeightProperty, ref _itemHeight, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
@@ -92,10 +92,8 @@ internal class NodeSwitcherButton : ToggleButton
o => o.IconMode,
(o, v) => o.IconMode = v);
internal static readonly DirectProperty<NodeSwitcherButton, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<NodeSwitcherButton, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<NodeSwitcherButton>();
internal bool IsLeafIconVisible
{
@@ -111,12 +109,10 @@ internal class NodeSwitcherButton : ToggleButton
set => SetAndRaise(IconModeProperty, ref _iconMode, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
internal bool IsNodeAnimating { get; set; } = false;
+4 -8
View File
@@ -195,10 +195,8 @@ public class TreeViewItem : AvaloniaTreeItem,
internal static readonly StyledProperty<CornerRadius> EffectiveNodeCornerRadiusProperty
= AvaloniaProperty.Register<TreeViewItem, CornerRadius>(nameof(EffectiveNodeCornerRadius));
internal static readonly DirectProperty<TreeViewItem, bool> IsMotionEnabledProperty
= AvaloniaProperty.RegisterDirect<TreeViewItem, bool>(nameof(IsMotionEnabled),
o => o.IsMotionEnabled,
(o, v) => o.IsMotionEnabled = v);
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= AnimationAwareControlProperty.IsMotionEnabledProperty.AddOwner<TreeViewItem>();
internal static readonly DirectProperty<TreeViewItem, TimeSpan> MotionDurationProperty =
AvaloniaProperty.RegisterDirect<TreeViewItem, TimeSpan>(nameof(MotionDuration),
@@ -309,12 +307,10 @@ public class TreeViewItem : AvaloniaTreeItem,
set => SetValue(EffectiveNodeCornerRadiusProperty, value);
}
private bool _isMotionEnabled;
internal bool IsMotionEnabled
{
get => _isMotionEnabled;
set => SetAndRaise(IsMotionEnabledProperty, ref _isMotionEnabled, value);
get => GetValue(IsMotionEnabledProperty);
set => SetValue(IsMotionEnabledProperty, value);
}
private TimeSpan _motionDuration;
@@ -3,7 +3,6 @@ using System.Reactive.Disposables;
using AtomUI.Theme;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
namespace AtomUI.Controls;