OperationViewSub.xaml.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Sorter.UI.Controls;
  3. using Aitex.Sorter.UI.ViewModel;
  4. using System;
  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 System.Windows.Threading;
  20. namespace Aitex.Sorter.UI.Views
  21. {
  22. /// <summary>
  23. /// OperationViewSub.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class OperationViewSub : UserControl
  26. {
  27. private static int loadPortCount = 8;
  28. private OperationMultiLPViewModel operationViewModel;
  29. private readonly DispatcherTimer _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
  30. public OperationViewSub()
  31. {
  32. InitializeComponent();
  33. operationViewModel = new OperationViewSubModel();
  34. ChangedFoupListSize();
  35. DataContext = operationViewModel;
  36. IsVisibleChanged += OperationView_IsVisibleChanged;
  37. _timer.Start();
  38. _timer.Tick += TimerOnTick;
  39. }
  40. private void ChangedFoupListSize()
  41. {
  42. switch (loadPortCount)
  43. {
  44. case 1:
  45. case 2:
  46. this.foupList.Width = 200;
  47. this.FoupListViewbox.Width = 250;
  48. break;
  49. case 3:
  50. case 4:
  51. this.foupList.Width = 400;
  52. this.FoupListViewbox.Width = 500;
  53. break;
  54. case 5:
  55. case 6:
  56. this.foupList.Width = 600;
  57. this.FoupListViewbox.Width = 600;
  58. break;
  59. case 7:
  60. case 8:
  61. this.foupList.Width = 800;
  62. this.FoupListViewbox.Width = 800;
  63. break;
  64. case 9:
  65. case 10:
  66. this.foupList.Width = 900;
  67. this.FoupListViewbox.Width = 900;
  68. break;
  69. default:
  70. break;
  71. }
  72. }
  73. private void TimerOnTick(object sender, EventArgs e)
  74. {
  75. if (IsVisible)
  76. {
  77. operationViewModel.UpdateAllConfig();
  78. }
  79. }
  80. private void OperationView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  81. {
  82. ((OperationMultiLPViewModel)DataContext).EnableTimer(IsVisible);
  83. }
  84. private void CreateWafer_Click(object sender, RoutedEventArgs e)
  85. {
  86. }
  87. // private void BatchID_Click(object sender, RoutedEventArgs e)
  88. // {
  89. // string value = InputBatchID.Text.Trim();
  90. // string origin = value;
  91. //
  92. // InputBatchID.Text = origin;
  93. // InputBatchID.CaretIndex = InputBatchID.Text.Length;
  94. //
  95. //
  96. // InvokeClient.Instance.Service.DoOperation("System.SetBatchId", value);
  97. // }
  98. }
  99. public class FoupListConverter : IValueConverter
  100. {
  101. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  102. {
  103. var type = (string)value;
  104. var image = string.Format("EFEMbg{0}.png", type);
  105. string packUri = "pack://application:,,,/AitexSorterUI;component/Resources/images/" + image;
  106. var source = new BitmapImage(new Uri(packUri));
  107. return source;
  108. }
  109. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  110. {
  111. throw new NotImplementedException();
  112. }
  113. }
  114. public class EFEMControlConverter : IMultiValueConverter
  115. {
  116. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  117. {
  118. var root = values[1] as FrameworkElement;
  119. if (values[0] != null)
  120. {
  121. var type = (string)values[0];
  122. switch (type)
  123. {
  124. case "41":
  125. var efem41 = root.FindResource("EFEM41");
  126. ((ViewModelControl)efem41).SubscribeKeys((SubscriptionViewModelBase)(root.DataContext));
  127. return efem41;
  128. case "4":
  129. var efem4 = root.FindResource("EFEM4H");
  130. ((ViewModelControl)efem4).SubscribeKeys((SubscriptionViewModelBase)(root.DataContext));
  131. return efem4;
  132. case "6":
  133. var efem6 = root.FindResource("EFEM4");
  134. ((ViewModelControl)efem6).SubscribeKeys((SubscriptionViewModelBase)(root.DataContext));
  135. return efem6;
  136. default:
  137. var image = string.Format("EFEMbg{0}.png", type);
  138. string packUri = "pack://application:,,,/AitexSorterUI;component/Resources/images/" + image;
  139. var source = new BitmapImage(new Uri(packUri));
  140. var content = new Image() { Source = source };
  141. return content;
  142. }
  143. }
  144. return null;
  145. }
  146. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  147. {
  148. throw new NotImplementedException();
  149. }
  150. }
  151. }