SusceptorControl.xaml.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using Aitex.Core.Equipment.SusceptorDefine;
  15. using Aitex.Core.Util;
  16. namespace Aitex.Core.UI.Control
  17. {
  18. /// <summary>
  19. /// Interaction logic for SusceptorControl.xaml
  20. /// </summary>
  21. public partial class SusceptorControl : UserControl
  22. {
  23. public WaferType DefaultWaferType { get; set; }
  24. Susceptor _susceptorInfo;
  25. bool _isShining = false;
  26. public SusceptorControl()
  27. {
  28. InitializeComponent();
  29. }
  30. public static readonly DependencyProperty SusceptorInfoProperty = DependencyProperty.Register(
  31. "SusceptorInfo", typeof(Susceptor), typeof(SusceptorControl),
  32. new FrameworkPropertyMetadata(new Susceptor(), FrameworkPropertyMetadataOptions.AffectsRender));
  33. public Susceptor SusceptorInfo
  34. {
  35. get
  36. {
  37. return (Susceptor)GetValue(SusceptorInfoProperty);
  38. }
  39. set
  40. {
  41. SetValue(SusceptorInfoProperty, value);
  42. }
  43. }
  44. public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(
  45. "IsActive", typeof(bool), typeof(SusceptorControl),
  46. new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  47. public bool IsActive
  48. {
  49. get
  50. {
  51. return (bool)GetValue(IsActiveProperty);
  52. }
  53. set
  54. {
  55. SetValue(IsActiveProperty, value);
  56. }
  57. }
  58. public static readonly DependencyProperty IsReadonlyProperty = DependencyProperty.Register(
  59. "IsReadonly", typeof(Boolean), typeof(SusceptorControl),
  60. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
  61. public bool IsReadonly
  62. {
  63. get
  64. {
  65. return (bool)GetValue(IsReadonlyProperty);
  66. }
  67. set
  68. {
  69. SetValue(IsReadonlyProperty, value);
  70. }
  71. }
  72. public void StartShining(SolidColorBrush brush, bool isShining)
  73. {
  74. if (layout.Children != null && layout.Children.Count > 0)
  75. {
  76. ((Ellipse)layout.Children[0]).Fill = brush;
  77. }
  78. _isShining = isShining;
  79. }
  80. public void UpdateWaferType(WaferType waferType)
  81. {
  82. for (int i = 0; i < SusceptorInfo.WaferTypeArray.Length && i < SusceptorInfo.Config.Notches.Count; i++)
  83. {
  84. if (SusceptorInfo.WaferTypeArray[i] != WaferType.Empty)
  85. SusceptorInfo.WaferTypeArray[i] = waferType;
  86. }
  87. for (int i = 1; i < layout.Children.Count; i++)
  88. {
  89. SusceptorNotchControl control = layout.Children[i] as SusceptorNotchControl;
  90. control.CurrentWaferType = SusceptorInfo.WaferTypeArray[control.Index-1];
  91. control.Update();
  92. }
  93. DefaultWaferType = waferType;
  94. }
  95. public void SetAllHasWafer()
  96. {
  97. for (int i = 0; i < SusceptorInfo.WaferTypeArray.Length && i<SusceptorInfo.Config.Notches.Count; i++)
  98. {
  99. SusceptorInfo.WaferTypeArray[i] = DefaultWaferType;
  100. }
  101. for (int i = 1; i < layout.Children.Count; i++)
  102. {
  103. SusceptorNotchControl control = layout.Children[i] as SusceptorNotchControl;
  104. control.CurrentWaferType = SusceptorInfo.WaferTypeArray[control.Index-1];
  105. control.Update();
  106. }
  107. }
  108. public void SetAllNoWafer()
  109. {
  110. for (int i = 0; i < SusceptorInfo.WaferTypeArray.Length && i < SusceptorInfo.Config.Notches.Count; i++)
  111. {
  112. SusceptorInfo.WaferTypeArray[i] = WaferType.Empty;
  113. }
  114. for (int i = 1; i < layout.Children.Count; i++)
  115. {
  116. SusceptorNotchControl control = layout.Children[i] as SusceptorNotchControl;
  117. control.CurrentWaferType = SusceptorInfo.WaferTypeArray[control.Index-1];
  118. control.Update();
  119. }
  120. }
  121. public void RevertWaferType()
  122. {
  123. for (int i = 0; i < SusceptorInfo.WaferTypeArray.Length && i < SusceptorInfo.Config.Notches.Count; i++)
  124. {
  125. SusceptorInfo.WaferTypeArray[i] = SusceptorInfo.WaferTypeArray[i] == WaferType.Empty ? DefaultWaferType : WaferType.Empty;
  126. }
  127. for (int i = 1; i < layout.Children.Count; i++)
  128. {
  129. SusceptorNotchControl control = layout.Children[i] as SusceptorNotchControl;
  130. control.CurrentWaferType = SusceptorInfo.WaferTypeArray[control.Index-1];
  131. control.Update();
  132. }
  133. }
  134. protected override void OnRender(DrawingContext drawingContext)
  135. {
  136. if (SusceptorInfo == null || SusceptorInfo.Id.Equals(Guid.Empty) || SusceptorInfo.Config == null)
  137. {
  138. layout.Children.Clear();
  139. _susceptorInfo = null;
  140. }
  141. else
  142. {
  143. if (_susceptorInfo == null || _susceptorInfo.Type != SusceptorInfo.Type)
  144. {
  145. layout.Children.Clear();
  146. DrawContour();
  147. DrawNotchControls();
  148. _susceptorInfo = SusceptorInfo;
  149. }
  150. Update();
  151. layout.Width = _susceptorInfo.Config.Diameter;
  152. layout.Height = _susceptorInfo.Config.Diameter;
  153. }
  154. if (!IsReadonly)
  155. {
  156. for (int i = 1; i < layout.Children.Count; i++)
  157. {
  158. (layout.Children[i] as SusceptorNotchControl).IsReadonly = false;
  159. }
  160. }
  161. }
  162. void Update()
  163. {
  164. for (int i = 1; i < layout.Children.Count; i++)
  165. {
  166. SusceptorNotchControl control = layout.Children[i] as SusceptorNotchControl;
  167. control.CurrentWaferType = SusceptorInfo.WaferTypeArray[control.Index-1];
  168. control.CurrentSusceptorStatus = SusceptorInfo.Status;
  169. control.Update();
  170. }
  171. if (!_isShining && layout.Children.Count > 0 && layout.Children[0].GetType() == typeof(Ellipse))
  172. {
  173. Ellipse ellipse = layout.Children[0] as Ellipse;
  174. ellipse.Fill = (SusceptorInfo == null || SusceptorInfo.Status <= SusceptorStatus.Unprocessed) ? SusceptorBrush.BackgroundBrush : SusceptorBrush.GetBrush(SusceptorInfo.Status);
  175. }
  176. }
  177. void DrawContour()
  178. {
  179. Ellipse contourEllipse = new Ellipse()
  180. {
  181. Fill = (SusceptorInfo == null || SusceptorInfo.Status <= SusceptorStatus.Unprocessed) ? SusceptorBrush.BackgroundBrush : SusceptorBrush.GetBrush(SusceptorInfo.Status),
  182. Stroke = SusceptorBrush.StrokeBrush,
  183. Width = SusceptorInfo.Config.Diameter,
  184. Height = SusceptorInfo.Config.Diameter,
  185. Opacity = 1,
  186. };
  187. layout.Children.Add(contourEllipse);
  188. }
  189. void DrawNotchControls()
  190. {
  191. double diameter = SusceptorInfo.Config.NotchDiameter;
  192. foreach (var notch in SusceptorInfo.Config.Notches)
  193. {
  194. double x = notch.X;
  195. double y = notch.Y;
  196. SusceptorNotchControl container = new SusceptorNotchControl()
  197. {
  198. Width = diameter,
  199. Height = diameter,
  200. Index = notch.Index,
  201. DisplayIndex = notch.DisplayIndex,
  202. IsActive = IsActive,
  203. IsReadonly = IsReadonly,
  204. MouseDownCallback = (nc, isShiftDown) =>
  205. {
  206. if (nc.CurrentWaferType == WaferType.Empty)
  207. {
  208. nc.CurrentWaferType = DefaultWaferType;
  209. if (isShiftDown)
  210. nc.CurrentWaferStatus = WaferStatus.Dummy;
  211. SusceptorInfo.WaferTypeArray[nc.Index-1] = DefaultWaferType;
  212. }
  213. else
  214. {
  215. nc.CurrentWaferType = WaferType.Empty;
  216. nc.CurrentWaferStatus = WaferStatus.Normal;
  217. SusceptorInfo.WaferTypeArray[nc.Index-1] = WaferType.Empty;
  218. }
  219. },
  220. };
  221. container.SetValue(Canvas.LeftProperty, y + SusceptorInfo.Config.Diameter / 2 - SusceptorInfo.Config.NotchDiameter / 2);
  222. container.SetValue(Canvas.TopProperty, x + SusceptorInfo.Config.Diameter / 2 - SusceptorInfo.Config.NotchDiameter / 2);
  223. layout.Children.Add(container);
  224. }
  225. }
  226. }
  227. }