ShellView.xaml.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using Prism.Regions;
  2. using System.Collections.Generic;
  3. using System.Windows;
  4. using Venus_Themes.CustomControls;
  5. using Venus_UI.Themes.Attach;
  6. using Venus_Unity;
  7. using System.Linq;
  8. using System.Threading;
  9. using System;
  10. using Venus_MainPages.Views;
  11. using System.Windows.Controls;
  12. using Aitex.Core.UI.View.Frame;
  13. using System.Windows.Media;
  14. using Venus_Core;
  15. using System.Reflection;
  16. using Venus_MainPages.Unity;
  17. using MECF.Framework.Common.DataCenter;
  18. using Aitex.Core.RT.SCCore;
  19. using MECF.Framework.Common.OperationCenter;
  20. using Aitex.Core.RT.OperationCenter;
  21. using Venus_MainPages.ViewModels;
  22. using MECF.Framework.Common.CommonData;
  23. using System.Windows.Controls.Primitives;
  24. using System.Timers;
  25. using System.Windows.Threading;
  26. namespace Venus_UI.Views
  27. {
  28. /// <summary>
  29. /// ShellView.xaml 的交互逻辑
  30. /// </summary>
  31. public partial class ShellView : Window
  32. {
  33. IRegionManager m_regionManager;
  34. IRegionNavigationService m_regionNavigationService;
  35. List<VenusMenu> VenusMenu;
  36. List<TabControl> centerTabViews=new List<TabControl> ();
  37. List<Button> buttonList=new List<Button> ();
  38. DispatcherTimer timer = new DispatcherTimer();
  39. public ShellView(IRegionManager regionManager, IRegionNavigationService regionNavigationService)
  40. {
  41. InitializeComponent();
  42. m_regionManager = regionManager;
  43. m_regionNavigationService = regionNavigationService;
  44. m_regionManager.RegisterViewWithRegion("TopRegion", typeof(Venus_MainPages.Views.TopView));
  45. VenusGlobalEvents.SlotRightClickChangedEvent += Instance_SlotRightClickChangedEvent;
  46. VenusGlobalEvents.SlotWaferTransferEvent += Instance_SlotStartTransferEvent;
  47. timer.Tick += timer_Tick;
  48. timer.Interval = TimeSpan.FromSeconds(0.5);
  49. timer.Start();
  50. }
  51. void timer_Tick(object sender, EventArgs e)
  52. {
  53. if (Anychange.needchange)
  54. {
  55. Anystationchange(Anychange.menuname, Anychange.args);
  56. Anychange.needchange=false;
  57. }
  58. }
  59. private void Instance_SlotRightClickChangedEvent(OpenSEMI.Ctrlib.Controls.Slot slot)
  60. {
  61. if (slot != null)
  62. {
  63. ContextMenu cm = ContextMenuManager.Instance.GetSlotMenus(slot);
  64. if (cm != null)
  65. {
  66. slot.ContextMenu = cm;
  67. }
  68. return;
  69. }
  70. }
  71. private void Instance_SlotStartTransferEvent(OpenSEMI.Ctrlib.Controls.DragDropEventArgs e)
  72. {
  73. InvokeClient.Instance.Service.DoOperation("System.MoveWafer",
  74. e.TranferFrom.ModuleID,e.TranferFrom.SlotID, e.TranferTo.ModuleID, e.TranferTo.SlotID,false,1,false,1,"");
  75. e.TranferFrom.ClearDragDropStatus();
  76. e.TranferTo.ClearDragDropStatus();
  77. }
  78. private void CustomWnd_Loaded(object sender, RoutedEventArgs e)
  79. {
  80. VenusMenu = SerializeHelper.Instance.ReadFromJsonFile<List<VenusMenu>>($"Config/UIMenu.json");
  81. int index = 0;
  82. for (int i = 0; i < VenusMenu.Count; i++)
  83. {
  84. if (VenusMenu[i].IsShow == false)
  85. {
  86. continue;
  87. }
  88. string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');
  89. if (VenusMenu[i].Id == "PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD" || VenusMenu[i].Id == "TM")
  90. {
  91. if (!allModules.Contains(VenusMenu[i].Id))
  92. {
  93. continue;
  94. }
  95. }
  96. AduRadioButtonIcon aduRadioButtonIcon = new AduRadioButtonIcon();
  97. if (i == 0)
  98. {
  99. aduRadioButtonIcon.IsChecked = true;
  100. }
  101. IconElement.SetPathData(aduRadioButtonIcon,(Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  102. aduRadioButtonIcon.Content = VenusMenu[i].Id;
  103. aduRadioButtonIcon.Click += AduRadioButtonIcon_Click;
  104. aduRadioButtonIcon.SelectBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6AD7FF"));
  105. aduRadioButtonIcon.SelectColor = new SolidColorBrush((Colors.Black));
  106. aduRadioButtonIcon.DefaultBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#94BCD7"));
  107. //aduRadioButtonIcon.DefaultBackground = new SolidColorBrush(Colors.DarkGray);
  108. aduRadioButtonIcon.Width = 180;
  109. aduRadioButtonIcon.Height= 40;
  110. //aduRadioButtonIcon.Foreground=Brushes.White;
  111. aduRadioButtonIcon.Tag = index;
  112. index += 1;
  113. Bottom_Frame.Children.Add(aduRadioButtonIcon);
  114. //if (VenusMenu[i].Id == "PMC")
  115. //{
  116. // AduRadioButtonIcon aduRadioButtonIcon2 = new AduRadioButtonIcon();
  117. // IconElement.SetPathData(aduRadioButtonIcon2, (Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  118. // aduRadioButtonIcon2.Content = "PMD";
  119. // //aduRadioButtonIcon2.Click += AduRadioButtonIcon_Click;
  120. // aduRadioButtonIcon2.SelectBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6AD7FF"));
  121. // aduRadioButtonIcon2.SelectColor = new SolidColorBrush((Colors.Black));
  122. // aduRadioButtonIcon2.DefaultBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#94BCD7"));
  123. // //aduRadioButtonIcon.DefaultBackground = new SolidColorBrush(Colors.DarkGray);
  124. // aduRadioButtonIcon2.Width = 180;
  125. // aduRadioButtonIcon2.Height = 40;
  126. // Bottom_Frame.Children.Add(aduRadioButtonIcon2);
  127. //}
  128. TabControl tabControl = new TabControl();
  129. for (int j = 0; j < VenusMenu[i].MenuItem.Count; j++)
  130. {
  131. if (VenusMenu[i].MenuItem[j].IsShow == false)
  132. {
  133. continue;
  134. }
  135. string className;
  136. if ((VenusMenu[i].Id == "PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD")&& VenusMenu[i].MenuItem[j].Id== "Operation")
  137. {
  138. JetChamber jetChamber = (JetChamber)(Convert.ToInt32(QueryDataClient.Instance.Service.GetConfig($"{VenusMenu[i].Id}.ChamberType")));
  139. className = $"Venus_MainPages.Views.Over{jetChamber.ToString()}View";
  140. }
  141. else
  142. {
  143. className = $"Venus_MainPages.Views.{VenusMenu[i].MenuItem[j].View}";
  144. }
  145. Type t = Type.GetType($"{className},Venus_MainPages");
  146. var obj = System.Activator.CreateInstance(t);
  147. if (VenusMenu[i].Id=="PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD" || VenusMenu[i].Id == "TM")
  148. {
  149. MethodInfo methodInfo = t.GetMethod("Init", new Type[] { typeof(string) });
  150. methodInfo?.Invoke(obj, new object[] { VenusMenu[i].Id });
  151. }
  152. tabControl.Items.Add(new TabItem() { Header = VenusMenu[i].MenuItem[j].Name, Content = obj });
  153. }
  154. centerTabViews.Add(tabControl);
  155. }
  156. Main_Frame.Content = centerTabViews[0];
  157. ModuleManager.Initialize();
  158. }
  159. public void Anystationchange(string menuviewItem, WaferHistoryWafer queryFilter)
  160. {
  161. UserControl address = new ProcessHistoryView();
  162. ProcessHistoryViewModel vm = new ProcessHistoryViewModel() {};
  163. vm.SearchRecipe(queryFilter.StartTime, queryFilter.EndTime);
  164. vm.OnDataGridSelectionChanged(new Venus_MainPages.ViewModels.RecipeItem { StartTime=queryFilter.StartTime, EndTime= queryFilter.EndTime});
  165. address.DataContext = vm;
  166. centerTabViews.Last().Items[2]= new TabItem() { Header = menuviewItem, Content = address };
  167. centerTabViews.Last().SelectedIndex = 2;
  168. Main_Frame.Content = centerTabViews.Last();
  169. }
  170. private void AduRadioButtonIcon_Click(object sender, RoutedEventArgs e)
  171. {
  172. var currentButton = sender as AduRadioButtonIcon;
  173. Main_Frame.Content = centerTabViews[Convert.ToInt32(currentButton.Tag)];
  174. }
  175. private void CustomWnd_Closed(object sender, EventArgs e)
  176. {
  177. System.Diagnostics.Process.GetCurrentProcess().Kill();
  178. }
  179. }
  180. }