using OpenSEMI.Ctrlib.Window;
using Prism.Regions;
using System.Collections.Generic;
using System.Windows;
using Venus_Themes.CustomControls;
using Venus_UI.Models;
using Venus_UI.Themes.Attach;
using Venus_Unity;
using System.Linq;
using System.Threading;
using System;
using Venus_MainPages.Views;
using System.Windows.Controls;
using Aitex.Core.UI.View.Frame;
using System.Windows.Media;
namespace Venus_UI.Views
{
///
/// ShellView.xaml 的交互逻辑
///
public partial class ShellView : CustomWnd
{
IRegionManager m_regionManager;
IRegionNavigationService m_regionNavigationService;
List VenusMenu;
List centerTabViews=new List ();
List buttonList=new List ();
public ShellView(IRegionManager regionManager, IRegionNavigationService regionNavigationService)
{
InitializeComponent();
m_regionManager = regionManager;
m_regionNavigationService = regionNavigationService;
//m_regionManager.RegisterViewWithRegion("MainRegion", typeof(Venus_MainPages.Views.OverView));
//m_regionManager.RegisterViewWithRegion("MainRegion", typeof(Venus_MainPages.Views.RecipeView));
//m_regionManager.RegisterViewWithRegion("MainRegion", typeof(Venus_MainPages.Views.DataAnalysisView));
m_regionManager.RegisterViewWithRegion("TopRegion", typeof(Venus_MainPages.Views.TopView));
}
private void CustomWnd_Loaded(object sender, RoutedEventArgs e)
{
VenusMenu= SerializeHelper.Instance.ReadFromJsonFile>("Config/VenusMenu.json");
for (int i = 0; i < VenusMenu.Count; i++)
{
Button button = new Button();
button.Tag=i;
button.Width = 150;
button.Margin=new Thickness(20,10,0,10);
button.Content = VenusMenu[i].Id;
button.Click += Button_Click;
buttonList.Add(button);
if (i == 0)
{
button.Background= new SolidColorBrush(Colors.Green);
}
else
{
button.Background = new SolidColorBrush(Colors.Silver);
}
Bottom_Frame.Children.Add(button);
TabControl tabControl = new TabControl();
for (int j = 0; j < VenusMenu[i].MenuItem.Count; j++)
{
if (VenusMenu[i].MenuItem[j].View == "")
{
break;
}
string className = $"Venus_MainPages.Views.{VenusMenu[i].MenuItem[j].View}";
Type t = Type.GetType($"{className},Venus_MainPages");
tabControl.Items.Add(new TabItem() { Header= VenusMenu[i].MenuItem[j].Name, Content= Activator.CreateInstance(t)});
}
centerTabViews.Add(tabControl);
}
Main_Frame.Content = centerTabViews[0];
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var currentButton = sender as Button;
Main_Frame.Content = centerTabViews[Convert.ToInt32(currentButton.Tag)];
buttonList.ForEach(x =>
{
x.Background = new SolidColorBrush(Colors.Silver);
});
currentButton.Background = new SolidColorBrush(Colors.Green);
}
}
}