2021-12-26 21:56:44 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using ReactiveUI;
|
|
|
|
|
|
2021-12-30 00:15:37 +00:00
|
|
|
|
namespace Wabbajack
|
2021-12-26 21:56:44 +00:00
|
|
|
|
{
|
|
|
|
|
public abstract class ConfirmationIntervention : AUserIntervention
|
|
|
|
|
{
|
|
|
|
|
public enum Choice
|
|
|
|
|
{
|
|
|
|
|
Continue,
|
|
|
|
|
Abort
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TaskCompletionSource<Choice> _source = new TaskCompletionSource<Choice>();
|
|
|
|
|
public Task<Choice> Task => _source.Task;
|
|
|
|
|
|
|
|
|
|
public ICommand ConfirmCommand { get; }
|
|
|
|
|
|
|
|
|
|
public ConfirmationIntervention()
|
|
|
|
|
{
|
|
|
|
|
ConfirmCommand = ReactiveCommand.Create(() => Confirm());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Cancel()
|
|
|
|
|
{
|
|
|
|
|
Handled = true;
|
|
|
|
|
_source.SetResult(Choice.Abort);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Confirm()
|
|
|
|
|
{
|
|
|
|
|
Handled = true;
|
|
|
|
|
_source.SetResult(Choice.Continue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|