PufControl.xaml.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace CyberX8_Themes.UserControls
  17. {
  18. /// <summary>
  19. /// PufControl.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class PufControl : UserControl
  22. {
  23. public enum LoaderXLocation
  24. {
  25. Parker = 0,
  26. Efem = 1,
  27. Loader = 2
  28. }
  29. public enum LoaderRotation
  30. {
  31. Origin=0,
  32. Reverse = 1
  33. }
  34. public PufControl()
  35. {
  36. InitializeComponent();
  37. }
  38. public static readonly DependencyProperty RotateTransformValueProperty = DependencyProperty.Register("RotateTransformValue", typeof(int), typeof(PufControl));
  39. public int RotateTransformValue
  40. {
  41. get { return (int)this.GetValue(RotateTransformValueProperty); }
  42. set { this.SetValue(RotateTransformValueProperty, value); }
  43. }
  44. public static readonly DependencyProperty PufNameProperty = DependencyProperty.Register("PufName", typeof(string), typeof(PufControl));
  45. public string PufName
  46. {
  47. get { return this.GetValue(PufNameProperty).ToString(); }
  48. set { this.SetValue(PufNameProperty, value); }
  49. }
  50. public static readonly DependencyProperty RobotWaferAProperty = DependencyProperty.Register("RobotWaferA", typeof(WaferInfo), typeof(PufControl));
  51. public WaferInfo RobotWaferA
  52. {
  53. get => (WaferInfo)GetValue(RobotWaferAProperty);
  54. set => SetValue(RobotWaferAProperty, value);
  55. }
  56. public static readonly DependencyProperty RobotWaferBProperty = DependencyProperty.Register("RobotWaferB", typeof(WaferInfo), typeof(PufControl));
  57. public WaferInfo RobotWaferB
  58. {
  59. get => (WaferInfo)GetValue(RobotWaferBProperty);
  60. set => SetValue(RobotWaferBProperty, value);
  61. }
  62. //public static readonly DependencyProperty IsPufChangeProperty = DependencyProperty.Register("IsPufChange", typeof(bool), typeof(PufControl));
  63. //public bool IsPufChange
  64. //{
  65. // get => (bool)GetValue(IsPufChangeProperty);
  66. // set => SetValue(IsPufChangeProperty, value);
  67. //}
  68. /// <summary>
  69. /// Puf Roation UI 动画位置
  70. /// </summary>
  71. public static readonly DependencyProperty CurrentXLocationProperty = DependencyProperty.Register("CurrentXLocation", typeof(LoaderXLocation), typeof(PufControl),
  72. new PropertyMetadata(LoaderXLocation.Parker, PositionChangedCallback));
  73. public LoaderXLocation CurrentXLocation
  74. {
  75. get { return (LoaderXLocation)this.GetValue(CurrentXLocationProperty); }
  76. set
  77. {
  78. this.SetValue(CurrentXLocationProperty, value);
  79. }
  80. }
  81. /// <summary>
  82. /// Puf Flip UI 动画位置
  83. /// </summary>
  84. public static readonly DependencyProperty CurrentRotationProperty = DependencyProperty.Register("CurrentRotation", typeof(LoaderRotation), typeof(PufControl),
  85. new PropertyMetadata(LoaderRotation.Origin, RotationChangedCallback));
  86. public LoaderRotation CurrentRotation
  87. {
  88. get { return (LoaderRotation)this.GetValue(CurrentRotationProperty); }
  89. set
  90. {
  91. this.SetValue(CurrentRotationProperty, value);
  92. }
  93. }
  94. /// <summary>
  95. /// Puf Rotation UI位置
  96. /// </summary>
  97. public static readonly DependencyProperty PufRotationPositionProperty = DependencyProperty.Register("PufRotationPosition", typeof(double), typeof(PufControl),
  98. new PropertyMetadata((double)15));
  99. public double PufRotationPosition
  100. {
  101. get { return (double)this.GetValue(PufRotationPositionProperty); }
  102. set
  103. {
  104. this.SetValue(PufRotationPositionProperty, value);
  105. }
  106. }
  107. /// <summary>
  108. /// Puf Flip UI位置
  109. /// </summary>
  110. public static readonly DependencyProperty PufFlipPositionProperty = DependencyProperty.Register("PufFlipPosition", typeof(double), typeof(PufControl),
  111. new PropertyMetadata((double)15));
  112. public double PufFlipPosition
  113. {
  114. get { return (double)this.GetValue(PufFlipPositionProperty); }
  115. set
  116. {
  117. this.SetValue(PufFlipPositionProperty, value);
  118. }
  119. }
  120. private static void PositionChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  121. {
  122. var newAct = (LoaderXLocation)e.NewValue;
  123. var control = d as PufControl;
  124. GoToPosition(control, newAct);
  125. }
  126. private static void RotationChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  127. {
  128. var newAct = (LoaderRotation)e.NewValue;
  129. var control = d as PufControl;
  130. GoToRotation(control, newAct);
  131. }
  132. private static void GoToPosition(Control control, LoaderXLocation location)
  133. {
  134. VisualStateManager.GoToElementState(control, location.ToString(), false);
  135. }
  136. private static void GoToRotation(Control control, LoaderRotation rotation)
  137. {
  138. VisualStateManager.GoToElementState(control, rotation.ToString(), false);
  139. }
  140. }
  141. }