Files
ShrlAlgoToolkit/Melskin/Controls/Decorations/SlotBorder.xaml.cs
2026-02-17 22:17:13 +08:00

70 lines
2.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace Melskin.Controls.Decorations;
/// <summary>
/// SlotBorder 类继承自 DecorationBase用于为控件添加具有圆角和阴影效果的装饰边框。
/// 通过设置 CornerRadius 属性可以控制边框的圆角程度,同时 LightShadowBrush 和 DarkShadowBrush 属性允许用户自定义浅色和深色阴影的颜色。
/// </summary>
public class SlotBorder : DecorationBase
{
static SlotBorder()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(SlotBorder),
new FrameworkPropertyMetadata(typeof(SlotBorder)));
}
/// <summary>
/// 获取或设置边框的圆角半径。
/// </summary>
public CornerRadius CornerRadius
{
get => (CornerRadius)GetValue(CornerRadiusProperty);
set => SetValue(CornerRadiusProperty, value);
}
/// <summary>
/// 高亮笔刷
/// </summary>
public SolidColorBrush LightShadowBrush
{
get => (SolidColorBrush)GetValue(LightShadowBrushProperty);
set => SetValue(LightShadowBrushProperty, value);
}
/// <summary>
/// 阴影笔刷
/// </summary>
public SolidColorBrush DarkShadowBrush
{
get => (SolidColorBrush)GetValue(DarkShadowBrushProperty);
set => SetValue(DarkShadowBrushProperty, value);
}
#region Dependency Properties
/// <summary>
/// 用于定义边角半径的依赖属性,控制装饰控件的圆角程度。
/// </summary>
public static readonly DependencyProperty CornerRadiusProperty =
DependencyProperty.Register(nameof(CornerRadius),
typeof(CornerRadius), typeof(SlotBorder),
new PropertyMetadata(new CornerRadius(4)));
/// <summary>
/// 浅色阴影笔刷
/// </summary>
public static readonly DependencyProperty LightShadowBrushProperty =
DependencyProperty.Register(nameof(LightShadowBrush),
typeof(SolidColorBrush), typeof(SlotBorder),
new PropertyMetadata(Brushes.WhiteSmoke));
/// <summary>
/// 深色阴影笔刷
/// </summary>
public static readonly DependencyProperty DarkShadowBrushProperty =
DependencyProperty.Register(nameof(DarkShadowBrush),
typeof(SolidColorBrush), typeof(SlotBorder),
new PropertyMetadata(Brushes.DarkGray));
#endregion
}