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