ShellView.xaml.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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("MainRegion", typeof(Venus_MainPages.Views.OverView));
  34. //m_regionManager.RegisterViewWithRegion("MainRegion", typeof(Venus_MainPages.Views.RecipeView));
  35. //m_regionManager.RegisterViewWithRegion("MainRegion", typeof(Venus_MainPages.Views.DataAnalysisView));
  36. m_regionManager.RegisterViewWithRegion("TopRegion", typeof(Venus_MainPages.Views.TopView));
  37. }
  38. private void CustomWnd_Loaded(object sender, RoutedEventArgs e)
  39. {
  40. VenusMenu= SerializeHelper.Instance.ReadFromJsonFile<List<VenusMenu>>("Config/VenusMenu.json");
  41. for (int i = 0; i < VenusMenu.Count; i++)
  42. {
  43. Button button = new Button();
  44. button.Tag=i;
  45. button.Width = 150;
  46. button.Margin=new Thickness(20,10,0,10);
  47. button.Content = VenusMenu[i].Id;
  48. button.Click += Button_Click;
  49. buttonList.Add(button);
  50. if (i == 0)
  51. {
  52. button.Background= new SolidColorBrush(Colors.Green);
  53. }
  54. else
  55. {
  56. button.Background = new SolidColorBrush(Colors.Silver);
  57. }
  58. Bottom_Frame.Children.Add(button);
  59. TabControl tabControl = new TabControl();
  60. for (int j = 0; j < VenusMenu[i].MenuItem.Count; j++)
  61. {
  62. if (VenusMenu[i].MenuItem[j].View == "")
  63. {
  64. break;
  65. }
  66. string className = $"Venus_MainPages.Views.{VenusMenu[i].MenuItem[j].View}";
  67. Type t = Type.GetType($"{className},Venus_MainPages");
  68. tabControl.Items.Add(new TabItem() { Header= VenusMenu[i].MenuItem[j].Name, Content= Activator.CreateInstance(t)});
  69. }
  70. centerTabViews.Add(tabControl);
  71. }
  72. Main_Frame.Content = centerTabViews[0];
  73. }
  74. private void Button_Click(object sender, RoutedEventArgs e)
  75. {
  76. var currentButton = sender as Button;
  77. Main_Frame.Content = centerTabViews[Convert.ToInt32(currentButton.Tag)];
  78. buttonList.ForEach(x =>
  79. {
  80. x.Background = new SolidColorBrush(Colors.Silver);
  81. });
  82. currentButton.Background = new SolidColorBrush(Colors.Green);
  83. }
  84. }
  85. }