ShellView.xaml.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. using Venus_Themes.Unity;
  27. using Venus_Themes.UserControls;
  28. using OpenSEMI.Ctrlib.Controls;
  29. namespace Venus_UI.Views
  30. {
  31. /// <summary>
  32. /// ShellView.xaml 的交互逻辑
  33. /// </summary>
  34. public partial class ShellView : Window
  35. {
  36. IRegionManager m_regionManager;
  37. IRegionNavigationService m_regionNavigationService;
  38. List<VenusMenu> VenusMenu;
  39. List<TabControl> centerTabViews=new List<TabControl> ();
  40. List<Button> buttonList=new List<Button> ();
  41. DispatcherTimer timer = new DispatcherTimer();
  42. public ShellView(IRegionManager regionManager, IRegionNavigationService regionNavigationService)
  43. {
  44. InitializeComponent();
  45. m_regionManager = regionManager;
  46. m_regionNavigationService = regionNavigationService;
  47. m_regionManager.RegisterViewWithRegion("TopRegion", typeof(Venus_MainPages.Views.TopView));
  48. VenusGlobalEvents.SlotRightClickChangedEvent += Instance_SlotRightClickChangedEvent;
  49. VenusGlobalEvents.SlotWaferTransferEvent += Instance_SlotStartTransferEvent;
  50. timer.Tick += timer_Tick;
  51. timer.Interval = TimeSpan.FromSeconds(0.5);
  52. timer.Start();
  53. UIEvents.PMDoorRaiseChangedEvent += UIEvents_PMDoorRaiseChangedEvent;
  54. UIEvents.LLTDoorRaiseChangedEvent += UIEvents_LLTDoorRaiseChangedEvent;
  55. UIEvents.LLEDoorRaiseChangedEvent += UIEvents_LLEDoorRaiseChangedEvent;
  56. UIEvents.ChamberCreateDeleteWaferEvent += UIEvents_ChamberCreateDeleteWaferEvent;
  57. }
  58. void timer_Tick(object sender, EventArgs e)
  59. {
  60. if (Anychange.needchange)
  61. {
  62. Anystationchange(Anychange.menuname, Anychange.args);
  63. Anychange.needchange=false;
  64. }
  65. }
  66. private void Instance_SlotRightClickChangedEvent(OpenSEMI.Ctrlib.Controls.Slot slot)
  67. {
  68. if (slot != null)
  69. {
  70. ContextMenu cm = ContextMenuManager.Instance.GetSlotMenus(slot);
  71. if (cm != null)
  72. {
  73. slot.ContextMenu = cm;
  74. }
  75. return;
  76. }
  77. }
  78. private void Instance_SlotStartTransferEvent(OpenSEMI.Ctrlib.Controls.DragDropEventArgs e)
  79. {
  80. InvokeClient.Instance.Service.DoOperation("System.MoveWafer",
  81. e.TranferFrom.ModuleID,e.TranferFrom.SlotID, e.TranferTo.ModuleID, e.TranferTo.SlotID,false,1,false,1,"");
  82. e.TranferFrom.ClearDragDropStatus();
  83. e.TranferTo.ClearDragDropStatus();
  84. }
  85. private void CustomWnd_Loaded(object sender, RoutedEventArgs e)
  86. {
  87. VenusMenu = SerializeHelper.Instance.ReadFromJsonFile<List<VenusMenu>>($"Config/UIMenu.json");
  88. int index = 0;
  89. for (int i = 0; i < VenusMenu.Count; i++)
  90. {
  91. if (VenusMenu[i].IsShow == false)
  92. {
  93. continue;
  94. }
  95. string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');
  96. if (VenusMenu[i].Id == "PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD" || VenusMenu[i].Id == "TM")
  97. {
  98. if (!allModules.Contains(VenusMenu[i].Id))
  99. {
  100. continue;
  101. }
  102. }
  103. AduRadioButtonIcon aduRadioButtonIcon = new AduRadioButtonIcon();
  104. if (i == 0)
  105. {
  106. aduRadioButtonIcon.IsChecked = true;
  107. }
  108. IconElement.SetPathData(aduRadioButtonIcon,(Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  109. aduRadioButtonIcon.Content = VenusMenu[i].Id;
  110. aduRadioButtonIcon.Click += AduRadioButtonIcon_Click;
  111. aduRadioButtonIcon.SelectBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6AD7FF"));
  112. aduRadioButtonIcon.SelectColor = new SolidColorBrush((Colors.Black));
  113. aduRadioButtonIcon.DefaultBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#94BCD7"));
  114. //aduRadioButtonIcon.DefaultBackground = new SolidColorBrush(Colors.DarkGray);
  115. aduRadioButtonIcon.Width = 180;
  116. aduRadioButtonIcon.Height= 40;
  117. //aduRadioButtonIcon.Foreground=Brushes.White;
  118. aduRadioButtonIcon.Tag = index;
  119. index += 1;
  120. Bottom_Frame.Children.Add(aduRadioButtonIcon);
  121. //if (VenusMenu[i].Id == "PMC")
  122. //{
  123. // AduRadioButtonIcon aduRadioButtonIcon2 = new AduRadioButtonIcon();
  124. // IconElement.SetPathData(aduRadioButtonIcon2, (Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  125. // aduRadioButtonIcon2.Content = "PMD";
  126. // //aduRadioButtonIcon2.Click += AduRadioButtonIcon_Click;
  127. // aduRadioButtonIcon2.SelectBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6AD7FF"));
  128. // aduRadioButtonIcon2.SelectColor = new SolidColorBrush((Colors.Black));
  129. // aduRadioButtonIcon2.DefaultBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#94BCD7"));
  130. // //aduRadioButtonIcon.DefaultBackground = new SolidColorBrush(Colors.DarkGray);
  131. // aduRadioButtonIcon2.Width = 180;
  132. // aduRadioButtonIcon2.Height = 40;
  133. // Bottom_Frame.Children.Add(aduRadioButtonIcon2);
  134. //}
  135. TabControl tabControl = new TabControl();
  136. for (int j = 0; j < VenusMenu[i].MenuItem.Count; j++)
  137. {
  138. if (VenusMenu[i].MenuItem[j].IsShow == false)
  139. {
  140. continue;
  141. }
  142. string className;
  143. if ((VenusMenu[i].Id == "PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD")&& VenusMenu[i].MenuItem[j].Id== "Operation")
  144. {
  145. JetChamber jetChamber = (JetChamber)(Convert.ToInt32(QueryDataClient.Instance.Service.GetConfig($"{VenusMenu[i].Id}.ChamberType")));
  146. className = $"Venus_MainPages.Views.Over{jetChamber.ToString()}View";
  147. }
  148. else
  149. {
  150. className = $"Venus_MainPages.Views.{VenusMenu[i].MenuItem[j].View}";
  151. }
  152. Type t = Type.GetType($"{className},Venus_MainPages");
  153. var obj = System.Activator.CreateInstance(t);
  154. if (VenusMenu[i].Id=="PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD" || VenusMenu[i].Id == "TM")
  155. {
  156. MethodInfo methodInfo = t.GetMethod("Init", new Type[] { typeof(string) });
  157. methodInfo?.Invoke(obj, new object[] { VenusMenu[i].Id });
  158. }
  159. tabControl.Items.Add(new TabItem() { Header = VenusMenu[i].MenuItem[j].Name, Content = obj });
  160. }
  161. centerTabViews.Add(tabControl);
  162. }
  163. Main_Frame.Content = centerTabViews[0];
  164. ModuleManager.Initialize();
  165. }
  166. public void Anystationchange(string menuviewItem, WaferHistoryWafer queryFilter)
  167. {
  168. UserControl address = new ProcessHistoryView();
  169. ProcessHistoryViewModel vm = new ProcessHistoryViewModel() {};
  170. vm.searchlot(queryFilter.WaferGuid);
  171. vm.OnDataGridSelectionChanged(vm.Recipes[0]);
  172. address.DataContext = vm;
  173. centerTabViews.Last().Items[2]= new TabItem() { Header = menuviewItem, Content = address };
  174. centerTabViews.Last().SelectedIndex = 2;
  175. Main_Frame.Content = centerTabViews.Last();
  176. }
  177. private void AduRadioButtonIcon_Click(object sender, RoutedEventArgs e)
  178. {
  179. var currentButton = sender as AduRadioButtonIcon;
  180. Main_Frame.Content = centerTabViews[Convert.ToInt32(currentButton.Tag)];
  181. }
  182. private void CustomWnd_Closed(object sender, EventArgs e)
  183. {
  184. System.Diagnostics.Process.GetCurrentProcess().Kill();
  185. }
  186. private void UIEvents_ChamberCreateDeleteWaferEvent(WaferOperation obj)
  187. {
  188. if (obj.IsCreate == true)
  189. {
  190. InvokeClient.Instance.Service.DoOperation("CreateWafer", obj.ModuleName, 0);
  191. }
  192. else
  193. {
  194. InvokeClient.Instance.Service.DoOperation("DeleteWafer", obj.ModuleName, 0);
  195. }
  196. }
  197. private void UIEvents_PMDoorRaiseChangedEvent(DoorPara obj)
  198. {
  199. //InvokeClient.Instance.Service.DoOperation($"{obj?.ModuleName}.SlitDoor.{obj?.IsOpen}");
  200. InvokeClient.Instance.Service.DoOperation($"{obj?.ModuleName}.SetSlitDoor", obj.IsOpen == "Open" ? true : false);
  201. }
  202. private void UIEvents_LLTDoorRaiseChangedEvent(DoorPara obj)
  203. {
  204. InvokeClient.Instance.Service.DoOperation($"TM.SetMFSlitDoor", obj.ModuleName, obj.IsOpen == "Open" ? true : false);
  205. }
  206. private void UIEvents_LLEDoorRaiseChangedEvent(DoorPara obj)
  207. {
  208. InvokeClient.Instance.Service.DoOperation($"TM.SetEFEMSlitDoor", obj.ModuleName, obj.IsOpen == "Open" ? true : false);
  209. }
  210. }
  211. }