GuangChuanRobot.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using OpenSEMI.ClientBase;
  2. using System;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Media.Animation;
  6. namespace CyberX8_Themes.CustomControls
  7. {
  8. public class GuangChuanRobotControl : Control
  9. {
  10. static GuangChuanRobotControl()
  11. {
  12. DefaultStyleKeyProperty.OverrideMetadata(typeof(GuangChuanRobotControl), new FrameworkPropertyMetadata(typeof(GuangChuanRobotControl)));
  13. }
  14. public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(GuangChuanRobotControl));
  15. public int Wafer { get => (int)GetValue(WaferProperty); set => SetValue(WaferProperty, value); }
  16. public static readonly DependencyProperty ExtendTimeProperty = DependencyProperty.Register("ExtendTime", typeof(KeyTime), typeof(GuangChuanRobotControl),new PropertyMetadata (KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9))));
  17. public KeyTime ExtendTime { get => (KeyTime)GetValue(ExtendTimeProperty); set => SetValue(ExtendTimeProperty, value); }
  18. public static readonly DependencyProperty RobotWaferProperty = DependencyProperty.Register(
  19. "RobotWafer",
  20. typeof(WaferInfo),
  21. typeof(GuangChuanRobotControl));
  22. public WaferInfo RobotWafer
  23. {
  24. get => (WaferInfo)GetValue(RobotWaferProperty);
  25. set => SetValue(RobotWaferProperty, value);
  26. }
  27. public static readonly DependencyProperty RobotXActionProperty = DependencyProperty.Register(
  28. "RobotXAction",
  29. typeof(WaferRobotXAction),
  30. typeof(GuangChuanRobotControl),
  31. new PropertyMetadata(WaferRobotXAction.X_Origin, RobotXActionPropertyChangedCallback));
  32. public WaferRobotXAction RobotXAction
  33. {
  34. get => (WaferRobotXAction)GetValue(RobotXActionProperty);
  35. set => SetValue(RobotXActionProperty, value);
  36. }
  37. private static void RobotXActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  38. {
  39. //KeyTime value = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9));
  40. var control = d as GuangChuanRobotControl;
  41. var oldAct = (WaferRobotXAction)e.OldValue;
  42. var newAct = (WaferRobotXAction)e.NewValue;
  43. switch (newAct)
  44. {
  45. case WaferRobotXAction.X_Origin:
  46. VisualStateManager.GoToState(control, newAct.ToString(), true);
  47. break;
  48. case WaferRobotXAction.Extend:
  49. if (newAct != oldAct)
  50. {
  51. VisualStateManager.GoToState(control, newAct.ToString(), true);
  52. }
  53. break;
  54. case WaferRobotXAction.Extend2:
  55. if (newAct != oldAct)
  56. {
  57. VisualStateManager.GoToState(control, newAct.ToString(), true);
  58. }
  59. break;
  60. case WaferRobotXAction.Retract2:
  61. if (newAct != oldAct)
  62. {
  63. VisualStateManager.GoToState(control, newAct.ToString(), true);
  64. }
  65. break;
  66. case WaferRobotXAction.Retract:
  67. if (newAct != oldAct)
  68. {
  69. VisualStateManager.GoToState(control, newAct.ToString(), true);
  70. }
  71. break;
  72. default:
  73. break;
  74. }
  75. }
  76. public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register(
  77. "RobotTAction",
  78. typeof(WaferRobotTAction),
  79. typeof(GuangChuanRobotControl),
  80. new PropertyMetadata(WaferRobotTAction.T_Origin, RobotTActionPropertyChangedCallback));
  81. public WaferRobotTAction RobotTAction
  82. {
  83. get => (WaferRobotTAction)GetValue(RobotTActionProperty);
  84. set => SetValue(RobotTActionProperty, value);
  85. }
  86. public string OriginT { get; set; }
  87. private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  88. {
  89. var control = d as GuangChuanRobotControl;
  90. var oldAct = (WaferRobotTAction)e.OldValue;
  91. var newAct = (WaferRobotTAction)e.NewValue;
  92. if(oldAct!=newAct)
  93. {
  94. VisualStateManager.GoToState(control, newAct.ToString(), true);
  95. }
  96. }
  97. public override void OnApplyTemplate()
  98. {
  99. base.OnApplyTemplate();
  100. VisualStateManager.GoToState(this, WaferRobotXAction.X_Origin.ToString(), true);
  101. VisualStateManager.GoToState(this, OriginT, true);
  102. }
  103. }
  104. }