using CapMachine.Core; using Prism.Commands; using Prism.Services.Dialogs; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace CapMachine.Wpf.ViewModels { public class DialogMeterCycleCountViewModel : DialogViewModel { public DialogMeterCycleCountViewModel() { this.Title = "循环次数配置"; } private int _CycleCount; /// /// 循环次数 /// public int CycleCount { get { return _CycleCount; } set { _CycleCount = value; RaisePropertyChanged(); } } private DelegateCommand saveCmd; /// /// 保存命令 /// public DelegateCommand SaveCmd { set { saveCmd = value; } get { if (saveCmd == null) { saveCmd = new DelegateCommand(() => SaveCmdMethod()); } return saveCmd; } } /// /// 保存命令方法 /// /// private void SaveCmdMethod() { //if (string.IsNullOrEmpty(Name)) //{ // MessageBox.Show("请输入正确的名称!"); // return; //} DialogParameters pars = new DialogParameters { { "CycleCount", CycleCount } }; RaiseRequestClose(new DialogResult(ButtonResult.OK, pars)); } private DelegateCommand cancelCmd; /// /// 保存命令 /// public DelegateCommand CancelCmd { set { cancelCmd = value; } get { if (cancelCmd == null) { cancelCmd = new DelegateCommand(() => CancelCmdMethod()); } return cancelCmd; } } /// /// 取消命令方法 /// /// private void CancelCmdMethod() { RaiseRequestClose(new DialogResult(ButtonResult.Cancel)); } /// /// 窗口打开时的传递的参数 /// /// public override void OnDialogOpened(IDialogParameters parameters) { CycleCount = parameters.GetValue("CycleCount"); } } }