功能完善
This commit is contained in:
74
NeuWPF/NeoUI/Assists/ButtonAssist.cs
Normal file
74
NeuWPF/NeoUI/Assists/ButtonAssist.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using NeumUI.Assets;
|
||||
using NeumUI.Controls;
|
||||
|
||||
namespace NeumUI.Assists;
|
||||
|
||||
/// <summary>
|
||||
/// ButtonAssist 类提供了对按钮控件外观类型的辅助功能。
|
||||
/// 通过此辅助类,可以方便地获取或设置按钮的AppearanceType属性,
|
||||
/// 从而控制按钮的视觉样式。支持的样式包括Primary、Info、Success、Warning和Error。
|
||||
/// </summary>
|
||||
public class ButtonAssist
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取指定对象的外观类型。
|
||||
/// </summary>
|
||||
/// <param name="obj">要获取其外观类型的依赖对象。</param>
|
||||
/// <returns>返回指定对象的AppearanceType枚举值,表示其外观类型。</returns>
|
||||
public static AppearanceType GetAppearanceType(DependencyObject obj)
|
||||
{
|
||||
return (AppearanceType)obj.GetValue(AppearanceTypeProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定对象的外观类型。
|
||||
/// </summary>
|
||||
/// <param name="obj">要设置其外观类型的依赖对象。</param>
|
||||
/// <param name="value">AppearanceType枚举值,表示要设置的外观类型。</param>
|
||||
public static void SetAppearanceType(DependencyObject obj, AppearanceType value)
|
||||
{
|
||||
obj.SetValue(AppearanceTypeProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 代表按钮控件的外观类型依赖属性。通过此属性,可以设置或获取按钮的视觉样式。
|
||||
/// 支持的样式包括Primary、Info、Success、Warning和Error,分别对应不同的视觉效果。
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user