You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 line
2.7 KiB

  1. using BPA.UIControl.Commons.KnownBoxes;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. namespace BPA.UIControl
  5. {
  6. /// <summary>
  7. /// 控件遮罩
  8. /// 用于提供 MouseOver 和 Pressed 等效果
  9. /// </summary>
  10. public class ControlMask : Control
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="ControlMask"/> class.
  14. /// </summary>
  15. static ControlMask()
  16. {
  17. DefaultStyleKeyProperty.OverrideMetadata(typeof(ControlMask), new FrameworkPropertyMetadata(typeof(ControlMask)));
  18. }
  19. /// <summary>
  20. /// 是否激活
  21. /// </summary>
  22. public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(
  23. "IsActive", typeof(bool), typeof(ControlMask), new PropertyMetadata(BooleanBoxes.FalseBox));
  24. /// <summary>
  25. /// 是否激活
  26. /// </summary>
  27. public bool IsActive
  28. {
  29. get { return (bool)GetValue(IsActiveProperty); }
  30. set { SetValue(IsActiveProperty, BooleanBoxes.Box(value)); }
  31. }
  32. /// <summary>
  33. /// 圆角半径
  34. /// </summary>
  35. public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
  36. "CornerRadius", typeof(CornerRadius), typeof(ControlMask), new PropertyMetadata(default(CornerRadius)));
  37. /// <summary>
  38. /// 圆角半径
  39. /// </summary>
  40. public CornerRadius CornerRadius
  41. {
  42. get { return (CornerRadius)GetValue(CornerRadiusProperty); }
  43. set { SetValue(CornerRadiusProperty, value); }
  44. }
  45. /// <summary>
  46. /// 遮罩透明度
  47. /// </summary>
  48. public static readonly DependencyProperty MaskOpacityProperty = DependencyProperty.Register(
  49. "MaskOpacity", typeof(double), typeof(ControlMask), new PropertyMetadata(default(double)));
  50. /// <summary>
  51. /// 遮罩透明度
  52. /// </summary>
  53. public double MaskOpacity
  54. {
  55. get { return (double)GetValue(MaskOpacityProperty); }
  56. set { SetValue(MaskOpacityProperty, value); }
  57. }
  58. /// <summary>
  59. /// 父元素 (用于出发 IsMouseOver)
  60. /// </summary>
  61. public static readonly DependencyProperty ParentElementProperty = DependencyProperty.Register(
  62. "ParentElement", typeof(UIElement), typeof(ControlMask), new PropertyMetadata(default(UIElement)));
  63. /// <summary>
  64. /// 父元素 (用于出发 IsMouseOver)
  65. /// </summary>
  66. public UIElement ParentElement
  67. {
  68. get { return (UIElement)GetValue(ParentElementProperty); }
  69. set { SetValue(ParentElementProperty, value); }
  70. }
  71. }
  72. }