77 lines
1.6 KiB
C#
77 lines
1.6 KiB
C#
///
|
|
/// Copyright (c) 2013-2018 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 MessageBoxOp : IOperation
|
|
{
|
|
MessageBoxForm messageBoxForm;
|
|
|
|
string message;
|
|
Color backColor;
|
|
bool completed = false;
|
|
|
|
/// <returns>Reference to the operation</returns>
|
|
public MessageBoxOp()
|
|
: this(Strings.Message)
|
|
{
|
|
}
|
|
|
|
public MessageBoxOp(string message)
|
|
: this (message, Color.Goldenrod)
|
|
{
|
|
}
|
|
|
|
public MessageBoxOp(string message, Color backColor)
|
|
{
|
|
this.message = message;
|
|
this.backColor = backColor;
|
|
}
|
|
|
|
delegate void MessageBoxFormDlgt(MessageBoxOp myRef);
|
|
///
|
|
void OpenFormDlg(MessageBoxOp myRef)
|
|
{
|
|
myRef.messageBoxForm = new MessageBoxForm(message, backColor);
|
|
messageBoxForm.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 (completed || messageBoxForm.Completed)
|
|
{
|
|
completed = true;
|
|
messageBoxForm = null;
|
|
return Event.OK;
|
|
}
|
|
|
|
return Event.None;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
if (messageBoxForm != null)
|
|
{
|
|
messageBoxForm.OnCloseThisForm(this, null);
|
|
messageBoxForm = null;
|
|
}
|
|
}
|
|
}
|
|
}
|