using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using QC.GlobalVariableManager;
using QC.QsprTestObjects.Parameters;
using QC.QTMInterface;

namespace QC.QsprTestObjects.TestConditions;

public class CreateConditionUC : UserControl
{
	public const int INPUT_IMAGE = 0;

	public const int OUTPUT_IMAGE = 1;

	private Panel panelTop;

	private Panel panelCondition;

	private ImageList imageList;

	private Panel panelParameter;

	private Panel panelResult;

	private ComboBox cmbSelection;

	private Label label1;

	private TreeView treeParameter;

	private IContainer components;

	private Label labelIndex;

	private ConditionParameterType parameterType = ConditionParameterType.Output;

	private BaseCondition condition;

	private Panel panelGV;

	private TreeView ultraTreeGV;

	private Panel panelGVRight;

	private Label label4;

	private TextBox txtName;

	private RadioButton radioParamToGlobal;

	private TextBox txtParameterValue;

	private RadioButton radioParamToValue;

	private RadioButton radioGlobalToGlobal;

	private RadioButton radioGlobalToValue;

	private TextBox txtGlobalValue;

	private Button btnParamToGlobal;

	private Button btnGlobalToGlobal;

	private TextBox txtParamToGlobal;

	private TextBox txtGlobalToGlobal;

	private RadioButton radioParamToUL;

	private RadioButton radioParamToLL;

	private ComboBox ultraComboIndex;

	private GroupBox groupBoxPassFail;

	private RadioButton radioButtonFailed;

	private RadioButton radioButtonPassed;

	private GroupBox groupBoxParam;

	private RadioButton radioButtonGreaterThanEq;

	private RadioButton radioButtonGreater;

	private RadioButton radioButtonLessThanEq;

	private RadioButton radioButtonLessThan;

	private RadioButton radioButtonNotEqual;

	private RadioButton radioButtonEquals;

	private GroupBox groupBoxGV;

	private RadioButton radioButtonGreaterEqGV;

	private RadioButton radioButtonGreaterGV;

	private RadioButton radioButtonLessThanEqGV;

	private RadioButton radioButtonLessThanGV;

	private RadioButton radioButtonNotEqualGV;

	private RadioButton radioButtonEqualsGV;

	[Browsable(false)]
	public ParameterCollection Parameters
	{
		set
		{
			try
			{
				treeParameter.Nodes.Clear();
				ultraComboIndex.Enabled = false;
				if (value == null)
				{
					return;
				}
				foreach (ParameterCls item in value)
				{
					switch (parameterType)
					{
					case ConditionParameterType.Input:
						if (item.IsInput)
						{
							TreeNode treeNode3 = treeParameter.Nodes.Add(item.Name, item.Name);
							treeNode3.Tag = item;
							treeNode3.ImageIndex = 0;
							treeNode3.SelectedImageIndex = 0;
						}
						break;
					case ConditionParameterType.Output:
						if (item.IsOutput)
						{
							TreeNode treeNode2 = treeParameter.Nodes.Add(item.Name, item.Name);
							treeNode2.Tag = item;
							treeNode2.ImageIndex = 1;
							treeNode2.SelectedImageIndex = 1;
						}
						break;
					case ConditionParameterType.Both:
					{
						TreeNode treeNode = treeParameter.Nodes.Add(item.Name, item.Name);
						treeNode.Tag = item;
						if (item.IsInput)
						{
							treeNode.ImageIndex = 0;
							treeNode.SelectedImageIndex = 0;
						}
						else
						{
							treeNode.ImageIndex = 1;
							treeNode.SelectedImageIndex = 1;
						}
						break;
					}
					}
				}
			}
			catch
			{
			}
		}
	}

	public ConditionParameterType ParameterType
	{
		set
		{
			parameterType = value;
		}
	}

	[Browsable(false)]
	public BaseCondition Condition
	{
		get
		{
			return condition;
		}
		set
		{
			if (value != null)
			{
				condition = new BaseCondition();
				txtName.Text = value.Name;
				switch (value.TestConditionType)
				{
				case ConditionType.TestParameters:
				{
					cmbSelection.SelectedValue = ConditionType.TestParameters.ToString();
					TreeNode selectedNode3 = treeParameter.Nodes[value.ParameterName];
					treeParameter.SelectedNode = selectedNode3;
					ultraComboIndex.SelectedValue = value.ParameterIndex;
					SetSelectedRBValue(groupBoxParam, value.ParameterSign.ToString());
					switch (value.CompareToType)
					{
					case CompareType.Constant:
						txtParameterValue.Text = value.ParameterValue;
						break;
					case CompareType.GlobalVariable:
						txtParamToGlobal.Text = value.GVToCompareName;
						radioParamToGlobal.Checked = true;
						break;
					case CompareType.LowerLimit:
						radioParamToLL.Checked = true;
						break;
					case CompareType.UpperLimit:
						radioParamToUL.Checked = true;
						break;
					}
					ultraTreeGV.SelectedNode = null;
					value.GlobalVariableName = "";
					SetSelectedRBValue(groupBoxGV, ConditionSign.Equals.ToString());
					value.GlobalVariableSign = ConditionSign.Equals;
					txtGlobalValue.Text = "";
					txtGlobalToGlobal.Text = "";
					radioGlobalToValue.Checked = true;
					value.GlobalVariableValue = "";
					SetSelectedRBValue(groupBoxPassFail, TestResult.Failed.ToString());
					value.Result = TestResult.Failed;
					break;
				}
				case ConditionType.GlobalVariables:
					cmbSelection.SelectedValue = ConditionType.GlobalVariables.ToString();
					try
					{
						TreeNode selectedNode = ultraTreeGV.Nodes[value.GlobalVariableName];
						ultraTreeGV.SelectedNode = selectedNode;
					}
					catch
					{
						if (value.GlobalVariableName.Length != 0)
						{
							QTMGlobalVariable.SetGlobalVariable(value.GlobalVariableName, "");
							LoadGV();
							TreeNode selectedNode2 = ultraTreeGV.Nodes[value.GlobalVariableName];
							ultraTreeGV.SelectedNode = selectedNode2;
						}
					}
					SetSelectedRBValue(groupBoxGV, value.GlobalVariableSign.ToString());
					switch (value.CompareToType)
					{
					case CompareType.Constant:
						txtGlobalValue.Text = value.GlobalVariableValue;
						break;
					case CompareType.GlobalVariable:
						txtGlobalToGlobal.Text = value.GVToCompareName;
						radioGlobalToGlobal.Checked = true;
						break;
					}
					treeParameter.SelectedNode = null;
					value.ParameterName = "";
					SetSelectedRBValue(groupBoxParam, ConditionSign.Equals.ToString());
					value.ParameterSign = ConditionSign.Equals;
					txtParameterValue.Text = "";
					txtParamToGlobal.Text = "";
					radioParamToValue.Checked = true;
					value.ParameterValue = "";
					ultraComboIndex.Enabled = false;
					ultraComboIndex.SelectedValue = "";
					SetSelectedRBValue(groupBoxPassFail, TestResult.Failed.ToString());
					value.Result = TestResult.Failed;
					break;
				case ConditionType.TestResult:
					cmbSelection.SelectedValue = ConditionType.TestResult.ToString();
					SetSelectedRBValue(groupBoxPassFail, value.Result.ToString());
					ultraTreeGV.SelectedNode = null;
					value.GlobalVariableName = "";
					SetSelectedRBValue(groupBoxGV, ConditionSign.Equals.ToString());
					value.GlobalVariableSign = ConditionSign.Equals;
					txtGlobalValue.Text = "";
					txtGlobalToGlobal.Text = "";
					radioGlobalToValue.Checked = true;
					value.GlobalVariableValue = "";
					treeParameter.SelectedNode = null;
					value.ParameterName = "";
					SetSelectedRBValue(groupBoxParam, ConditionSign.Equals.ToString());
					value.ParameterSign = ConditionSign.Equals;
					txtParameterValue.Text = "";
					txtParamToGlobal.Text = "";
					radioParamToValue.Checked = true;
					value.ParameterValue = "";
					value.GVToCompareName = "";
					value.CompareToType = CompareType.Constant;
					ultraComboIndex.Enabled = false;
					ultraComboIndex.SelectedValue = "";
					break;
				case ConditionType.None:
					cmbSelection.SelectedValue = ConditionType.TestResult.ToString();
					value.TestConditionType = ConditionType.TestResult;
					ultraTreeGV.SelectedNode = null;
					value.GlobalVariableName = "";
					SetSelectedRBValue(groupBoxGV, ConditionSign.Equals.ToString());
					value.GlobalVariableSign = ConditionSign.Equals;
					txtGlobalValue.Text = "";
					txtGlobalToGlobal.Text = "";
					radioGlobalToValue.Checked = true;
					value.GlobalVariableValue = "";
					treeParameter.SelectedNode = null;
					value.ParameterName = "";
					SetSelectedRBValue(groupBoxParam, ConditionSign.Equals.ToString());
					value.ParameterSign = ConditionSign.Equals;
					txtParameterValue.Text = "";
					txtParamToGlobal.Text = "";
					radioParamToValue.Checked = true;
					value.ParameterValue = "";
					ultraComboIndex.Enabled = false;
					ultraComboIndex.SelectedValue = "";
					SetSelectedRBValue(groupBoxPassFail, TestResult.Failed.ToString());
					value.Result = TestResult.Failed;
					value.GVToCompareName = "";
					value.CompareToType = CompareType.Constant;
					ultraComboIndex.Enabled = false;
					ultraComboIndex.SelectedValue = "";
					break;
				}
			}
			condition = value;
		}
	}

	public CreateConditionUC()
	{
		InitializeComponent();
		List<KeyValuePair<string, string>> dataSource = new Dictionary<string, string>
		{
			{ "TestParameters", "Test Parameters" },
			{ "TestResult", "Test Result" },
			{ "GlobalVariables", "Global Variables" }
		}.ToList();
		cmbSelection.DataSource = dataSource;
		cmbSelection.SelectedValue = "TestResult";
		LoadGV();
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.components = new System.ComponentModel.Container();
		System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QC.QsprTestObjects.TestConditions.CreateConditionUC));
		this.panelTop = new System.Windows.Forms.Panel();
		this.txtName = new System.Windows.Forms.TextBox();
		this.label4 = new System.Windows.Forms.Label();
		this.label1 = new System.Windows.Forms.Label();
		this.cmbSelection = new System.Windows.Forms.ComboBox();
		this.panelParameter = new System.Windows.Forms.Panel();
		this.treeParameter = new System.Windows.Forms.TreeView();
		this.imageList = new System.Windows.Forms.ImageList(this.components);
		this.panelCondition = new System.Windows.Forms.Panel();
		this.groupBoxParam = new System.Windows.Forms.GroupBox();
		this.radioButtonGreaterThanEq = new System.Windows.Forms.RadioButton();
		this.radioButtonGreater = new System.Windows.Forms.RadioButton();
		this.radioButtonLessThanEq = new System.Windows.Forms.RadioButton();
		this.radioButtonLessThan = new System.Windows.Forms.RadioButton();
		this.radioButtonNotEqual = new System.Windows.Forms.RadioButton();
		this.radioButtonEquals = new System.Windows.Forms.RadioButton();
		this.radioParamToUL = new System.Windows.Forms.RadioButton();
		this.radioParamToLL = new System.Windows.Forms.RadioButton();
		this.txtParamToGlobal = new System.Windows.Forms.TextBox();
		this.btnParamToGlobal = new System.Windows.Forms.Button();
		this.radioParamToGlobal = new System.Windows.Forms.RadioButton();
		this.txtParameterValue = new System.Windows.Forms.TextBox();
		this.radioParamToValue = new System.Windows.Forms.RadioButton();
		this.labelIndex = new System.Windows.Forms.Label();
		this.ultraComboIndex = new System.Windows.Forms.ComboBox();
		this.panelResult = new System.Windows.Forms.Panel();
		this.groupBoxPassFail = new System.Windows.Forms.GroupBox();
		this.radioButtonFailed = new System.Windows.Forms.RadioButton();
		this.radioButtonPassed = new System.Windows.Forms.RadioButton();
		this.panelGV = new System.Windows.Forms.Panel();
		this.panelGVRight = new System.Windows.Forms.Panel();
		this.groupBoxGV = new System.Windows.Forms.GroupBox();
		this.radioButtonGreaterEqGV = new System.Windows.Forms.RadioButton();
		this.radioButtonGreaterGV = new System.Windows.Forms.RadioButton();
		this.radioButtonLessThanEqGV = new System.Windows.Forms.RadioButton();
		this.radioButtonLessThanGV = new System.Windows.Forms.RadioButton();
		this.radioButtonNotEqualGV = new System.Windows.Forms.RadioButton();
		this.radioButtonEqualsGV = new System.Windows.Forms.RadioButton();
		this.txtGlobalToGlobal = new System.Windows.Forms.TextBox();
		this.btnGlobalToGlobal = new System.Windows.Forms.Button();
		this.radioGlobalToGlobal = new System.Windows.Forms.RadioButton();
		this.radioGlobalToValue = new System.Windows.Forms.RadioButton();
		this.txtGlobalValue = new System.Windows.Forms.TextBox();
		this.ultraTreeGV = new System.Windows.Forms.TreeView();
		this.panelTop.SuspendLayout();
		this.panelParameter.SuspendLayout();
		this.panelCondition.SuspendLayout();
		this.groupBoxParam.SuspendLayout();
		this.panelResult.SuspendLayout();
		this.groupBoxPassFail.SuspendLayout();
		this.panelGV.SuspendLayout();
		this.panelGVRight.SuspendLayout();
		this.groupBoxGV.SuspendLayout();
		base.SuspendLayout();
		this.panelTop.Controls.Add(this.txtName);
		this.panelTop.Controls.Add(this.label4);
		this.panelTop.Controls.Add(this.label1);
		this.panelTop.Controls.Add(this.cmbSelection);
		this.panelTop.Dock = System.Windows.Forms.DockStyle.Top;
		this.panelTop.Location = new System.Drawing.Point(0, 0);
		this.panelTop.Name = "panelTop";
		this.panelTop.Size = new System.Drawing.Size(456, 32);
		this.panelTop.TabIndex = 0;
		this.txtName.Location = new System.Drawing.Point(49, 6);
		this.txtName.Name = "txtName";
		this.txtName.Size = new System.Drawing.Size(187, 20);
		this.txtName.TabIndex = 3;
		this.txtName.TextChanged += new System.EventHandler(txtName_TextChanged);
		this.label4.Location = new System.Drawing.Point(3, 6);
		this.label4.Name = "label4";
		this.label4.Size = new System.Drawing.Size(40, 21);
		this.label4.TabIndex = 2;
		this.label4.Text = "Name:";
		this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
		this.label1.Location = new System.Drawing.Point(242, 6);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(35, 21);
		this.label1.TabIndex = 0;
		this.label1.Text = "Type:";
		this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
		this.cmbSelection.DisplayMember = "Value";
		this.cmbSelection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cmbSelection.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.cmbSelection.Location = new System.Drawing.Point(283, 6);
		this.cmbSelection.Name = "cmbSelection";
		this.cmbSelection.Size = new System.Drawing.Size(168, 21);
		this.cmbSelection.TabIndex = 1;
		this.cmbSelection.ValueMember = "Key";
		this.cmbSelection.SelectedValueChanged += new System.EventHandler(cmbSelection_SelectedValueChanged);
		this.panelParameter.Controls.Add(this.treeParameter);
		this.panelParameter.Controls.Add(this.panelCondition);
		this.panelParameter.Controls.Add(this.labelIndex);
		this.panelParameter.Controls.Add(this.ultraComboIndex);
		this.panelParameter.Location = new System.Drawing.Point(0, 445);
		this.panelParameter.Name = "panelParameter";
		this.panelParameter.Padding = new System.Windows.Forms.Padding(5);
		this.panelParameter.Size = new System.Drawing.Size(456, 192);
		this.panelParameter.TabIndex = 1;
		this.panelParameter.Visible = false;
		this.treeParameter.HideSelection = false;
		this.treeParameter.ImageIndex = 0;
		this.treeParameter.ImageList = this.imageList;
		this.treeParameter.Location = new System.Drawing.Point(5, 5);
		this.treeParameter.Name = "treeParameter";
		this.treeParameter.SelectedImageIndex = 0;
		this.treeParameter.ShowRootLines = false;
		this.treeParameter.Size = new System.Drawing.Size(258, 157);
		this.treeParameter.TabIndex = 0;
		this.treeParameter.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeParameter_AfterSelect);
		this.imageList.ImageStream = (System.Windows.Forms.ImageListStreamer)resources.GetObject("imageList.ImageStream");
		this.imageList.TransparentColor = System.Drawing.Color.Transparent;
		this.imageList.Images.SetKeyName(0, "In.bmp");
		this.imageList.Images.SetKeyName(1, "Out.bmp");
		this.panelCondition.Controls.Add(this.groupBoxParam);
		this.panelCondition.Controls.Add(this.radioParamToUL);
		this.panelCondition.Controls.Add(this.radioParamToLL);
		this.panelCondition.Controls.Add(this.txtParamToGlobal);
		this.panelCondition.Controls.Add(this.btnParamToGlobal);
		this.panelCondition.Controls.Add(this.radioParamToGlobal);
		this.panelCondition.Controls.Add(this.txtParameterValue);
		this.panelCondition.Controls.Add(this.radioParamToValue);
		this.panelCondition.Dock = System.Windows.Forms.DockStyle.Right;
		this.panelCondition.Location = new System.Drawing.Point(267, 5);
		this.panelCondition.Name = "panelCondition";
		this.panelCondition.Size = new System.Drawing.Size(184, 182);
		this.panelCondition.TabIndex = 1;
		this.groupBoxParam.Controls.Add(this.radioButtonGreaterThanEq);
		this.groupBoxParam.Controls.Add(this.radioButtonGreater);
		this.groupBoxParam.Controls.Add(this.radioButtonLessThanEq);
		this.groupBoxParam.Controls.Add(this.radioButtonLessThan);
		this.groupBoxParam.Controls.Add(this.radioButtonNotEqual);
		this.groupBoxParam.Controls.Add(this.radioButtonEquals);
		this.groupBoxParam.Location = new System.Drawing.Point(10, 1);
		this.groupBoxParam.Margin = new System.Windows.Forms.Padding(0);
		this.groupBoxParam.Name = "groupBoxParam";
		this.groupBoxParam.Size = new System.Drawing.Size(162, 116);
		this.groupBoxParam.TabIndex = 11;
		this.groupBoxParam.TabStop = false;
		this.radioButtonGreaterThanEq.AutoSize = true;
		this.radioButtonGreaterThanEq.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonGreaterThanEq.Location = new System.Drawing.Point(6, 95);
		this.radioButtonGreaterThanEq.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonGreaterThanEq.Name = "radioButtonGreaterThanEq";
		this.radioButtonGreaterThanEq.Size = new System.Drawing.Size(142, 17);
		this.radioButtonGreaterThanEq.TabIndex = 5;
		this.radioButtonGreaterThanEq.TabStop = true;
		this.radioButtonGreaterThanEq.Tag = "GreaterThanEqual";
		this.radioButtonGreaterThanEq.Text = ">=  (Greater Than Equal)";
		this.radioButtonGreaterThanEq.UseVisualStyleBackColor = true;
		this.radioButtonGreaterThanEq.CheckedChanged += new System.EventHandler(optionSetConditions_ValueChanged);
		this.radioButtonGreater.AutoSize = true;
		this.radioButtonGreater.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonGreater.Location = new System.Drawing.Point(6, 78);
		this.radioButtonGreater.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonGreater.Name = "radioButtonGreater";
		this.radioButtonGreater.Size = new System.Drawing.Size(106, 17);
		this.radioButtonGreater.TabIndex = 4;
		this.radioButtonGreater.TabStop = true;
		this.radioButtonGreater.Tag = "GreaterThan";
		this.radioButtonGreater.Text = ">  (Greater Than)";
		this.radioButtonGreater.UseVisualStyleBackColor = true;
		this.radioButtonGreater.CheckedChanged += new System.EventHandler(optionSetConditions_ValueChanged);
		this.radioButtonLessThanEq.AutoSize = true;
		this.radioButtonLessThanEq.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonLessThanEq.Location = new System.Drawing.Point(6, 61);
		this.radioButtonLessThanEq.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonLessThanEq.Name = "radioButtonLessThanEq";
		this.radioButtonLessThanEq.Size = new System.Drawing.Size(129, 17);
		this.radioButtonLessThanEq.TabIndex = 3;
		this.radioButtonLessThanEq.TabStop = true;
		this.radioButtonLessThanEq.Tag = "LessThanEqual";
		this.radioButtonLessThanEq.Text = "<=  (Less Than Equal)";
		this.radioButtonLessThanEq.UseVisualStyleBackColor = true;
		this.radioButtonLessThanEq.CheckedChanged += new System.EventHandler(optionSetConditions_ValueChanged);
		this.radioButtonLessThan.AutoSize = true;
		this.radioButtonLessThan.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonLessThan.Location = new System.Drawing.Point(6, 44);
		this.radioButtonLessThan.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonLessThan.Name = "radioButtonLessThan";
		this.radioButtonLessThan.Size = new System.Drawing.Size(93, 17);
		this.radioButtonLessThan.TabIndex = 2;
		this.radioButtonLessThan.TabStop = true;
		this.radioButtonLessThan.Tag = "LessThan";
		this.radioButtonLessThan.Text = "<  (Less Than)";
		this.radioButtonLessThan.UseVisualStyleBackColor = true;
		this.radioButtonLessThan.CheckedChanged += new System.EventHandler(optionSetConditions_ValueChanged);
		this.radioButtonNotEqual.AutoSize = true;
		this.radioButtonNotEqual.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonNotEqual.Location = new System.Drawing.Point(6, 27);
		this.radioButtonNotEqual.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonNotEqual.Name = "radioButtonNotEqual";
		this.radioButtonNotEqual.Size = new System.Drawing.Size(93, 17);
		this.radioButtonNotEqual.TabIndex = 1;
		this.radioButtonNotEqual.TabStop = true;
		this.radioButtonNotEqual.Tag = "NotEqual";
		this.radioButtonNotEqual.Text = "!=  (Not Equal)";
		this.radioButtonNotEqual.UseVisualStyleBackColor = true;
		this.radioButtonNotEqual.CheckedChanged += new System.EventHandler(optionSetConditions_ValueChanged);
		this.radioButtonEquals.AutoSize = true;
		this.radioButtonEquals.Checked = true;
		this.radioButtonEquals.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonEquals.Location = new System.Drawing.Point(6, 10);
		this.radioButtonEquals.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonEquals.Name = "radioButtonEquals";
		this.radioButtonEquals.Size = new System.Drawing.Size(75, 17);
		this.radioButtonEquals.TabIndex = 0;
		this.radioButtonEquals.TabStop = true;
		this.radioButtonEquals.Tag = "Equals";
		this.radioButtonEquals.Text = "=  (Equals)";
		this.radioButtonEquals.UseVisualStyleBackColor = true;
		this.radioButtonEquals.CheckedChanged += new System.EventHandler(optionSetConditions_ValueChanged);
		this.radioParamToUL.AutoSize = true;
		this.radioParamToUL.Location = new System.Drawing.Point(94, 163);
		this.radioParamToUL.Name = "radioParamToUL";
		this.radioParamToUL.Size = new System.Drawing.Size(78, 17);
		this.radioParamToUL.TabIndex = 13;
		this.radioParamToUL.TabStop = true;
		this.radioParamToUL.Text = "Upper Limit";
		this.radioParamToUL.UseVisualStyleBackColor = true;
		this.radioParamToUL.CheckedChanged += new System.EventHandler(radiosParamCompareType_CheckedChanged);
		this.radioParamToLL.AutoSize = true;
		this.radioParamToLL.Location = new System.Drawing.Point(10, 163);
		this.radioParamToLL.Name = "radioParamToLL";
		this.radioParamToLL.Size = new System.Drawing.Size(78, 17);
		this.radioParamToLL.TabIndex = 12;
		this.radioParamToLL.TabStop = true;
		this.radioParamToLL.Text = "Lower Limit";
		this.radioParamToLL.UseVisualStyleBackColor = true;
		this.radioParamToLL.CheckedChanged += new System.EventHandler(radiosParamCompareType_CheckedChanged);
		this.txtParamToGlobal.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
		this.txtParamToGlobal.BackColor = System.Drawing.SystemColors.Control;
		this.txtParamToGlobal.Enabled = false;
		this.txtParamToGlobal.Location = new System.Drawing.Point(68, 141);
		this.txtParamToGlobal.Name = "txtParamToGlobal";
		this.txtParamToGlobal.ReadOnly = true;
		this.txtParamToGlobal.Size = new System.Drawing.Size(86, 20);
		this.txtParamToGlobal.TabIndex = 11;
		this.txtParamToGlobal.TextChanged += new System.EventHandler(txtParamToGlobal_TextChanged);
		this.btnParamToGlobal.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
		this.btnParamToGlobal.Enabled = false;
		this.btnParamToGlobal.Location = new System.Drawing.Point(156, 140);
		this.btnParamToGlobal.Name = "btnParamToGlobal";
		this.btnParamToGlobal.Size = new System.Drawing.Size(25, 22);
		this.btnParamToGlobal.TabIndex = 10;
		this.btnParamToGlobal.Text = "..";
		this.btnParamToGlobal.UseVisualStyleBackColor = true;
		this.btnParamToGlobal.Click += new System.EventHandler(btnParamToGlobal_Click);
		this.radioParamToGlobal.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
		this.radioParamToGlobal.AutoSize = true;
		this.radioParamToGlobal.Location = new System.Drawing.Point(10, 142);
		this.radioParamToGlobal.Name = "radioParamToGlobal";
		this.radioParamToGlobal.Size = new System.Drawing.Size(58, 17);
		this.radioParamToGlobal.TabIndex = 10;
		this.radioParamToGlobal.Text = "Global:";
		this.radioParamToGlobal.UseVisualStyleBackColor = true;
		this.radioParamToGlobal.CheckedChanged += new System.EventHandler(radiosParamCompareType_CheckedChanged);
		this.txtParameterValue.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
		this.txtParameterValue.Location = new System.Drawing.Point(68, 119);
		this.txtParameterValue.Name = "txtParameterValue";
		this.txtParameterValue.Size = new System.Drawing.Size(113, 20);
		this.txtParameterValue.TabIndex = 4;
		this.txtParameterValue.TextChanged += new System.EventHandler(txtParameterValue_TextChanged);
		this.radioParamToValue.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
		this.radioParamToValue.AutoSize = true;
		this.radioParamToValue.Checked = true;
		this.radioParamToValue.Location = new System.Drawing.Point(10, 120);
		this.radioParamToValue.Name = "radioParamToValue";
		this.radioParamToValue.Size = new System.Drawing.Size(55, 17);
		this.radioParamToValue.TabIndex = 9;
		this.radioParamToValue.TabStop = true;
		this.radioParamToValue.Text = "Value:";
		this.radioParamToValue.UseVisualStyleBackColor = true;
		this.radioParamToValue.CheckedChanged += new System.EventHandler(radiosParamCompareType_CheckedChanged);
		this.labelIndex.Location = new System.Drawing.Point(137, 168);
		this.labelIndex.Name = "labelIndex";
		this.labelIndex.Size = new System.Drawing.Size(40, 16);
		this.labelIndex.TabIndex = 0;
		this.labelIndex.Text = "Index:";
		this.labelIndex.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
		this.ultraComboIndex.DisplayMember = "Key";
		this.ultraComboIndex.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.ultraComboIndex.Enabled = false;
		this.ultraComboIndex.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.ultraComboIndex.Location = new System.Drawing.Point(183, 166);
		this.ultraComboIndex.Name = "ultraComboIndex";
		this.ultraComboIndex.Size = new System.Drawing.Size(80, 21);
		this.ultraComboIndex.TabIndex = 1;
		this.ultraComboIndex.ValueMember = "Value";
		this.ultraComboIndex.SelectedValueChanged += new System.EventHandler(ultraComboIndex_SelectedValueChanged);
		this.panelResult.Controls.Add(this.groupBoxPassFail);
		this.panelResult.Location = new System.Drawing.Point(0, 54);
		this.panelResult.Name = "panelResult";
		this.panelResult.Padding = new System.Windows.Forms.Padding(40);
		this.panelResult.Size = new System.Drawing.Size(456, 160);
		this.panelResult.TabIndex = 2;
		this.panelResult.Visible = false;
		this.groupBoxPassFail.Controls.Add(this.radioButtonFailed);
		this.groupBoxPassFail.Controls.Add(this.radioButtonPassed);
		this.groupBoxPassFail.ForeColor = System.Drawing.SystemColors.ControlText;
		this.groupBoxPassFail.Location = new System.Drawing.Point(192, 43);
		this.groupBoxPassFail.Name = "groupBoxPassFail";
		this.groupBoxPassFail.Size = new System.Drawing.Size(85, 84);
		this.groupBoxPassFail.TabIndex = 1;
		this.groupBoxPassFail.TabStop = false;
		this.radioButtonFailed.AutoSize = true;
		this.radioButtonFailed.Checked = true;
		this.radioButtonFailed.Font = new System.Drawing.Font("Microsoft Sans Serif", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonFailed.Location = new System.Drawing.Point(6, 55);
		this.radioButtonFailed.Name = "radioButtonFailed";
		this.radioButtonFailed.Size = new System.Drawing.Size(59, 19);
		this.radioButtonFailed.TabIndex = 1;
		this.radioButtonFailed.TabStop = true;
		this.radioButtonFailed.Tag = "Failed";
		this.radioButtonFailed.Text = "Failed";
		this.radioButtonFailed.UseVisualStyleBackColor = true;
		this.radioButtonFailed.CheckedChanged += new System.EventHandler(optionSetPassFail_ValueChanged);
		this.radioButtonPassed.AutoSize = true;
		this.radioButtonPassed.Font = new System.Drawing.Font("Microsoft Sans Serif", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonPassed.Location = new System.Drawing.Point(6, 19);
		this.radioButtonPassed.Name = "radioButtonPassed";
		this.radioButtonPassed.Size = new System.Drawing.Size(66, 19);
		this.radioButtonPassed.TabIndex = 0;
		this.radioButtonPassed.TabStop = true;
		this.radioButtonPassed.Tag = "Passed";
		this.radioButtonPassed.Text = "Passed";
		this.radioButtonPassed.UseVisualStyleBackColor = true;
		this.radioButtonPassed.CheckedChanged += new System.EventHandler(optionSetPassFail_ValueChanged);
		this.panelGV.Controls.Add(this.panelGVRight);
		this.panelGV.Controls.Add(this.ultraTreeGV);
		this.panelGV.Location = new System.Drawing.Point(0, 238);
		this.panelGV.Name = "panelGV";
		this.panelGV.Padding = new System.Windows.Forms.Padding(5);
		this.panelGV.Size = new System.Drawing.Size(456, 192);
		this.panelGV.TabIndex = 3;
		this.panelGVRight.Controls.Add(this.groupBoxGV);
		this.panelGVRight.Controls.Add(this.txtGlobalToGlobal);
		this.panelGVRight.Controls.Add(this.btnGlobalToGlobal);
		this.panelGVRight.Controls.Add(this.radioGlobalToGlobal);
		this.panelGVRight.Controls.Add(this.radioGlobalToValue);
		this.panelGVRight.Controls.Add(this.txtGlobalValue);
		this.panelGVRight.Dock = System.Windows.Forms.DockStyle.Right;
		this.panelGVRight.Location = new System.Drawing.Point(263, 5);
		this.panelGVRight.Name = "panelGVRight";
		this.panelGVRight.Size = new System.Drawing.Size(188, 182);
		this.panelGVRight.TabIndex = 5;
		this.groupBoxGV.Controls.Add(this.radioButtonGreaterEqGV);
		this.groupBoxGV.Controls.Add(this.radioButtonGreaterGV);
		this.groupBoxGV.Controls.Add(this.radioButtonLessThanEqGV);
		this.groupBoxGV.Controls.Add(this.radioButtonLessThanGV);
		this.groupBoxGV.Controls.Add(this.radioButtonNotEqualGV);
		this.groupBoxGV.Controls.Add(this.radioButtonEqualsGV);
		this.groupBoxGV.Location = new System.Drawing.Point(14, 11);
		this.groupBoxGV.Margin = new System.Windows.Forms.Padding(0);
		this.groupBoxGV.Name = "groupBoxGV";
		this.groupBoxGV.Size = new System.Drawing.Size(162, 116);
		this.groupBoxGV.TabIndex = 12;
		this.groupBoxGV.TabStop = false;
		this.radioButtonGreaterEqGV.AutoSize = true;
		this.radioButtonGreaterEqGV.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonGreaterEqGV.Location = new System.Drawing.Point(6, 95);
		this.radioButtonGreaterEqGV.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonGreaterEqGV.Name = "radioButtonGreaterEqGV";
		this.radioButtonGreaterEqGV.Size = new System.Drawing.Size(142, 17);
		this.radioButtonGreaterEqGV.TabIndex = 5;
		this.radioButtonGreaterEqGV.TabStop = true;
		this.radioButtonGreaterEqGV.Tag = "GreaterThanEqual";
		this.radioButtonGreaterEqGV.Text = ">=  (Greater Than Equal)";
		this.radioButtonGreaterEqGV.UseVisualStyleBackColor = true;
		this.radioButtonGreaterEqGV.CheckedChanged += new System.EventHandler(optionSetGVSign_ValueChanged);
		this.radioButtonGreaterGV.AutoSize = true;
		this.radioButtonGreaterGV.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonGreaterGV.Location = new System.Drawing.Point(6, 78);
		this.radioButtonGreaterGV.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonGreaterGV.Name = "radioButtonGreaterGV";
		this.radioButtonGreaterGV.Size = new System.Drawing.Size(106, 17);
		this.radioButtonGreaterGV.TabIndex = 4;
		this.radioButtonGreaterGV.TabStop = true;
		this.radioButtonGreaterGV.Tag = "GreaterThan";
		this.radioButtonGreaterGV.Text = ">  (Greater Than)";
		this.radioButtonGreaterGV.UseVisualStyleBackColor = true;
		this.radioButtonGreaterGV.CheckedChanged += new System.EventHandler(optionSetGVSign_ValueChanged);
		this.radioButtonLessThanEqGV.AutoSize = true;
		this.radioButtonLessThanEqGV.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonLessThanEqGV.Location = new System.Drawing.Point(6, 61);
		this.radioButtonLessThanEqGV.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonLessThanEqGV.Name = "radioButtonLessThanEqGV";
		this.radioButtonLessThanEqGV.Size = new System.Drawing.Size(129, 17);
		this.radioButtonLessThanEqGV.TabIndex = 3;
		this.radioButtonLessThanEqGV.TabStop = true;
		this.radioButtonLessThanEqGV.Tag = "LessThanEqual";
		this.radioButtonLessThanEqGV.Text = "<=  (Less Than Equal)";
		this.radioButtonLessThanEqGV.UseVisualStyleBackColor = true;
		this.radioButtonLessThanEqGV.CheckedChanged += new System.EventHandler(optionSetGVSign_ValueChanged);
		this.radioButtonLessThanGV.AutoSize = true;
		this.radioButtonLessThanGV.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonLessThanGV.Location = new System.Drawing.Point(6, 44);
		this.radioButtonLessThanGV.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonLessThanGV.Name = "radioButtonLessThanGV";
		this.radioButtonLessThanGV.Size = new System.Drawing.Size(93, 17);
		this.radioButtonLessThanGV.TabIndex = 2;
		this.radioButtonLessThanGV.TabStop = true;
		this.radioButtonLessThanGV.Tag = "LessThan";
		this.radioButtonLessThanGV.Text = "<  (Less Than)";
		this.radioButtonLessThanGV.UseVisualStyleBackColor = true;
		this.radioButtonLessThanGV.CheckedChanged += new System.EventHandler(optionSetGVSign_ValueChanged);
		this.radioButtonNotEqualGV.AutoSize = true;
		this.radioButtonNotEqualGV.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonNotEqualGV.Location = new System.Drawing.Point(6, 27);
		this.radioButtonNotEqualGV.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonNotEqualGV.Name = "radioButtonNotEqualGV";
		this.radioButtonNotEqualGV.Size = new System.Drawing.Size(93, 17);
		this.radioButtonNotEqualGV.TabIndex = 1;
		this.radioButtonNotEqualGV.TabStop = true;
		this.radioButtonNotEqualGV.Tag = "NotEqual";
		this.radioButtonNotEqualGV.Text = "!=  (Not Equal)";
		this.radioButtonNotEqualGV.UseVisualStyleBackColor = true;
		this.radioButtonNotEqualGV.CheckedChanged += new System.EventHandler(optionSetGVSign_ValueChanged);
		this.radioButtonEqualsGV.AutoSize = true;
		this.radioButtonEqualsGV.Checked = true;
		this.radioButtonEqualsGV.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.radioButtonEqualsGV.Location = new System.Drawing.Point(6, 10);
		this.radioButtonEqualsGV.Margin = new System.Windows.Forms.Padding(0);
		this.radioButtonEqualsGV.Name = "radioButtonEqualsGV";
		this.radioButtonEqualsGV.Size = new System.Drawing.Size(75, 17);
		this.radioButtonEqualsGV.TabIndex = 0;
		this.radioButtonEqualsGV.TabStop = true;
		this.radioButtonEqualsGV.Tag = "Equals";
		this.radioButtonEqualsGV.Text = "=  (Equals)";
		this.radioButtonEqualsGV.UseVisualStyleBackColor = true;
		this.radioButtonEqualsGV.CheckedChanged += new System.EventHandler(optionSetGVSign_ValueChanged);
		this.txtGlobalToGlobal.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
		this.txtGlobalToGlobal.BackColor = System.Drawing.SystemColors.Control;
		this.txtGlobalToGlobal.Enabled = false;
		this.txtGlobalToGlobal.Location = new System.Drawing.Point(72, 162);
		this.txtGlobalToGlobal.Name = "txtGlobalToGlobal";
		this.txtGlobalToGlobal.ReadOnly = true;
		this.txtGlobalToGlobal.Size = new System.Drawing.Size(86, 20);
		this.txtGlobalToGlobal.TabIndex = 10;
		this.txtGlobalToGlobal.TextChanged += new System.EventHandler(txtGlobalToGlobal_TextChanged);
		this.btnGlobalToGlobal.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
		this.btnGlobalToGlobal.Enabled = false;
		this.btnGlobalToGlobal.Location = new System.Drawing.Point(160, 160);
		this.btnGlobalToGlobal.Name = "btnGlobalToGlobal";
		this.btnGlobalToGlobal.Size = new System.Drawing.Size(25, 22);
		this.btnGlobalToGlobal.TabIndex = 9;
		this.btnGlobalToGlobal.Text = "..";
		this.btnGlobalToGlobal.UseVisualStyleBackColor = true;
		this.btnGlobalToGlobal.Click += new System.EventHandler(btnGlobalToGlobal_Click);
		this.radioGlobalToGlobal.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
		this.radioGlobalToGlobal.AutoSize = true;
		this.radioGlobalToGlobal.Location = new System.Drawing.Point(14, 163);
		this.radioGlobalToGlobal.Name = "radioGlobalToGlobal";
		this.radioGlobalToGlobal.Size = new System.Drawing.Size(58, 17);
		this.radioGlobalToGlobal.TabIndex = 7;
		this.radioGlobalToGlobal.Text = "Global:";
		this.radioGlobalToGlobal.UseVisualStyleBackColor = true;
		this.radioGlobalToValue.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
		this.radioGlobalToValue.AutoSize = true;
		this.radioGlobalToValue.Checked = true;
		this.radioGlobalToValue.Location = new System.Drawing.Point(14, 140);
		this.radioGlobalToValue.Name = "radioGlobalToValue";
		this.radioGlobalToValue.Size = new System.Drawing.Size(55, 17);
		this.radioGlobalToValue.TabIndex = 6;
		this.radioGlobalToValue.TabStop = true;
		this.radioGlobalToValue.Text = "Value:";
		this.radioGlobalToValue.UseVisualStyleBackColor = true;
		this.radioGlobalToValue.CheckedChanged += new System.EventHandler(radioGlobalToValue_CheckedChanged);
		this.txtGlobalValue.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
		this.txtGlobalValue.Location = new System.Drawing.Point(72, 139);
		this.txtGlobalValue.Name = "txtGlobalValue";
		this.txtGlobalValue.Size = new System.Drawing.Size(113, 20);
		this.txtGlobalValue.TabIndex = 5;
		this.txtGlobalValue.TextChanged += new System.EventHandler(txtGlobalValue_TextChanged);
		this.ultraTreeGV.Dock = System.Windows.Forms.DockStyle.Left;
		this.ultraTreeGV.HideSelection = false;
		this.ultraTreeGV.ImageIndex = 0;
		this.ultraTreeGV.ImageList = this.imageList;
		this.ultraTreeGV.Location = new System.Drawing.Point(5, 5);
		this.ultraTreeGV.Name = "ultraTreeGV";
		this.ultraTreeGV.SelectedImageIndex = 0;
		this.ultraTreeGV.ShowRootLines = false;
		this.ultraTreeGV.Size = new System.Drawing.Size(258, 182);
		this.ultraTreeGV.TabIndex = 4;
		this.ultraTreeGV.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(ultraTreeGV_AfterSelect);
		this.BackColor = System.Drawing.Color.White;
		base.Controls.Add(this.panelGV);
		base.Controls.Add(this.panelParameter);
		base.Controls.Add(this.panelResult);
		base.Controls.Add(this.panelTop);
		base.Name = "CreateConditionUC";
		base.Size = new System.Drawing.Size(456, 669);
		this.panelTop.ResumeLayout(false);
		this.panelTop.PerformLayout();
		this.panelParameter.ResumeLayout(false);
		this.panelCondition.ResumeLayout(false);
		this.panelCondition.PerformLayout();
		this.groupBoxParam.ResumeLayout(false);
		this.groupBoxParam.PerformLayout();
		this.panelResult.ResumeLayout(false);
		this.groupBoxPassFail.ResumeLayout(false);
		this.groupBoxPassFail.PerformLayout();
		this.panelGV.ResumeLayout(false);
		this.panelGVRight.ResumeLayout(false);
		this.panelGVRight.PerformLayout();
		this.groupBoxGV.ResumeLayout(false);
		this.groupBoxGV.PerformLayout();
		base.ResumeLayout(false);
	}

	private void ultraComboIndex_SelectedValueChanged(object sender, EventArgs e)
	{
		try
		{
			condition.ParameterIndex = (int)ultraComboIndex.SelectedValue;
		}
		catch
		{
		}
	}

	public ParameterCls GetSelectedParameter()
	{
		try
		{
			return (ParameterCls)treeParameter.SelectedNode.Tag;
		}
		catch
		{
		}
		return null;
	}

	private void cmbSelection_SelectedValueChanged(object sender, EventArgs e)
	{
		try
		{
			panelParameter.Dock = DockStyle.None;
			panelResult.Dock = DockStyle.None;
			panelGV.Dock = DockStyle.None;
			panelParameter.Visible = false;
			panelResult.Visible = false;
			panelGV.Visible = false;
			ConditionType conditionType = ConditionType.TestParameters;
			conditionType = (ConditionType)Enum.Parse(conditionType.GetType(), cmbSelection.SelectedValue.ToString());
			switch (conditionType)
			{
			case ConditionType.TestParameters:
				panelParameter.Visible = true;
				panelParameter.Dock = DockStyle.Fill;
				condition.TestConditionType = conditionType;
				if (radioParamToValue.Checked)
				{
					condition.CompareToType = CompareType.Constant;
				}
				else if (radioParamToGlobal.Checked)
				{
					condition.CompareToType = CompareType.GlobalVariable;
					condition.GVToCompareName = txtParamToGlobal.Text;
				}
				else if (radioParamToLL.Checked)
				{
					condition.CompareToType = CompareType.LowerLimit;
				}
				else
				{
					condition.CompareToType = CompareType.UpperLimit;
				}
				break;
			case ConditionType.TestResult:
				panelResult.Visible = true;
				panelResult.Dock = DockStyle.Fill;
				condition.TestConditionType = conditionType;
				break;
			case ConditionType.GlobalVariables:
				panelGV.Visible = true;
				panelGV.Dock = DockStyle.Fill;
				condition.TestConditionType = conditionType;
				if (radioGlobalToValue.Checked)
				{
					condition.CompareToType = CompareType.Constant;
					break;
				}
				condition.CompareToType = CompareType.GlobalVariable;
				condition.GVToCompareName = txtGlobalToGlobal.Text;
				break;
			}
		}
		catch
		{
		}
	}

	private void cmbSelection_ValueChanged(object sender, EventArgs e)
	{
		try
		{
			panelParameter.Dock = DockStyle.None;
			panelResult.Dock = DockStyle.None;
			panelGV.Dock = DockStyle.None;
			panelParameter.Visible = false;
			panelResult.Visible = false;
			panelGV.Visible = false;
			ConditionType conditionType = ConditionType.TestParameters;
			conditionType = (ConditionType)Enum.Parse(conditionType.GetType(), cmbSelection.SelectedValue.ToString());
			switch (conditionType)
			{
			case ConditionType.TestParameters:
				panelParameter.Visible = true;
				panelParameter.Dock = DockStyle.Fill;
				condition.TestConditionType = conditionType;
				if (radioParamToValue.Checked)
				{
					condition.CompareToType = CompareType.Constant;
				}
				else if (radioParamToGlobal.Checked)
				{
					condition.CompareToType = CompareType.GlobalVariable;
					condition.GVToCompareName = txtParamToGlobal.Text;
				}
				else if (radioParamToLL.Checked)
				{
					condition.CompareToType = CompareType.LowerLimit;
				}
				else
				{
					condition.CompareToType = CompareType.UpperLimit;
				}
				break;
			case ConditionType.TestResult:
				panelResult.Visible = true;
				panelResult.Dock = DockStyle.Fill;
				condition.TestConditionType = conditionType;
				break;
			case ConditionType.GlobalVariables:
				panelGV.Visible = true;
				panelGV.Dock = DockStyle.Fill;
				condition.TestConditionType = conditionType;
				if (radioGlobalToValue.Checked)
				{
					condition.CompareToType = CompareType.Constant;
					break;
				}
				condition.CompareToType = CompareType.GlobalVariable;
				condition.GVToCompareName = txtGlobalToGlobal.Text;
				break;
			}
		}
		catch
		{
		}
	}

	private void treeParameter_AfterSelect(object sender, TreeViewEventArgs e)
	{
		try
		{
			ParameterCls parameterCls = (ParameterCls)e.Node.Tag;
			condition.ParameterName = parameterCls.Name;
			if (parameterCls.NoOfElements > 1)
			{
				labelIndex.Enabled = true;
				ultraComboIndex.Enabled = true;
				ultraComboIndex.DataSource = null;
				ultraComboIndex.ValueMember = "Value";
				ultraComboIndex.DisplayMember = "Key";
				Dictionary<string, int> dictionary = new Dictionary<string, int>();
				dictionary.Add("Any", -2);
				dictionary.Add("All", -1);
				for (int i = 0; i < parameterCls.NoOfElements; i++)
				{
					dictionary.Add(i.ToString(), i);
				}
				ultraComboIndex.DataSource = dictionary.ToList();
				ultraComboIndex.SelectedValue = -2;
			}
			else
			{
				ultraComboIndex.SelectedValue = -3;
				ultraComboIndex.Enabled = false;
				labelIndex.Enabled = false;
			}
			if (parameterCls.IsOutput)
			{
				radioParamToLL.Enabled = true;
				radioParamToUL.Enabled = true;
				return;
			}
			if (radioParamToLL.Checked || radioParamToUL.Checked)
			{
				radioParamToValue.Checked = true;
			}
			radioParamToLL.Enabled = false;
			radioParamToUL.Enabled = false;
		}
		catch
		{
		}
	}

	private string GetSelectedRBValue(GroupBox groupBox)
	{
		RadioButton radioButton = groupBox.Controls.OfType<RadioButton>().FirstOrDefault((RadioButton n) => n.Checked);
		return radioButton.Tag.ToString();
	}

	private void SetSelectedRBValue(GroupBox groupBox, string RBText)
	{
		RadioButton radioButton = groupBox.Controls.OfType<RadioButton>().FirstOrDefault((RadioButton n) => n.Tag.ToString() == RBText);
		radioButton.Checked = true;
	}

	private void optionSetConditions_ValueChanged(object sender, EventArgs e)
	{
		try
		{
			switch (GetSelectedRBValue(groupBoxParam))
			{
			case "Equals":
				condition.ParameterSign = ConditionSign.Equals;
				break;
			case "NotEqual":
				condition.ParameterSign = ConditionSign.NotEqual;
				break;
			case "GreaterThan":
				condition.ParameterSign = ConditionSign.GreaterThan;
				break;
			case "LessThan":
				condition.ParameterSign = ConditionSign.LessThan;
				break;
			case "GreaterThanEqual":
				condition.ParameterSign = ConditionSign.GreaterThanEqual;
				break;
			case "LessThanEqual":
				condition.ParameterSign = ConditionSign.LessThanEqual;
				break;
			}
		}
		catch
		{
		}
	}

	private void optionSetPassFail_ValueChanged(object sender, EventArgs e)
	{
		try
		{
			switch (GetSelectedRBValue(groupBoxPassFail))
			{
			case "Passed":
				condition.Result = TestResult.Passed;
				break;
			case "Failed":
				condition.Result = TestResult.Failed;
				break;
			}
		}
		catch
		{
		}
	}

	private void ultraTreeGV_AfterSelect(object sender, TreeViewEventArgs e)
	{
		try
		{
			condition.GlobalVariableName = e.Node.Text;
		}
		catch
		{
		}
	}

	private void optionSetGVSign_ValueChanged(object sender, EventArgs e)
	{
		try
		{
			switch (GetSelectedRBValue(groupBoxGV))
			{
			case "Equals":
				condition.GlobalVariableSign = ConditionSign.Equals;
				break;
			case "NotEqual":
				condition.GlobalVariableSign = ConditionSign.NotEqual;
				break;
			case "GreaterThan":
				condition.GlobalVariableSign = ConditionSign.GreaterThan;
				break;
			case "LessThan":
				condition.GlobalVariableSign = ConditionSign.LessThan;
				break;
			case "GreaterThanEqual":
				condition.GlobalVariableSign = ConditionSign.GreaterThanEqual;
				break;
			case "LessThanEqual":
				condition.GlobalVariableSign = ConditionSign.LessThanEqual;
				break;
			}
		}
		catch
		{
		}
	}

	private void radioGlobalToValue_CheckedChanged(object sender, EventArgs e)
	{
		if (radioGlobalToValue.Checked)
		{
			txtGlobalValue.Enabled = true;
			btnGlobalToGlobal.Enabled = false;
			txtGlobalToGlobal.Enabled = false;
			txtGlobalToGlobal.BackColor = SystemColors.Control;
			condition.CompareToType = CompareType.Constant;
			condition.GlobalVariableValue = txtGlobalValue.Text;
		}
		else if (radioGlobalToGlobal.Checked)
		{
			txtGlobalValue.Enabled = false;
			btnGlobalToGlobal.Enabled = true;
			txtGlobalToGlobal.Enabled = true;
			txtGlobalToGlobal.BackColor = SystemColors.Window;
			condition.CompareToType = CompareType.GlobalVariable;
			condition.GVToCompareName = txtGlobalToGlobal.Text;
		}
		else
		{
			txtGlobalValue.Enabled = true;
			btnGlobalToGlobal.Enabled = false;
			txtGlobalToGlobal.Enabled = false;
			txtGlobalToGlobal.BackColor = SystemColors.Control;
			condition.CompareToType = CompareType.Constant;
			condition.GlobalVariableValue = txtGlobalValue.Text;
			radioGlobalToValue.Checked = true;
		}
	}

	private void radiosParamCompareType_CheckedChanged(object sender, EventArgs e)
	{
		if (radioParamToValue.Checked)
		{
			txtParameterValue.Enabled = true;
			btnParamToGlobal.Enabled = false;
			txtParamToGlobal.Enabled = false;
			txtParamToGlobal.BackColor = SystemColors.Control;
			condition.CompareToType = CompareType.Constant;
			condition.ParameterValue = txtParameterValue.Text;
		}
		else if (radioParamToGlobal.Checked)
		{
			txtParameterValue.Enabled = false;
			btnParamToGlobal.Enabled = true;
			txtParamToGlobal.Enabled = true;
			txtParamToGlobal.BackColor = SystemColors.Window;
			condition.CompareToType = CompareType.GlobalVariable;
			condition.GVToCompareName = txtParamToGlobal.Text;
		}
		else if (radioParamToLL.Checked)
		{
			txtParameterValue.Enabled = false;
			btnParamToGlobal.Enabled = false;
			txtParamToGlobal.Enabled = false;
			txtParamToGlobal.BackColor = SystemColors.Control;
			condition.CompareToType = CompareType.LowerLimit;
		}
		else if (radioParamToUL.Checked)
		{
			txtParameterValue.Enabled = false;
			btnParamToGlobal.Enabled = false;
			txtParamToGlobal.Enabled = false;
			txtParamToGlobal.BackColor = SystemColors.Control;
			condition.CompareToType = CompareType.UpperLimit;
		}
		else
		{
			txtParameterValue.Enabled = true;
			btnParamToGlobal.Enabled = false;
			txtParamToGlobal.Enabled = false;
			txtParamToGlobal.BackColor = SystemColors.Control;
			condition.CompareToType = CompareType.Constant;
			condition.ParameterValue = txtParameterValue.Text;
			radioParamToValue.Checked = true;
		}
	}

	private void btnGlobalToGlobal_Click(object sender, EventArgs e)
	{
		QTMGlobalVariablesDialog qTMGlobalVariablesDialog = new QTMGlobalVariablesDialog();
		if (txtGlobalToGlobal.Text != "")
		{
			qTMGlobalVariablesDialog.CurrentSelection = txtGlobalToGlobal.Text;
		}
		if (qTMGlobalVariablesDialog.ShowDialog() == DialogResult.OK)
		{
			txtGlobalToGlobal.Text = qTMGlobalVariablesDialog.CurrentSelection;
			LoadGV();
		}
	}

	private void btnParamToGlobal_Click(object sender, EventArgs e)
	{
		QTMGlobalVariablesDialog qTMGlobalVariablesDialog = new QTMGlobalVariablesDialog();
		if (txtParamToGlobal.Text != "")
		{
			qTMGlobalVariablesDialog.CurrentSelection = txtParamToGlobal.Text;
		}
		if (qTMGlobalVariablesDialog.ShowDialog() == DialogResult.OK)
		{
			txtParamToGlobal.Text = qTMGlobalVariablesDialog.CurrentSelection;
			LoadGV();
		}
	}

	private void txtGlobalValue_TextChanged(object sender, EventArgs e)
	{
		condition.GlobalVariableValue = txtGlobalValue.Text;
	}

	private void txtGlobalToGlobal_TextChanged(object sender, EventArgs e)
	{
		condition.GVToCompareName = txtGlobalToGlobal.Text;
	}

	private void txtParameterValue_TextChanged(object sender, EventArgs e)
	{
		condition.ParameterValue = txtParameterValue.Text;
	}

	private void txtParamToGlobal_TextChanged(object sender, EventArgs e)
	{
		condition.GVToCompareName = txtParamToGlobal.Text;
	}

	private void txtName_TextChanged(object sender, EventArgs e)
	{
		condition.Name = txtName.Text.Trim();
	}

	public void LoadGV()
	{
		try
		{
			ultraTreeGV.Nodes.Clear();
			foreach (string sortedGVName in QTMGlobalVariable.SortedGVNames)
			{
				ultraTreeGV.Nodes.Add(sortedGVName, sortedGVName);
			}
		}
		catch
		{
		}
	}
}
