FoupItemPro.xaml.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. using Aitex.Sorter.Common;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Globalization;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. using MECF.Framework.Common.Equipment;
  19. using Aitex.Core.Common;
  20. namespace Aitex.Sorter.UI.Controls
  21. {
  22. /// <summary>
  23. /// Foup6.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class FoupItemPro : UserControl
  26. {
  27. public FoupItemPro()
  28. {
  29. InitializeComponent();
  30. root.DataContext = this;
  31. Slot.DataContext = this;
  32. }
  33. public static readonly DependencyProperty SlotsProperty = DependencyProperty.Register(
  34. "Slots", typeof(IEnumerable), typeof(FoupItemPro),
  35. new FrameworkPropertyMetadata(null));
  36. public Visibility ShowSlotsIndex
  37. {
  38. get { return (Visibility)GetValue(ShowSlotsIndexProperty); }
  39. set { SetValue(ShowSlotsIndexProperty, value); }
  40. }
  41. public static readonly DependencyProperty ShowSlotsIndexProperty =
  42. DependencyProperty.Register("ShowSlotsIndex", typeof(Visibility), typeof(FoupItemPro), new PropertyMetadata(Visibility.Collapsed));
  43. public int FoupCount
  44. {
  45. get { return (int)GetValue(FoupCountProperty); }
  46. set { SetValue(FoupCountProperty, value); }
  47. }
  48. public static readonly DependencyProperty FoupCountProperty =
  49. DependencyProperty.Register("FoupCount", typeof(int), typeof(FoupItemPro), new PropertyMetadata(8));
  50. public bool ShowControl
  51. {
  52. get { return (bool)GetValue(ShowControlProperty); }
  53. set
  54. {
  55. SetValue(ShowControlProperty, value);
  56. }
  57. }
  58. public static readonly DependencyProperty ShowControlProperty =
  59. DependencyProperty.Register("ShowControl", typeof(bool), typeof(FoupItemPro), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.None));
  60. public IEnumerable Slots
  61. {
  62. get
  63. {
  64. return (IEnumerable)GetValue(SlotsProperty);
  65. }
  66. set
  67. {
  68. SetValue(SlotsProperty, value);
  69. }
  70. }
  71. public int SlotCount
  72. {
  73. get { return (int)GetValue(SlotCountProperty); }
  74. set { SetValue(SlotCountProperty, value); }
  75. }
  76. // Using a DependencyProperty as the backing store for SlotCount. This enables animation, styling, binding, etc...
  77. public static readonly DependencyProperty SlotCountProperty =
  78. DependencyProperty.Register("SlotCount", typeof(int), typeof(FoupItemPro), new PropertyMetadata(25));
  79. public ModuleName Station
  80. {
  81. get { return (ModuleName)GetValue(StationProperty); }
  82. set { SetValue(StationProperty, value); }
  83. }
  84. // Using a DependencyProperty as the backing store for Station. This enables animation, styling, binding, etc...
  85. public static readonly DependencyProperty StationProperty =
  86. DependencyProperty.Register("Station", typeof(ModuleName), typeof(FoupItemPro), new PropertyMetadata(ModuleName.System));
  87. public string Title
  88. {
  89. get { return (string)GetValue(TitleProperty); }
  90. set { SetValue(TitleProperty, value); }
  91. }
  92. // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc...
  93. public static readonly DependencyProperty TitleProperty =
  94. DependencyProperty.Register("Title", typeof(string), typeof(FoupItemPro), new PropertyMetadata(null));
  95. public ICommand WaferTransferCommand
  96. {
  97. get { return (ICommand)GetValue(WaferTransferCommandProperty); }
  98. set { SetValue(WaferTransferCommandProperty, value); }
  99. }
  100. // Using a DependencyProperty as the backing store for WaferMovementCommand. This enables animation, styling, binding, etc...
  101. public static readonly DependencyProperty WaferTransferCommandProperty =
  102. DependencyProperty.Register("WaferTransferCommand", typeof(ICommand), typeof(FoupItemPro), new PropertyMetadata(null));
  103. public ICommand WaferTransferOptionCommand
  104. {
  105. get { return (ICommand)GetValue(WaferTransferOptionCommandProperty); }
  106. set { SetValue(WaferTransferOptionCommandProperty, value); }
  107. }
  108. // Using a DependencyProperty as the backing store for WaferTransferOptionCommand. This enables animation, styling, binding, etc...
  109. public static readonly DependencyProperty WaferTransferOptionCommandProperty =
  110. DependencyProperty.Register("WaferTransferOptionCommand", typeof(ICommand), typeof(FoupItemPro), new PropertyMetadata(null));
  111. public LoadPortCarrierMode CarrierMode
  112. {
  113. get { return (LoadPortCarrierMode)GetValue(CarrierModeProperty); }
  114. set { SetValue(CarrierModeProperty, value); }
  115. }
  116. // Using a DependencyProperty as the backing store for CarrierMode. This enables animation, styling, binding, etc...
  117. public static readonly DependencyProperty CarrierModeProperty =
  118. DependencyProperty.Register("CarrierMode", typeof(LoadPortCarrierMode), typeof(FoupItemPro), new PropertyMetadata(LoadPortCarrierMode.Both));
  119. public bool FristChick { get; set; } = true;
  120. private WaferPro fristwafer;
  121. private WaferPro endwafer;
  122. private void lbItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  123. {
  124. //if (Keyboard.IsKeyDown(Key.LeftCtrl))
  125. //{
  126. var obj = (WaferPro)sender;
  127. if (obj.WaferItem.Status != Aitex.Core.Common.WaferStatus.Empty)
  128. {
  129. obj.WaferItem.IsChecked = !obj.WaferItem.IsChecked;
  130. }
  131. // }
  132. //if (Keyboard.IsKeyDown(Key.LeftShift))
  133. //{
  134. // if (FristChick)
  135. // {
  136. // FristChick = false;
  137. // fristwafer = (WaferPro)sender;
  138. // fristwafer.WaferItem.IsChecked = true;
  139. // }
  140. // else
  141. // {
  142. // FristChick = true;
  143. // endwafer = (WaferPro)sender;
  144. // var fristSlot = fristwafer.WaferItem.Slot < endwafer.WaferItem.Slot ? fristwafer.WaferItem.Slot : endwafer.WaferItem.Slot;
  145. // var endSlot = fristwafer.WaferItem.Slot > endwafer.WaferItem.Slot ? fristwafer.WaferItem.Slot : endwafer.WaferItem.Slot;
  146. // for (int i = fristSlot; i < endSlot + 1; i++)
  147. // {
  148. // if (((WaferInfo)this.Slot.Items[24 - i]).Status != Aitex.Core.Common.WaferStatus.Empty)
  149. // {
  150. // ((WaferInfo)this.Slot.Items[24 - i]).IsChecked = true;
  151. // }
  152. // }
  153. // }
  154. //}
  155. //if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift)))
  156. //{
  157. // foreach (var item in this.Slot.Items)
  158. // {
  159. // ((WaferInfo)item).IsChecked = false;
  160. // }
  161. //}
  162. }
  163. private void lbItem_PreviewMouseMove(object sender, MouseEventArgs e)
  164. {
  165. //if (e.LeftButton == MouseButtonState.Pressed && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift)))
  166. //{
  167. // var data = new DataObject();
  168. // data.SetData("Station", Station);
  169. // data.SetData("Slots", Slots);
  170. // DragDrop.DoDragDrop(sender as DependencyObject,
  171. // data,
  172. // DragDropEffects.Copy | DragDropEffects.Move);
  173. // FristChick = true;
  174. //}
  175. }
  176. private void UserControl_PreviewKeyDown(object sender, KeyEventArgs e)
  177. {
  178. int keyValue = KeyInterop.VirtualKeyFromKey(e.Key);
  179. }
  180. private void Slot_Drop(object sender, DragEventArgs e)
  181. {
  182. //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
  183. //{
  184. // var dialog = new TransferSelectionDialog();
  185. // dialog.DestinationStation = ((WaferPro)e.Source).Station;
  186. // dialog.DestinationName = ((WaferPro)e.Source).Name;
  187. // dialog.FoupCount = FoupCount;
  188. // var sourceStation = (ModuleName)e.Data.GetData("Station");
  189. // var sourceSlots = (IEnumerable)e.Data.GetData("Slots");
  190. // List<WaferInfo> DestinationWaferInfos = new List<WaferInfo>();
  191. // dialog.OriginalFoupItem.Slots = sourceSlots;
  192. // dialog.DestinationFoupItem.Slots = this.Slots;
  193. // dialog.Closing += Dialog_Closing;
  194. // FristChick = true;
  195. // // dialog.Show();
  196. // dialog.TransferSelectionViewModel.OriginalSelectedValue = sourceStation.ToString();
  197. // dialog.TransferSelectionViewModel.DestinationSelectedValue = ((WaferPro)e.Source).Station.ToString();
  198. // ////对话框关闭后下指令
  199. // if (dialog.ShowDialog() == true)
  200. // {
  201. // //下命令
  202. // }
  203. //}
  204. }
  205. private void Dialog_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  206. {
  207. var dialog = (TransferSelectionDialog)sender;
  208. foreach (var item in dialog.OriginalFoupItem.Slots)
  209. {
  210. ((WaferInfo)item).IsChecked = false;
  211. }
  212. foreach (var item in dialog.DestinationFoupItem.Slots)
  213. {
  214. ((WaferInfo)item).IsChecked = false;
  215. }
  216. }
  217. }
  218. }