using NeumUI.Assets; using NeumUI.Controls; namespace NeumUI.Assists; /// /// ButtonAssist 类提供了对按钮控件外观类型的辅助功能。 /// 通过此辅助类,可以方便地获取或设置按钮的AppearanceType属性, /// 从而控制按钮的视觉样式。支持的样式包括Primary、Info、Success、Warning和Error。 /// public class ButtonAssist { /// /// 获取指定对象的外观类型。 /// /// 要获取其外观类型的依赖对象。 /// 返回指定对象的AppearanceType枚举值,表示其外观类型。 public static AppearanceType GetAppearanceType(DependencyObject obj) { return (AppearanceType)obj.GetValue(AppearanceTypeProperty); } /// /// 设置指定对象的外观类型。 /// /// 要设置其外观类型的依赖对象。 /// AppearanceType枚举值,表示要设置的外观类型。 public static void SetAppearanceType(DependencyObject obj, AppearanceType value) { obj.SetValue(AppearanceTypeProperty, value); } /// /// 代表按钮控件的外观类型依赖属性。通过此属性,可以设置或获取按钮的视觉样式。 /// 支持的样式包括Primary、Info、Success、Warning和Error,分别对应不同的视觉效果。 /// public static readonly DependencyProperty AppearanceTypeProperty = DependencyProperty.RegisterAttached("AppearanceType", typeof(AppearanceType), typeof(ButtonAssist), new PropertyMetadata(AppearanceType.None)); public static MaterialSymbol GetIcon(DependencyObject obj) { return (MaterialSymbol)obj.GetValue(IconProperty); } public static void SetIcon(DependencyObject obj, MaterialSymbol value) { obj.SetValue(IconProperty, value); } public static readonly DependencyProperty IconProperty = DependencyProperty.RegisterAttached("Icon", typeof(MaterialSymbol), typeof(ButtonAssist), new PropertyMetadata(MaterialSymbol.Cr)); public static Dock GetIconPlacement(DependencyObject obj) { return (Dock)obj.GetValue(IconPlacementProperty); } public static void SetIconPlacement(DependencyObject obj, Dock value) { obj.SetValue(IconPlacementProperty, value); } // Using a DependencyProperty as the backing store for IconPlacement. This enables animation, styling, binding, etc... public static readonly DependencyProperty IconPlacementProperty = DependencyProperty.RegisterAttached("IconPlacement", typeof(Dock), typeof(ButtonAssist), new PropertyMetadata(Dock.Left)); public static readonly DependencyProperty IsRunningProperty = DependencyProperty.RegisterAttached("IsRunning", typeof(bool), typeof(ButtonAssist), new PropertyMetadata(false)); public static bool GetIsRunning(DependencyObject obj) => (bool)obj.GetValue(IsRunningProperty); public static void SetIsRunning(DependencyObject obj, bool value) => obj.SetValue(IsRunningProperty, value); }