using BPA.UIControl.Commons.KnownBoxes; using System.Windows; using System.Windows.Controls; namespace BPA.UIControl { /// /// 控件遮罩 /// 用于提供 MouseOver 和 Pressed 等效果 /// public class ControlMask : Control { /// /// Initializes a new instance of the class. /// static ControlMask() { DefaultStyleKeyProperty.OverrideMetadata(typeof(ControlMask), new FrameworkPropertyMetadata(typeof(ControlMask))); } /// /// 是否激活 /// public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register( "IsActive", typeof(bool), typeof(ControlMask), new PropertyMetadata(BooleanBoxes.FalseBox)); /// /// 是否激活 /// public bool IsActive { get { return (bool)GetValue(IsActiveProperty); } set { SetValue(IsActiveProperty, BooleanBoxes.Box(value)); } } /// /// 圆角半径 /// public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register( "CornerRadius", typeof(CornerRadius), typeof(ControlMask), new PropertyMetadata(default(CornerRadius))); /// /// 圆角半径 /// public CornerRadius CornerRadius { get { return (CornerRadius)GetValue(CornerRadiusProperty); } set { SetValue(CornerRadiusProperty, value); } } /// /// 遮罩透明度 /// public static readonly DependencyProperty MaskOpacityProperty = DependencyProperty.Register( "MaskOpacity", typeof(double), typeof(ControlMask), new PropertyMetadata(default(double))); /// /// 遮罩透明度 /// public double MaskOpacity { get { return (double)GetValue(MaskOpacityProperty); } set { SetValue(MaskOpacityProperty, value); } } /// /// 父元素 (用于出发 IsMouseOver) /// public static readonly DependencyProperty ParentElementProperty = DependencyProperty.Register( "ParentElement", typeof(UIElement), typeof(ControlMask), new PropertyMetadata(default(UIElement))); /// /// 父元素 (用于出发 IsMouseOver) /// public UIElement ParentElement { get { return (UIElement)GetValue(ParentElementProperty); } set { SetValue(ParentElementProperty, value); } } } }