ShellView.xaml.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.Models;
  7. using Venus_UI.Themes.Attach;
  8. using Venus_Unity;
  9. using System.Linq;
  10. using System.Threading;
  11. using System;
  12. using Venus_MainPages.Views;
  13. using System.Windows.Controls;
  14. using Aitex.Core.UI.View.Frame;
  15. using System.Windows.Media;
  16. namespace Venus_UI.Views
  17. {
  18. /// <summary>
  19. /// ShellView.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class ShellView : CustomWnd
  22. {
  23. IRegionManager m_regionManager;
  24. IRegionNavigationService m_regionNavigationService;
  25. List<VenusMenu> VenusMenu;
  26. List<TabControl> centerTabViews=new List<TabControl> ();
  27. List<Button> buttonList=new List<Button> ();
  28. public ShellView(IRegionManager regionManager, IRegionNavigationService regionNavigationService)
  29. {
  30. InitializeComponent();
  31. m_regionManager = regionManager;
  32. m_regionNavigationService = regionNavigationService;
  33. m_regionManager.RegisterViewWithRegion("TopRegion", typeof(Venus_MainPages.Views.TopView));
  34. }
  35. private void CustomWnd_Loaded(object sender, RoutedEventArgs e)
  36. {
  37. VenusMenu= SerializeHelper.Instance.ReadFromJsonFile<List<VenusMenu>>("Config/VenusMenu.json");
  38. for (int i = 0; i < VenusMenu.Count; i++)
  39. {
  40. AduRadioButtonIcon aduRadioButtonIcon = new AduRadioButtonIcon();
  41. if (i == 0)
  42. {
  43. aduRadioButtonIcon.IsChecked = true;
  44. }
  45. IconElement.SetPathData(aduRadioButtonIcon,(Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  46. aduRadioButtonIcon.Content = VenusMenu[i].Id;
  47. aduRadioButtonIcon.Click += AduRadioButtonIcon_Click;
  48. aduRadioButtonIcon.Tag = i;
  49. Bottom_Frame.Children.Add(aduRadioButtonIcon);
  50. TabControl tabControl = new TabControl();
  51. for (int j = 0; j < VenusMenu[i].MenuItem.Count; j++)
  52. {
  53. if (VenusMenu[i].MenuItem[j].View == "")
  54. {
  55. break;
  56. }
  57. string className = $"Venus_MainPages.Views.{VenusMenu[i].MenuItem[j].View}";
  58. Type t = Type.GetType($"{className},Venus_MainPages");
  59. tabControl.Items.Add(new TabItem() { Header= VenusMenu[i].MenuItem[j].Name, Content= Activator.CreateInstance(t)});
  60. }
  61. centerTabViews.Add(tabControl);
  62. }
  63. Main_Frame.Content = centerTabViews[0];
  64. }
  65. private void AduRadioButtonIcon_Click(object sender, RoutedEventArgs e)
  66. {
  67. var currentButton = sender as AduRadioButtonIcon;
  68. Main_Frame.Content = centerTabViews[Convert.ToInt32(currentButton.Tag)];
  69. }
  70. }
  71. }