SERobot.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. using Venus_Themes.UserControls;
  11. namespace Venus_Themes.CustomControls
  12. {
  13. public class SERobot : Control
  14. {
  15. public enum SERobotXAction
  16. {
  17. X_Origin,
  18. Extend,
  19. ToAligner,
  20. ToVCE,
  21. FromVCE,
  22. FromAligner,
  23. Retract,
  24. X_Origin2,
  25. Extend2,
  26. ToVCE2,
  27. FromVCE2,
  28. ToAligner2,
  29. FromAligner2,
  30. Retract2
  31. }
  32. public enum SERobotTAction
  33. {
  34. T_Origin,
  35. PMA,
  36. PMB,
  37. PMC,
  38. VCE1,
  39. Aligner1,
  40. VPARight,
  41. RightLocation,
  42. LeftLocation
  43. }
  44. static SERobot()
  45. {
  46. DefaultStyleKeyProperty.OverrideMetadata(typeof(SERobot), new FrameworkPropertyMetadata(typeof(SERobot)));
  47. }
  48. //注册Wafer、ExtendTime、RobotWafer、RobotXAction属性
  49. public static readonly DependencyProperty PMCIsInstalledProperty = DependencyProperty.Register(
  50. "PMCIsInstalled", typeof(bool), typeof(SERobot));
  51. public bool PMCIsInstalled
  52. {
  53. get { return (bool)this.GetValue(PMCIsInstalledProperty); }
  54. set { SetValue(PMCIsInstalledProperty, value); }
  55. }
  56. public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(SERobot));
  57. public int Wafer { get => (int)GetValue(WaferProperty); set => SetValue(WaferProperty, value); }
  58. public static readonly DependencyProperty ExtendTimeProperty = DependencyProperty.Register("ExtendTime", typeof(KeyTime), typeof(SERobot), new PropertyMetadata(KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9))));
  59. public KeyTime ExtendTime { get => (KeyTime)GetValue(ExtendTimeProperty); set => SetValue(ExtendTimeProperty, value); }
  60. public static readonly DependencyProperty RobotWaferProperty = DependencyProperty.Register(
  61. "RobotWafer",
  62. typeof(WaferInfo),
  63. typeof(SERobot));
  64. public WaferInfo RobotWafer
  65. {
  66. get => (WaferInfo)GetValue(RobotWaferProperty);
  67. set => SetValue(RobotWaferProperty, value);
  68. }
  69. public static readonly DependencyProperty RobotXActionProperty = DependencyProperty.Register(
  70. "RobotXAction",
  71. typeof(SERobotXAction),
  72. typeof(SERobot),
  73. new PropertyMetadata(SERobotXAction.X_Origin, RobotXActionPropertyChangedCallback));
  74. public SERobotXAction RobotXAction
  75. {
  76. get => (SERobotXAction)GetValue(RobotXActionProperty);
  77. set => SetValue(RobotXActionProperty, value);
  78. }
  79. //RobotXAction依赖属性的值被改变之后此委托会被调用
  80. private static void RobotXActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  81. {
  82. //KeyTime value = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9));
  83. var control = d as SERobot; //d转换为SERobot
  84. var oldAct = (SERobotXAction)e.OldValue; //现在的位置
  85. var newAct = (SERobotXAction)e.NewValue; //下一个位置
  86. switch (newAct)
  87. {
  88. case SERobotXAction.X_Origin:
  89. VisualStateManager.GoToState(control, newAct.ToString(), true);
  90. break;
  91. case SERobotXAction.Extend:
  92. if (newAct != oldAct)
  93. {
  94. VisualStateManager.GoToState(control, newAct.ToString(), true);
  95. }
  96. break;
  97. case SERobotXAction.Retract:
  98. if (newAct != oldAct)
  99. {
  100. VisualStateManager.GoToState(control, newAct.ToString(), true);
  101. }
  102. break;
  103. case SERobotXAction.ToVCE:
  104. if (newAct != oldAct)
  105. {
  106. VisualStateManager.GoToState(control, newAct.ToString(), true);
  107. }
  108. break;
  109. case SERobotXAction.FromVCE:
  110. if (newAct != oldAct)
  111. {
  112. VisualStateManager.GoToState(control, newAct.ToString(), true);
  113. }
  114. break;
  115. case SERobotXAction.X_Origin2:
  116. VisualStateManager.GoToState(control, newAct.ToString(), true);
  117. break;
  118. case SERobotXAction.Extend2:
  119. if (newAct != oldAct)
  120. {
  121. VisualStateManager.GoToState(control, newAct.ToString(), true);
  122. }
  123. break;
  124. case SERobotXAction.Retract2:
  125. if (newAct != oldAct)
  126. {
  127. VisualStateManager.GoToState(control, newAct.ToString(), true);
  128. }
  129. break;
  130. case SERobotXAction.ToVCE2:
  131. if (newAct != oldAct)
  132. {
  133. VisualStateManager.GoToState(control, newAct.ToString(), true);
  134. }
  135. break;
  136. case SERobotXAction.FromVCE2:
  137. if (newAct != oldAct)
  138. {
  139. VisualStateManager.GoToState(control, newAct.ToString(), true);
  140. }
  141. break;
  142. case SERobotXAction.ToAligner:
  143. if (newAct != oldAct)
  144. {
  145. VisualStateManager.GoToState(control, newAct.ToString(), true);
  146. }
  147. break;
  148. case SERobotXAction.FromAligner:
  149. if (newAct != oldAct)
  150. {
  151. VisualStateManager.GoToState(control, newAct.ToString(), true);
  152. }
  153. break;
  154. case SERobotXAction.ToAligner2:
  155. if (newAct != oldAct)
  156. {
  157. VisualStateManager.GoToState(control, newAct.ToString(), true);
  158. }
  159. break;
  160. case SERobotXAction.FromAligner2:
  161. if (newAct != oldAct)
  162. {
  163. VisualStateManager.GoToState(control, newAct.ToString(), true);
  164. }
  165. break;
  166. default:
  167. break;
  168. }
  169. }
  170. public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register(
  171. "RobotTAction",
  172. typeof(SERobotTAction),
  173. typeof(SERobot),
  174. new PropertyMetadata(SERobotTAction.T_Origin, RobotTActionPropertyChangedCallback));
  175. public SERobotTAction RobotTAction
  176. {
  177. get => (SERobotTAction)GetValue(RobotTActionProperty);
  178. set => SetValue(RobotTActionProperty, value);
  179. }
  180. public static readonly DependencyProperty RobotSpeedProperty = DependencyProperty.Register(
  181. "RobotSpeed",
  182. typeof(double),
  183. typeof(SERobot),
  184. new PropertyMetadata(9.0d, RobotSpeedPropertyChangedCallback));
  185. public double RobotSpeed
  186. {
  187. get => (double)GetValue(RobotSpeedProperty);
  188. set => SetValue(RobotSpeedProperty, value);
  189. }
  190. private static void RobotSpeedPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  191. {
  192. }
  193. public string OriginX { get; set; }
  194. public string OriginT { get; set; }
  195. private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  196. {
  197. var control = d as SERobot;
  198. var oldAct = (SERobotTAction)e.OldValue;
  199. var newAct = (SERobotTAction)e.NewValue;
  200. //while (newAct.ToString() == "Aligner1" && !control.PMCIsInstalled)
  201. //{
  202. // newAct = SERobotTAction.VPARight;
  203. //}
  204. if (oldAct != newAct)
  205. {
  206. VisualStateManager.GoToState(control, newAct.ToString(), true);//前后动作不一致,改变控件状态
  207. }
  208. }
  209. public override void OnApplyTemplate()
  210. {
  211. base.OnApplyTemplate();
  212. VisualStateManager.GoToState(this, OriginX, true);
  213. //VisualStateManager.GoToState(this, SERobotXAction.X_Origin.ToString(), true);
  214. VisualStateManager.GoToState(this, OriginT, true);
  215. }
  216. }
  217. }