2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
2018-02-06 14:26:50 +00:00
|
|
|
|
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
|
2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
using System.Collections.Generic;
|
2018-02-06 14:26:50 +00:00
|
|
|
|
using System.Drawing;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
using TBF.BenchControl;
|
2014-08-12 20:21:26 +00:00
|
|
|
|
using TBF.Resources;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.Operations
|
|
|
|
|
|
{
|
|
|
|
|
|
public class MessageBoxOp : IOperation
|
|
|
|
|
|
{
|
2018-09-18 13:25:31 +00:00
|
|
|
|
MessageBoxForm messageBoxForm;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
|
2014-08-12 20:21:26 +00:00
|
|
|
|
string message;
|
2018-02-06 14:26:50 +00:00
|
|
|
|
Color backColor;
|
2016-10-10 12:23:20 +00:00
|
|
|
|
bool completed = false;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
|
|
|
|
|
|
/// <returns>Reference to the operation</returns>
|
|
|
|
|
|
public MessageBoxOp()
|
2014-08-12 20:21:26 +00:00
|
|
|
|
: this(Strings.Message)
|
2014-08-12 16:22:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-06 14:26:50 +00:00
|
|
|
|
public MessageBoxOp(string message)
|
|
|
|
|
|
: this (message, Color.Goldenrod)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public MessageBoxOp(string message, Color backColor)
|
2014-08-12 16:22:32 +00:00
|
|
|
|
{
|
2014-08-12 20:21:26 +00:00
|
|
|
|
this.message = message;
|
2018-02-06 14:26:50 +00:00
|
|
|
|
this.backColor = backColor;
|
2014-08-12 16:22:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-12 20:21:26 +00:00
|
|
|
|
delegate void MessageBoxFormDlgt(MessageBoxOp myRef);
|
2014-08-12 16:22:32 +00:00
|
|
|
|
///
|
|
|
|
|
|
void OpenFormDlg(MessageBoxOp myRef)
|
|
|
|
|
|
{
|
2018-09-18 13:25:31 +00:00
|
|
|
|
myRef.messageBoxForm = new MessageBoxForm(message, backColor);
|
|
|
|
|
|
messageBoxForm.Show();
|
2014-08-12 16:22:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Start this operation</summary>
|
|
|
|
|
|
public void Start()
|
|
|
|
|
|
{
|
2016-10-10 12:23:20 +00:00
|
|
|
|
completed = false;
|
|
|
|
|
|
Program.MainWnd.Invoke(new MessageBoxFormDlgt(OpenFormDlg), this);
|
2014-08-12 16:22:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Run this operation</summary>
|
|
|
|
|
|
/// <returns>Event.ResultsPrinted</returns>
|
|
|
|
|
|
public Event Run()
|
|
|
|
|
|
{
|
2018-09-18 13:25:31 +00:00
|
|
|
|
if (completed || messageBoxForm.Completed)
|
2016-10-10 12:23:20 +00:00
|
|
|
|
{
|
|
|
|
|
|
completed = true;
|
2018-09-18 13:25:31 +00:00
|
|
|
|
messageBoxForm = null;
|
2016-10-10 12:23:20 +00:00
|
|
|
|
return Event.OK;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-12 16:22:32 +00:00
|
|
|
|
return Event.None;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
|
|
|
|
public void Stop()
|
|
|
|
|
|
{
|
2018-09-18 13:25:31 +00:00
|
|
|
|
if (messageBoxForm != null)
|
2016-10-10 12:23:20 +00:00
|
|
|
|
{
|
2018-09-18 13:25:31 +00:00
|
|
|
|
messageBoxForm.OnCloseThisForm(this, null);
|
|
|
|
|
|
messageBoxForm = null;
|
2016-10-10 12:23:20 +00:00
|
|
|
|
}
|
2014-08-12 16:22:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|