Foup.xaml.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using Aitex.Core.Common;
  2. using Aitex.Sorter.Common;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.ComponentModel;
  8. using System.Globalization;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Input;
  13. using MECF.Framework.Common.Equipment;
  14. namespace Aitex.Sorter.UI.Controls
  15. {
  16. /// <summary>
  17. /// Foup.xaml 的交互逻辑
  18. /// </summary>
  19. public partial class Foup : UserControl
  20. {
  21. public Foup()
  22. {
  23. InitializeComponent();
  24. root.DataContext = this;
  25. Slot.DataContext = this;
  26. }
  27. public static readonly DependencyProperty SlotsProperty = DependencyProperty.Register(
  28. "Slots", typeof(IEnumerable), typeof(Foup),
  29. new FrameworkPropertyMetadata(null));
  30. public IEnumerable Slots
  31. {
  32. get
  33. {
  34. return (IEnumerable)GetValue(SlotsProperty);
  35. }
  36. set
  37. {
  38. SetValue(SlotsProperty, value);
  39. }
  40. }
  41. public int SlotCount
  42. {
  43. get;
  44. set;
  45. }
  46. public CheckedItem[] SlotIndexes
  47. {
  48. get
  49. {
  50. var indexes = new CheckedItem[SlotCount];
  51. for (int i = 0; i < SlotCount; i++)
  52. {
  53. indexes[i] = new CheckedItem { ItemIndex = SlotCount - i - 1 };
  54. }
  55. return indexes;
  56. }
  57. }
  58. public ModuleName Station
  59. {
  60. get { return (ModuleName)GetValue(StationProperty); }
  61. set { SetValue(StationProperty, value); }
  62. }
  63. // Using a DependencyProperty as the backing store for Station. This enables animation, styling, binding, etc...
  64. public static readonly DependencyProperty StationProperty =
  65. DependencyProperty.Register("Station", typeof(ModuleName), typeof(Foup), new PropertyMetadata(ModuleName.System));
  66. public string Title
  67. {
  68. get { return (string)GetValue(TitleProperty); }
  69. set { SetValue(TitleProperty, value); }
  70. }
  71. // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc...
  72. public static readonly DependencyProperty TitleProperty =
  73. DependencyProperty.Register("Title", typeof(string), typeof(Foup), new PropertyMetadata(null));
  74. public ICommand WaferTransferCommand
  75. {
  76. get { return (ICommand)GetValue(WaferTransferCommandProperty); }
  77. set { SetValue(WaferTransferCommandProperty, value); }
  78. }
  79. // Using a DependencyProperty as the backing store for WaferMovementCommand. This enables animation, styling, binding, etc...
  80. public static readonly DependencyProperty WaferTransferCommandProperty =
  81. DependencyProperty.Register("WaferTransferCommand", typeof(ICommand), typeof(Foup), new PropertyMetadata(null));
  82. public SlotTransferInfo[] SlotTransferInfo
  83. {
  84. get { return (SlotTransferInfo[])GetValue(SlotTransferInfoProperty); }
  85. set { SetValue(SlotTransferInfoProperty, value); }
  86. }
  87. // Using a DependencyProperty as the backing store for SlotTransferInfo. This enables animation, styling, binding, etc...
  88. public static readonly DependencyProperty SlotTransferInfoProperty =
  89. DependencyProperty.Register("SlotTransferInfo", typeof(SlotTransferInfo[]), typeof(Foup), new PropertyMetadata(null));
  90. public ICommand WaferTransferOptionCommand
  91. {
  92. get { return (ICommand)GetValue(WaferTransferOptionCommandProperty); }
  93. set { SetValue(WaferTransferOptionCommandProperty, value); }
  94. }
  95. // Using a DependencyProperty as the backing store for WaferTransferOptionCommand. This enables animation, styling, binding, etc...
  96. public static readonly DependencyProperty WaferTransferOptionCommandProperty =
  97. DependencyProperty.Register("WaferTransferOptionCommand", typeof(ICommand), typeof(Foup), new PropertyMetadata(null));
  98. }
  99. public class CheckedItem : INotifyPropertyChanged
  100. {
  101. private int itemIndex;
  102. private bool isChecked;
  103. public int ItemIndex
  104. {
  105. get
  106. {
  107. return itemIndex;
  108. }
  109. set
  110. {
  111. itemIndex = value;
  112. Notify("ItemIndex");
  113. }
  114. }
  115. public bool IsChecked
  116. {
  117. get
  118. {
  119. return isChecked;
  120. }
  121. set
  122. {
  123. isChecked = value;
  124. Notify("IsChecked");
  125. }
  126. }
  127. private void Notify(string property)
  128. {
  129. if (PropertyChanged != null)
  130. {
  131. PropertyChanged(this, new PropertyChangedEventArgs(property));
  132. }
  133. }
  134. public event PropertyChangedEventHandler PropertyChanged;
  135. }
  136. public class TransferInfoConverter : IMultiValueConverter
  137. {
  138. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  139. {
  140. var slot = (int)values[0];
  141. var slotTransferInfos = (SlotTransferInfo[])values[1];
  142. if (slotTransferInfos != null)
  143. {
  144. return slotTransferInfos[slot];
  145. }
  146. return null;
  147. }
  148. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  149. {
  150. throw new NotImplementedException();
  151. }
  152. }
  153. }