CommonValveControl.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 CyberX8_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 static readonly DependencyProperty ValveOrientationProperty = DependencyProperty.Register(
  48. "ValveOrientation",
  49. typeof(Orientation),
  50. typeof(CommonValveControl));
  51. public Orientation ValveOrientation
  52. {
  53. get => (Orientation)GetValue(ValveOrientationProperty);
  54. set => SetValue(ValveOrientationProperty, value);
  55. }
  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. public static readonly DependencyProperty ValveTypeProperty = DependencyProperty.Register(
  67. "ValveType", typeof(string), typeof(CommonValveControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  68. /// <summary>
  69. /// Valve类型
  70. /// </summary>
  71. public string ValveType
  72. {
  73. get => (string)GetValue(ValveTypeProperty);
  74. set => SetValue(ValveTypeProperty, value);
  75. }
  76. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
  77. "ModuleName", typeof(string), typeof(CommonValveControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  78. /// <summary>
  79. /// ModuleName
  80. /// </summary>
  81. public string ModuleName
  82. {
  83. get => (string)GetValue(ModuleNameProperty);
  84. set => SetValue(ModuleNameProperty, value);
  85. }
  86. public static readonly DependencyProperty OperationNameProperty = DependencyProperty.Register(
  87. "OperationName", typeof(string), typeof(CommonValveControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  88. /// <summary>
  89. /// OperationName
  90. /// </summary>
  91. public string OperationName
  92. {
  93. get => (string)GetValue(OperationNameProperty);
  94. set => SetValue(OperationNameProperty, value);
  95. }
  96. private void OpenClick(object sender, RoutedEventArgs e)
  97. {
  98. }
  99. private void CloseClick(object sender, RoutedEventArgs e)
  100. {
  101. }
  102. }
  103. }