添加 MX-PD-盘古 项目文件
将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using MaxwellFramework.Core.Common.Command;
|
||||
using Stylet;
|
||||
|
||||
namespace MainShell.Common.ViewModel
|
||||
{
|
||||
public class MwMessageBoxWindowViewModel : PropertyChangedBase
|
||||
{
|
||||
private bool? _dialogResult;
|
||||
private MessageBoxResult _result;
|
||||
|
||||
public MwMessageBoxWindowViewModel(MwMessageBoxState state)
|
||||
{
|
||||
State = state ?? throw new ArgumentNullException(nameof(state));
|
||||
SelectButtonCommand = new DelegateCommand(OnSelectButton);
|
||||
WindowClosingCommand = new DelegateCommand(OnWindowClosing);
|
||||
}
|
||||
|
||||
public MwMessageBoxState State { get; }
|
||||
|
||||
public bool? DialogResult
|
||||
{
|
||||
get => _dialogResult;
|
||||
set => SetAndNotify(ref _dialogResult, value);
|
||||
}
|
||||
|
||||
public MessageBoxResult Result
|
||||
{
|
||||
get => _result;
|
||||
private set => SetAndNotify(ref _result, value);
|
||||
}
|
||||
|
||||
public ICommand SelectButtonCommand { get; }
|
||||
|
||||
public ICommand WindowClosingCommand { get; }
|
||||
|
||||
private void OnSelectButton(object parameter)
|
||||
{
|
||||
var definition = parameter as MwMessageBoxButtonDefinition;
|
||||
if (definition == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Result = definition.Result;
|
||||
DialogResult = true;
|
||||
}
|
||||
|
||||
private void OnWindowClosing(object parameter)
|
||||
{
|
||||
if (Result != MessageBoxResult.None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Result = MwMessageBox.ResolveFallbackResult(State);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user