73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
using MonitoringTechnology.Base;
|
|
using MonitoringTechnology.Common;
|
|
using MonitoringTechnology.Views;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace MonitoringTechnology.ViewModels
|
|
{
|
|
public class MainViewModel : NotifyPropertyBase
|
|
{
|
|
|
|
private UIElement _mainContent;
|
|
|
|
public UIElement MainContent
|
|
{
|
|
get { return _mainContent; }
|
|
set
|
|
{
|
|
Set<UIElement>(ref _mainContent, value);
|
|
}
|
|
}
|
|
|
|
public CommandBase TabChangedCommand { get; set; }
|
|
|
|
public MainViewModel()
|
|
{
|
|
TabChangedCommand = new CommandBase(OnTabChanged);
|
|
|
|
OnTabChanged("MonitoringTechnology.Views.FirstPageView");
|
|
}
|
|
|
|
private void OnTabChanged(object obj)
|
|
{
|
|
if (obj == null) return;
|
|
// 完整方式
|
|
//string[] strValues = o.ToString().Split('|');
|
|
//Assembly assembly = Assembly.LoadFrom(strValues[0]);
|
|
//Type type = assembly.GetType(strValues[1]);
|
|
//this.MainContent = (UIElement)Activator.CreateInstance(type);
|
|
|
|
//切换页面之前清理一下内存
|
|
tools.ClearMemory(this);
|
|
|
|
|
|
// 简化方式,必须在同一个程序集下
|
|
|
|
if (obj.ToString().Equals("MonitoringTechnology.Views.SystemOperationView"))
|
|
{
|
|
if (LYScanPage._bleDevice.Mac != null)
|
|
{
|
|
SystemOperationView view = new SystemOperationView(LYScanPage._bleDevice);
|
|
MainWindow.mainViewModel.MainContent = view;
|
|
}
|
|
else
|
|
{
|
|
Type type = Type.GetType(obj.ToString());
|
|
this.MainContent = (UIElement)Activator.CreateInstance(type);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Type type = Type.GetType(obj.ToString());
|
|
this.MainContent = (UIElement)Activator.CreateInstance(type);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|