FoupItemPro.xaml.cs 11 KB

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