FoupItem.xaml.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. namespace Aitex.Sorter.UI.Controls
  20. {
  21. /// <summary>
  22. /// Foup6.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class FoupItem : UserControl
  25. {
  26. public FoupItem()
  27. {
  28. InitializeComponent();
  29. root.DataContext = this;
  30. Slot.DataContext = this;
  31. }
  32. public static readonly DependencyProperty SlotsProperty = DependencyProperty.Register(
  33. "Slots", typeof(IEnumerable), typeof(FoupItem),
  34. new FrameworkPropertyMetadata(null));
  35. public IEnumerable Slots
  36. {
  37. get
  38. {
  39. return (IEnumerable)GetValue(SlotsProperty);
  40. }
  41. set
  42. {
  43. SetValue(SlotsProperty, value);
  44. }
  45. }
  46. public bool ShowControl
  47. {
  48. get { return (bool)GetValue(ShowControlProperty); }
  49. set
  50. {
  51. SetValue(ShowControlProperty, value);
  52. }
  53. }
  54. public static readonly DependencyProperty ShowControlProperty =
  55. DependencyProperty.Register("ShowControl", typeof(bool), typeof(FoupItem), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.None));
  56. public int SlotCount
  57. {
  58. get { return (int)GetValue(SlotCountProperty); }
  59. set { SetValue(SlotCountProperty, value); }
  60. }
  61. // Using a DependencyProperty as the backing store for SlotCount. This enables animation, styling, binding, etc...
  62. public static readonly DependencyProperty SlotCountProperty =
  63. DependencyProperty.Register("SlotCount", typeof(int), typeof(FoupItem), new PropertyMetadata(25));
  64. public ModuleName Station
  65. {
  66. get { return (ModuleName)GetValue(StationProperty); }
  67. set { SetValue(StationProperty, value); }
  68. }
  69. // Using a DependencyProperty as the backing store for Station. This enables animation, styling, binding, etc...
  70. public static readonly DependencyProperty StationProperty =
  71. DependencyProperty.Register("Station", typeof(ModuleName), typeof(FoupItem), new PropertyMetadata(ModuleName.System));
  72. public string Title
  73. {
  74. get { return (string)GetValue(TitleProperty); }
  75. set { SetValue(TitleProperty, value); }
  76. }
  77. // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc...
  78. public static readonly DependencyProperty TitleProperty =
  79. DependencyProperty.Register("Title", typeof(string), typeof(FoupItem), new PropertyMetadata(null));
  80. public ICommand WaferTransferCommand
  81. {
  82. get { return (ICommand)GetValue(WaferTransferCommandProperty); }
  83. set { SetValue(WaferTransferCommandProperty, value); }
  84. }
  85. // Using a DependencyProperty as the backing store for WaferMovementCommand. This enables animation, styling, binding, etc...
  86. public static readonly DependencyProperty WaferTransferCommandProperty =
  87. DependencyProperty.Register("WaferTransferCommand", typeof(ICommand), typeof(FoupItem), new PropertyMetadata(null));
  88. public ICommand WaferTransferOptionCommand
  89. {
  90. get { return (ICommand)GetValue(WaferTransferOptionCommandProperty); }
  91. set { SetValue(WaferTransferOptionCommandProperty, value); }
  92. }
  93. // Using a DependencyProperty as the backing store for WaferTransferOptionCommand. This enables animation, styling, binding, etc...
  94. public static readonly DependencyProperty WaferTransferOptionCommandProperty =
  95. DependencyProperty.Register("WaferTransferOptionCommand", typeof(ICommand), typeof(FoupItem), new PropertyMetadata(null));
  96. public LoadPortCarrierMode CarrierMode
  97. {
  98. get { return (LoadPortCarrierMode)GetValue(CarrierModeProperty); }
  99. set { SetValue(CarrierModeProperty, value); }
  100. }
  101. // Using a DependencyProperty as the backing store for CarrierMode. This enables animation, styling, binding, etc...
  102. public static readonly DependencyProperty CarrierModeProperty =
  103. DependencyProperty.Register("CarrierMode", typeof(LoadPortCarrierMode), typeof(FoupItem), new PropertyMetadata(LoadPortCarrierMode.Both));
  104. }
  105. public class FoupModeConverter : IValueConverter
  106. {
  107. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  108. {
  109. var mode = (LoadPortCarrierMode)value;
  110. var brush = Brushes.Gray;
  111. switch (mode)
  112. {
  113. case LoadPortCarrierMode.Loader:
  114. brush = Brushes.Cyan;
  115. break;
  116. case LoadPortCarrierMode.Unloader:
  117. brush = Brushes.DodgerBlue;
  118. break;
  119. case LoadPortCarrierMode.Both:
  120. brush = Brushes.LightBlue;
  121. break;
  122. default:
  123. break;
  124. }
  125. return brush;
  126. }
  127. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  128. {
  129. throw new NotImplementedException();
  130. }
  131. }
  132. public class ItemIndexConverter : IMultiValueConverter
  133. {
  134. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  135. {
  136. var index = (int)values[0];
  137. var count = (int)values[1];
  138. return count - index-1;
  139. }
  140. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  141. {
  142. throw new NotImplementedException();
  143. }
  144. }
  145. public class ItemIndexConverter2 : IMultiValueConverter
  146. {
  147. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  148. {
  149. var index = (int)values[0];
  150. var count = 25;
  151. return count - index - 1;
  152. }
  153. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  154. {
  155. throw new NotImplementedException();
  156. }
  157. }
  158. public class ShowSlotItemConverter : IMultiValueConverter
  159. {
  160. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  161. {
  162. var index = (int)values[0];
  163. var count = (int)values[1];
  164. return 25-index - 1 < count?true: false;
  165. }
  166. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  167. {
  168. throw new NotImplementedException();
  169. }
  170. }
  171. }