ShellView.xaml.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using OpenSEMI.Ctrlib.Window;
  2. using Prism.Regions;
  3. using System.Collections.Generic;
  4. using System.Windows;
  5. using Venus_Themes.CustomControls;
  6. using Venus_UI.Themes.Attach;
  7. using Venus_Unity;
  8. using System.Linq;
  9. using System.Threading;
  10. using System;
  11. using Venus_MainPages.Views;
  12. using System.Windows.Controls;
  13. using Aitex.Core.UI.View.Frame;
  14. using System.Windows.Media;
  15. using Venus_Core;
  16. using System.Reflection;
  17. using Venus_MainPages.Unity;
  18. using MECF.Framework.Common.DataCenter;
  19. using Aitex.Core.RT.SCCore;
  20. namespace Venus_UI.Views
  21. {
  22. /// <summary>
  23. /// ShellView.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class ShellView : Window
  26. {
  27. IRegionManager m_regionManager;
  28. IRegionNavigationService m_regionNavigationService;
  29. List<VenusMenu> VenusMenu;
  30. List<TabControl> centerTabViews=new List<TabControl> ();
  31. List<Button> buttonList=new List<Button> ();
  32. public ShellView(IRegionManager regionManager, IRegionNavigationService regionNavigationService)
  33. {
  34. InitializeComponent();
  35. m_regionManager = regionManager;
  36. m_regionNavigationService = regionNavigationService;
  37. m_regionManager.RegisterViewWithRegion("TopRegion", typeof(Venus_MainPages.Views.TopView));
  38. VenusGlobalEvents.SlotRightClickChangedEvent += Instance_SlotRightClickChangedEvent;
  39. }
  40. private void Instance_SlotRightClickChangedEvent(OpenSEMI.Ctrlib.Controls.Slot slot)
  41. {
  42. if (slot != null)
  43. {
  44. ContextMenu cm = ContextMenuManager.Instance.GetSlotMenus(slot);
  45. if (cm != null)
  46. {
  47. slot.ContextMenu = cm;
  48. }
  49. return;
  50. }
  51. }
  52. private void CustomWnd_Loaded(object sender, RoutedEventArgs e)
  53. {
  54. JetChamber jetChamber = (JetChamber)(SC.GetValue<int>("System.ChamberSelect"));//Venus or Kepler
  55. VenusMenu = SerializeHelper.Instance.ReadFromJsonFile<List<VenusMenu>>($"Config/{jetChamber.ToString()}Menu.json");
  56. int index = 0;
  57. for (int i = 0; i < VenusMenu.Count; i++)
  58. {
  59. if (VenusMenu[i].IsShow == false)
  60. {
  61. continue;
  62. }
  63. AduRadioButtonIcon aduRadioButtonIcon = new AduRadioButtonIcon();
  64. if (i == 0)
  65. {
  66. aduRadioButtonIcon.IsChecked = true;
  67. }
  68. IconElement.SetPathData(aduRadioButtonIcon,(Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  69. aduRadioButtonIcon.Content = VenusMenu[i].Id;
  70. aduRadioButtonIcon.Click += AduRadioButtonIcon_Click;
  71. aduRadioButtonIcon.Tag = index;
  72. index += 1;
  73. Bottom_Frame.Children.Add(aduRadioButtonIcon);
  74. TabControl tabControl = new TabControl();
  75. for (int j = 0; j < VenusMenu[i].MenuItem.Count; j++)
  76. {
  77. if (VenusMenu[i].MenuItem[j].IsShow == false)
  78. {
  79. continue;
  80. }
  81. string className = $"Venus_MainPages.Views.{VenusMenu[i].MenuItem[j].View}";
  82. Type t = Type.GetType($"{className},Venus_MainPages");
  83. var obj = System.Activator.CreateInstance(t);
  84. if (VenusMenu[i].Id=="PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD" || VenusMenu[i].Id == "TM")
  85. {
  86. MethodInfo methodInfo = t.GetMethod("Init", new Type[] { typeof(string) });
  87. methodInfo?.Invoke(obj, new object[] { VenusMenu[i].Id });
  88. }
  89. tabControl.Items.Add(new TabItem() { Header = VenusMenu[i].MenuItem[j].Name, Content = obj });
  90. }
  91. centerTabViews.Add(tabControl);
  92. }
  93. Main_Frame.Content = centerTabViews[0];
  94. }
  95. private void AduRadioButtonIcon_Click(object sender, RoutedEventArgs e)
  96. {
  97. var currentButton = sender as AduRadioButtonIcon;
  98. Main_Frame.Content = centerTabViews[Convert.ToInt32(currentButton.Tag)];
  99. }
  100. private void CustomWnd_Closed(object sender, EventArgs e)
  101. {
  102. System.Diagnostics.Process.GetCurrentProcess().Kill();
  103. }
  104. }
  105. }