tbf/TBF/BenchControl/Operations/LargeMessageBoxOp.cs

72 lines
1.6 KiB
C#

///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using TBF.BenchControl;
using TBF.Resources;
namespace TBF.BenchControl.Operations
{
public class LargeMessageBoxOp : IOperation
{
LargeMessageBoxForm form;
string message;
Color backColor;
bool completed = false;
/// <returns>Reference to the operation</returns>
public LargeMessageBoxOp()
: this(Strings.Message)
{
}
public LargeMessageBoxOp(string message)
: this (message, Color.Goldenrod)
{
}
public LargeMessageBoxOp(string message, Color backColor)
{
this.message = message;
this.backColor = backColor;
}
delegate void MessageBoxFormDlgt(LargeMessageBoxOp myRef);
///
void OpenFormDlg(LargeMessageBoxOp myRef)
{
myRef.form = new LargeMessageBoxForm(message, backColor);
form.Show();
}
/// <summary>Start this operation</summary>
public void Start()
{
completed = false;
Program.MainWnd.Invoke(new MessageBoxFormDlgt(OpenFormDlg), this);
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
if (form.CompletedContinue) return Event.Continue;
if (form.CompletedAbort) return Event.Abort;
return Event.None;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
if (form != null)
{
form.OnCloseThisForm(this, null);
form = null;
}
}
}
}