CustomRobot.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. using OpenSEMI.ClientBase;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Animation;
  10. namespace Venus_Themes.CustomControls
  11. {
  12. public class WaferIntToColorConverter : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  15. {
  16. return int.Parse(value.ToString()) == 1 ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Green);
  17. }
  18. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  19. {
  20. throw new NotImplementedException();
  21. }
  22. }
  23. public class WaferIntToVisibilityConverter : IValueConverter
  24. {
  25. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  26. {
  27. return int.Parse(value.ToString()) == 1 ? Visibility.Visible : Visibility.Hidden;
  28. }
  29. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  30. {
  31. throw new NotImplementedException();
  32. }
  33. }
  34. public enum WaferRobotXAction
  35. {
  36. X_Origin,
  37. Extend,
  38. Retract
  39. }
  40. public enum WaferRobotTAction
  41. {
  42. T_Origin,
  43. PMA,
  44. PMB,
  45. PMC,
  46. PMD,
  47. LLA,
  48. LLB,
  49. LP1,
  50. LP2,
  51. LP3,
  52. Aligner1,
  53. RightLocation,
  54. LeftLocation
  55. }
  56. public class WaferRobotControl : Control
  57. {
  58. static WaferRobotControl()
  59. {
  60. DefaultStyleKeyProperty.OverrideMetadata(typeof(WaferRobotControl), new FrameworkPropertyMetadata(typeof(WaferRobotControl)));
  61. }
  62. public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(WaferRobotControl));
  63. public int Wafer { get => (int)GetValue(WaferProperty); set => SetValue(WaferProperty, value); }
  64. public static readonly DependencyProperty ExtendTimeProperty = DependencyProperty.Register("ExtendTime", typeof(KeyTime), typeof(WaferRobotControl),new PropertyMetadata (KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9))));
  65. public KeyTime ExtendTime { get => (KeyTime)GetValue(ExtendTimeProperty); set => SetValue(ExtendTimeProperty, value); }
  66. public static readonly DependencyProperty RobotWaferProperty = DependencyProperty.Register(
  67. "RobotWafer",
  68. typeof(WaferInfo),
  69. typeof(WaferRobotControl));
  70. public WaferInfo RobotWafer
  71. {
  72. get => (WaferInfo)GetValue(RobotWaferProperty);
  73. set => SetValue(RobotWaferProperty, value);
  74. }
  75. public static readonly DependencyProperty RobotXActionProperty = DependencyProperty.Register(
  76. "RobotXAction",
  77. typeof(WaferRobotXAction),
  78. typeof(WaferRobotControl),
  79. new PropertyMetadata(WaferRobotXAction.X_Origin, RobotXActionPropertyChangedCallback));
  80. public WaferRobotXAction RobotXAction
  81. {
  82. get => (WaferRobotXAction)GetValue(RobotXActionProperty);
  83. set => SetValue(RobotXActionProperty, value);
  84. }
  85. private static void RobotXActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  86. {
  87. //KeyTime value = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9));
  88. var control = d as WaferRobotControl;
  89. var oldAct = (WaferRobotXAction)e.OldValue;
  90. var newAct = (WaferRobotXAction)e.NewValue;
  91. switch (newAct)
  92. {
  93. case WaferRobotXAction.X_Origin:
  94. VisualStateManager.GoToState(control, newAct.ToString(), true);
  95. break;
  96. case WaferRobotXAction.Extend:
  97. if (newAct != oldAct)
  98. {
  99. VisualStateManager.GoToState(control, newAct.ToString(), true);
  100. }
  101. break;
  102. case WaferRobotXAction.Retract:
  103. if (newAct != oldAct)
  104. {
  105. VisualStateManager.GoToState(control, newAct.ToString(), true);
  106. }
  107. break;
  108. default:
  109. break;
  110. }
  111. }
  112. public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register(
  113. "RobotTAction",
  114. typeof(WaferRobotTAction),
  115. typeof(WaferRobotControl),
  116. new PropertyMetadata(WaferRobotTAction.T_Origin, RobotTActionPropertyChangedCallback));
  117. public WaferRobotTAction RobotTAction
  118. {
  119. get => (WaferRobotTAction)GetValue(RobotTActionProperty);
  120. set => SetValue(RobotTActionProperty, value);
  121. }
  122. public static readonly DependencyProperty RobotSpeedProperty = DependencyProperty.Register(
  123. "RobotSpeed",
  124. typeof(double),
  125. typeof(WaferRobotControl),
  126. new PropertyMetadata(9.0d, RobotSpeedPropertyChangedCallback));
  127. public double RobotSpeed
  128. {
  129. get => (double)GetValue(RobotSpeedProperty);
  130. set => SetValue(RobotSpeedProperty, value);
  131. }
  132. private static void RobotSpeedPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  133. {
  134. }
  135. public string OriginT { get; set; }
  136. private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  137. {
  138. var control = d as WaferRobotControl;
  139. var oldAct = (WaferRobotTAction)e.OldValue;
  140. var newAct = (WaferRobotTAction)e.NewValue;
  141. if(oldAct!=newAct)
  142. {
  143. VisualStateManager.GoToState(control, newAct.ToString(), true);
  144. }
  145. }
  146. public override void OnApplyTemplate()
  147. {
  148. base.OnApplyTemplate();
  149. VisualStateManager.GoToState(this, WaferRobotXAction.X_Origin.ToString(), true);
  150. VisualStateManager.GoToState(this, OriginT, true);
  151. }
  152. }
  153. }