tbf/TBF/BenchControl/Operations/AskYesNoOp.cs

62 lines
1.3 KiB
C#

///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.BenchControl;
using TBF.Resources;
namespace TBF.BenchControl.Operations
{
public class AskYesNoOp : IOperation
{
AskYesNoForm askYesNoForm;
string question;
/// <returns>Reference to the operation</returns>
public AskYesNoOp()
: this(Strings.Question)
{
}
public AskYesNoOp(string question)
{
this.question = question;
}
delegate void AskYesNoFormDlgt(AskYesNoOp myRef);
///
void OpenFormDlg(AskYesNoOp myRef)
{
myRef.askYesNoForm = new AskYesNoForm(question);
askYesNoForm.Show();
}
/// <summary>Start this operation</summary>
public void Start()
{
Program.MainWnd.Invoke(new AskYesNoFormDlgt(OpenFormDlg), this);
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
if (askYesNoForm.CompletedYes) return Event.Yes;
if (askYesNoForm.CompletedNo) return Event.No;
return Event.None;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
if (askYesNoForm != null)
{
askYesNoForm.OnCloseThisForm(this, null);
askYesNoForm = null;
}
}
}
}