PunkRobotControl.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 RobotTActionProperty = DependencyProperty.Register(
  94. "RobotTAction",
  95. typeof(WaferRobotTAction),
  96. typeof(PunkRobotControl),
  97. new PropertyMetadata(WaferRobotTAction.T_Origin, RobotTActionPropertyChangedCallback));
  98. public WaferRobotTAction RobotTAction
  99. {
  100. get => (WaferRobotTAction)GetValue(RobotTActionProperty);
  101. set => SetValue(RobotTActionProperty, value);
  102. }
  103. private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  104. {
  105. var control = d as PunkRobotControl;
  106. var oldAct = (WaferRobotTAction)e.OldValue;
  107. var newAct = (WaferRobotTAction)e.NewValue;
  108. if (oldAct != newAct)
  109. {
  110. VisualStateManager.GoToState(control, newAct.ToString(), true);
  111. }
  112. }
  113. public string OriginT { get; set; }
  114. public override void OnApplyTemplate()
  115. {
  116. base.OnApplyTemplate();
  117. VisualStateManager.GoToState(this, WaferRobotXAction.X_Origin.ToString(), true);
  118. VisualStateManager.GoToState(this, OriginT, true);
  119. }
  120. }
  121. }