CommonValveControl.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Controls.Primitives;
  9. namespace Venus_Themes.CustomControls
  10. {
  11. public class CommonValveControl : Button
  12. {
  13. public CommonValveControl()
  14. {
  15. //this.MouseDoubleClick += CommonValveControl_MouseDoubleClick;
  16. }
  17. static CommonValveControl()
  18. {
  19. DefaultStyleKeyProperty.OverrideMetadata(typeof(CommonValveControl), new FrameworkPropertyMetadata(typeof(CommonValveControl)));
  20. }
  21. //private void CommonValveControl_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
  22. //{
  23. // Status = !Status;
  24. //}
  25. public override void OnApplyTemplate()
  26. {
  27. var devBtn = GetTemplateChild("mainBody") as Grid;
  28. devBtn.MouseLeftButtonDown += DevBtn_Click;
  29. base.OnApplyTemplate();
  30. }
  31. private void DevBtn_Click(object sender, RoutedEventArgs e)
  32. {
  33. //if (IsCanEdit == true)
  34. //{
  35. // Status = !Status;
  36. //}
  37. }
  38. public bool Status
  39. {
  40. get => (bool)GetValue(StatusProperty);
  41. set => SetValue(StatusProperty, value);
  42. }
  43. public static readonly DependencyProperty StatusProperty = DependencyProperty.Register(
  44. "Status",
  45. typeof(bool),
  46. typeof(CommonValveControl));
  47. public Orientation ValveOrientation
  48. {
  49. get => (Orientation)GetValue(CommonValveOrientationProperty);
  50. set => SetValue(CommonValveOrientationProperty, value);
  51. }
  52. public static readonly DependencyProperty CommonValveOrientationProperty = DependencyProperty.Register(
  53. "ValveOrientation",
  54. typeof(Orientation),
  55. typeof(CommonValveControl));
  56. public static readonly DependencyProperty IsCanEditProperty = DependencyProperty.Register("IsCanEdit"
  57. , typeof(bool), typeof(CommonValveControl));
  58. /// <summary>
  59. /// 是否可以编辑
  60. /// </summary>
  61. public bool IsCanEdit
  62. {
  63. get { return (bool)GetValue(IsCanEditProperty); }
  64. set { SetValue(IsCanEditProperty, value); }
  65. }
  66. }
  67. }