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.

78 lines
2.5 KiB
C#

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<object>(DoRecordChangeContent);
this.RecordChangeContentCommand.CanExecuteFunc = new Func<bool>(() => true);
this.LogChangeContentCommand = new CommandBase();
this.LogChangeContentCommand.ExcuteAction = new Action<object>(DoLogChangeContent);
this.LogChangeContentCommand.CanExecuteFunc = new Func<bool>(() => 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);
}
}
}