Files
CapMachine/CapMachine.Wpf/ViewModels/HostDialogViewModel.cs
Tyrone CT e49a48fb25 增加了初始弹窗,但是没有成功
更改了CAN和LIN协调
更改了配置程序的名称顺序
2025-01-11 12:04:34 +08:00

61 lines
1.7 KiB
C#

using CapMachine.Wpf.Services;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using Prism.Ioc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CapMachine.Wpf.ViewModels
{
public abstract class HostDialogViewModel : BindableBase, IHostDialogAware
{
public string Title { get; set; }
public string IdentifierName { get; set; }
public DelegateCommand SaveCommand { get; private set; }
public DelegateCommand CancelCommand { get; private set; }
private IHostDialogService dialogService;
public HostDialogViewModel()
{
SaveCommand = new DelegateCommand(async () => await Save());
CancelCommand = new DelegateCommand(Cancel);
dialogService = ContainerLocator.Container.Resolve<IHostDialogService>();
}
public virtual void Cancel()
{
dialogService.Close(IdentifierName, new DialogResult(ButtonResult.No));
}
public virtual async Task Save()
{
dialogService.Close(IdentifierName, new DialogResult(ButtonResult.OK));
await Task.CompletedTask;
}
protected virtual void Save(object value)
{
DialogParameters param = new DialogParameters();
param.Add("Value", value);
dialogService.Close(IdentifierName, new DialogResult(ButtonResult.OK, param));
}
protected virtual void Save(DialogParameters param)
{
dialogService.Close(IdentifierName, new DialogResult(ButtonResult.OK, param));
}
public abstract void OnDialogOpened(IDialogParameters parameters);
}
}