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

namespace QC.QTMToolKit;

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

	private string caption = "";

	private string userInput = "";

	private int intData;

	private double doubleData;

	private string regularExpression = "";

	private RegexOptions regExOption;

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

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

	[QTMParameter(ParameterIOType.Output, TestList = "InputDialog", DefaultValue = "", Description = "User Input String")]
	public string UserInput
	{
		get
		{
			return userInput;
		}
		set
		{
			userInput = value;
		}
	}

	[QTMParameter(ParameterIOType.Output, TestList = "GetIntData", DefaultValue = "", Description = "User Input")]
	public int IntData
	{
		get
		{
			return intData;
		}
		set
		{
			intData = value;
		}
	}

	[QTMParameter(ParameterIOType.Output, TestList = "GetDoubleData", DefaultValue = "", Description = "User Input")]
	public double DoubleData
	{
		get
		{
			return doubleData;
		}
		set
		{
			doubleData = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "InputDialog", DefaultValue = "", Description = "Regular Expression used to test the User Input")]
	public string RegularExpression
	{
		get
		{
			return regularExpression;
		}
		set
		{
			regularExpression = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, TestList = "InputDialog", DefaultValue = "", Description = "Regular Expression Option for the regular expression")]
	public RegexOptions RegexOption
	{
		get
		{
			return regExOption;
		}
		set
		{
			regExOption = value;
		}
	}

	[QTMTest(CanAddToTestPlan = true)]
	public bool InputDialog()
	{
		InputForm inputForm = new InputForm();
		inputForm.lblMessage.Text = message;
		inputForm.Text = caption;
		inputForm.RegularExpression = regularExpression;
		inputForm.RegexOption = regExOption;
		if (DialogResult.OK == inputForm.ShowDialog())
		{
			userInput = inputForm.txtInput.Text;
			return true;
		}
		return false;
	}

	[QTMTest(CanAddToTestPlan = true)]
	public bool GetIntData()
	{
		InputForm inputForm = new InputForm();
		inputForm.lblMessage.Text = message;
		inputForm.Text = caption;
		inputForm.DataType = InputForm.InputDataTypes.IntType;
		inputForm.ShowDialog();
		intData = inputForm.IntData;
		return true;
	}

	[QTMTest(CanAddToTestPlan = true)]
	public bool GetDoubleData()
	{
		InputForm inputForm = new InputForm();
		inputForm.lblMessage.Text = message;
		inputForm.Text = caption;
		inputForm.DataType = InputForm.InputDataTypes.DoubleType;
		inputForm.ShowDialog();
		DoubleData = inputForm.DoubleData;
		return true;
	}
}
