FoupItemPro3.xaml.cs 13 KB

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