添加项目文件。
This commit is contained in:
109
OrpaonEMS.App/ViewModels/DialogBmsConfigViewModel.cs
Normal file
109
OrpaonEMS.App/ViewModels/DialogBmsConfigViewModel.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using OrpaonEMS.App.Models;
|
||||
using OrpaonEMS.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 OrpaonEMS.App.ViewModels
|
||||
{
|
||||
public class DialogBmsConfigViewModel : DialogViewModel
|
||||
{
|
||||
public DialogBmsConfigViewModel()
|
||||
{
|
||||
this.Title = "修改";
|
||||
}
|
||||
|
||||
private BmsRwCell _ConfigModel;
|
||||
/// <summary>
|
||||
/// 当前配置的值
|
||||
/// </summary>
|
||||
public BmsRwCell ConfigModel
|
||||
{
|
||||
get { return _ConfigModel; }
|
||||
set { _ConfigModel = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private DelegateCommand saveCmd;
|
||||
/// <summary>
|
||||
/// 保存命令
|
||||
/// </summary>
|
||||
public DelegateCommand SaveCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
saveCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (saveCmd == null)
|
||||
{
|
||||
saveCmd = new DelegateCommand(() => SaveCmdMethod());
|
||||
}
|
||||
return saveCmd;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存命令方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void SaveCmdMethod()
|
||||
{
|
||||
if (string.IsNullOrEmpty(ConfigModel.Name))
|
||||
{
|
||||
MessageBox.Show("请输入正确的名称!");
|
||||
return;
|
||||
}
|
||||
|
||||
DialogParameters pars = new DialogParameters
|
||||
{
|
||||
{ "Model", ConfigModel }
|
||||
};
|
||||
|
||||
RaiseRequestClose(new DialogResult(ButtonResult.OK, pars));
|
||||
}
|
||||
|
||||
private DelegateCommand cancelCmd;
|
||||
/// <summary>
|
||||
/// 保存命令
|
||||
/// </summary>
|
||||
public DelegateCommand CancelCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
cancelCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (cancelCmd == null)
|
||||
{
|
||||
cancelCmd = new DelegateCommand(() => CancelCmdMethod());
|
||||
}
|
||||
return cancelCmd;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消命令方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void CancelCmdMethod()
|
||||
{
|
||||
RaiseRequestClose(new DialogResult(ButtonResult.Cancel));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口打开时的传递的参数
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
public override void OnDialogOpened(IDialogParameters parameters)
|
||||
{
|
||||
ConfigModel = parameters.GetValue<BmsRwCell>("Model");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user