using MaterialTraceabilityUI.Common; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows; namespace MaterialTraceabilityUI.ViewModel { internal class FirstPageViewModel : NotifyPropertyBase { public CommandBase RecordChangeContentCommand { get; set; } public CommandBase LogChangeContentCommand { get; set; } private FrameworkElement recordContent; private FrameworkElement logContent; public FrameworkElement RecordContent { get { return recordContent; } set { recordContent = value; this.Notify(); } } public FrameworkElement LogContent { get { return logContent; } set { logContent = value; this.Notify(); } } private bool isShowWait; public bool IsShowWait { get { return isShowWait; } set { isShowWait = value; this.Notify(); } } public FirstPageViewModel() { this.IsShowWait = false; this.RecordChangeContentCommand = new CommandBase(); this.RecordChangeContentCommand.ExcuteAction = new Action(DoRecordChangeContent); this.RecordChangeContentCommand.CanExecuteFunc = new Func(() => true); this.LogChangeContentCommand = new CommandBase(); this.LogChangeContentCommand.ExcuteAction = new Action(DoLogChangeContent); this.LogChangeContentCommand.CanExecuteFunc = new Func(() => true); //单记录、完工记录 this.DoRecordChangeContent("OrderRecordControl"); //MES日志、PLC日志 this.DoLogChangeContent("MesLogControl"); } private void DoRecordChangeContent(object param) { // 初始化需要显示的Content对象 Type type = Type.GetType("MaterialTraceabilityUI." + param.ToString()); ConstructorInfo ct1 = type.GetConstructor(System.Type.EmptyTypes); this.RecordContent = (FrameworkElement)ct1.Invoke(null); } private void DoLogChangeContent(object param) { // 初始化需要显示的Content对象 Type type = Type.GetType("MaterialTraceabilityUI." + param.ToString()); ConstructorInfo ct1 = type.GetConstructor(System.Type.EmptyTypes); this.LogContent = (FrameworkElement)ct1.Invoke(null); } } }