2026-01-02 17:30:41 +08:00
|
|
|
|
namespace Melskin.Controls.Decorations;
|
2025-08-12 23:08:54 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-08-20 12:10:13 +08:00
|
|
|
|
/// SlotBorder 类继承自 DecorationBase,用于为控件添加具有圆角和阴影效果的装饰边框。
|
|
|
|
|
|
/// 通过设置 CornerRadius 属性可以控制边框的圆角程度,同时 LightShadowBrush 和 DarkShadowBrush 属性允许用户自定义浅色和深色阴影的颜色。
|
2025-08-12 23:08:54 +08:00
|
|
|
|
/// </summary>
|
2025-08-20 12:10:13 +08:00
|
|
|
|
public class SlotBorder : DecorationBase
|
2025-08-12 23:08:54 +08:00
|
|
|
|
{
|
2025-08-20 12:10:13 +08:00
|
|
|
|
static SlotBorder()
|
2025-08-12 23:08:54 +08:00
|
|
|
|
{
|
2025-08-20 12:10:13 +08:00
|
|
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(SlotBorder),
|
|
|
|
|
|
new FrameworkPropertyMetadata(typeof(SlotBorder)));
|
2025-08-12 23:08:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-08-20 12:10:13 +08:00
|
|
|
|
/// 获取或设置边框的圆角半径。
|
2025-08-12 23:08:54 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public CornerRadius CornerRadius
|
|
|
|
|
|
{
|
|
|
|
|
|
get => (CornerRadius)GetValue(CornerRadiusProperty);
|
|
|
|
|
|
set => SetValue(CornerRadiusProperty, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2025-08-20 12:10:13 +08:00
|
|
|
|
/// 高亮笔刷
|
2025-08-12 23:08:54 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public SolidColorBrush LightShadowBrush
|
|
|
|
|
|
{
|
|
|
|
|
|
get => (SolidColorBrush)GetValue(LightShadowBrushProperty);
|
|
|
|
|
|
set => SetValue(LightShadowBrushProperty, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2025-08-20 12:10:13 +08:00
|
|
|
|
/// 阴影笔刷
|
2025-08-12 23:08:54 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public SolidColorBrush DarkShadowBrush
|
|
|
|
|
|
{
|
|
|
|
|
|
get => (SolidColorBrush)GetValue(DarkShadowBrushProperty);
|
|
|
|
|
|
set => SetValue(DarkShadowBrushProperty, value);
|
|
|
|
|
|
}
|
2025-08-20 12:10:13 +08:00
|
|
|
|
|
2025-08-12 23:08:54 +08:00
|
|
|
|
#region Dependency Properties
|
|
|
|
|
|
|
2025-08-20 12:10:13 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 用于定义边角半径的依赖属性,控制装饰控件的圆角程度。
|
|
|
|
|
|
/// </summary>
|
2025-08-12 23:08:54 +08:00
|
|
|
|
public static readonly DependencyProperty CornerRadiusProperty =
|
|
|
|
|
|
DependencyProperty.Register(nameof(CornerRadius),
|
2025-08-20 12:10:13 +08:00
|
|
|
|
typeof(CornerRadius), typeof(SlotBorder),
|
2025-08-12 23:08:54 +08:00
|
|
|
|
new PropertyMetadata(new CornerRadius(4)));
|
2025-08-20 12:10:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 浅色阴影笔刷
|
|
|
|
|
|
/// </summary>
|
2025-08-12 23:08:54 +08:00
|
|
|
|
public static readonly DependencyProperty LightShadowBrushProperty =
|
|
|
|
|
|
DependencyProperty.Register(nameof(LightShadowBrush),
|
2025-08-20 12:10:13 +08:00
|
|
|
|
typeof(SolidColorBrush), typeof(SlotBorder),
|
2025-08-12 23:08:54 +08:00
|
|
|
|
new PropertyMetadata(Brushes.WhiteSmoke));
|
2025-08-20 12:10:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 深色阴影笔刷
|
|
|
|
|
|
/// </summary>
|
2025-08-12 23:08:54 +08:00
|
|
|
|
public static readonly DependencyProperty DarkShadowBrushProperty =
|
|
|
|
|
|
DependencyProperty.Register(nameof(DarkShadowBrush),
|
2025-08-20 12:10:13 +08:00
|
|
|
|
typeof(SolidColorBrush), typeof(SlotBorder),
|
2025-08-12 23:08:54 +08:00
|
|
|
|
new PropertyMetadata(Brushes.DarkGray));
|
2025-08-20 12:10:13 +08:00
|
|
|
|
|
2025-08-12 23:08:54 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
}
|