GuangChuanRobot.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using OpenSEMI.ClientBase;
  2. using System;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Media.Animation;
  6. namespace Venus_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.Retract:
  55. if (newAct != oldAct)
  56. {
  57. VisualStateManager.GoToState(control, newAct.ToString(), true);
  58. }
  59. break;
  60. default:
  61. break;
  62. }
  63. }
  64. public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register(
  65. "RobotTAction",
  66. typeof(WaferRobotTAction),
  67. typeof(GuangChuanRobotControl),
  68. new PropertyMetadata(WaferRobotTAction.T_Origin, RobotTActionPropertyChangedCallback));
  69. public WaferRobotTAction RobotTAction
  70. {
  71. get => (WaferRobotTAction)GetValue(RobotTActionProperty);
  72. set => SetValue(RobotTActionProperty, value);
  73. }
  74. public string OriginT { get; set; }
  75. private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  76. {
  77. var control = d as GuangChuanRobotControl;
  78. var oldAct = (WaferRobotTAction)e.OldValue;
  79. var newAct = (WaferRobotTAction)e.NewValue;
  80. if(oldAct!=newAct)
  81. {
  82. VisualStateManager.GoToState(control, newAct.ToString(), true);
  83. }
  84. }
  85. public override void OnApplyTemplate()
  86. {
  87. base.OnApplyTemplate();
  88. VisualStateManager.GoToState(this, WaferRobotXAction.X_Origin.ToString(), true);
  89. VisualStateManager.GoToState(this, OriginT, true);
  90. }
  91. }
  92. }