using BPA.UIControl.Commons.KnownBoxes; using System.Windows; using System.Windows.Media; namespace BPA.UIControl { /// /// 控件帮助基类 /// public class ControlHelper { /// /// 圆角半径 /// public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.RegisterAttached( "CornerRadius", typeof(CornerRadius), typeof(ControlHelper), new PropertyMetadata(default(CornerRadius))); /// /// Sets the corner radius. /// /// The element. /// The value. public static void SetCornerRadius(DependencyObject element, CornerRadius value) { element.SetValue(CornerRadiusProperty, value); } /// /// Gets the corner radius. /// /// The element. /// A CornerRadius. public static CornerRadius GetCornerRadius(DependencyObject element) { return (CornerRadius)element.GetValue(CornerRadiusProperty); } /// /// 聚焦颜色 /// public static readonly DependencyProperty FocusedBrushProperty = DependencyProperty.RegisterAttached( "FocusedBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush))); /// /// Sets the focused brush. /// /// The element. /// The value. public static void SetFocusedBrush(DependencyObject element, Brush value) { element.SetValue(FocusedBrushProperty, value); } /// /// Gets the focused brush. /// /// The element. /// A Brush. public static Brush GetFocusedBrush(DependencyObject element) { return (Brush)element.GetValue(FocusedBrushProperty); } /// /// 聚焦前景色 /// public static readonly DependencyProperty FocusedForegroundBrushProperty = DependencyProperty.RegisterAttached( "FocusedForegroundBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush))); /// /// Sets the focused foreground brush. /// /// The element. /// The value. public static void SetFocusedForegroundBrush(DependencyObject element, Brush value) { element.SetValue(FocusedForegroundBrushProperty, value); } /// /// Gets the focused foreground brush. /// /// The element. /// A Brush. public static Brush GetFocusedForegroundBrush(DependencyObject element) { return (Brush)element.GetValue(FocusedForegroundBrushProperty); } /// /// 聚焦边框颜色 /// public static readonly DependencyProperty FocusBorderBrushProperty = DependencyProperty.RegisterAttached( "FocusBorderBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush))); /// /// Sets the focus border brush. /// /// The element. /// The value. public static void SetFocusBorderBrush(DependencyObject element, Brush value) { element.SetValue(FocusBorderBrushProperty, value); } /// /// Gets the focus border brush. /// /// The element. /// A Brush. public static Brush GetFocusBorderBrush(DependencyObject element) { return (Brush)element.GetValue(FocusBorderBrushProperty); } /// /// 聚焦边框厚度 /// public static readonly DependencyProperty FocusBorderThicknessProperty = DependencyProperty.RegisterAttached( "FocusBorderThickness", typeof(Thickness), typeof(ControlHelper), new PropertyMetadata(default(Thickness))); /// /// Sets the focus border thickness. /// /// The element. /// The value. public static void SetFocusBorderThickness(DependencyObject element, Thickness value) { element.SetValue(FocusBorderThicknessProperty, value); } /// /// Gets the focus border thickness. /// /// The element. /// A Thickness. public static Thickness GetFocusBorderThickness(DependencyObject element) { return (Thickness)element.GetValue(FocusBorderThicknessProperty); } /// /// 鼠标悬停颜色 /// public static readonly DependencyProperty MouseOverBrushProperty = DependencyProperty.RegisterAttached( "MouseOverBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush))); /// /// Sets the mouse over brush. /// /// The element. /// The value. public static void SetMouseOverBrush(DependencyObject element, Brush value) { element.SetValue(MouseOverBrushProperty, value); } /// /// Gets the mouse over brush. /// /// The element. /// A Brush. public static Brush GetMouseOverBrush(DependencyObject element) { return (Brush)element.GetValue(MouseOverBrushProperty); } /// /// 按下颜色 /// public static readonly DependencyProperty PressedBrushProperty = DependencyProperty.RegisterAttached( "PressedBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush))); /// /// Sets the pressed brush. /// /// The element. /// The value. public static void SetPressedBrush(DependencyObject element, Brush value) { element.SetValue(PressedBrushProperty, value); } /// /// Gets the pressed brush. /// /// The element. /// A Brush. public static Brush GetPressedBrush(DependencyObject element) { return (Brush)element.GetValue(PressedBrushProperty); } /// /// 选中颜色 /// public static readonly DependencyProperty SelectedBrushProperty = DependencyProperty.RegisterAttached( "SelectedBrush", typeof(Brush), typeof(ControlHelper), new PropertyMetadata(default(Brush))); /// /// Sets the Selected brush. /// /// The element. /// The value. public static void SetSelectedBrush(DependencyObject element, Brush value) { element.SetValue(SelectedBrushProperty, value); } /// /// Gets the Selected brush. /// /// The element. /// A Brush. public static Brush GetSelectedBrush(DependencyObject element) { return (Brush)element.GetValue(SelectedBrushProperty); } /// /// 是否聚焦 /// public static readonly DependencyProperty IsKeyBoardFocusedProperty = DependencyProperty.RegisterAttached( "IsKeyBoardFocused", typeof(bool), typeof(ControlHelper), new PropertyMetadata(BooleanBoxes.FalseBox)); /// /// Gets the is key board focused. /// /// The obj. /// A bool. public static bool GetIsKeyBoardFocused(DependencyObject obj) { return (bool)obj.GetValue(IsKeyBoardFocusedProperty); } /// /// Sets the is key board focused. /// /// The obj. /// If true, value. public static void SetIsKeyBoardFocused(DependencyObject obj, bool value) { obj.SetValue(IsKeyBoardFocusedProperty, BooleanBoxes.Box(value)); } /// /// 遮罩透明度 /// public static readonly DependencyProperty MaskOpacityProperty = DependencyProperty.RegisterAttached( "MaskOpacity", typeof(double), typeof(ControlHelper), new PropertyMetadata(0.6)); /// /// Gets the mask opacity. /// /// The obj. /// A double. public static double GetMaskOpacity(DependencyObject obj) { return (double)obj.GetValue(MaskOpacityProperty); } /// /// Sets the mask opacity. /// /// The obj. /// The value. public static void SetMaskOpacity(DependencyObject obj, double value) { obj.SetValue(MaskOpacityProperty, value); } } }