FoupItemPro1.xaml.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. using Aitex.Sorter.UI.Controls;
  21. using Aitex.Core.Util;
  22. namespace EfemUI.Controls
  23. {
  24. /// <summary>
  25. /// Foup6.xaml 的交互逻辑
  26. /// </summary>
  27. public partial class FoupItemPro1 : UserControl
  28. {
  29. public FoupItemPro1()
  30. {
  31. InitializeComponent();
  32. root.DataContext = this;
  33. Slot.DataContext = this;
  34. }
  35. public bool IsEnableTextMenu1
  36. {
  37. get { return (bool)GetValue(IsEnableTextMenu1Property); }
  38. set { SetValue(IsEnableTextMenu1Property, value); }
  39. }
  40. // Using a DependencyProperty as the backing store for IsEnableTextMenu. This enables animation, styling, binding, etc...
  41. public static readonly DependencyProperty IsEnableTextMenu1Property =
  42. DependencyProperty.Register("IsEnableTextMenu1", typeof(bool), typeof(FoupItemPro1), new PropertyMetadata(true));
  43. public static readonly DependencyProperty SlotsProperty = DependencyProperty.Register(
  44. "Slots", typeof(IEnumerable), typeof(FoupItemPro1),
  45. new FrameworkPropertyMetadata(null));
  46. public Visibility ShowSlotsIndex
  47. {
  48. get { return (Visibility)GetValue(ShowSlotsIndexProperty); }
  49. set { SetValue(ShowSlotsIndexProperty, value); }
  50. }
  51. public static readonly DependencyProperty ShowSlotsIndexProperty =
  52. DependencyProperty.Register("ShowSlotsIndex", typeof(Visibility), typeof(FoupItemPro1), new PropertyMetadata(Visibility.Collapsed));
  53. public int FoupCount
  54. {
  55. get { return (int)GetValue(FoupCountProperty); }
  56. set { SetValue(FoupCountProperty, value); }
  57. }
  58. public static readonly DependencyProperty FoupCountProperty =
  59. DependencyProperty.Register("FoupCount", typeof(int), typeof(FoupItemPro1), new PropertyMetadata(8));
  60. public bool ShowControl
  61. {
  62. get { return (bool)GetValue(ShowControlProperty); }
  63. set
  64. {
  65. SetValue(ShowControlProperty, value);
  66. }
  67. }
  68. public static readonly DependencyProperty ShowControlProperty =
  69. DependencyProperty.Register("ShowControl", typeof(bool), typeof(FoupItemPro1), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.None));
  70. public IEnumerable Slots
  71. {
  72. get
  73. {
  74. return (IEnumerable)GetValue(SlotsProperty);
  75. }
  76. set
  77. {
  78. SetValue(SlotsProperty, value);
  79. }
  80. }
  81. public int SlotCount
  82. {
  83. get { return (int)GetValue(SlotCountProperty); }
  84. set { SetValue(SlotCountProperty, value); }
  85. }
  86. // Using a DependencyProperty as the backing store for SlotCount. This enables animation, styling, binding, etc...
  87. public static readonly DependencyProperty SlotCountProperty =
  88. DependencyProperty.Register("SlotCount", typeof(int), typeof(FoupItemPro1), new PropertyMetadata(25));
  89. public ModuleName Station
  90. {
  91. get { return (ModuleName)GetValue(StationProperty); }
  92. set { SetValue(StationProperty, value); }
  93. }
  94. // Using a DependencyProperty as the backing store for Station. This enables animation, styling, binding, etc...
  95. public static readonly DependencyProperty StationProperty =
  96. DependencyProperty.Register("Station", typeof(ModuleName), typeof(FoupItemPro1), new PropertyMetadata(ModuleName.System));
  97. public string Title
  98. {
  99. get { return (string)GetValue(TitleProperty); }
  100. set { SetValue(TitleProperty, value); }
  101. }
  102. // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc...
  103. public static readonly DependencyProperty TitleProperty =
  104. DependencyProperty.Register("Title", typeof(string), typeof(FoupItemPro1), new PropertyMetadata(null));
  105. public ICommand WaferTransferCommand
  106. {
  107. get { return (ICommand)GetValue(WaferTransferCommandProperty); }
  108. set { SetValue(WaferTransferCommandProperty, value); }
  109. }
  110. // Using a DependencyProperty as the backing store for WaferMovementCommand. This enables animation, styling, binding, etc...
  111. public static readonly DependencyProperty WaferTransferCommandProperty =
  112. DependencyProperty.Register("WaferTransferCommand", typeof(ICommand), typeof(FoupItemPro1), new PropertyMetadata(null));
  113. public ICommand WaferTransferOptionCommand
  114. {
  115. get { return (ICommand)GetValue(WaferTransferOptionCommandProperty); }
  116. set { SetValue(WaferTransferOptionCommandProperty, value); }
  117. }
  118. // Using a DependencyProperty as the backing store for WaferTransferOptionCommand. This enables animation, styling, binding, etc...
  119. public static readonly DependencyProperty WaferTransferOptionCommandProperty =
  120. DependencyProperty.Register("WaferTransferOptionCommand", typeof(ICommand), typeof(FoupItemPro1), new PropertyMetadata(null));
  121. public LoadPortCarrierMode CarrierMode
  122. {
  123. get { return (LoadPortCarrierMode)GetValue(CarrierModeProperty); }
  124. set { SetValue(CarrierModeProperty, value); }
  125. }
  126. // Using a DependencyProperty as the backing store for CarrierMode. This enables animation, styling, binding, etc...
  127. public static readonly DependencyProperty CarrierModeProperty =
  128. DependencyProperty.Register("CarrierMode", typeof(LoadPortCarrierMode), typeof(FoupItemPro1), new PropertyMetadata(LoadPortCarrierMode.Both));
  129. public bool FristChick { get; set; } = true;
  130. private WaferPro fristwafer;
  131. private WaferPro endwafer;
  132. private void lbItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  133. {
  134. //if (Keyboard.IsKeyDown(Key.LeftCtrl))
  135. //{
  136. var obj = (WaferPro)sender;
  137. if (obj.WaferItem.Status != Aitex.Core.Common.WaferStatus.Empty)
  138. {
  139. obj.WaferItem.IsChecked = !obj.WaferItem.IsChecked;
  140. }
  141. // }
  142. //if (Keyboard.IsKeyDown(Key.LeftShift))
  143. //{
  144. // if (FristChick)
  145. // {
  146. // FristChick = false;
  147. // fristwafer = (WaferPro)sender;
  148. // fristwafer.WaferItem.IsChecked = true;
  149. // }
  150. // else
  151. // {
  152. // FristChick = true;
  153. // endwafer = (WaferPro)sender;
  154. // var fristSlot = fristwafer.WaferItem.Slot < endwafer.WaferItem.Slot ? fristwafer.WaferItem.Slot : endwafer.WaferItem.Slot;
  155. // var endSlot = fristwafer.WaferItem.Slot > endwafer.WaferItem.Slot ? fristwafer.WaferItem.Slot : endwafer.WaferItem.Slot;
  156. // for (int i = fristSlot; i < endSlot + 1; i++)
  157. // {
  158. // if (((WaferInfo)this.Slot.Items[24 - i]).Status != Aitex.Core.Common.WaferStatus.Empty)
  159. // {
  160. // ((WaferInfo)this.Slot.Items[24 - i]).IsChecked = true;
  161. // }
  162. // }
  163. // }
  164. //}
  165. //if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift)))
  166. //{
  167. // foreach (var item in this.Slot.Items)
  168. // {
  169. // ((WaferInfo)item).IsChecked = false;
  170. // }
  171. //}
  172. }
  173. private void lbItem_PreviewMouseMove(object sender, MouseEventArgs e)
  174. {
  175. //if (e.LeftButton == MouseButtonState.Pressed && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift)))
  176. //{
  177. // var data = new DataObject();
  178. // data.SetData("Station", Station);
  179. // data.SetData("Slots", Slots);
  180. // DragDrop.DoDragDrop(sender as DependencyObject,
  181. // data,
  182. // DragDropEffects.Copy | DragDropEffects.Move);
  183. // FristChick = true;
  184. //}
  185. }
  186. private void UserControl_PreviewKeyDown(object sender, KeyEventArgs e)
  187. {
  188. int keyValue = KeyInterop.VirtualKeyFromKey(e.Key);
  189. }
  190. private void Slot_Drop(object sender, DragEventArgs e)
  191. {
  192. //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
  193. //{
  194. // var dialog = new TransferSelectionDialog();
  195. // dialog.DestinationStation = ((WaferPro)e.Source).Station;
  196. // dialog.DestinationName = ((WaferPro)e.Source).Name;
  197. // dialog.FoupCount = FoupCount;
  198. // var sourceStation = (ModuleName)e.Data.GetData("Station");
  199. // var sourceSlots = (IEnumerable)e.Data.GetData("Slots");
  200. // List<WaferInfo> DestinationWaferInfos = new List<WaferInfo>();
  201. // dialog.OriginalFoupItem.Slots = sourceSlots;
  202. // dialog.DestinationFoupItem.Slots = this.Slots;
  203. // dialog.Closing += Dialog_Closing;
  204. // FristChick = true;
  205. // // dialog.Show();
  206. // dialog.TransferSelectionViewModel.OriginalSelectedValue = sourceStation.ToString();
  207. // dialog.TransferSelectionViewModel.DestinationSelectedValue = ((WaferPro)e.Source).Station.ToString();
  208. // ////对话框关闭后下指令
  209. // if (dialog.ShowDialog() == true)
  210. // {
  211. // //下命令
  212. // }
  213. //}
  214. }
  215. private void Dialog_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  216. {
  217. //var dialog = (TransferSelectionDialog)sender;
  218. //foreach (var item in dialog.OriginalFoupItem.Slots)
  219. //{
  220. // ((WaferInfo)item).IsChecked = false;
  221. //}
  222. //foreach (var item in dialog.DestinationFoupItem.Slots)
  223. //{
  224. // ((WaferInfo)item).IsChecked = false;
  225. //}
  226. }
  227. }
  228. public class ItemIndexConverter1 : IMultiValueConverter
  229. {
  230. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  231. {
  232. var index = (int)values[0];
  233. var count = 25;
  234. return count - index - 1;
  235. }
  236. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  237. {
  238. throw new NotImplementedException();
  239. }
  240. }
  241. public class ShowSlotItemConverter1 : IMultiValueConverter
  242. {
  243. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  244. {
  245. var index = (int)values[0];
  246. var count = (int)values[1];
  247. return index < count ? true : false;
  248. }
  249. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  250. {
  251. throw new NotImplementedException();
  252. }
  253. }
  254. public class ItemIndexConverter3 : IValueConverter
  255. {
  256. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  257. {
  258. var index = (int)value;
  259. return (25 - index).ToString("D2");
  260. }
  261. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  262. {
  263. throw new NotImplementedException();
  264. }
  265. }
  266. public class ShowSlotItemConverter3 : IMultiValueConverter
  267. {
  268. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  269. {
  270. var index = (int)values[0];
  271. var count = (int)values[1];
  272. return (25 - index - 1) < count ? Visibility.Visible : Visibility.Hidden;
  273. }
  274. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  275. {
  276. throw new NotImplementedException();
  277. }
  278. }
  279. }