ShellView.xaml.cs 3.9 KB

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