ShellView.xaml.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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 MECF.Framework.Common.OperationCenter;
  19. using Aitex.Core.RT.OperationCenter;
  20. using Venus_MainPages.ViewModels;
  21. using MECF.Framework.Common.CommonData;
  22. using System.Windows.Controls.Primitives;
  23. using System.Timers;
  24. using System.Windows.Threading;
  25. using Venus_Themes.Unity;
  26. using Venus_Themes.UserControls;
  27. using OpenSEMI.Ctrlib.Controls;
  28. using OpenSEMI.ClientBase;
  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. string info = " from " + e.TranferFrom.ModuleID + " slot " + (e.TranferFrom.SlotID + 1).ToString() + " to " + e.TranferTo.ModuleID + " slot " + (e.TranferTo.SlotID + 1).ToString();
  81. string message = "Are you sure to transfer the wafer: \n" + info;
  82. WaferDialogViewModel vm = new WaferDialogViewModel();
  83. vm.ConfirmText = message;
  84. WaferDialogView dialog = new WaferDialogView()
  85. {
  86. Owner = Application.Current.MainWindow,
  87. };
  88. dialog.DataContext = vm;
  89. dialog.Height = 300;
  90. dialog.Width = 400;
  91. double angel = 0;
  92. double coolingtime = 0;
  93. if (dialog.ShowDialog() == true)
  94. {
  95. if ((bool)dialog.AlignFlag == true && !string.IsNullOrEmpty(dialog.Angle))
  96. {
  97. angel = Convert.ToDouble(dialog.Angle);
  98. }
  99. if ((bool)dialog.CoolingFlag == true && !string.IsNullOrEmpty(dialog.CoolingTime))
  100. {
  101. coolingtime = Convert.ToDouble(dialog.CoolingTime);
  102. }
  103. InvokeClient.Instance.Service.DoOperation("System.MoveWafer",
  104. e.TranferFrom.ModuleID, e.TranferFrom.SlotID, e.TranferTo.ModuleID, e.TranferTo.SlotID, false, 1, false, 1, "");
  105. e.TranferFrom.ClearDragDropStatus();
  106. e.TranferTo.ClearDragDropStatus();
  107. }
  108. else
  109. {
  110. ModuleManager.OnFlashWafer(new FlashWaferInformation() { ModuleName = e.TranferFrom.ModuleID, SoltId = e.TranferFrom.SlotID });
  111. //ModuleManager.OnFlashWafer(new FlashWaferInformation() { ModuleName = e.TranferTo.ModuleID, SoltId = e.TranferTo.SlotID });
  112. }
  113. }
  114. private void CustomWnd_Loaded(object sender, RoutedEventArgs e)
  115. {
  116. VenusMenu = SerializeHelper.Instance.ReadFromJsonFile<List<VenusMenu>>($"Config/UIMenu.json");
  117. int index = 0;
  118. for (int i = 0; i < VenusMenu.Count; i++)
  119. {
  120. if (VenusMenu[i].IsShow == false)
  121. {
  122. continue;
  123. }
  124. string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');
  125. if (VenusMenu[i].Id == "PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD" || VenusMenu[i].Id == "TM")
  126. {
  127. if (!allModules.Contains(VenusMenu[i].Id))
  128. {
  129. continue;
  130. }
  131. }
  132. //if (VenusMenu[i].Id == "SETM" && SC.GetStringValue("System.ChamberSelect") !="4" && SC.GetStringValue("System.ChamberSelect") != "5")
  133. //{
  134. // //不是SE DE
  135. // continue;
  136. //}
  137. AduRadioButtonIcon aduRadioButtonIcon = new AduRadioButtonIcon();
  138. if (i == 0)
  139. {
  140. aduRadioButtonIcon.IsChecked = true;
  141. }
  142. IconElement.SetPathData(aduRadioButtonIcon,(Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  143. aduRadioButtonIcon.Content = VenusMenu[i].Name;
  144. aduRadioButtonIcon.Click += AduRadioButtonIcon_Click;
  145. aduRadioButtonIcon.SelectBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6AD7FF"));
  146. aduRadioButtonIcon.SelectColor = new SolidColorBrush((Colors.Black));
  147. aduRadioButtonIcon.DefaultBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#94BCD7"));
  148. //aduRadioButtonIcon.DefaultBackground = new SolidColorBrush(Colors.DarkGray);
  149. aduRadioButtonIcon.Width = 180;
  150. aduRadioButtonIcon.Height= 40;
  151. //aduRadioButtonIcon.Foreground=Brushes.White;
  152. aduRadioButtonIcon.Tag = index;
  153. index += 1;
  154. Bottom_Frame.Children.Add(aduRadioButtonIcon);
  155. //if (VenusMenu[i].Id == "PMC")
  156. //{
  157. // AduRadioButtonIcon aduRadioButtonIcon2 = new AduRadioButtonIcon();
  158. // IconElement.SetPathData(aduRadioButtonIcon2, (Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  159. // aduRadioButtonIcon2.Content = "PMD";
  160. // //aduRadioButtonIcon2.Click += AduRadioButtonIcon_Click;
  161. // aduRadioButtonIcon2.SelectBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6AD7FF"));
  162. // aduRadioButtonIcon2.SelectColor = new SolidColorBrush((Colors.Black));
  163. // aduRadioButtonIcon2.DefaultBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#94BCD7"));
  164. // //aduRadioButtonIcon.DefaultBackground = new SolidColorBrush(Colors.DarkGray);
  165. // aduRadioButtonIcon2.Width = 180;
  166. // aduRadioButtonIcon2.Height = 40;
  167. // Bottom_Frame.Children.Add(aduRadioButtonIcon2);
  168. //}
  169. TabControl tabControl = new TabControl();
  170. for (int j = 0; j < VenusMenu[i].MenuItem.Count; j++)
  171. {
  172. if (VenusMenu[i].MenuItem[j].IsShow == false)
  173. {
  174. continue;
  175. }
  176. string className;
  177. if ((VenusMenu[i].Id == "PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD")&& VenusMenu[i].MenuItem[j].Id== "Operation")
  178. {
  179. JetChamber jetChamber = (JetChamber)(Convert.ToInt32(QueryDataClient.Instance.Service.GetConfig($"{VenusMenu[i].Id}.ChamberType")));
  180. className = $"Venus_MainPages.Views.Over{jetChamber.ToString()}View";
  181. }
  182. else
  183. {
  184. className = $"Venus_MainPages.Views.{VenusMenu[i].MenuItem[j].View}";
  185. }
  186. Type t = Type.GetType($"{className},Venus_MainPages");
  187. var obj = System.Activator.CreateInstance(t);
  188. if (VenusMenu[i].Id=="PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD" || VenusMenu[i].Id == "TM" || VenusMenu[i].Id == "SETM")
  189. {
  190. MethodInfo methodInfo = t.GetMethod("Init", new Type[] { typeof(string) });
  191. methodInfo?.Invoke(obj, new object[] { VenusMenu[i].Id });
  192. }
  193. tabControl.Items.Add(new TabItem() { Header = VenusMenu[i].MenuItem[j].Name, Content = obj });
  194. }
  195. centerTabViews.Add(tabControl);
  196. }
  197. Main_Frame.Content = centerTabViews[0];
  198. ModuleManager.Initialize();
  199. }
  200. public void Anystationchange(string menuviewItem, WaferHistoryWafer queryFilter)
  201. {
  202. UserControl address = new ProcessHistoryView();
  203. ProcessHistoryViewModel vm = new ProcessHistoryViewModel() {};
  204. vm.searchlot(queryFilter.WaferGuid);
  205. //vm.OnDataGridSelectionChanged(vm.Recipes[0]);
  206. address.DataContext = vm;
  207. int s = 0;
  208. for(int i = 0; i < centerTabViews.Count; i++)
  209. {
  210. var item = centerTabViews[i];
  211. foreach(TabItem v in item.Items)
  212. {
  213. if (v.Header.ToString()== "Process History")
  214. {
  215. s = i;
  216. }
  217. }
  218. }
  219. centerTabViews[s].Items[2]= new TabItem() { Header = menuviewItem, Content = address };
  220. centerTabViews[s].SelectedIndex = 2;
  221. Main_Frame.Content = centerTabViews[s];
  222. }
  223. private void AduRadioButtonIcon_Click(object sender, RoutedEventArgs e)
  224. {
  225. var currentButton = sender as AduRadioButtonIcon;
  226. Main_Frame.Content = centerTabViews[Convert.ToInt32(currentButton.Tag)];
  227. }
  228. private void CustomWnd_Closed(object sender, EventArgs e)
  229. {
  230. System.Diagnostics.Process.GetCurrentProcess().Kill();
  231. }
  232. private void UIEvents_ChamberCreateDeleteWaferEvent(WaferOperation obj)
  233. {
  234. if (obj.IsCreate == true)
  235. {
  236. InvokeClient.Instance.Service.DoOperation("CreateWafer", obj.ModuleName, 0);
  237. }
  238. else
  239. {
  240. InvokeClient.Instance.Service.DoOperation("DeleteWafer", obj.ModuleName, 0);
  241. }
  242. }
  243. private void UIEvents_PMDoorRaiseChangedEvent(DoorPara obj)
  244. {
  245. //InvokeClient.Instance.Service.DoOperation($"{obj?.ModuleName}.SlitDoor.{obj?.IsOpen}");
  246. InvokeClient.Instance.Service.DoOperation($"{obj?.ModuleName}.SetSlitDoor", obj.IsOpen == "Open" ? true : false);
  247. }
  248. private void UIEvents_LLTDoorRaiseChangedEvent(DoorPara obj)
  249. {
  250. InvokeClient.Instance.Service.DoOperation($"TM.SetMFSlitDoor", obj.ModuleName, obj.IsOpen == "Open" ? true : false);
  251. }
  252. private void UIEvents_LLEDoorRaiseChangedEvent(DoorPara obj)
  253. {
  254. InvokeClient.Instance.Service.DoOperation($"TM.SetEFEMSlitDoor", obj.ModuleName, obj.IsOpen == "Open" ? true : false);
  255. }
  256. }
  257. }