PunkRobotControl.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using OpenSEMI.ClientBase;
  2. using System;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Media.Animation;
  6. namespace PunkHPX8_Themes.CustomControls
  7. {
  8. public class PunkRobotControl : Control
  9. {
  10. static PunkRobotControl()
  11. {
  12. DefaultStyleKeyProperty.OverrideMetadata(typeof(PunkRobotControl), new FrameworkPropertyMetadata(typeof(PunkRobotControl)));
  13. }
  14. public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(PunkRobotControl));
  15. public int Wafer
  16. {
  17. get => (int)GetValue(WaferProperty);
  18. set => SetValue(WaferProperty, value);
  19. }
  20. public static readonly DependencyProperty ExtendTimeProperty = DependencyProperty.Register("ExtendTime", typeof(KeyTime), typeof(PunkRobotControl), new PropertyMetadata(KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9))));
  21. public KeyTime ExtendTime
  22. {
  23. get => (KeyTime)GetValue(ExtendTimeProperty);
  24. set => SetValue(ExtendTimeProperty, value);
  25. }
  26. public static readonly DependencyProperty Robot2WaferProperty = DependencyProperty.Register(
  27. "Robot2Wafer",
  28. typeof(WaferInfo),
  29. typeof(PunkRobotControl));
  30. public WaferInfo Robot2Wafer
  31. {
  32. get => (WaferInfo)GetValue(Robot2WaferProperty);
  33. set => SetValue(Robot2WaferProperty, value);
  34. }
  35. public static readonly DependencyProperty RobotWaferProperty = DependencyProperty.Register(
  36. "RobotWafer",
  37. typeof(WaferInfo),
  38. typeof(PunkRobotControl));
  39. public WaferInfo RobotWafer
  40. {
  41. get => (WaferInfo)GetValue(RobotWaferProperty);
  42. set => SetValue(RobotWaferProperty, value);
  43. }
  44. public static readonly DependencyProperty RobotXActionProperty = DependencyProperty.Register(
  45. "RobotXAction",
  46. typeof(WaferRobotXAction),
  47. typeof(PunkRobotControl),
  48. new PropertyMetadata(WaferRobotXAction.X_Origin, RobotXActionPropertyChangedCallback));
  49. public WaferRobotXAction RobotXAction
  50. {
  51. get => (WaferRobotXAction)GetValue(RobotXActionProperty);
  52. set => SetValue(RobotXActionProperty, value);
  53. }
  54. private static void RobotXActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  55. {
  56. //KeyTime value = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9));
  57. var control = d as PunkRobotControl;
  58. var oldAct = (WaferRobotXAction)e.OldValue;
  59. var newAct = (WaferRobotXAction)e.NewValue;
  60. switch (newAct)
  61. {
  62. case WaferRobotXAction.X_Origin:
  63. VisualStateManager.GoToState(control, newAct.ToString(), true);
  64. break;
  65. case WaferRobotXAction.Extend:
  66. if (newAct != oldAct)
  67. {
  68. VisualStateManager.GoToState(control, newAct.ToString(), true);
  69. }
  70. break;
  71. case WaferRobotXAction.Extend2:
  72. if (newAct != oldAct)
  73. {
  74. VisualStateManager.GoToState(control, newAct.ToString(), true);
  75. }
  76. break;
  77. case WaferRobotXAction.Retract2:
  78. if (newAct != oldAct)
  79. {
  80. VisualStateManager.GoToState(control, newAct.ToString(), true);
  81. }
  82. break;
  83. case WaferRobotXAction.Retract:
  84. if (newAct != oldAct)
  85. {
  86. VisualStateManager.GoToState(control, newAct.ToString(), true);
  87. }
  88. break;
  89. default:
  90. break;
  91. }
  92. }
  93. public static readonly DependencyProperty RobotFActionProperty = DependencyProperty.Register(
  94. "RobotFAction",
  95. typeof(WaferRobotFAction),
  96. typeof(PunkRobotControl),
  97. new PropertyMetadata(WaferRobotFAction.None, RobotFActionPropertyChangedCallback));
  98. public WaferRobotFAction RobotFAction
  99. {
  100. get => (WaferRobotFAction)GetValue(RobotFActionProperty);
  101. set => SetValue(RobotFActionProperty, value);
  102. }
  103. private static void RobotFActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  104. {
  105. //KeyTime value = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9));
  106. var control = d as PunkRobotControl;
  107. var oldAct = (WaferRobotFAction)e.OldValue;
  108. var newAct = (WaferRobotFAction)e.NewValue;
  109. switch (newAct)
  110. {
  111. case WaferRobotFAction.UpperToDown:
  112. if (newAct != oldAct)
  113. {
  114. VisualStateManager.GoToState(control, newAct.ToString(), true);
  115. }
  116. break;
  117. case WaferRobotFAction.DownToUpper:
  118. if (newAct != oldAct)
  119. {
  120. VisualStateManager.GoToState(control, newAct.ToString(), true);
  121. }
  122. break;
  123. default:
  124. break;
  125. }
  126. }
  127. public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register(
  128. "RobotTAction",
  129. typeof(WaferRobotTAction),
  130. typeof(PunkRobotControl),
  131. new PropertyMetadata(WaferRobotTAction.T_Origin, RobotTActionPropertyChangedCallback));
  132. public WaferRobotTAction RobotTAction
  133. {
  134. get => (WaferRobotTAction)GetValue(RobotTActionProperty);
  135. set => SetValue(RobotTActionProperty, value);
  136. }
  137. private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  138. {
  139. var control = d as PunkRobotControl;
  140. var oldAct = (WaferRobotTAction)e.OldValue;
  141. var newAct = (WaferRobotTAction)e.NewValue;
  142. if (oldAct != newAct)
  143. {
  144. VisualStateManager.GoToState(control, newAct.ToString(), true);
  145. }
  146. }
  147. public string OriginT { get; set; }
  148. public override void OnApplyTemplate()
  149. {
  150. base.OnApplyTemplate();
  151. VisualStateManager.GoToState(this, WaferRobotXAction.X_Origin.ToString(), true);
  152. VisualStateManager.GoToState(this, WaferRobotTAction.T_Origin.ToString(), true);
  153. VisualStateManager.GoToState(this, WaferRobotFAction.DownToUpper.ToString(), true);
  154. }
  155. }
  156. }