DERobot.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. using OpenSEMI.ClientBase;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Media.Animation;
  10. namespace Venus_Themes.CustomControls
  11. {
  12. public class DERobot: Control
  13. {
  14. public enum DERobotXAction
  15. {
  16. X_Origin,
  17. Extend,
  18. ToVCE,
  19. FromVCE,
  20. Retract,
  21. X_Origin2,
  22. Extend2,
  23. ToVCE2,
  24. FromVCE2,
  25. Retract2
  26. }
  27. public enum DERobotTAction
  28. {
  29. T_Origin,
  30. PMA,
  31. PMB,
  32. PMC,
  33. PMD,
  34. VCEA,
  35. VCEB,
  36. Aligner1
  37. }
  38. static DERobot()
  39. {
  40. DefaultStyleKeyProperty.OverrideMetadata(typeof(DERobot), new FrameworkPropertyMetadata(typeof(DERobot)));
  41. }
  42. //注册Wafer、ExtendTime、RobotWafer、RobotXAction属性
  43. public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(DERobot));
  44. public int Wafer { get => (int)GetValue(WaferProperty); set => SetValue(WaferProperty, value); }
  45. public static readonly DependencyProperty ExtendTimeProperty = DependencyProperty.Register("ExtendTime", typeof(KeyTime), typeof(DERobot), new PropertyMetadata(KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9))));
  46. public KeyTime ExtendTime { get => (KeyTime)GetValue(ExtendTimeProperty); set => SetValue(ExtendTimeProperty, value); }
  47. public static readonly DependencyProperty RobotWaferProperty = DependencyProperty.Register(
  48. "RobotWafer",
  49. typeof(WaferInfo),
  50. typeof(DERobot));
  51. public WaferInfo RobotWafer
  52. {
  53. get => (WaferInfo)GetValue(RobotWaferProperty);
  54. set => SetValue(RobotWaferProperty, value);
  55. }
  56. public static readonly DependencyProperty RobotXActionProperty = DependencyProperty.Register(
  57. "RobotXAction",
  58. typeof(DERobotXAction),
  59. typeof(DERobot),
  60. new PropertyMetadata(DERobotXAction.X_Origin, RobotXActionPropertyChangedCallback));
  61. public DERobotXAction RobotXAction
  62. {
  63. get => (DERobotXAction)GetValue(RobotXActionProperty);
  64. set => SetValue(RobotXActionProperty, value);
  65. }
  66. //RobotXAction依赖属性的值被改变之后此委托会被调用
  67. private static void RobotXActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  68. {
  69. var control = d as DERobot;
  70. var oldAct = (DERobotXAction)e.OldValue; //现在的位置
  71. var newAct = (DERobotXAction)e.NewValue; //下一个位置
  72. switch (newAct)
  73. {
  74. case DERobotXAction.X_Origin:
  75. VisualStateManager.GoToState(control, newAct.ToString(), true);
  76. break;
  77. case DERobotXAction.Extend:
  78. if (newAct != oldAct)
  79. {
  80. VisualStateManager.GoToState(control, newAct.ToString(), true);
  81. }
  82. break;
  83. case DERobotXAction.Retract:
  84. if (newAct != oldAct)
  85. {
  86. VisualStateManager.GoToState(control, newAct.ToString(), true);
  87. }
  88. break;
  89. case DERobotXAction.ToVCE:
  90. if (newAct != oldAct)
  91. {
  92. VisualStateManager.GoToState(control, newAct.ToString(), true);
  93. }
  94. break;
  95. case DERobotXAction.FromVCE:
  96. if (newAct != oldAct)
  97. {
  98. VisualStateManager.GoToState(control, newAct.ToString(), true);
  99. }
  100. break;
  101. case DERobotXAction.X_Origin2:
  102. VisualStateManager.GoToState(control, newAct.ToString(), true);
  103. break;
  104. case DERobotXAction.Extend2:
  105. if (newAct != oldAct)
  106. {
  107. VisualStateManager.GoToState(control, newAct.ToString(), true);
  108. }
  109. break;
  110. case DERobotXAction.Retract2:
  111. if (newAct != oldAct)
  112. {
  113. VisualStateManager.GoToState(control, newAct.ToString(), true);
  114. }
  115. break;
  116. case DERobotXAction.ToVCE2:
  117. if (newAct != oldAct)
  118. {
  119. VisualStateManager.GoToState(control, newAct.ToString(), true);
  120. }
  121. break;
  122. case DERobotXAction.FromVCE2:
  123. if (newAct != oldAct)
  124. {
  125. VisualStateManager.GoToState(control, newAct.ToString(), true);
  126. }
  127. break;
  128. default:
  129. break;
  130. }
  131. }
  132. public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register(
  133. "RobotTAction",
  134. typeof(DERobotTAction),
  135. typeof(DERobot),
  136. new PropertyMetadata(DERobotTAction.T_Origin, RobotTActionPropertyChangedCallback));
  137. public DERobotTAction RobotTAction
  138. {
  139. get => (DERobotTAction)GetValue(RobotTActionProperty);
  140. set => SetValue(RobotTActionProperty, value);
  141. }
  142. public static readonly DependencyProperty RobotSpeedProperty = DependencyProperty.Register(
  143. "RobotSpeed",
  144. typeof(double),
  145. typeof(DERobot),
  146. new PropertyMetadata(9.0d, RobotSpeedPropertyChangedCallback));
  147. public double RobotSpeed
  148. {
  149. get => (double)GetValue(RobotSpeedProperty);
  150. set => SetValue(RobotSpeedProperty, value);
  151. }
  152. private static void RobotSpeedPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  153. {
  154. }
  155. public string OriginX { get; set; }
  156. public string OriginT { get; set; }
  157. private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  158. {
  159. var control = d as DERobot;
  160. var oldAct = (DERobotTAction)e.OldValue;
  161. var newAct = (DERobotTAction)e.NewValue;
  162. //while (newAct.ToString() == "Aligner1" && !control.PMDIsInstalled)
  163. //{
  164. // newAct = DERobotTAction.VPARight;
  165. //}
  166. if (oldAct != newAct)
  167. {
  168. VisualStateManager.GoToState(control, newAct.ToString(), true);//前后动作不一致,改变控件状态
  169. }
  170. }
  171. public override void OnApplyTemplate()
  172. {
  173. base.OnApplyTemplate();
  174. VisualStateManager.GoToState(this, OriginX, true);
  175. //VisualStateManager.GoToState(this, DERobotXAction.X_Origin.ToString(), true);
  176. VisualStateManager.GoToState(this, OriginT, true);
  177. }
  178. }
  179. }