FoupItem.xaml.cs 13 KB

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