FoupItemPro.xaml.cs 13 KB

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