You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.3 KiB
C#

using MaterialTraceabilityUI.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace MaterialTraceabilityUI.ViewModel
{
public class MainWindowViewModel: NotifyPropertyBase
{
private readonly string process = ConfigurationManager.AppSettings["ProcessID"];
public CommandBase ChangeContentCommand { get; set; }
private FrameworkElement childContent;
public FrameworkElement ChildContent
{
get { return childContent; }
set { childContent = value; this.Notify(); }
}
private bool isShowWait;
public bool IsShowWait
{
get { return isShowWait; }
set { isShowWait = value; this.Notify(); }
}
public MainWindowViewModel()
{
this.IsShowWait = false;
this.ChangeContentCommand = new CommandBase();
this.ChangeContentCommand.ExcuteAction = new Action<object>(DoChangeContent);
this.ChangeContentCommand.CanExecuteFunc = new Func<bool>(() => true);
//涂布CoatingProcess、冷压firstPage、模切DieCuttingProcess
this.DoChangeContent("");
}
private void DoChangeContent(object param)
{
if (param.ToString() == "" || param.ToString() == "IndexPage")
{
// 初始化需要显示的Content对象
if (process == "TB")
{
param = "CoatingProcess";
}
if (process.Contains("LY"))
{
param = "firstPage";
}
if (process.Contains("MQ"))
{
param = "DieCuttingProcess";
}
if (process.Contains("AB"))
{
param = "intaglioPage";
}
}
Type type = Type.GetType("MaterialTraceabilityUI." + param.ToString());
ConstructorInfo ct1 = type.GetConstructor(System.Type.EmptyTypes);
this.ChildContent = (FrameworkElement)ct1.Invoke(null);
}
}
}