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