WaferPro.xaml.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.SCCore;
  3. using Aitex.Core.UI.MVVM;
  4. using Aitex.Sorter.Common;
  5. using MECF.Framework.Common.OperationCenter;
  6. using System;
  7. using System.ComponentModel;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Input;
  11. using MECF.Framework.Common.Equipment;
  12. namespace Aitex.Sorter.UI.Controls
  13. {
  14. /// <summary>
  15. /// Wafer.xaml 的交互逻辑
  16. /// </summary>
  17. public partial class WaferPro : UserControl
  18. {
  19. public bool IsEnableTextMenu1
  20. {
  21. get { return (bool)GetValue(IsEnableTextMenu1Property); }
  22. set { SetValue(IsEnableTextMenu1Property, value); }
  23. }
  24. // Using a DependencyProperty as the backing store for IsEnableTextMenu. This enables animation, styling, binding, etc...
  25. public static readonly DependencyProperty IsEnableTextMenu1Property =
  26. DependencyProperty.Register("IsEnableTextMenu1", typeof(bool), typeof(WaferPro), new PropertyMetadata(true));
  27. public static readonly DependencyProperty WaferItemProperty = DependencyProperty.Register(
  28. "WaferItem", typeof(WaferInfo), typeof(WaferPro),
  29. new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  30. public WaferInfo WaferItem
  31. {
  32. get
  33. {
  34. return (WaferInfo)GetValue(WaferItemProperty);
  35. }
  36. set
  37. {
  38. SetValue(WaferItemProperty, value);
  39. }
  40. }
  41. public int Slot
  42. {
  43. get { return (int)GetValue(SlotProperty); }
  44. set { SetValue(SlotProperty, value); }
  45. }
  46. // Using a DependencyProperty as the backing store for Slot. This enables animation, styling, binding, etc...
  47. public static readonly DependencyProperty SlotProperty =
  48. DependencyProperty.Register("Slot", typeof(int), typeof(WaferPro), new PropertyMetadata(-1));
  49. public ModuleName Station
  50. {
  51. get { return (ModuleName)GetValue(StationProperty); }
  52. set { SetValue(StationProperty, value); }
  53. }
  54. // Using a DependencyProperty as the backing store for Station. This enables animation, styling, binding, etc...
  55. public static readonly DependencyProperty StationProperty =
  56. DependencyProperty.Register("Station", typeof(ModuleName), typeof(WaferPro), new PropertyMetadata(ModuleName.System));
  57. public ICommand WaferTransferCommand
  58. {
  59. get { return (ICommand)GetValue(WaferTransferCommandProperty); }
  60. set { SetValue(WaferTransferCommandProperty, value); }
  61. }
  62. public bool ShowSlot
  63. {
  64. get { return (bool)GetValue(ShowSlotProperty); }
  65. set { SetValue(ShowSlotProperty, value); }
  66. }
  67. // Using a DependencyProperty as the backing store for ShowSlot. This enables animation, styling, binding, etc...
  68. public static readonly DependencyProperty ShowSlotProperty =
  69. DependencyProperty.Register("ShowSlot", typeof(bool), typeof(WaferPro), new PropertyMetadata(false));
  70. public bool ShowControl
  71. {
  72. get { return (bool)GetValue(ShowControlProperty); }
  73. set
  74. {
  75. SetValue(ShowControlProperty, value);
  76. }
  77. }
  78. public static readonly DependencyProperty ShowControlProperty =
  79. DependencyProperty.Register("ShowControl", typeof(bool), typeof(WaferPro), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.None));
  80. public Visibility ShowSlotIndex
  81. {
  82. get { return (Visibility)GetValue(ShowSlotIndexProperty); }
  83. set { SetValue(ShowSlotIndexProperty, value); }
  84. }
  85. // Using a DependencyProperty as the backing store for ShowSlot. This enables animation, styling, binding, etc...
  86. public static readonly DependencyProperty ShowSlotIndexProperty =
  87. DependencyProperty.Register("ShowSlotIndex", typeof(Visibility), typeof(WaferPro), new PropertyMetadata(Visibility.Hidden));
  88. // Using a DependencyProperty as the backing store for WaferMovementCommand. This enables animation, styling, binding, etc...
  89. public static readonly DependencyProperty WaferTransferCommandProperty =
  90. DependencyProperty.Register("WaferTransferCommand", typeof(ICommand), typeof(WaferPro), new PropertyMetadata(null));
  91. public WaferDisplayMode WaferIDDisplayMode
  92. {
  93. get { return (WaferDisplayMode)GetValue(WaferDisplayModeProperty); }
  94. set { SetValue(WaferDisplayModeProperty, value); }
  95. }
  96. // Using a DependencyProperty as the backing store for WaferIDDisplayMode. This enables animation, styling, binding, etc...
  97. public static readonly DependencyProperty WaferDisplayModeProperty =
  98. DependencyProperty.Register("WaferIDDisplayMode", typeof(WaferDisplayMode), typeof(WaferPro), new PropertyMetadata(WaferDisplayMode.None));
  99. public ICommand WaferTransferOptionCommand
  100. {
  101. get { return (ICommand)GetValue(WaferTransferOptionCommandProperty); }
  102. set { SetValue(WaferTransferOptionCommandProperty, value); }
  103. }
  104. // Using a DependencyProperty as the backing store for WaferTransferOptionCommand. This enables animation, styling, binding, etc...
  105. public static readonly DependencyProperty WaferTransferOptionCommandProperty =
  106. DependencyProperty.Register("WaferTransferOptionCommand", typeof(ICommand), typeof(WaferPro), new PropertyMetadata(null));
  107. public ICommand CreateDeleteWaferCommand
  108. {
  109. get { return (ICommand)GetValue(CreateDeleteWaferCommandProperty); }
  110. set { SetValue(CreateDeleteWaferCommandProperty, value); }
  111. }
  112. // Using a DependencyProperty as the backing store for CreateDeleteWaferCommand. This enables animation, styling, binding, etc...
  113. public static readonly DependencyProperty CreateDeleteWaferCommandProperty =
  114. DependencyProperty.Register("CreateDeleteWaferCommand", typeof(ICommand), typeof(WaferPro), new PropertyMetadata(null));
  115. private WaferStyle waferStyle = WaferStyle.Rect;
  116. public WaferStyle WaferStyle
  117. {
  118. get
  119. {
  120. return waferStyle;
  121. }
  122. set
  123. {
  124. waferStyle = value;
  125. }
  126. }
  127. public WaferPro()
  128. {
  129. InitializeComponent();
  130. CreateDeleteWaferCommand = new DelegateCommand<string>(CreateDeleteWafer);
  131. root.DataContext = this;
  132. }
  133. private void PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
  134. {
  135. e.Handled = IsEnableTextMenu1 ? false : true;
  136. }
  137. private void Wafer_MouseMove(object sender, MouseEventArgs e)
  138. {
  139. if (WaferItem == null || !ShowSlot)
  140. {
  141. return;
  142. }
  143. //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
  144. //{ return; }
  145. if (e.LeftButton == MouseButtonState.Pressed && (WaferItem.Status == WaferStatus.Normal || WaferItem.Status == WaferStatus.Dummy) && !WaferItem.IsSource)
  146. {
  147. var data = new DataObject();
  148. data.SetData("Object", WaferItem);
  149. data.SetData("Station", Station);
  150. data.SetData("Slot", Slot);
  151. DragDrop.DoDragDrop(sender as DependencyObject,
  152. data,
  153. DragDropEffects.Copy | DragDropEffects.Move);
  154. }
  155. }
  156. private void Wafer_Drop(object sender, DragEventArgs e)
  157. {
  158. //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
  159. //{ return; }
  160. if (sender != null)
  161. {
  162. var target = (Border)sender;
  163. target.BorderThickness = new Thickness(0);
  164. if (target.ToolTip as ToolTip != null)
  165. ((ToolTip)target.ToolTip).IsOpen = false;
  166. var sourceWafer = (WaferInfo)e.Data.GetData("Object");
  167. var sourceStation = (ModuleName)e.Data.GetData("Station");
  168. var sourceSlot = (int)e.Data.GetData("Slot");
  169. if (sourceWafer == null)
  170. {
  171. return;
  172. }
  173. if (sourceStation == ModuleName.Robot && Station == ModuleName.Robot)
  174. {
  175. return;
  176. }
  177. WaferTransferOption transferOption = null;
  178. if (WaferTransferOptionCommand != null)
  179. {
  180. transferOption = new WaferTransferOption();
  181. WaferTransferOptionCommand.Execute(transferOption);
  182. }
  183. //if (sourceWafer.SubstE90Status == EnumE90Status.InProcess || sourceWafer.SubstE90Status== EnumE90Status.NeedProcessing)
  184. //{
  185. // return;
  186. //}
  187. var dialog = new WaferTransferDialog(sourceWafer, sourceStation, sourceSlot, Station, Slot, transferOption);
  188. //dialog.SetControlShow(ShowControl);
  189. dialog.Owner = Window.GetWindow(this);
  190. if (dialog.ShowDialog() == true)
  191. {
  192. if (sourceWafer.Status == WaferStatus.Empty)
  193. {
  194. if (WaferTransferCommand != null)
  195. {
  196. WaferTransferCommand.Execute(new SorterRecipeTransferTableItem
  197. {
  198. SourceStation = sourceStation,
  199. SourceSlot = sourceSlot,
  200. DestinationStation = Station,
  201. DestinationSlot = Slot,
  202. IsAlign = dialog.Aligner,
  203. IsTurnOver = dialog.TurnOver,
  204. IsReadLaserMarker = dialog.ReadLaserMarker,
  205. IsReadT7Code = dialog.ReadT7Code,
  206. AlignAngle = dialog.AlignerAngle
  207. });
  208. }
  209. }
  210. else
  211. {
  212. if (WaferTransferCommand != null)
  213. {
  214. WaferTransferCommand.Execute(new SorterRecipeTransferTableItem
  215. {
  216. SourceStation = sourceStation,
  217. SourceSlot = sourceSlot,
  218. DestinationStation = Station,
  219. DestinationSlot = Slot,
  220. IsAlign = dialog.Aligner,
  221. IsTurnOver = dialog.TurnOver,
  222. IsReadLaserMarker = dialog.ReadLaserMarker,
  223. IsReadT7Code = dialog.ReadT7Code,
  224. AlignAngle = dialog.AlignerAngle
  225. });
  226. }
  227. else
  228. {
  229. var moveType = MoveType.Move;
  230. MoveOption moveOption = 0;
  231. if (dialog.Aligner)
  232. {
  233. moveOption |= MoveOption.Align;
  234. }
  235. if (dialog.TurnOver)
  236. {
  237. moveOption |= MoveOption.Turnover;
  238. }
  239. if (dialog.ReadLaserMarker)
  240. {
  241. moveOption |= MoveOption.ReadID;
  242. }
  243. if (dialog.ReadT7Code)
  244. {
  245. moveOption |= MoveOption.ReadID2;
  246. }
  247. var hand = (Hand)dialog.Blade;
  248. object[] param;
  249. if (hand == Hand.Both)
  250. {
  251. param = new object[]
  252. {
  253. moveType,
  254. moveOption,
  255. hand,
  256. sourceStation,
  257. sourceSlot,
  258. Station,
  259. Slot
  260. };
  261. InvokeClient.Instance.Service.DoOperation(OperationName.MultiMoveWafer, param);
  262. }
  263. else
  264. {
  265. param = new object[]
  266. {
  267. moveType,
  268. moveOption,
  269. hand,
  270. sourceStation,
  271. sourceSlot,
  272. Station,
  273. Slot
  274. };
  275. InvokeClient.Instance.Service.DoOperation(OperationName.MoveWafer.ToString(), param);
  276. }
  277. }
  278. }
  279. }
  280. }
  281. }
  282. private void CreateDeleteWafer(string cmd)
  283. {
  284. var param = new object[] { Station, Slot, WaferStatus.Normal };
  285. InvokeClient.Instance.Service.DoOperation(cmd, param);
  286. }
  287. private void Border_DragOver(object sender, DragEventArgs e)
  288. {
  289. //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
  290. //{ return; }
  291. var sourceWafer = (WaferInfo)e.Data.GetData("Object");
  292. var sourceStation = (ModuleName)e.Data.GetData("Station");
  293. var sourceSlot = (int)e.Data.GetData("Slot");
  294. if (!(sourceStation == Station && sourceSlot == Slot))
  295. {
  296. var target = (Border)sender;
  297. target.BorderThickness = new Thickness(1);
  298. ((ToolTip)target.ToolTip).Content = Slot + 1;
  299. ((ToolTip)target.ToolTip).IsOpen = true;
  300. }
  301. }
  302. private void Border_DragLeave(object sender, DragEventArgs e)
  303. {
  304. //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
  305. //{ return; }
  306. var sourceWafer = (WaferInfo)e.Data.GetData("Object");
  307. var sourceStation = (ModuleName)e.Data.GetData("Station");
  308. var sourceSlot = (int)e.Data.GetData("Slot");
  309. if (!(sourceStation == Station && sourceSlot == Slot))
  310. {
  311. var target = (Border)sender;
  312. target.BorderThickness = new Thickness(0);
  313. ((ToolTip)target.ToolTip).IsOpen = false;
  314. }
  315. }
  316. }
  317. }