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

76 lines
2.6 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.
using System.ComponentModel;
namespace Melskin.Controls;
/// <summary>
/// Card 类继承自 ContentControl用于创建具有圆角和光照效果的卡片边框。此控件可以用来装饰应用程序中的内容区域使其外观更加美观。
/// 通过设置 CornerRadius 属性,您可以控制卡片四角的圆滑程度;利用 LightSize 属性调节光照效果的大小;
/// 同时ShaderEnabled 属性允许您启用或禁用阴影效果以增强视觉体验。
/// </summary>
public class Card : ContentControl
{
static Card()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Card),
new FrameworkPropertyMetadata(typeof(Card)));
}
/// <summary>
/// 设置或获取卡片四角的圆角半径,该属性控制卡片边框的圆滑程度。
/// </summary>
[Category("自定义")]
[Description("设置卡片圆角半径")]
public CornerRadius CornerRadius
{
get => (CornerRadius)GetValue(CornerRadiusProperty);
set => SetValue(CornerRadiusProperty, value);
}
/// <summary>
/// 表示 Card 控件圆角半径的依赖属性。此属性用于控制卡片四角的圆滑程度。
/// </summary>
public static readonly DependencyProperty CornerRadiusProperty =
DependencyProperty.Register(nameof(CornerRadius),
typeof(CornerRadius), typeof(Card),
new PropertyMetadata(new CornerRadius(4)));
/// <summary>
/// 设置或获取光照效果的尺寸,该属性控制卡片周围光照效果的大小。
/// </summary>
[Category("自定义")]
[Description("设置光的尺寸")]
public double LightSize
{
get => (double)GetValue(LightSizeProperty);
set => SetValue(LightSizeProperty, value);
}
/// <summary>
/// 设置光照效果的尺寸
/// </summary>
public static readonly DependencyProperty LightSizeProperty =
DependencyProperty.Register(nameof(LightSize),
typeof(double), typeof(Card),
new PropertyMetadata(200.0));
/// <summary>
/// Enable or disable the border effect
/// </summary>
public bool ShaderEnabled
{
get => (bool)GetValue(ShaderEnabledProperty);
set => SetValue(ShaderEnabledProperty, value);
}
/// <summary>
/// 获取或设置一个值,该值指示是否启用卡片的阴影效果。启用阴影效果可以增强控件的视觉层次感和美观度。
/// </summary>
public static readonly DependencyProperty ShaderEnabledProperty =
DependencyProperty.Register(nameof(ShaderEnabled),
typeof(bool), typeof(Card),
new PropertyMetadata(true));
}