ShellView.xaml.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. namespace Venus_UI.Views
  19. {
  20. /// <summary>
  21. /// ShellView.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class ShellView : Window
  24. {
  25. IRegionManager m_regionManager;
  26. IRegionNavigationService m_regionNavigationService;
  27. List<VenusMenu> VenusMenu;
  28. List<TabControl> centerTabViews=new List<TabControl> ();
  29. List<Button> buttonList=new List<Button> ();
  30. public ShellView(IRegionManager regionManager, IRegionNavigationService regionNavigationService)
  31. {
  32. InitializeComponent();
  33. m_regionManager = regionManager;
  34. m_regionNavigationService = regionNavigationService;
  35. m_regionManager.RegisterViewWithRegion("TopRegion", typeof(Venus_MainPages.Views.TopView));
  36. VenusGlobalEvents.SlotRightClickChangedEvent += Instance_SlotRightClickChangedEvent;
  37. }
  38. private void Instance_SlotRightClickChangedEvent(OpenSEMI.Ctrlib.Controls.Slot slot)
  39. {
  40. if (slot != null)
  41. {
  42. ContextMenu cm = ContextMenuManager.Instance.GetSlotMenus(slot);
  43. if (cm != null)
  44. {
  45. slot.ContextMenu = cm;
  46. }
  47. return;
  48. }
  49. }
  50. private void CustomWnd_Loaded(object sender, RoutedEventArgs e)
  51. {
  52. VenusMenu= SerializeHelper.Instance.ReadFromJsonFile<List<VenusMenu>>("Config/VenusMenu.json");
  53. int index = 0;
  54. for (int i = 0; i < VenusMenu.Count; i++)
  55. {
  56. if (VenusMenu[i].IsShow == false)
  57. {
  58. continue;
  59. }
  60. AduRadioButtonIcon aduRadioButtonIcon = new AduRadioButtonIcon();
  61. if (i == 0)
  62. {
  63. aduRadioButtonIcon.IsChecked = true;
  64. }
  65. IconElement.SetPathData(aduRadioButtonIcon,(Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  66. aduRadioButtonIcon.Content = VenusMenu[i].Id;
  67. aduRadioButtonIcon.Click += AduRadioButtonIcon_Click;
  68. aduRadioButtonIcon.Tag = index;
  69. index += 1;
  70. Bottom_Frame.Children.Add(aduRadioButtonIcon);
  71. TabControl tabControl = new TabControl();
  72. for (int j = 0; j < VenusMenu[i].MenuItem.Count; j++)
  73. {
  74. if (VenusMenu[i].MenuItem[j].IsShow == false)
  75. {
  76. continue;
  77. }
  78. string className = $"Venus_MainPages.Views.{VenusMenu[i].MenuItem[j].View}";
  79. Type t = Type.GetType($"{className},Venus_MainPages");
  80. var obj = System.Activator.CreateInstance(t);
  81. if (VenusMenu[i].Id=="PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD" || VenusMenu[i].Id == "TM")
  82. {
  83. MethodInfo methodInfo = t.GetMethod("Init", new Type[] { typeof(string) });
  84. methodInfo?.Invoke(obj, new object[] { VenusMenu[i].Id });
  85. }
  86. tabControl.Items.Add(new TabItem() { Header = VenusMenu[i].MenuItem[j].Name, Content = obj });
  87. }
  88. centerTabViews.Add(tabControl);
  89. }
  90. Main_Frame.Content = centerTabViews[0];
  91. }
  92. private void AduRadioButtonIcon_Click(object sender, RoutedEventArgs e)
  93. {
  94. var currentButton = sender as AduRadioButtonIcon;
  95. Main_Frame.Content = centerTabViews[Convert.ToInt32(currentButton.Tag)];
  96. }
  97. private void CustomWnd_Closed(object sender, EventArgs e)
  98. {
  99. System.Diagnostics.Process.GetCurrentProcess().Kill();
  100. }
  101. }
  102. }