using System.Windows.Forms;
using QC.QTMDotNetKernelInterface;

namespace QC.QTMToolKit;

[QTMTestClass]
public class QTMMessageBox
{
	private string message = "";

	private string caption = "";

	private MessageBoxButtons buttons;

	private int result;

	[QTMParameter(ParameterIOType.Input, DefaultValue = "QSPR Message", Description = "Message displayed on the Message Box")]
	public string Message
	{
		get
		{
			return message;
		}
		set
		{
			message = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, DefaultValue = "QSPR", Description = "Caption the Message Box")]
	public string Caption
	{
		get
		{
			return caption;
		}
		set
		{
			caption = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, DefaultValue = "OK", Description = "Message Box Buttons")]
	public MessageBoxButtons Buttons
	{
		get
		{
			return buttons;
		}
		set
		{
			buttons = value;
		}
	}

	[QTMParameter(ParameterIOType.Output, DefaultValue = "0", UpperLimit = "7", LowerLimit = "0", Description = "OK=1,Cancel=2,Abort=3,Retry=4,Ignore=5,Yes=6,No=7")]
	public int Result
	{
		get
		{
			return result;
		}
		set
		{
			result = value;
		}
	}

	[QTMTest(CanAddToTestPlan = true)]
	public bool QMessageBox()
	{
		MessageBoxIcon icon = MessageBoxIcon.None;
		switch (buttons)
		{
		case MessageBoxButtons.AbortRetryIgnore:
		case MessageBoxButtons.RetryCancel:
			icon = MessageBoxIcon.Hand;
			break;
		case MessageBoxButtons.OK:
			icon = MessageBoxIcon.Asterisk;
			break;
		case MessageBoxButtons.OKCancel:
		case MessageBoxButtons.YesNoCancel:
		case MessageBoxButtons.YesNo:
			icon = MessageBoxIcon.Question;
			break;
		}
		message = message.Replace("\\n", "\n");
		DialogResult dialogResult = MessageBox.Show(message, caption, buttons, icon);
		result = (int)dialogResult;
		return true;
	}
}
