功能完善

This commit is contained in:
ShrlAlgo
2025-08-20 12:10:13 +08:00
parent d0cfc64450
commit fcd306b0f7
270 changed files with 11503 additions and 7193 deletions

View File

@@ -0,0 +1,74 @@
namespace NeumUI.Controls;
using System.Windows;
using ContentControlBase = System.Windows.Controls.ContentControl;
/// <summary>
/// A spinner for displaying loading state of a page or a section.
/// </summary>
[TemplateVisualState(Name = "Spun", GroupName = "SpinStates")]
[TemplateVisualState(Name = "Unspun", GroupName = "SpinStates")]
public class Spin : ContentControlBase
{
#region Properties
public static readonly DependencyProperty IndicatorProperty =
DependencyProperty.Register(
nameof(Indicator),
typeof(UIElement),
typeof(Spin),
new PropertyMetadata(null, OnSpinningChanged));
/// <summary>
/// Gets/sets element of the spinning indicator.
/// </summary>
public UIElement Indicator
{
get => (UIElement)GetValue(IndicatorProperty);
set => SetValue(IndicatorProperty, value);
}
public static readonly DependencyProperty SpinningProperty =
DependencyProperty.Register(
nameof(Spinning),
typeof(bool),
typeof(Spin),
new PropertyMetadata(true, OnSpinningChanged));
/// <summary>
/// Gets/sets whether spin is spinning.
/// </summary>
public bool Spinning { get => (bool)GetValue(SpinningProperty);
set => SetValue(SpinningProperty, value);
}
private static void OnSpinningChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ (d as Spin).GoToSpinState(); }
private void GoToSpinState()
{ VisualStateManager.GoToState(this, Spinning && null == Indicator ? "Spun" : "Unspun", true); }
public static readonly DependencyProperty TipProperty =
DependencyProperty.Register(nameof(Tip), typeof(string), typeof(Spin), new PropertyMetadata(string.Empty));
/// <summary>
/// Gets/sets customize description content when spin has children.
/// </summary>
public string Tip { get => (string)GetValue(TipProperty);
set => SetValue(TipProperty, value);
}
#endregion
#region Constructors
static Spin()
{ DefaultStyleKeyProperty.OverrideMetadata(typeof(Spin), new FrameworkPropertyMetadata(typeof(Spin))); }
#endregion
#region Overrides
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
GoToSpinState();
}
#endregion
}