using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Xml.Serialization;
using QC.QsprTestObjects.Parameters;
using QC.QsprTestObjects.Tests.Base;
using QC.QTMInterface;

namespace QC.QsprTestObjects.Tests.Script;

[Serializable]
public class ScriptTestProperties : TestProperties
{
	private bool bRedirectStandardOutput = true;

	private bool bUseShellExecute;

	private bool bCreateNoWindow = true;

	private string verb = "";

	private string workingDirectory = "";

	private string debugWindowName = "Script Log";

	private bool exitAfterStart;

	[Description("Name of the debug window.")]
	[Category("Script Settings")]
	public string DebugWindowName
	{
		get
		{
			return debugWindowName;
		}
		set
		{
			debugWindowName = value.Trim();
			if (debugWindowName.Length == 0)
			{
				debugWindowName = "Script Log";
			}
		}
	}

	[DefaultValue(true)]
	[Category("Script Settings")]
	[Description("Set to True for getting standard output from the script.")]
	public bool RedirectStandardOutput
	{
		get
		{
			return bRedirectStandardOutput;
		}
		set
		{
			bRedirectStandardOutput = value;
			if (bRedirectStandardOutput)
			{
				bUseShellExecute = false;
			}
		}
	}

	[Description("Sets and Gets the working directory of the script")]
	[DefaultValue("")]
	[Category("Script Settings")]
	[Editor(typeof(OpenDirectoryUITypeEditor), typeof(UITypeEditor))]
	public string WorkingDirectory
	{
		get
		{
			return workingDirectory;
		}
		set
		{
			workingDirectory = value;
		}
	}

	[Category("Script Settings")]
	[DefaultValue(false)]
	[Description("Set to True for running scripts. No RedirectStandard Output")]
	public bool UseShellExecute
	{
		get
		{
			return bUseShellExecute;
		}
		set
		{
			bUseShellExecute = value;
			if (bUseShellExecute)
			{
				bRedirectStandardOutput = false;
			}
		}
	}

	[DefaultValue("")]
	[Category("Script Settings")]
	[Description("open, print, perl etc. The Action set up in the 'Folder Options\\File Types' in the Windows Explorer")]
	public string Verb
	{
		get
		{
			return verb;
		}
		set
		{
			verb = value;
		}
	}

	[Description("False means  to create a window and run the App.")]
	[DefaultValue(true)]
	[Category("Script Settings")]
	public bool CreateNoWindow
	{
		get
		{
			return bCreateNoWindow;
		}
		set
		{
			bCreateNoWindow = value;
		}
	}

	[DefaultValue(false)]
	[Category("Script Settings")]
	[Description("QSPR continues running after starting the script. QSPR does not wait till the script ends")]
	public bool ExitAfterStart
	{
		get
		{
			return exitAfterStart;
		}
		set
		{
			exitAfterStart = value;
		}
	}

	[XmlIgnore]
	[Browsable(false)]
	public int InputParameterCount
	{
		get
		{
			int num = 0;
			try
			{
				foreach (ParameterCls parameter in Parameters)
				{
					if (parameter.Type == IOType.Input)
					{
						num++;
					}
				}
			}
			catch
			{
			}
			return num;
		}
	}

	public override TestProperties Clone()
	{
		ScriptTestProperties scriptTestProperties = new ScriptTestProperties();
		scriptTestProperties.CreateNoWindow = CreateNoWindow;
		scriptTestProperties.RedirectStandardOutput = RedirectStandardOutput;
		scriptTestProperties.UseShellExecute = UseShellExecute;
		scriptTestProperties.Verb = Verb;
		scriptTestProperties.WorkingDirectory = WorkingDirectory;
		scriptTestProperties.debugWindowName = debugWindowName;
		Copy(scriptTestProperties);
		return scriptTestProperties;
	}
}
