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

namespace QC.QsprTestObjects.Parameters;

public sealed class LinkedFolderPropView
{
	private FolderTest folderTest;

	[Description("Configuration File Path for link tree. ")]
	[Editor(typeof(OpenFileUITypeEditor), typeof(UITypeEditor))]
	[Category("Linked Tree")]
	public string ConfigLocation
	{
		get
		{
			return folderTest.FolderProperties.ConfigLocation;
		}
		set
		{
			folderTest.FolderProperties.ConfigLocation = value;
		}
	}

	[Description("If True, link tree's data will be stored on different xml file(s).")]
	[Category("Linked Tree")]
	public bool SaveAsNewSession
	{
		get
		{
			return folderTest.FolderProperties.SaveAsNewSession;
		}
		set
		{
			folderTest.FolderProperties.SaveAsNewSession = value;
		}
	}

	[Editor(typeof(OpenFileUITypeEditor), typeof(UITypeEditor))]
	[Category("Linked Tree")]
	[Description("Link Tree's File name.")]
	public string LinkLocation
	{
		get
		{
			return folderTest.FolderProperties.LinkLocation;
		}
		set
		{
			folderTest.FolderProperties.LinkLocation = value;
		}
	}

	[Description("Link Tree's String ID.")]
	[ReadOnly(true)]
	[Category("Linked Tree")]
	public string LinkTreeStringID => folderTest.FolderProperties.LinkTreeStringID;

	[Category("Linked Tree")]
	[Description("Link Tree's Registered Machine.")]
	public string LinkRegisteredMachine => folderTest.FolderProperties.LinkRegisteredMachine;

	[Description("When true, the tests within this folder will set as Tool tests and the tests will run before GoNoGo starts.")]
	[Category("Settings")]
	public bool IsSetupFolder
	{
		get
		{
			return folderTest.FolderProperties.IsSetupFolder;
		}
		set
		{
			folderTest.FolderProperties.IsSetupFolder = value;
		}
	}

	[Category("Attributes")]
	[Description("Refreshes the Loop values from a file just before starting the Looping")]
	public bool RefreshLoopValuesAtLoopStart
	{
		get
		{
			return folderTest.FolderProperties.RefreshLoopValuesAtLoopStart;
		}
		set
		{
			folderTest.FolderProperties.RefreshLoopValuesAtLoopStart = value;
		}
	}

	[Description("Disabling looping runs the folder as if no loops are present.")]
	[Category("Settings")]
	public bool DisableLooping
	{
		get
		{
			return folderTest.FolderProperties.DisableLooping;
		}
		set
		{
			folderTest.FolderProperties.DisableLooping = value;
		}
	}

	[Description("Test name used for data collection and display.")]
	[Category("Settings")]
	public string TestName
	{
		get
		{
			return folderTest.Properties.TestName;
		}
		set
		{
			folderTest.Properties.TestName = value;
		}
	}

	[Category("Settings")]
	[Description("Additional description about the test.")]
	public string Description
	{
		get
		{
			return folderTest.Properties.Description;
		}
		set
		{
			folderTest.Properties.Description = value;
		}
	}

	[Category("Settings")]
	[Description("Comments for the test.")]
	public string Comment
	{
		get
		{
			return folderTest.Properties.Comment;
		}
		set
		{
			folderTest.Properties.Comment = value;
		}
	}

	[Description("Specifies the number of times to run the test before it passes. Eg. 2 means the test will run a total of 2 times.")]
	[Category("Settings")]
	public int RetryCount
	{
		get
		{
			return folderTest.Properties.RetryCount;
		}
		set
		{
			folderTest.Properties.RetryCount = value;
		}
	}

	[Category("Settings")]
	[Description("Specifies the looping for the test.\nUse Loop setup dialog to edit this property.")]
	[Editor(typeof(LoopSetupUITypeEditor), typeof(UITypeEditor))]
	public string LoopSetup
	{
		get
		{
			return folderTest.Properties.LoopSetup;
		}
		set
		{
		}
	}

	[Editor(typeof(PreConditionUITypeEditor), typeof(UITypeEditor))]
	[Description("Specifies the pre condition for the test.\nUse Pre Condition dialog to edit this property.")]
	[Category("Settings")]
	public string PreConditionEnabled
	{
		get
		{
			return folderTest.Properties.PreConditionEnabled;
		}
		set
		{
		}
	}

	[Category("Debug")]
	[Description("If enabled, QSPR temporarily stops the test tree at this location.  While a test tree is paused, click Resume Tree to continue.")]
	public BreakPointTypes BreakPoint
	{
		get
		{
			return folderTest.Properties.BreakPoint;
		}
		set
		{
			folderTest.Properties.BreakPoint = value;
		}
	}

	[Category("Debug")]
	[Description("If enabled, debug messages for this test will be logged.")]
	public bool LoggingEnabled
	{
		get
		{
			return folderTest.Properties.LoggingEnabled;
		}
		set
		{
			folderTest.Properties.LoggingEnabled = value;
		}
	}

	[Description("Always return true as test result")]
	[Category("Settings")]
	public bool BookKeeping
	{
		get
		{
			return folderTest.Properties.BookKeeping;
		}
		set
		{
			folderTest.Properties.BookKeeping = value;
		}
	}

	[Category("Attributes")]
	[Description("When true, Empty string parameters will not be logged in data collection")]
	public bool IgnoreEmptyStringParameters
	{
		get
		{
			return folderTest.Properties.IgnoreEmptyStringParameters;
		}
		set
		{
			folderTest.Properties.IgnoreEmptyStringParameters = value;
		}
	}

	[Description("Test runs only from context menu or if branch on error is set on it.")]
	[Category("Attributes")]
	public bool ToolTest
	{
		get
		{
			return folderTest.Properties.ToolTest;
		}
		set
		{
			folderTest.Properties.ToolTest = value;
		}
	}

	[Category("Attributes")]
	[Description("Test runs if any test in the tree runs.")]
	public bool TreeMustRun
	{
		get
		{
			return folderTest.Properties.TreeMustRun;
		}
		set
		{
			folderTest.Properties.TreeMustRun = value;
		}
	}

	[Category("Attributes")]
	[Description("Test Must Always Run, even if not selected as well as for each Rerun iteration.")]
	public bool MustRunTest
	{
		get
		{
			return folderTest.Properties.MustRunTest;
		}
		set
		{
			folderTest.Properties.MustRunTest = value;
		}
	}

	[Description("Notifies scheduler what action to be taken when test fails.")]
	[Category("Attributes")]
	public StopOnErrorTypes StopOnError
	{
		get
		{
			return folderTest.Properties.StopOnError;
		}
		set
		{
			folderTest.Properties.StopOnError = value;
		}
	}

	[Description("The error code string will be set when the test fails. The GoNoGo result will reflect the first error code set during the GoNoGo")]
	[Category("Settings")]
	public string TestErrorCode
	{
		get
		{
			return folderTest.Properties.TestErrorCode;
		}
		set
		{
			folderTest.Properties.TestErrorCode = value;
		}
	}

	[Browsable(false)]
	public bool SkipWhenLinked
	{
		get
		{
			return folderTest.Properties.SkipWhenLinked;
		}
		set
		{
			folderTest.Properties.SkipWhenLinked = value;
		}
	}

	[Description("If TRUE, the Pass result is verified with the Upper and Lower Limits.")]
	[Category("Attributes")]
	public bool TestResultBasedOnLimits
	{
		get
		{
			return folderTest.Properties.TestResultBasedOnLimits;
		}
		set
		{
			folderTest.Properties.TestResultBasedOnLimits = value;
		}
	}

	[Category("Attributes")]
	[Description("If TRUE, data is collected only if test FAILs.")]
	public bool DataLoggingOnlyOnFailure
	{
		get
		{
			return folderTest.Properties.DataLoggingOnlyOnFailure;
		}
		set
		{
			folderTest.Properties.DataLoggingOnlyOnFailure = value;
		}
	}

	[Category("Settings")]
	[Description("Specifies the length of time in seconds before test times out and is stopped.\nA zero value indicates that test will not time out.")]
	public int TestTimeOut
	{
		get
		{
			return folderTest.Properties.TestTimeOut;
		}
		set
		{
			folderTest.Properties.TestTimeOut = value;
		}
	}

	[Category("Settings")]
	[Description("Specifies the action to take if the test times out.")]
	public TimeOutActions TimeOutAction
	{
		get
		{
			return folderTest.Properties.TimeOutAction;
		}
		set
		{
			folderTest.Properties.TimeOutAction = value;
		}
	}

	[Category("Attributes")]
	[Description("Test runs if any test in its parent folder runs.")]
	public bool FolderMustRun
	{
		get
		{
			return folderTest.Properties.FolderMustRun;
		}
		set
		{
			folderTest.Properties.FolderMustRun = value;
		}
	}

	[Browsable(false)]
	[XmlIgnore]
	public FolderTest Owner => folderTest;

	public LinkedFolderPropView(FolderTest folderTest)
	{
		this.folderTest = folderTest;
	}
}
