using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Xml.Serialization;
using QC.GlobalVariableManager;
using QC.QSPR;
using QC.QsprShared.Dialogs;
using QC.QsprShared.GlobalData;
using QC.QsprShared.Trace;
using QC.QsprShared.Utilities;
using QC.QsprTestObjects.Parameters;
using QC.QsprTestObjects.Tests.Base;
using QC.QTMInterface;
using QsprMiscShared.Utilities;

namespace QC.QsprTestObjects.Loops;

public class LoopSetup : Form
{
	public delegate void ExitTutorialDelegate(object sender, EventArgs e);

	public const string GV_LIST = "Global Variables";

	public const int ROW_ID_COLUMN_INDEX = 0;

	public const int CHECK_COLUMN_INDEX = 1;

	public const int DON_T_RUN_CONDITION_INDEX = 2;

	public const int DESCRIPTION_COLUMN_INDEX = 3;

	public const int SCENARIO_START_COLUMN_INDEX = 4;

	private const int NOT_ARRAY_PARAMETER = -2;

	private const int SCENARIO_ON_ALL_INDEX = -1;

	private const string VALUE = "Value";

	private const string INPUT = "Input";

	private const string UPPER_LIMIT = "UL";

	private const string LOWER_LIMIT = "LL";

	private const string SUFFIX_LL = "LL";

	private const string SUFFIX_UL = "UL";

	public const string SELECTION = "Selection";

	public const string ROW_ID = "Row ID";

	public const string DESCRIPTION = "Description";

	public const string DONT_RUN_CONDITION = "Don't Run Condition";

	private const string TUTORIAL_FILENAME = "\\\\host-cts\\QTM\\Help\\Tutorial\\Looping.exe";

	public const string TEST_DESCRIPTION_NAME_SEPARATOR = ",";

	public const string DONT_RUN_CONDITIONS = "<=,=<,>=,=<,!=,=,<,>";

	public const string LOOP_FOREVER = "Loop Forever";

	public const string ALL_TESTS = "ALLTests";

	private const int FOLDER_IMAGE = 0;

	private const int FOLDER_SELECTED_IMAGE = 1;

	private const int TEST_IMAGE = 2;

	private const int INPUT_PARAMETER_IMAGE = 3;

	private const int OUTPUT_PARAMETER_IMAGE = 4;

	private DataGridViewColumn currentCol;

	private string oldColumnName = "";

	private TreeNode testNode;

	private LoopScenarioValues loopScenario;

	private ArrayList clipBoard;

	private bool modified;

	private bool userEdited;

	private FolderTest loopFolder;

	private bool bColumnNameChangeUser;

	private bool warningShownForListFromFile;

	private LoopCondition currLoopCond;

	private string previoiuslySelectedLoopName = string.Empty;

	private List<TreeNode> _disabledNodes = new List<TreeNode>();

	private bool LoopSelectionChanged;

	private bool LoopRowDeleted;

	private bool LoopChanged;

	private TextBox txtColumnName;

	private TextBox textSSS;

	private TextBox textList;

	private Button btnUpdateList;

	private TextBox txtLoopName;

	private Button btnOK;

	private Button btnCancel;

	private Button btnRemove;

	private Button btnTutorial;

	private Button btnInputChange;

	private Button btnULChange;

	private Button btnLLChange;

	private ComboBox cmParamterIndex;

	private TreeView treeParam;

	private TreeView treeTest;

	private ComboBox cmbLoopCount;

	private Button btnBreakCondition;

	private PictureBox pictureBoxBreak;

	private NumericUpDown numericUpDownTime;

	private RadioButton radioTime;

	private TextBox txtFilename;

	private CheckBox chkListFromFile;

	private Button btnLoadFile;

	private Label lblFileName;

	private Label lblFileColumnName;

	private ComboBox cmbFileColumnName;

	private CheckBox chkIgnoreIntermediateResults;

	private TextBox txt2DArrayIndex;

	private ToolTip toolTip1;

	private Label labelAllTests;

	private CheckBox chkFileNameFromGV;

	private Button ultraButtonEditGV;

	private Button btnApplyAllTests;

	private Label labelLoopOptions;

	private CheckBox chkLoopTimeFromGV;

	private Button btnSelectTimeGV;

	private CheckBox chkLoopCountFromGV;

	private Button btnSelectCountGV;

	private CheckBox chkBoxSuppressWarnings;

	private GroupBox groupBoxFileType;

	private RadioButton radioButton2;

	private RadioButton radioButton1;

	private GroupBox groupBoxHoursMinutes;

	private RadioButton radioButton5;

	private RadioButton radioButton4;

	private RadioButton radioButton3;

	private ContextMenuStrip contextMenuStrip1;

	private ToolStripMenuItem moveRightToolStripMenuItem;

	private ToolStripMenuItem moveLeftToolStripMenuItem;

	private ToolStripSeparator toolStripSeparator1;

	private ToolStripMenuItem addRowToolStripMenuItem;

	private ToolStripMenuItem deleteRowToolStripMenuItem;

	private ToolStripMenuItem insertRowToolStripMenuItem;

	private ToolStripMenuItem deleteColumnToolStripMenuItem;

	private ToolStripMenuItem changeLoopNameToolStripMenuItem;

	private ToolStripMenuItem applyToAllTestsToolStripMenuItem;

	private ToolStripMenuItem cutToolStripMenuItem;

	private ToolStripMenuItem copyToolStripMenuItem;

	private ToolStripMenuItem pasteToolStripMenuItem;

	private ToolStripMenuItem pasteLastToolStripMenuItem;

	private ToolStripMenuItem selectionToolStripMenuItem;

	private ToolStripMenuItem selectAllToolStripMenuItem;

	private ToolStripMenuItem deselectAllToolStripMenuItem;

	private ToolStripMenuItem removeLoopSetupToolStripMenuItem;

	private DataGridView dataGridLoop;

	private RadioButton radioSequence;

	private Button btnGenPermutations;

	private bool LoopValueChanged;

	private Panel panelLoopvalue;

	private RadioButton radioSSS;

	private Label label3;

	private RadioButton radioList;

	private RadioButton radioCount;

	private Splitter splitter1;

	private Panel panelButtons;

	private Panel panelChangeButtons;

	private Label label5;

	private Panel panelChangeColumnName;

	private Label lblNewColumnName;

	private Panel panel3;

	private Label lblIndex;

	private IContainer components;

	private ImageList imageListSmall;

	private Panel LoopSetup_Fill_Panel;

	private Panel panelSetup;

	private Panel panelTree;

	private Panel panelGrid;

	private Panel panelTwoTree;

	private Panel panelIndex;

	private HelpProvider helpProvider;

	private Splitter splitter2;

	private bool cancelPressed;

	private bool ctrlPressed;

	private bool okPressed;

	private TextBox timeTxt = new TextBox();

	public bool singleTestSelected;

	[XmlIgnore]
	public FolderTest LoopFolder
	{
		get
		{
			return loopFolder;
		}
		set
		{
			loopFolder = value;
		}
	}

	private void ResetRegistrationBooleans()
	{
		LoopSelectionChanged = false;
		LoopRowDeleted = false;
		LoopValueChanged = false;
		LoopChanged = false;
	}

	public LoopSetup()
	{
		InitializeComponent();
	}

	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.Loops.LoopSetup));
		this.panelLoopvalue = new System.Windows.Forms.Panel();
		this.btnSelectCountGV = new System.Windows.Forms.Button();
		this.radioSequence = new System.Windows.Forms.RadioButton();
		this.btnGenPermutations = new System.Windows.Forms.Button();
		this.chkListFromFile = new System.Windows.Forms.CheckBox();
		this.groupBoxHoursMinutes = new System.Windows.Forms.GroupBox();
		this.radioButton5 = new System.Windows.Forms.RadioButton();
		this.radioButton4 = new System.Windows.Forms.RadioButton();
		this.radioButton3 = new System.Windows.Forms.RadioButton();
		this.groupBoxFileType = new System.Windows.Forms.GroupBox();
		this.radioButton2 = new System.Windows.Forms.RadioButton();
		this.radioButton1 = new System.Windows.Forms.RadioButton();
		this.chkLoopTimeFromGV = new System.Windows.Forms.CheckBox();
		this.btnSelectTimeGV = new System.Windows.Forms.Button();
		this.chkLoopCountFromGV = new System.Windows.Forms.CheckBox();
		this.chkFileNameFromGV = new System.Windows.Forms.CheckBox();
		this.chkIgnoreIntermediateResults = new System.Windows.Forms.CheckBox();
		this.cmbFileColumnName = new System.Windows.Forms.ComboBox();
		this.lblFileColumnName = new System.Windows.Forms.Label();
		this.lblFileName = new System.Windows.Forms.Label();
		this.btnLoadFile = new System.Windows.Forms.Button();
		this.txtFilename = new System.Windows.Forms.TextBox();
		this.numericUpDownTime = new System.Windows.Forms.NumericUpDown();
		this.radioTime = new System.Windows.Forms.RadioButton();
		this.cmbLoopCount = new System.Windows.Forms.ComboBox();
		this.txtLoopName = new System.Windows.Forms.TextBox();
		this.textList = new System.Windows.Forms.TextBox();
		this.radioCount = new System.Windows.Forms.RadioButton();
		this.radioList = new System.Windows.Forms.RadioButton();
		this.label3 = new System.Windows.Forms.Label();
		this.textSSS = new System.Windows.Forms.TextBox();
		this.btnUpdateList = new System.Windows.Forms.Button();
		this.radioSSS = new System.Windows.Forms.RadioButton();
		this.btnBreakCondition = new System.Windows.Forms.Button();
		this.imageListSmall = new System.Windows.Forms.ImageList(this.components);
		this.panelTwoTree = new System.Windows.Forms.Panel();
		this.treeParam = new System.Windows.Forms.TreeView();
		this.splitter1 = new System.Windows.Forms.Splitter();
		this.treeTest = new System.Windows.Forms.TreeView();
		this.panelButtons = new System.Windows.Forms.Panel();
		this.btnTutorial = new System.Windows.Forms.Button();
		this.btnRemove = new System.Windows.Forms.Button();
		this.btnCancel = new System.Windows.Forms.Button();
		this.btnOK = new System.Windows.Forms.Button();
		this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
		this.moveRightToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.moveLeftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
		this.addRowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.deleteRowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.insertRowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.deleteColumnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.changeLoopNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.applyToAllTestsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.pasteLastToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.selectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.deselectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.removeLoopSetupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.panelChangeButtons = new System.Windows.Forms.Panel();
		this.btnLLChange = new System.Windows.Forms.Button();
		this.btnULChange = new System.Windows.Forms.Button();
		this.btnInputChange = new System.Windows.Forms.Button();
		this.label5 = new System.Windows.Forms.Label();
		this.panelChangeColumnName = new System.Windows.Forms.Panel();
		this.chkBoxSuppressWarnings = new System.Windows.Forms.CheckBox();
		this.btnApplyAllTests = new System.Windows.Forms.Button();
		this.ultraButtonEditGV = new System.Windows.Forms.Button();
		this.labelAllTests = new System.Windows.Forms.Label();
		this.pictureBoxBreak = new System.Windows.Forms.PictureBox();
		this.txtColumnName = new System.Windows.Forms.TextBox();
		this.lblNewColumnName = new System.Windows.Forms.Label();
		this.panelIndex = new System.Windows.Forms.Panel();
		this.txt2DArrayIndex = new System.Windows.Forms.TextBox();
		this.cmParamterIndex = new System.Windows.Forms.ComboBox();
		this.lblIndex = new System.Windows.Forms.Label();
		this.panel3 = new System.Windows.Forms.Panel();
		this.labelLoopOptions = new System.Windows.Forms.Label();
		this.panelSetup = new System.Windows.Forms.Panel();
		this.splitter2 = new System.Windows.Forms.Splitter();
		this.panelTree = new System.Windows.Forms.Panel();
		this.LoopSetup_Fill_Panel = new System.Windows.Forms.Panel();
		this.panelGrid = new System.Windows.Forms.Panel();
		this.dataGridLoop = new System.Windows.Forms.DataGridView();
		this.helpProvider = new System.Windows.Forms.HelpProvider();
		this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
		this.panelLoopvalue.SuspendLayout();
		this.groupBoxHoursMinutes.SuspendLayout();
		this.groupBoxFileType.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.numericUpDownTime).BeginInit();
		this.panelTwoTree.SuspendLayout();
		this.panelButtons.SuspendLayout();
		this.contextMenuStrip1.SuspendLayout();
		this.panelChangeButtons.SuspendLayout();
		this.panelChangeColumnName.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.pictureBoxBreak).BeginInit();
		this.panelIndex.SuspendLayout();
		this.panel3.SuspendLayout();
		this.panelSetup.SuspendLayout();
		this.panelTree.SuspendLayout();
		this.LoopSetup_Fill_Panel.SuspendLayout();
		this.panelGrid.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.dataGridLoop).BeginInit();
		base.SuspendLayout();
		this.panelLoopvalue.Controls.Add(this.btnSelectCountGV);
		this.panelLoopvalue.Controls.Add(this.radioSequence);
		this.panelLoopvalue.Controls.Add(this.btnGenPermutations);
		this.panelLoopvalue.Controls.Add(this.chkListFromFile);
		this.panelLoopvalue.Controls.Add(this.groupBoxHoursMinutes);
		this.panelLoopvalue.Controls.Add(this.groupBoxFileType);
		this.panelLoopvalue.Controls.Add(this.chkLoopTimeFromGV);
		this.panelLoopvalue.Controls.Add(this.btnSelectTimeGV);
		this.panelLoopvalue.Controls.Add(this.chkLoopCountFromGV);
		this.panelLoopvalue.Controls.Add(this.chkFileNameFromGV);
		this.panelLoopvalue.Controls.Add(this.chkIgnoreIntermediateResults);
		this.panelLoopvalue.Controls.Add(this.cmbFileColumnName);
		this.panelLoopvalue.Controls.Add(this.lblFileColumnName);
		this.panelLoopvalue.Controls.Add(this.lblFileName);
		this.panelLoopvalue.Controls.Add(this.btnLoadFile);
		this.panelLoopvalue.Controls.Add(this.txtFilename);
		this.panelLoopvalue.Controls.Add(this.numericUpDownTime);
		this.panelLoopvalue.Controls.Add(this.radioTime);
		this.panelLoopvalue.Controls.Add(this.cmbLoopCount);
		this.panelLoopvalue.Controls.Add(this.txtLoopName);
		this.panelLoopvalue.Controls.Add(this.textList);
		this.panelLoopvalue.Controls.Add(this.radioCount);
		this.panelLoopvalue.Controls.Add(this.radioList);
		this.panelLoopvalue.Controls.Add(this.label3);
		this.panelLoopvalue.Controls.Add(this.textSSS);
		this.panelLoopvalue.Controls.Add(this.btnUpdateList);
		this.panelLoopvalue.Controls.Add(this.radioSSS);
		this.panelLoopvalue.Dock = System.Windows.Forms.DockStyle.Fill;
		this.panelLoopvalue.Location = new System.Drawing.Point(456, 0);
		this.panelLoopvalue.Name = "panelLoopvalue";
		this.panelLoopvalue.Size = new System.Drawing.Size(455, 272);
		this.panelLoopvalue.TabIndex = 1;
		this.btnSelectCountGV.Enabled = false;
		this.btnSelectCountGV.Location = new System.Drawing.Point(262, 190);
		this.btnSelectCountGV.Name = "btnSelectCountGV";
		this.btnSelectCountGV.Size = new System.Drawing.Size(21, 23);
		this.btnSelectCountGV.TabIndex = 21;
		this.btnSelectCountGV.Text = "..";
		this.btnSelectCountGV.UseVisualStyleBackColor = true;
		this.btnSelectCountGV.Click += new System.EventHandler(btnSelectCountGV_Click);
		this.radioSequence.ForeColor = System.Drawing.Color.RoyalBlue;
		this.radioSequence.Location = new System.Drawing.Point(17, 169);
		this.radioSequence.Name = "radioSequence";
		this.radioSequence.Size = new System.Drawing.Size(96, 21);
		this.radioSequence.TabIndex = 27;
		this.radioSequence.TabStop = true;
		this.radioSequence.Text = "By Sequence";
		this.radioSequence.CheckedChanged += new System.EventHandler(radioSequence_CheckedChanged);
		this.btnGenPermutations.Enabled = false;
		this.btnGenPermutations.Location = new System.Drawing.Point(128, 165);
		this.btnGenPermutations.Name = "btnGenPermutations";
		this.btnGenPermutations.Size = new System.Drawing.Size(142, 25);
		this.btnGenPermutations.TabIndex = 21;
		this.btnGenPermutations.Text = "Generate Permutations";
		this.toolTip1.SetToolTip(this.btnGenPermutations, "Create a sequence loop by selecting a group of tests from the tree , then press Generate Permutations button");
		this.btnGenPermutations.UseVisualStyleBackColor = true;
		this.btnGenPermutations.Click += new System.EventHandler(btnGenPermutations_Click);
		this.chkListFromFile.AutoSize = true;
		this.chkListFromFile.Enabled = false;
		this.chkListFromFile.Location = new System.Drawing.Point(263, 57);
		this.chkListFromFile.Margin = new System.Windows.Forms.Padding(1);
		this.chkListFromFile.Name = "chkListFromFile";
		this.chkListFromFile.Size = new System.Drawing.Size(68, 17);
		this.chkListFromFile.TabIndex = 7;
		this.chkListFromFile.Text = "From File";
		this.chkListFromFile.UseVisualStyleBackColor = true;
		this.chkListFromFile.CheckedChanged += new System.EventHandler(chkListFromFile_CheckedChanged);
		this.groupBoxHoursMinutes.Controls.Add(this.radioButton5);
		this.groupBoxHoursMinutes.Controls.Add(this.radioButton4);
		this.groupBoxHoursMinutes.Controls.Add(this.radioButton3);
		this.groupBoxHoursMinutes.Enabled = false;
		this.groupBoxHoursMinutes.Location = new System.Drawing.Point(262, 209);
		this.groupBoxHoursMinutes.Name = "groupBoxHoursMinutes";
		this.groupBoxHoursMinutes.Size = new System.Drawing.Size(74, 62);
		this.groupBoxHoursMinutes.TabIndex = 26;
		this.groupBoxHoursMinutes.TabStop = false;
		this.radioButton5.AutoSize = true;
		this.radioButton5.Location = new System.Drawing.Point(6, 39);
		this.radioButton5.Name = "radioButton5";
		this.radioButton5.Size = new System.Drawing.Size(67, 17);
		this.radioButton5.TabIndex = 2;
		this.radioButton5.TabStop = true;
		this.radioButton5.Text = "Seconds";
		this.radioButton5.UseVisualStyleBackColor = true;
		this.radioButton5.CheckedChanged += new System.EventHandler(radioHoursMinutes_ValueChanged);
		this.radioButton4.AutoSize = true;
		this.radioButton4.Location = new System.Drawing.Point(6, 24);
		this.radioButton4.Name = "radioButton4";
		this.radioButton4.Size = new System.Drawing.Size(62, 17);
		this.radioButton4.TabIndex = 1;
		this.radioButton4.TabStop = true;
		this.radioButton4.Text = "Minutes";
		this.radioButton4.UseVisualStyleBackColor = true;
		this.radioButton4.CheckedChanged += new System.EventHandler(radioHoursMinutes_ValueChanged);
		this.radioButton3.AutoSize = true;
		this.radioButton3.Checked = true;
		this.radioButton3.Location = new System.Drawing.Point(5, 7);
		this.radioButton3.Name = "radioButton3";
		this.radioButton3.Size = new System.Drawing.Size(53, 17);
		this.radioButton3.TabIndex = 0;
		this.radioButton3.TabStop = true;
		this.radioButton3.Text = "Hours";
		this.radioButton3.UseVisualStyleBackColor = true;
		this.radioButton3.CheckedChanged += new System.EventHandler(radioHoursMinutes_ValueChanged);
		this.groupBoxFileType.Controls.Add(this.radioButton2);
		this.groupBoxFileType.Controls.Add(this.radioButton1);
		this.groupBoxFileType.Enabled = false;
		this.groupBoxFileType.Location = new System.Drawing.Point(263, 71);
		this.groupBoxFileType.Margin = new System.Windows.Forms.Padding(1);
		this.groupBoxFileType.Name = "groupBoxFileType";
		this.groupBoxFileType.Padding = new System.Windows.Forms.Padding(1);
		this.groupBoxFileType.Size = new System.Drawing.Size(68, 47);
		this.groupBoxFileType.TabIndex = 25;
		this.groupBoxFileType.TabStop = false;
		this.radioButton2.AutoSize = true;
		this.radioButton2.Checked = true;
		this.radioButton2.Location = new System.Drawing.Point(5, 26);
		this.radioButton2.Margin = new System.Windows.Forms.Padding(1);
		this.radioButton2.Name = "radioButton2";
		this.radioButton2.Size = new System.Drawing.Size(60, 17);
		this.radioButton2.TabIndex = 26;
		this.radioButton2.TabStop = true;
		this.radioButton2.Text = "Comma";
		this.radioButton2.UseVisualStyleBackColor = true;
		this.radioButton2.CheckedChanged += new System.EventHandler(radioFileType_ValueChanged);
		this.radioButton1.AutoSize = true;
		this.radioButton1.Location = new System.Drawing.Point(5, 9);
		this.radioButton1.Margin = new System.Windows.Forms.Padding(1);
		this.radioButton1.Name = "radioButton1";
		this.radioButton1.Size = new System.Drawing.Size(44, 17);
		this.radioButton1.TabIndex = 0;
		this.radioButton1.Text = "Tab";
		this.radioButton1.UseVisualStyleBackColor = true;
		this.radioButton1.CheckedChanged += new System.EventHandler(radioFileType_ValueChanged);
		this.chkLoopTimeFromGV.AutoSize = true;
		this.chkLoopTimeFromGV.Enabled = false;
		this.chkLoopTimeFromGV.Location = new System.Drawing.Point(366, 222);
		this.chkLoopTimeFromGV.Name = "chkLoopTimeFromGV";
		this.chkLoopTimeFromGV.Size = new System.Drawing.Size(67, 17);
		this.chkLoopTimeFromGV.TabIndex = 24;
		this.chkLoopTimeFromGV.Text = "From GV";
		this.toolTip1.SetToolTip(this.chkLoopTimeFromGV, "Get loop duration from a global variable.");
		this.chkLoopTimeFromGV.UseVisualStyleBackColor = true;
		this.chkLoopTimeFromGV.CheckedChanged += new System.EventHandler(chkLoopTimeFromGV_CheckedChanged);
		this.btnSelectTimeGV.Enabled = false;
		this.btnSelectTimeGV.Location = new System.Drawing.Point(339, 218);
		this.btnSelectTimeGV.Name = "btnSelectTimeGV";
		this.btnSelectTimeGV.Size = new System.Drawing.Size(21, 23);
		this.btnSelectTimeGV.TabIndex = 23;
		this.btnSelectTimeGV.Text = "..";
		this.btnSelectTimeGV.UseVisualStyleBackColor = true;
		this.btnSelectTimeGV.Click += new System.EventHandler(btnSelectTimeGV_Click);
		this.chkLoopCountFromGV.AutoSize = true;
		this.chkLoopCountFromGV.Enabled = false;
		this.chkLoopCountFromGV.Location = new System.Drawing.Point(289, 194);
		this.chkLoopCountFromGV.Name = "chkLoopCountFromGV";
		this.chkLoopCountFromGV.Size = new System.Drawing.Size(67, 17);
		this.chkLoopCountFromGV.TabIndex = 22;
		this.chkLoopCountFromGV.Text = "From GV";
		this.toolTip1.SetToolTip(this.chkLoopCountFromGV, "Get loop count from a global variable.");
		this.chkLoopCountFromGV.UseVisualStyleBackColor = true;
		this.chkLoopCountFromGV.CheckedChanged += new System.EventHandler(chkLoopCountFromGV_CheckedChanged);
		this.chkFileNameFromGV.AutoSize = true;
		this.chkFileNameFromGV.Enabled = false;
		this.chkFileNameFromGV.Location = new System.Drawing.Point(288, 121);
		this.chkFileNameFromGV.Margin = new System.Windows.Forms.Padding(1);
		this.chkFileNameFromGV.Name = "chkFileNameFromGV";
		this.chkFileNameFromGV.Size = new System.Drawing.Size(67, 17);
		this.chkFileNameFromGV.TabIndex = 20;
		this.chkFileNameFromGV.Text = "From GV";
		this.toolTip1.SetToolTip(this.chkFileNameFromGV, "Get Filename from a global variable.");
		this.chkFileNameFromGV.UseVisualStyleBackColor = true;
		this.chkFileNameFromGV.CheckedChanged += new System.EventHandler(chkFileNameFromGV_CheckedChanged);
		this.chkIgnoreIntermediateResults.AutoSize = true;
		this.chkIgnoreIntermediateResults.Location = new System.Drawing.Point(17, 239);
		this.chkIgnoreIntermediateResults.Name = "chkIgnoreIntermediateResults";
		this.chkIgnoreIntermediateResults.Size = new System.Drawing.Size(155, 17);
		this.chkIgnoreIntermediateResults.TabIndex = 19;
		this.chkIgnoreIntermediateResults.Text = "Ignore Intermediate Results";
		this.chkIgnoreIntermediateResults.UseVisualStyleBackColor = true;
		this.chkIgnoreIntermediateResults.Visible = false;
		this.chkIgnoreIntermediateResults.CheckedChanged += new System.EventHandler(chkIgnoreIntermediateResults_CheckedChanged);
		this.cmbFileColumnName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cmbFileColumnName.Enabled = false;
		this.cmbFileColumnName.Location = new System.Drawing.Point(128, 141);
		this.cmbFileColumnName.Name = "cmbFileColumnName";
		this.cmbFileColumnName.Size = new System.Drawing.Size(128, 21);
		this.cmbFileColumnName.TabIndex = 13;
		this.cmbFileColumnName.DropDown += new System.EventHandler(cmbFileColumnName_DropDown);
		this.cmbFileColumnName.SelectedIndexChanged += new System.EventHandler(cmbFileColumnName_SelectedIndexChanged);
		this.cmbFileColumnName.TextChanged += new System.EventHandler(cmbFileColumnName_TextChanged);
		this.lblFileColumnName.ForeColor = System.Drawing.Color.RoyalBlue;
		this.lblFileColumnName.Location = new System.Drawing.Point(14, 145);
		this.lblFileColumnName.Name = "lblFileColumnName";
		this.lblFileColumnName.Size = new System.Drawing.Size(80, 16);
		this.lblFileColumnName.TabIndex = 12;
		this.lblFileColumnName.Text = "Column Name";
		this.lblFileName.ForeColor = System.Drawing.Color.RoyalBlue;
		this.lblFileName.Location = new System.Drawing.Point(14, 118);
		this.lblFileName.Name = "lblFileName";
		this.lblFileName.Size = new System.Drawing.Size(80, 16);
		this.lblFileName.TabIndex = 9;
		this.lblFileName.Text = "File Name";
		this.btnLoadFile.Enabled = false;
		this.btnLoadFile.Location = new System.Drawing.Point(262, 117);
		this.btnLoadFile.Margin = new System.Windows.Forms.Padding(1);
		this.btnLoadFile.Name = "btnLoadFile";
		this.btnLoadFile.Size = new System.Drawing.Size(21, 23);
		this.btnLoadFile.TabIndex = 11;
		this.btnLoadFile.Text = "..";
		this.btnLoadFile.UseVisualStyleBackColor = true;
		this.btnLoadFile.Click += new System.EventHandler(btnLoadFile_Click);
		this.txtFilename.Enabled = false;
		this.txtFilename.Location = new System.Drawing.Point(128, 118);
		this.txtFilename.Margin = new System.Windows.Forms.Padding(1);
		this.txtFilename.Name = "txtFilename";
		this.txtFilename.Size = new System.Drawing.Size(128, 20);
		this.txtFilename.TabIndex = 10;
		this.txtFilename.MouseDown += new System.Windows.Forms.MouseEventHandler(txtFilename_MouseDown);
		this.numericUpDownTime.Enabled = false;
		this.numericUpDownTime.Location = new System.Drawing.Point(129, 218);
		this.numericUpDownTime.Maximum = new decimal(new int[4] { 100000, 0, 0, 0 });
		this.numericUpDownTime.Minimum = new decimal(new int[4] { 1, 0, 0, 0 });
		this.numericUpDownTime.Name = "numericUpDownTime";
		this.numericUpDownTime.Size = new System.Drawing.Size(127, 20);
		this.numericUpDownTime.TabIndex = 17;
		this.numericUpDownTime.Value = new decimal(new int[4] { 1, 0, 0, 0 });
		this.numericUpDownTime.ValueChanged += new System.EventHandler(numericUpDownTime_ValueChanged);
		this.radioTime.ForeColor = System.Drawing.Color.RoyalBlue;
		this.radioTime.Location = new System.Drawing.Point(17, 217);
		this.radioTime.Name = "radioTime";
		this.radioTime.Size = new System.Drawing.Size(96, 21);
		this.radioTime.TabIndex = 16;
		this.radioTime.TabStop = true;
		this.radioTime.Text = "By Time";
		this.radioTime.CheckedChanged += new System.EventHandler(radioTime_CheckedChanged);
		this.radioTime.MouseDown += new System.Windows.Forms.MouseEventHandler(radioTime_MouseDown);
		this.cmbLoopCount.Enabled = false;
		this.cmbLoopCount.FormattingEnabled = true;
		this.cmbLoopCount.Items.AddRange(new object[1] { "Loop Forever" });
		this.cmbLoopCount.Location = new System.Drawing.Point(128, 193);
		this.cmbLoopCount.Name = "cmbLoopCount";
		this.cmbLoopCount.Size = new System.Drawing.Size(128, 21);
		this.cmbLoopCount.TabIndex = 15;
		this.cmbLoopCount.SelectedIndexChanged += new System.EventHandler(cmbLoopCount_SelectedIndexChanged);
		this.cmbLoopCount.KeyDown += new System.Windows.Forms.KeyEventHandler(cmbLoopCount_KeyDown);
		this.txtLoopName.Location = new System.Drawing.Point(128, 4);
		this.txtLoopName.Name = "txtLoopName";
		this.txtLoopName.Size = new System.Drawing.Size(208, 20);
		this.txtLoopName.TabIndex = 1;
		this.txtLoopName.KeyDown += new System.Windows.Forms.KeyEventHandler(txtLoopName_KeyDown);
		this.textList.Enabled = false;
		this.textList.HideSelection = false;
		this.textList.Location = new System.Drawing.Point(128, 58);
		this.textList.Multiline = true;
		this.textList.Name = "textList";
		this.textList.ScrollBars = System.Windows.Forms.ScrollBars.Both;
		this.textList.Size = new System.Drawing.Size(128, 49);
		this.textList.TabIndex = 6;
		this.textList.Text = "Comma Delimited Value";
		this.textList.KeyDown += new System.Windows.Forms.KeyEventHandler(textList_KeyDown);
		this.radioCount.ForeColor = System.Drawing.Color.RoyalBlue;
		this.radioCount.Location = new System.Drawing.Point(17, 193);
		this.radioCount.Name = "radioCount";
		this.radioCount.Size = new System.Drawing.Size(96, 21);
		this.radioCount.TabIndex = 14;
		this.radioCount.TabStop = true;
		this.radioCount.Text = "By Count";
		this.radioCount.CheckedChanged += new System.EventHandler(radioCount_CheckedChanged);
		this.radioCount.MouseDown += new System.Windows.Forms.MouseEventHandler(radioCount_MouseDown);
		this.radioList.ForeColor = System.Drawing.Color.RoyalBlue;
		this.radioList.Location = new System.Drawing.Point(17, 59);
		this.radioList.Name = "radioList";
		this.radioList.Size = new System.Drawing.Size(48, 21);
		this.radioList.TabIndex = 5;
		this.radioList.TabStop = true;
		this.radioList.Text = "List";
		this.radioList.CheckedChanged += new System.EventHandler(radioList_CheckedChanged);
		this.radioList.MouseDown += new System.Windows.Forms.MouseEventHandler(radioList_MouseDown);
		this.label3.ForeColor = System.Drawing.Color.RoyalBlue;
		this.label3.Location = new System.Drawing.Point(14, 4);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(80, 16);
		this.label3.TabIndex = 0;
		this.label3.Text = "Loop Name";
		this.textSSS.Enabled = false;
		this.textSSS.Location = new System.Drawing.Point(128, 28);
		this.textSSS.Name = "textSSS";
		this.textSSS.Size = new System.Drawing.Size(128, 20);
		this.textSSS.TabIndex = 3;
		this.textSSS.Text = "Comma Delimited Value";
		this.textSSS.KeyDown += new System.Windows.Forms.KeyEventHandler(textSSS_KeyDown);
		this.btnUpdateList.Enabled = false;
		this.btnUpdateList.Location = new System.Drawing.Point(259, 28);
		this.btnUpdateList.Name = "btnUpdateList";
		this.btnUpdateList.Size = new System.Drawing.Size(73, 23);
		this.btnUpdateList.TabIndex = 4;
		this.btnUpdateList.Text = "Add To List";
		this.btnUpdateList.UseVisualStyleBackColor = true;
		this.btnUpdateList.Click += new System.EventHandler(btnUpdateList_Click);
		this.radioSSS.ForeColor = System.Drawing.Color.RoyalBlue;
		this.radioSSS.Location = new System.Drawing.Point(17, 28);
		this.radioSSS.Name = "radioSSS";
		this.radioSSS.Size = new System.Drawing.Size(112, 21);
		this.radioSSS.TabIndex = 2;
		this.radioSSS.TabStop = true;
		this.radioSSS.Text = "Start, Stop, Step";
		this.radioSSS.CheckedChanged += new System.EventHandler(radioSSS_CheckedChanged);
		this.radioSSS.MouseDown += new System.Windows.Forms.MouseEventHandler(radioSSS_MouseDown);
		this.btnBreakCondition.Location = new System.Drawing.Point(202, 95);
		this.btnBreakCondition.Name = "btnBreakCondition";
		this.btnBreakCondition.Size = new System.Drawing.Size(154, 23);
		this.btnBreakCondition.TabIndex = 9;
		this.btnBreakCondition.Text = "Loop Break Condition";
		this.btnBreakCondition.UseVisualStyleBackColor = true;
		this.btnBreakCondition.Click += new System.EventHandler(btnBreakCondition_Click);
		this.imageListSmall.ImageStream = (System.Windows.Forms.ImageListStreamer)resources.GetObject("imageListSmall.ImageStream");
		this.imageListSmall.TransparentColor = System.Drawing.Color.Transparent;
		this.imageListSmall.Images.SetKeyName(0, "folder-closed.png");
		this.imageListSmall.Images.SetKeyName(1, "folder-open.png");
		this.imageListSmall.Images.SetKeyName(2, "test.png");
		this.imageListSmall.Images.SetKeyName(3, "");
		this.imageListSmall.Images.SetKeyName(4, "");
		this.panelTwoTree.Controls.Add(this.treeParam);
		this.panelTwoTree.Controls.Add(this.splitter1);
		this.panelTwoTree.Controls.Add(this.treeTest);
		this.panelTwoTree.Dock = System.Windows.Forms.DockStyle.Fill;
		this.panelTwoTree.Location = new System.Drawing.Point(2, 2);
		this.panelTwoTree.Name = "panelTwoTree";
		this.panelTwoTree.Size = new System.Drawing.Size(452, 268);
		this.panelTwoTree.TabIndex = 6;
		this.treeParam.Dock = System.Windows.Forms.DockStyle.Fill;
		this.treeParam.HideSelection = false;
		this.treeParam.ImageIndex = 4;
		this.treeParam.ImageList = this.imageListSmall;
		this.treeParam.Location = new System.Drawing.Point(234, 0);
		this.treeParam.Name = "treeParam";
		this.treeParam.SelectedImageIndex = 4;
		this.treeParam.Size = new System.Drawing.Size(218, 268);
		this.treeParam.TabIndex = 1;
		this.treeParam.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(tree_BeforeCollapse);
		this.treeParam.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(tree_BeforeExpand);
		this.treeParam.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeParam_AfterSelect);
		this.treeParam.MouseDown += new System.Windows.Forms.MouseEventHandler(treeParam_MouseDown);
		this.splitter1.BackColor = System.Drawing.SystemColors.ControlLightLight;
		this.splitter1.Location = new System.Drawing.Point(232, 0);
		this.splitter1.Name = "splitter1";
		this.splitter1.Size = new System.Drawing.Size(2, 268);
		this.splitter1.TabIndex = 6;
		this.splitter1.TabStop = false;
		this.treeTest.Dock = System.Windows.Forms.DockStyle.Left;
		this.treeTest.HideSelection = false;
		this.treeTest.ImageIndex = 4;
		this.treeTest.ImageList = this.imageListSmall;
		this.treeTest.Location = new System.Drawing.Point(0, 0);
		this.treeTest.Name = "treeTest";
		this.treeTest.SelectedImageIndex = 4;
		this.treeTest.Size = new System.Drawing.Size(232, 268);
		this.treeTest.TabIndex = 0;
		this.treeTest.BeforeCheck += new System.Windows.Forms.TreeViewCancelEventHandler(treeTest_BeforeCheck);
		this.treeTest.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(treeTest_AfterCheck);
		this.treeTest.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(tree_BeforeCollapse);
		this.treeTest.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(tree_BeforeExpand);
		this.treeTest.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(treeTest_BeforeSelect);
		this.treeTest.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeTest_AfterSelect);
		this.treeTest.KeyDown += new System.Windows.Forms.KeyEventHandler(treeTest_KeyDown);
		this.treeTest.KeyUp += new System.Windows.Forms.KeyEventHandler(treeTest_KeyUp);
		this.treeTest.MouseDown += new System.Windows.Forms.MouseEventHandler(treeTest_MouseDown);
		this.panelButtons.Controls.Add(this.btnTutorial);
		this.panelButtons.Controls.Add(this.btnRemove);
		this.panelButtons.Controls.Add(this.btnCancel);
		this.panelButtons.Controls.Add(this.btnOK);
		this.panelButtons.Dock = System.Windows.Forms.DockStyle.Bottom;
		this.panelButtons.Location = new System.Drawing.Point(0, 580);
		this.panelButtons.Name = "panelButtons";
		this.panelButtons.Size = new System.Drawing.Size(911, 40);
		this.panelButtons.TabIndex = 0;
		this.btnTutorial.Location = new System.Drawing.Point(651, 8);
		this.btnTutorial.Name = "btnTutorial";
		this.btnTutorial.Size = new System.Drawing.Size(128, 23);
		this.btnTutorial.TabIndex = 3;
		this.btnTutorial.Text = "Tutorial";
		this.btnTutorial.Visible = false;
		this.btnTutorial.Click += new System.EventHandler(btnTutorial_Click);
		this.btnRemove.Location = new System.Drawing.Point(498, 8);
		this.btnRemove.Name = "btnRemove";
		this.btnRemove.Size = new System.Drawing.Size(128, 23);
		this.btnRemove.TabIndex = 2;
		this.btnRemove.Text = "&Remove Loop Setup";
		this.btnRemove.UseVisualStyleBackColor = true;
		this.btnRemove.Click += new System.EventHandler(btnRemove_Click);
		this.btnCancel.Location = new System.Drawing.Point(345, 8);
		this.btnCancel.Name = "btnCancel";
		this.btnCancel.Size = new System.Drawing.Size(128, 23);
		this.btnCancel.TabIndex = 1;
		this.btnCancel.Text = "&Cancel";
		this.btnCancel.UseVisualStyleBackColor = true;
		this.btnCancel.Click += new System.EventHandler(btnCancel_Click);
		this.btnOK.Location = new System.Drawing.Point(192, 8);
		this.btnOK.Name = "btnOK";
		this.btnOK.Size = new System.Drawing.Size(128, 23);
		this.btnOK.TabIndex = 0;
		this.btnOK.Text = "&Ok";
		this.btnOK.UseVisualStyleBackColor = true;
		this.btnOK.Click += new System.EventHandler(btnOK_Click);
		this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[15]
		{
			this.moveRightToolStripMenuItem, this.moveLeftToolStripMenuItem, this.toolStripSeparator1, this.addRowToolStripMenuItem, this.deleteRowToolStripMenuItem, this.insertRowToolStripMenuItem, this.deleteColumnToolStripMenuItem, this.changeLoopNameToolStripMenuItem, this.applyToAllTestsToolStripMenuItem, this.cutToolStripMenuItem,
			this.copyToolStripMenuItem, this.pasteToolStripMenuItem, this.pasteLastToolStripMenuItem, this.selectionToolStripMenuItem, this.removeLoopSetupToolStripMenuItem
		});
		this.contextMenuStrip1.Name = "contextMenuStrip1";
		this.contextMenuStrip1.Size = new System.Drawing.Size(181, 318);
		this.contextMenuStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(contextMenuStrip1_ItemClicked);
		this.moveRightToolStripMenuItem.Name = "moveRightToolStripMenuItem";
		this.moveRightToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.moveRightToolStripMenuItem.Text = "Move Right";
		this.moveRightToolStripMenuItem.Click += new System.EventHandler(moveToToolStripMenuItem_Click);
		this.moveLeftToolStripMenuItem.Name = "moveLeftToolStripMenuItem";
		this.moveLeftToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.moveLeftToolStripMenuItem.Text = "Move Left";
		this.toolStripSeparator1.Name = "toolStripSeparator1";
		this.toolStripSeparator1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
		this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
		this.addRowToolStripMenuItem.Name = "addRowToolStripMenuItem";
		this.addRowToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.addRowToolStripMenuItem.Text = "Add Row";
		this.deleteRowToolStripMenuItem.Name = "deleteRowToolStripMenuItem";
		this.deleteRowToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.deleteRowToolStripMenuItem.Text = "Delete Row";
		this.insertRowToolStripMenuItem.Name = "insertRowToolStripMenuItem";
		this.insertRowToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.insertRowToolStripMenuItem.Text = "Insert Row";
		this.deleteColumnToolStripMenuItem.Name = "deleteColumnToolStripMenuItem";
		this.deleteColumnToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.deleteColumnToolStripMenuItem.Text = "Delete Column";
		this.changeLoopNameToolStripMenuItem.Name = "changeLoopNameToolStripMenuItem";
		this.changeLoopNameToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.changeLoopNameToolStripMenuItem.Text = "Change Loop Name";
		this.applyToAllTestsToolStripMenuItem.Name = "applyToAllTestsToolStripMenuItem";
		this.applyToAllTestsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.applyToAllTestsToolStripMenuItem.Text = "Apply For All Tests";
		this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
		this.cutToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.cutToolStripMenuItem.Text = "Cut";
		this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
		this.copyToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.copyToolStripMenuItem.Text = "Copy";
		this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
		this.pasteToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.pasteToolStripMenuItem.Text = "Paste";
		this.pasteLastToolStripMenuItem.Name = "pasteLastToolStripMenuItem";
		this.pasteLastToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.pasteLastToolStripMenuItem.Text = "Paste Last";
		this.selectionToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[2] { this.selectAllToolStripMenuItem, this.deselectAllToolStripMenuItem });
		this.selectionToolStripMenuItem.Name = "selectionToolStripMenuItem";
		this.selectionToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.selectionToolStripMenuItem.Text = "Selection";
		this.selectionToolStripMenuItem.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(contextMenuStrip1_ItemClicked);
		this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem";
		this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
		this.selectAllToolStripMenuItem.Text = "Select All";
		this.deselectAllToolStripMenuItem.Name = "deselectAllToolStripMenuItem";
		this.deselectAllToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
		this.deselectAllToolStripMenuItem.Text = "Deselect All";
		this.removeLoopSetupToolStripMenuItem.Name = "removeLoopSetupToolStripMenuItem";
		this.removeLoopSetupToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
		this.removeLoopSetupToolStripMenuItem.Text = "Remove Loop Setup";
		this.panelChangeButtons.BackColor = System.Drawing.SystemColors.ControlLightLight;
		this.panelChangeButtons.Controls.Add(this.btnLLChange);
		this.panelChangeButtons.Controls.Add(this.btnULChange);
		this.panelChangeButtons.Controls.Add(this.btnInputChange);
		this.panelChangeButtons.Controls.Add(this.label5);
		this.panelChangeButtons.Location = new System.Drawing.Point(495, 1);
		this.panelChangeButtons.Name = "panelChangeButtons";
		this.panelChangeButtons.Size = new System.Drawing.Size(316, 87);
		this.panelChangeButtons.TabIndex = 0;
		this.btnLLChange.Location = new System.Drawing.Point(119, 32);
		this.btnLLChange.Name = "btnLLChange";
		this.btnLLChange.Size = new System.Drawing.Size(75, 23);
		this.btnLLChange.TabIndex = 2;
		this.btnLLChange.Text = "LL";
		this.btnLLChange.UseVisualStyleBackColor = true;
		this.btnLLChange.Click += new System.EventHandler(btnAddCol_Click);
		this.btnULChange.Location = new System.Drawing.Point(211, 32);
		this.btnULChange.Name = "btnULChange";
		this.btnULChange.Size = new System.Drawing.Size(75, 23);
		this.btnULChange.TabIndex = 1;
		this.btnULChange.Text = "UL";
		this.btnULChange.UseVisualStyleBackColor = true;
		this.btnULChange.Click += new System.EventHandler(btnAddCol_Click);
		this.btnInputChange.Location = new System.Drawing.Point(27, 32);
		this.btnInputChange.Name = "btnInputChange";
		this.btnInputChange.Size = new System.Drawing.Size(75, 23);
		this.btnInputChange.TabIndex = 0;
		this.btnInputChange.Text = "INPUT";
		this.btnInputChange.UseVisualStyleBackColor = true;
		this.btnInputChange.Click += new System.EventHandler(btnAddCol_Click);
		this.label5.ForeColor = System.Drawing.Color.RoyalBlue;
		this.label5.Location = new System.Drawing.Point(4, 8);
		this.label5.Name = "label5";
		this.label5.Size = new System.Drawing.Size(144, 16);
		this.label5.TabIndex = 3;
		this.label5.Text = "Use the Value as";
		this.panelChangeColumnName.Controls.Add(this.chkBoxSuppressWarnings);
		this.panelChangeColumnName.Controls.Add(this.btnApplyAllTests);
		this.panelChangeColumnName.Controls.Add(this.ultraButtonEditGV);
		this.panelChangeColumnName.Controls.Add(this.labelAllTests);
		this.panelChangeColumnName.Controls.Add(this.pictureBoxBreak);
		this.panelChangeColumnName.Controls.Add(this.btnBreakCondition);
		this.panelChangeColumnName.Controls.Add(this.txtColumnName);
		this.panelChangeColumnName.Controls.Add(this.lblNewColumnName);
		this.panelChangeColumnName.Controls.Add(this.panelIndex);
		this.panelChangeColumnName.Dock = System.Windows.Forms.DockStyle.Left;
		this.panelChangeColumnName.Location = new System.Drawing.Point(0, 0);
		this.panelChangeColumnName.Name = "panelChangeColumnName";
		this.panelChangeColumnName.Size = new System.Drawing.Size(496, 136);
		this.panelChangeColumnName.TabIndex = 14;
		this.chkBoxSuppressWarnings.AutoSize = true;
		this.chkBoxSuppressWarnings.Location = new System.Drawing.Point(3, 7);
		this.chkBoxSuppressWarnings.Name = "chkBoxSuppressWarnings";
		this.chkBoxSuppressWarnings.Size = new System.Drawing.Size(214, 17);
		this.chkBoxSuppressWarnings.TabIndex = 20;
		this.chkBoxSuppressWarnings.Text = "Suppress warnings when tree is opened";
		this.chkBoxSuppressWarnings.UseVisualStyleBackColor = true;
		this.chkBoxSuppressWarnings.CheckedChanged += new System.EventHandler(chkBoxSuppressWarnings_CheckedChanged);
		this.btnApplyAllTests.Enabled = false;
		this.btnApplyAllTests.Location = new System.Drawing.Point(363, 95);
		this.btnApplyAllTests.Name = "btnApplyAllTests";
		this.btnApplyAllTests.Size = new System.Drawing.Size(128, 23);
		this.btnApplyAllTests.TabIndex = 4;
		this.btnApplyAllTests.Text = "&Apply For All Tests";
		this.toolTip1.SetToolTip(this.btnApplyAllTests, "Apply the loop conditions to all tests under the folder");
		this.btnApplyAllTests.UseVisualStyleBackColor = true;
		this.btnApplyAllTests.Click += new System.EventHandler(btnApplyAllTests_Click);
		this.ultraButtonEditGV.Location = new System.Drawing.Point(254, 3);
		this.ultraButtonEditGV.Name = "ultraButtonEditGV";
		this.ultraButtonEditGV.Size = new System.Drawing.Size(154, 23);
		this.ultraButtonEditGV.TabIndex = 19;
		this.ultraButtonEditGV.Text = "Edit Global Variables";
		this.ultraButtonEditGV.UseVisualStyleBackColor = true;
		this.ultraButtonEditGV.Click += new System.EventHandler(ultraButtonEditGV_Click);
		this.labelAllTests.Location = new System.Drawing.Point(6, 30);
		this.labelAllTests.Name = "labelAllTests";
		this.labelAllTests.Size = new System.Drawing.Size(485, 21);
		this.labelAllTests.TabIndex = 16;
		this.labelAllTests.Text = "ALLTEST";
		this.labelAllTests.Visible = false;
		this.pictureBoxBreak.Image = (System.Drawing.Image)resources.GetObject("pictureBoxBreak.Image");
		this.pictureBoxBreak.Location = new System.Drawing.Point(185, 95);
		this.pictureBoxBreak.Name = "pictureBoxBreak";
		this.pictureBoxBreak.Size = new System.Drawing.Size(18, 21);
		this.pictureBoxBreak.TabIndex = 18;
		this.pictureBoxBreak.TabStop = false;
		this.pictureBoxBreak.Visible = false;
		this.txtColumnName.Location = new System.Drawing.Point(2, 92);
		this.txtColumnName.Name = "txtColumnName";
		this.txtColumnName.Size = new System.Drawing.Size(177, 20);
		this.txtColumnName.TabIndex = 0;
		this.txtColumnName.Visible = false;
		this.txtColumnName.KeyDown += new System.Windows.Forms.KeyEventHandler(txtColumnName_KeyDown);
		this.txtColumnName.Leave += new System.EventHandler(txtColumnName_Leave);
		this.lblNewColumnName.ForeColor = System.Drawing.Color.RoyalBlue;
		this.lblNewColumnName.Location = new System.Drawing.Point(8, 68);
		this.lblNewColumnName.Name = "lblNewColumnName";
		this.lblNewColumnName.Size = new System.Drawing.Size(144, 16);
		this.lblNewColumnName.TabIndex = 4;
		this.lblNewColumnName.Text = "Update Column Name";
		this.lblNewColumnName.Visible = false;
		this.panelIndex.Controls.Add(this.txt2DArrayIndex);
		this.panelIndex.Controls.Add(this.cmParamterIndex);
		this.panelIndex.Controls.Add(this.lblIndex);
		this.panelIndex.Location = new System.Drawing.Point(240, 56);
		this.panelIndex.Name = "panelIndex";
		this.panelIndex.Size = new System.Drawing.Size(208, 32);
		this.panelIndex.TabIndex = 17;
		this.txt2DArrayIndex.Location = new System.Drawing.Point(109, 6);
		this.txt2DArrayIndex.Name = "txt2DArrayIndex";
		this.txt2DArrayIndex.Size = new System.Drawing.Size(59, 20);
		this.txt2DArrayIndex.TabIndex = 17;
		this.txt2DArrayIndex.Text = "0,0";
		this.toolTip1.SetToolTip(this.txt2DArrayIndex, "Index starts from 0.");
		this.txt2DArrayIndex.Visible = false;
		this.cmParamterIndex.Location = new System.Drawing.Point(38, 6);
		this.cmParamterIndex.Name = "cmParamterIndex";
		this.cmParamterIndex.Size = new System.Drawing.Size(65, 21);
		this.cmParamterIndex.TabIndex = 15;
		this.cmParamterIndex.Visible = false;
		this.lblIndex.ForeColor = System.Drawing.Color.RoyalBlue;
		this.lblIndex.Location = new System.Drawing.Point(4, 8);
		this.lblIndex.Name = "lblIndex";
		this.lblIndex.Size = new System.Drawing.Size(38, 16);
		this.lblIndex.TabIndex = 16;
		this.lblIndex.Text = "Index";
		this.lblIndex.Visible = false;
		this.panel3.Controls.Add(this.labelLoopOptions);
		this.panel3.Controls.Add(this.panelChangeButtons);
		this.panel3.Controls.Add(this.panelChangeColumnName);
		this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
		this.panel3.Location = new System.Drawing.Point(0, 0);
		this.panel3.Name = "panel3";
		this.panel3.Size = new System.Drawing.Size(911, 136);
		this.panel3.TabIndex = 15;
		this.labelLoopOptions.AutoSize = true;
		this.labelLoopOptions.Location = new System.Drawing.Point(497, 114);
		this.labelLoopOptions.Name = "labelLoopOptions";
		this.labelLoopOptions.Size = new System.Drawing.Size(309, 13);
		this.labelLoopOptions.TabIndex = 15;
		this.labelLoopOptions.Text = "For more options on loop conditions, right click the column name";
		this.panelSetup.AutoScroll = true;
		this.panelSetup.Controls.Add(this.splitter2);
		this.panelSetup.Controls.Add(this.panelLoopvalue);
		this.panelSetup.Controls.Add(this.panelTree);
		this.panelSetup.Dock = System.Windows.Forms.DockStyle.Top;
		this.panelSetup.Location = new System.Drawing.Point(0, 0);
		this.panelSetup.Name = "panelSetup";
		this.panelSetup.Size = new System.Drawing.Size(911, 272);
		this.panelSetup.TabIndex = 16;
		this.splitter2.BackColor = System.Drawing.SystemColors.ControlLightLight;
		this.splitter2.Location = new System.Drawing.Point(456, 0);
		this.splitter2.Name = "splitter2";
		this.splitter2.Size = new System.Drawing.Size(2, 272);
		this.splitter2.TabIndex = 1;
		this.splitter2.TabStop = false;
		this.panelTree.Controls.Add(this.panelTwoTree);
		this.panelTree.Dock = System.Windows.Forms.DockStyle.Left;
		this.panelTree.Location = new System.Drawing.Point(0, 0);
		this.panelTree.Name = "panelTree";
		this.panelTree.Padding = new System.Windows.Forms.Padding(2);
		this.panelTree.Size = new System.Drawing.Size(456, 272);
		this.panelTree.TabIndex = 0;
		this.LoopSetup_Fill_Panel.AutoScroll = true;
		this.LoopSetup_Fill_Panel.Controls.Add(this.panelGrid);
		this.LoopSetup_Fill_Panel.Controls.Add(this.panelSetup);
		this.LoopSetup_Fill_Panel.Cursor = System.Windows.Forms.Cursors.Default;
		this.LoopSetup_Fill_Panel.Dock = System.Windows.Forms.DockStyle.Fill;
		this.LoopSetup_Fill_Panel.Location = new System.Drawing.Point(0, 0);
		this.LoopSetup_Fill_Panel.Name = "LoopSetup_Fill_Panel";
		this.LoopSetup_Fill_Panel.Size = new System.Drawing.Size(911, 580);
		this.LoopSetup_Fill_Panel.TabIndex = 0;
		this.panelGrid.Controls.Add(this.dataGridLoop);
		this.panelGrid.Controls.Add(this.panel3);
		this.panelGrid.Dock = System.Windows.Forms.DockStyle.Fill;
		this.panelGrid.Location = new System.Drawing.Point(0, 272);
		this.panelGrid.Name = "panelGrid";
		this.panelGrid.Size = new System.Drawing.Size(911, 308);
		this.panelGrid.TabIndex = 17;
		this.dataGridLoop.AllowUserToAddRows = false;
		this.dataGridLoop.AllowUserToDeleteRows = false;
		this.dataGridLoop.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.dataGridLoop.ContextMenuStrip = this.contextMenuStrip1;
		this.dataGridLoop.Dock = System.Windows.Forms.DockStyle.Fill;
		this.dataGridLoop.Location = new System.Drawing.Point(0, 136);
		this.dataGridLoop.Name = "dataGridLoop";
		this.dataGridLoop.Size = new System.Drawing.Size(911, 172);
		this.dataGridLoop.TabIndex = 16;
		this.dataGridLoop.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(dataGridLoop_CellBeginEdit);
		this.dataGridLoop.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(dataGridLoop_CellClick);
		this.dataGridLoop.ColumnAdded += new System.Windows.Forms.DataGridViewColumnEventHandler(dataGridLoop_ColumnAdded);
		this.dataGridLoop.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(dataGridLoop_ColumnHeaderMouseClick);
		this.dataGridLoop.CurrentCellChanged += new System.EventHandler(dataGridLoop_CurrentCellChanged);
		this.dataGridLoop.CurrentCellDirtyStateChanged += new System.EventHandler(dataGridLoop_CurrentCellDirtyStateChanged);
		this.dataGridLoop.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(dataGridLoop_DataError);
		this.dataGridLoop.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(dataGridLoop_RowsAdded);
		this.dataGridLoop.MouseDown += new System.Windows.Forms.MouseEventHandler(dataGridLoop_MouseDown);
		this.dataGridLoop.MouseUp += new System.Windows.Forms.MouseEventHandler(dataGridLoop_MouseUp);
		this.helpProvider.HelpNamespace = "\\\\qtm\\QTMWeb\\Documents\\QSPRUsersManual.pdf";
		this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
		this.AutoScroll = true;
		base.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
		this.BackColor = System.Drawing.SystemColors.ControlLightLight;
		base.ClientSize = new System.Drawing.Size(911, 620);
		base.Controls.Add(this.LoopSetup_Fill_Panel);
		base.Controls.Add(this.panelButtons);
		this.helpProvider.SetHelpKeyword(this, "Loops");
		this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Index);
		this.MinimumSize = new System.Drawing.Size(840, 600);
		base.Name = "LoopSetup";
		this.helpProvider.SetShowHelp(this, true);
		base.ShowIcon = false;
		base.ShowInTaskbar = false;
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
		this.Text = "LoopSetup";
		base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(LoopSetup_FormClosing);
		base.Load += new System.EventHandler(LoopSetup_Load);
		base.Shown += new System.EventHandler(LoopSetup_Shown);
		this.panelLoopvalue.ResumeLayout(false);
		this.panelLoopvalue.PerformLayout();
		this.groupBoxHoursMinutes.ResumeLayout(false);
		this.groupBoxHoursMinutes.PerformLayout();
		this.groupBoxFileType.ResumeLayout(false);
		this.groupBoxFileType.PerformLayout();
		((System.ComponentModel.ISupportInitialize)this.numericUpDownTime).EndInit();
		this.panelTwoTree.ResumeLayout(false);
		this.panelButtons.ResumeLayout(false);
		this.contextMenuStrip1.ResumeLayout(false);
		this.panelChangeButtons.ResumeLayout(false);
		this.panelChangeColumnName.ResumeLayout(false);
		this.panelChangeColumnName.PerformLayout();
		((System.ComponentModel.ISupportInitialize)this.pictureBoxBreak).EndInit();
		this.panelIndex.ResumeLayout(false);
		this.panelIndex.PerformLayout();
		this.panel3.ResumeLayout(false);
		this.panel3.PerformLayout();
		this.panelSetup.ResumeLayout(false);
		this.panelTree.ResumeLayout(false);
		this.LoopSetup_Fill_Panel.ResumeLayout(false);
		this.panelGrid.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.dataGridLoop).EndInit();
		base.ResumeLayout(false);
	}

	private void LoopSetup_Shown(object sender, EventArgs e)
	{
		if (loopScenario.LoopConditions.Count > 0)
		{
			LoopTypes loopType = (loopScenario.LoopConditions[0] as LoopCondition).LoopType;
			if (loopType == LoopTypes.BYCOUNT || loopType == LoopTypes.BYTIME)
			{
				txtLoopName.Text = (loopScenario.LoopConditions[0] as LoopCondition).LoopName;
			}
		}
	}

	private void ScenarioSetup()
	{
		try
		{
			for (int i = 0; i < loopScenario.LoopConditions.Count; i++)
			{
				LoopCondition loopCondition = (LoopCondition)loopScenario.LoopConditions[i];
				AppendColumn(loopCondition, loopCondition.LoopValues);
			}
			CheckGridRows(loopScenario.ConditionCheck);
			AddDescription(loopScenario.Descriptions);
			AddDontRunCondition(loopScenario.DontRunCondition);
			AddRowID();
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR : " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
		}
		Refresh();
	}

	private void AddRowID()
	{
		try
		{
			int num = 0;
			foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
			{
				num++;
				item.Cells[0].Value = num.ToString();
			}
		}
		catch
		{
		}
	}

	private void AppendColumn(LoopCondition loop, ArrayList loopValues)
	{
		string loopName = loop.LoopName;
		Cursor.Current = Cursors.WaitCursor;
		try
		{
			_ = dataGridLoop.Rows.Count;
			if (dataGridLoop.Columns.Count == 0)
			{
				DataGridViewTextBoxColumn dataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
				dataGridViewTextBoxColumn.Name = "Row ID";
				dataGridViewTextBoxColumn.ReadOnly = true;
				dataGridLoop.Columns.Add(dataGridViewTextBoxColumn);
				DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn = new DataGridViewCheckBoxColumn(threeState: false);
				dataGridViewCheckBoxColumn.Name = "Selection";
				dataGridLoop.Columns.Add(dataGridViewCheckBoxColumn);
				DataGridViewTextBoxColumn dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
				dataGridViewTextBoxColumn2.Name = "Don't Run Condition";
				dataGridLoop.Columns.Add(dataGridViewTextBoxColumn2);
				DataGridViewTextBoxColumn dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
				dataGridViewTextBoxColumn3.Name = "Description";
				dataGridLoop.Columns.Add(dataGridViewTextBoxColumn3);
			}
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn4 = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn4.Name = loopName;
			dataGridLoop.Columns.Add(dataGridViewTextBoxColumn4);
			if (IsExceedMaxLoopCount(loopScenario))
			{
				int index = dataGridLoop.Rows.Add();
				DataGridViewRow dataGridViewRow = dataGridLoop.Rows[index];
				dataGridViewRow.Cells[1].Value = true;
				dataGridViewRow.Cells[loopName].Value = loop.OriginalValue;
				dataGridLoop.Rows[0].Cells[4].Selected = true;
				dataGridLoop.Rows[0].Visible = true;
				return;
			}
			if (dataGridLoop != null && dataGridLoop.Rows.Count > 0)
			{
				dataGridLoop.Rows[0].Visible = true;
			}
			if (dataGridLoop.Rows.Count < loopValues.Count)
			{
				int count = dataGridLoop.Rows.Count;
				for (int i = 0; i < loopValues.Count - count; i++)
				{
					int index2 = dataGridLoop.Rows.Add();
					DataGridViewRow dataGridViewRow2 = dataGridLoop.Rows[index2];
					dataGridViewRow2.Cells[1].Value = true;
					dataGridViewRow2.Cells[loopName].Value = "";
				}
			}
			for (int j = 0; j < loopValues.Count; j++)
			{
				try
				{
					if (loopValues[j].ToString().Trim() != "")
					{
						if (loop.LoopType == LoopTypes.BYSEQUENCE)
						{
							dataGridLoop.Rows[j].Cells[loopName].Value = loop.GetDisplayString(LoopFolder.Root, loopValues[j].ToString());
							continue;
						}
						dataGridLoop.Rows[j].Cells[loopName].Value = loopValues[j];
						CreateDropDownCell(dataGridLoop.Rows[j].Cells[loopName], loop.TestIndex, loop.ParamName);
					}
				}
				catch (Exception ex)
				{
					TraceMessage.Write(ToString(), "AppendColumn " + ex.Message, TraceMessageType.Exception);
				}
			}
			try
			{
				dataGridLoop.Update();
			}
			catch (Exception ex2)
			{
				AppMessageDialog.Show("ERROR: " + ex2.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
			}
			clipBoard = null;
			LoopChanged = true;
		}
		catch (Exception ex3)
		{
			AppMessageDialog.Show(ex3.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
		}
		LoopChanged = true;
		Cursor.Current = Cursors.Default;
	}

	private void LoopSetup_Load(object sender, EventArgs e)
	{
		if (LoopFolder == null)
		{
			AppMessageDialog.Show("Loop Folder not selected!", "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Warning);
			Close();
			return;
		}
		if (loopFolder.Properties.LinkNode && loopFolder.Properties.IsLinkActive == true)
		{
			AppMessageDialog.Show("Loop Setup not valid for link nodes.", "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Warning);
			Close();
			return;
		}
		LoadGV();
		testNode = treeTest.Nodes.Add(LoopFolder.Properties.TestName);
		testNode.Tag = LoopFolder;
		LoadTree(LoopFolder, testNode);
		treeTest.ExpandAll();
		if (LoopFolder.FolderProperties.Scenarios == null || LoopFolder.FolderProperties.Scenarios.Count == 0)
		{
			radioSSS.Checked = true;
			loopScenario = new LoopScenarioValues();
		}
		else
		{
			loopScenario = LoopFolder.FolderProperties.Scenarios.Clone();
			ScenarioSetup();
			if (dataGridLoop.Rows != null && dataGridLoop.Rows.Count > 0)
			{
				dataGridLoop.CurrentCell = dataGridLoop.Rows[0].Cells[4];
			}
		}
		if (loopScenario.Condition != null)
		{
			if (loopScenario.Condition.IsValid)
			{
				pictureBoxBreak.Visible = true;
			}
		}
		else
		{
			pictureBoxBreak.Visible = false;
		}
		ResetTestTree(testNode);
		UpdateTreeForSequenceLoops();
		ResetRegistrationBooleans();
		chkBoxSuppressWarnings.Checked = loopScenario.SuppressWarnings;
		if (singleTestSelected)
		{
			radioSequence.Enabled = false;
		}
		modified = false;
		userEdited = false;
	}

	private void RemoveGvNode()
	{
		if (treeTest.Nodes[0].Text == "Global Variables")
		{
			treeTest.Nodes.RemoveAt(0);
		}
	}

	private void UpdateTreeForSequenceLoops()
	{
		if (loopScenario == null || loopScenario.LoopConditions == null || loopScenario.LoopConditions.Count <= 0 || ((LoopCondition)loopScenario.LoopConditions[0]).LoopType != LoopTypes.BYSEQUENCE)
		{
			return;
		}
		treeParam.Enabled = false;
		RemoveGvNode();
		btnApplyAllTests.Visible = false;
		List<string> list = new List<string>();
		foreach (LoopCondition loopCondition in loopScenario.LoopConditions)
		{
			string[] collection = loopCondition.TestIndex.Split(',');
			list.AddRange(collection);
		}
		foreach (TreeNode node in treeTest.Nodes)
		{
			SelectNodesFromList(node, list);
		}
		DisableSelectedNodes();
	}

	private void SelectNodesFromList(TreeNode node, List<string> testIndexList)
	{
		if (testIndexList.Contains((node.Tag as BaseTest).Index))
		{
			node.Checked = true;
		}
		if (!(node.Tag is FolderTest))
		{
			return;
		}
		foreach (TreeNode node2 in node.Nodes)
		{
			SelectNodesFromList(node2, testIndexList);
		}
	}

	private void LoadGV()
	{
		try
		{
			ParameterCollection parameterCollection = new ParameterCollection();
			treeParam.Nodes.Clear();
			foreach (string sortedGVName in QTMGlobalVariable.SortedGVNames)
			{
				treeParam.Nodes.Add(sortedGVName);
				ParameterCls parameterCls = new ParameterCls();
				parameterCls.DataType = DataType.String;
				parameterCls.Name = sortedGVName;
				parameterCls.Type = IOType.Input;
				parameterCollection.Add(parameterCls);
			}
			if (treeTest.Nodes.Count > 1 && string.Compare(treeTest.Nodes[0].Text, "Global Variables") == 0)
			{
				TreeNode treeNode = treeTest.Nodes[0];
				((FolderTest)treeNode.Tag).Properties.Parameters = parameterCollection;
				return;
			}
			FolderTest folderTest = new FolderTest();
			folderTest.Properties.TestName = "Global Variables";
			folderTest.Properties.Parameters = parameterCollection;
			TreeNode treeNode2 = treeTest.Nodes.Insert(0, "Global Variables");
			treeNode2.Tag = folderTest;
		}
		catch (Exception ex)
		{
			TraceMessage.Write(ToString(), "LoadGV failed " + ex.Message, TraceMessageType.Exception);
		}
	}

	private void LoadTree(FolderTest loopFolder, TreeNode parentNode)
	{
		try
		{
			foreach (BaseTest test in loopFolder.TestList)
			{
				TreeNode treeNode = parentNode.Nodes.Add("", test.Properties.TestName);
				treeNode.Tag = test;
				if (test is FolderTest)
				{
					LoadTree((FolderTest)test, treeNode);
				}
			}
		}
		catch (Exception ex)
		{
			TraceMessage.Write(ToString(), "LoadTree " + ex.Message, TraceMessageType.Exception);
		}
	}

	private bool HighlightTest(TreeNode nodeParent, string TestIndex, string ParamName)
	{
		try
		{
			foreach (TreeNode node in nodeParent.Nodes)
			{
				if (((BaseTest)node.Tag).Index == TestIndex)
				{
					treeTest.SelectedNode = node;
					foreach (TreeNode node2 in treeParam.Nodes)
					{
						if (node2.Text == ParamName)
						{
							treeParam.SelectedNode = node2;
							break;
						}
					}
					return true;
				}
				if (node.Nodes.Count > 0 && HighlightTest(node, TestIndex, ParamName))
				{
					return true;
				}
			}
		}
		catch (Exception ex)
		{
			TraceMessage.Write(ToString(), "HighLightTest " + ex.Message, TraceMessageType.Exception);
		}
		return false;
	}

	private bool HighlightGV(TreeNode nodeParent, string gvName)
	{
		try
		{
			treeTest.SelectedNode = nodeParent;
			foreach (TreeNode node in treeParam.Nodes)
			{
				if (node.Text == gvName)
				{
					treeParam.SelectedNode = node;
					break;
				}
			}
			return true;
		}
		catch (Exception ex)
		{
			TraceMessage.Write(ToString(), "HighlightGV " + ex.Message, TraceMessageType.Exception);
		}
		return false;
	}

	private void radioCount_CheckedChanged(object sender, EventArgs e)
	{
		if (radioCount.Checked)
		{
			chkLoopCountFromGV.Enabled = true;
			btnInputChange.Enabled = false;
			btnULChange.Enabled = false;
			btnLLChange.Enabled = false;
			cmbLoopCount.Enabled = true;
			btnUpdateList.Enabled = false;
			numericUpDownTime.Enabled = false;
			groupBoxHoursMinutes.Enabled = false;
			chkIgnoreIntermediateResults.Visible = true;
			if (chkLoopCountFromGV.Checked)
			{
				btnSelectCountGV.Enabled = true;
			}
		}
		else
		{
			btnSelectCountGV.Enabled = false;
			chkLoopCountFromGV.Enabled = false;
			btnInputChange.Enabled = true;
			btnULChange.Enabled = true;
			btnLLChange.Enabled = true;
			cmbLoopCount.Enabled = false;
			chkIgnoreIntermediateResults.Visible = false;
		}
	}

	private void radioTime_CheckedChanged(object sender, EventArgs e)
	{
		if (radioTime.Checked)
		{
			chkLoopTimeFromGV.Enabled = true;
			numericUpDownTime.Enabled = true;
			groupBoxHoursMinutes.Enabled = true;
			btnInputChange.Enabled = false;
			btnULChange.Enabled = false;
			btnLLChange.Enabled = false;
			cmbLoopCount.Enabled = false;
			btnUpdateList.Enabled = false;
			cmbLoopCount.Enabled = false;
			chkIgnoreIntermediateResults.Visible = true;
			if (chkLoopTimeFromGV.Checked)
			{
				btnSelectTimeGV.Enabled = true;
			}
		}
		else
		{
			btnSelectTimeGV.Enabled = false;
			chkLoopTimeFromGV.Enabled = false;
			btnInputChange.Enabled = true;
			btnULChange.Enabled = true;
			btnLLChange.Enabled = true;
			cmbLoopCount.Enabled = false;
			numericUpDownTime.Enabled = false;
			groupBoxHoursMinutes.Enabled = false;
			chkIgnoreIntermediateResults.Visible = false;
		}
	}

	private void radioTime_MouseDown(object sender, MouseEventArgs e)
	{
	}

	private void radioSSS_CheckedChanged(object sender, EventArgs e)
	{
		if (radioSSS.Checked)
		{
			textSSS.Enabled = true;
			btnUpdateList.Enabled = true;
		}
		else
		{
			textSSS.Enabled = false;
			btnUpdateList.Enabled = false;
		}
	}

	private void radioList_CheckedChanged(object sender, EventArgs e)
	{
		if (radioList.Checked)
		{
			textList.Enabled = true;
			chkListFromFile.Enabled = true;
			chkListFromFile_CheckedChanged(this, EventArgs.Empty);
			btnUpdateList.Enabled = false;
		}
		else
		{
			textList.Enabled = false;
			chkListFromFile.Enabled = false;
			chkListFromFile_CheckedChanged(this, EventArgs.Empty);
		}
	}

	private void ResetTestTree(TreeNode ParentNode)
	{
		bool isExpanded = ParentNode.IsExpanded;
		if (ParentNode.Nodes.Count > 0)
		{
			_ = (BaseTest)ParentNode.Tag;
			int selectedImageIndex = (ParentNode.ImageIndex = (isExpanded ? 1 : 0));
			ParentNode.SelectedImageIndex = selectedImageIndex;
		}
		foreach (TreeNode node in ParentNode.Nodes)
		{
			if (node.Nodes.Count > 0)
			{
				BaseTest baseTest = (BaseTest)node.Tag;
				int selectedImageIndex2 = (node.ImageIndex = (isExpanded ? 1 : 0));
				node.SelectedImageIndex = selectedImageIndex2;
				if (baseTest.Properties.LinkNode && baseTest.Properties.IsLinkActive != true)
				{
					node.ForeColor = Color.Red;
				}
				ResetTestTree(node);
				continue;
			}
			BaseTest baseTest2 = (BaseTest)node.Tag;
			if (baseTest2 is FolderTest)
			{
				int selectedImageIndex3 = (node.ImageIndex = (isExpanded ? 1 : 0));
				node.SelectedImageIndex = selectedImageIndex3;
			}
			else
			{
				node.ImageIndex = 2;
				node.SelectedImageIndex = 2;
			}
			if (baseTest2.Properties.LinkNode && baseTest2.Properties.IsLinkActive != true)
			{
				node.ForeColor = Color.Red;
			}
		}
		treeTest.Refresh();
	}

	private bool CheckForSingleLoop()
	{
		if (radioCount.Checked || radioTime.Checked)
		{
			Button button = new Button();
			button.Text = "Input";
			userEdited = false;
			if (!ProcessScenarioInput(button))
			{
				return false;
			}
		}
		return true;
	}

	public bool CompareStartStepStopValues(int column)
	{
		if (IsExceedMaxLoopCount(loopScenario))
		{
			return true;
		}
		ArrayList loopValues = ((LoopCondition)loopScenario.LoopConditions[column - 4]).LoopValues;
		ArrayList columnValues = GetColumnValues(column);
		int count = loopValues.Count;
		if (count > columnValues.Count)
		{
			count = columnValues.Count;
		}
		for (int i = 0; i < count; i++)
		{
			if (!loopValues[i].ToString().Equals(columnValues[i].ToString()))
			{
				return false;
			}
		}
		if (count == loopValues.Count)
		{
			for (int j = loopValues.Count; j < columnValues.Count; j++)
			{
				if (!columnValues[j].ToString().Trim().Equals(""))
				{
					return false;
				}
			}
		}
		else if (loopValues.Count > columnValues.Count)
		{
			return false;
		}
		return true;
	}

	public string GetString(ArrayList list)
	{
		string text = "";
		if (list.Count > 0)
		{
			text = (string)list[0];
		}
		for (int i = 1; i < list.Count; i++)
		{
			text = text + "," + (string)list[i];
		}
		return text;
	}

	private bool ValidateConditions(ref LoopCondition loop, Button button)
	{
		try
		{
			if (!radioCount.Checked && !radioTime.Checked)
			{
				if (loopScenario.Count > 0 && ((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.BYCOUNT)
				{
					AppMessageDialog.Show("Loop BYCOUNT exists, delete this Loop to add other loop conditions.", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
					return false;
				}
				if (loopScenario.Count > 0 && ((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.BYTIME)
				{
					AppMessageDialog.Show("Loop BYTIME exists, delete this Loop to add other loop conditions.", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
					return false;
				}
				if (treeTest.SelectedNode == null || treeParam.SelectedNode == null)
				{
					AppMessageDialog.Show("Select a Test and a parameter", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.UIWarning);
					return false;
				}
			}
			if (txtLoopName.Text.Trim().Length == 0)
			{
				AppMessageDialog.Show("Loop name cannot be empty.", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Error);
				return false;
			}
			if (txtLoopName.Text.Contains("_._"))
			{
				AppMessageDialog.Show("Loop name cannot contain the string: \"_._\"", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
				return false;
			}
			if (txtLoopName.Text.Contains("_ _"))
			{
				AppMessageDialog.Show("Loop name cannot contain the string: \"_ _\"", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
				return false;
			}
			if (txtLoopName.Text.Contains("__"))
			{
				AppMessageDialog.Show("Loop name cannot contain the string: \"__\"", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
				return false;
			}
			if (txtLoopName.Text.Contains("_;_"))
			{
				AppMessageDialog.Show("Loop name cannot contain the string: \"_;_\"", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
				return false;
			}
			loop.LoopName = txtLoopName.Text.Trim();
			if (radioSSS.Checked)
			{
				ParameterCls parameterCls = (ParameterCls)treeParam.SelectedNode.Tag;
				if (!ValidateDataTypeSSS(parameterCls))
				{
					AppMessageDialog.Show(string.Concat(parameterCls.DataType, " data type not valid for Start, Stop, Step type parameter."), "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
					return false;
				}
				if (parameterCls.Type == IOType.Input)
				{
					try
					{
						ValidateSSS(parameterCls, loop);
					}
					catch (Exception ex)
					{
						AppMessageDialog.Show("Error Calcuating Start, Step, Stop values " + ex.Message, "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
						return false;
					}
				}
				else
				{
					bool flag = false;
					try
					{
						if (textSSS.Text.Trim().Length != 0)
						{
							ValidateSSS(parameterCls, loop);
						}
						else
						{
							flag = true;
						}
					}
					catch (Exception ex2)
					{
						if (dataGridLoop.Rows.Count <= 0)
						{
							AppMessageDialog.Show("Error Calculating Start, Stop, Step values " + ex2.Message, "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
							return false;
						}
						DialogResult dialogResult = AppMessageDialog.Show("Error Calculating Start, Stop, Step values.\nDo you want to include default values?", "QSPR - Loop Error", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, DialogResult.Yes, MessageDialogType.UIWarning);
						if (dialogResult != DialogResult.Yes)
						{
							return false;
						}
						flag = true;
					}
					try
					{
						if (flag)
						{
							CreateDefaultValueLoop(loop, parameterCls, button.Text.Trim());
						}
					}
					catch (Exception ex3)
					{
						AppMessageDialog.Show("Error Calcuating Start, Stop, Step values " + ex3.Message, "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
						return false;
					}
				}
			}
			else if (radioList.Checked)
			{
				string loopDetails = "";
				if (chkListFromFile.Checked)
				{
					if (txtFilename.Text.Trim().Length == 0)
					{
						AppMessageDialog.Show("File Name cannot be empty.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
						txtFilename.Focus();
						return false;
					}
					string text = txtFilename.Text.Trim();
					if (chkFileNameFromGV.Checked)
					{
						if (!QTMGlobalVariable.GetGlobalVariable(txtFilename.Text.Trim(), out var gvValue) || string.IsNullOrEmpty(gvValue))
						{
							AppMessageDialog.Show("Global Variable: " + text + " has invalid value.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
							return false;
						}
						text = gvValue;
					}
					text = PathUtils.ConvertToAbsolute(LoopFolder.Root.Scheduler.GlobalStatus.TreeName, text);
					if (!File.Exists(text))
					{
						AppMessageDialog.Show("File " + text + " not found.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
						txtFilename.Focus();
						return false;
					}
					if (cmbFileColumnName.Text.Trim().Length == 0)
					{
						AppMessageDialog.Show("Column name cannot be empty.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
						cmbFileColumnName.Focus();
						return false;
					}
					if (!LoopCondition.GetLoopValuesFromFile(text, LoopFolder.Root.Scheduler.GlobalStatus.TreeName, cmbFileColumnName.Text.Trim(), GetSelectedRBValue(groupBoxFileType), out var strValues, out var errorMessage))
					{
						AppMessageDialog.Show(errorMessage, "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
						return false;
					}
					textList.Text = strValues;
					loopDetails = GetSelectedRBValue(groupBoxFileType) + "@#$%" + txtFilename.Text.Trim() + "@#$%" + cmbFileColumnName.Text.Trim() + "@#$%" + chkFileNameFromGV.Checked;
				}
				loop.LoopDetails = loopDetails;
				ParameterCls parameterCls2 = (ParameterCls)treeParam.SelectedNode.Tag;
				if (parameterCls2.Type == IOType.Input)
				{
					try
					{
						ValidateListValues(parameterCls2, loop);
					}
					catch (Exception ex4)
					{
						AppMessageDialog.Show("Error Calculating List " + ex4.Message, "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
						return false;
					}
				}
				else
				{
					bool flag2 = false;
					if (textList.Text.Trim().Length != 0)
					{
						try
						{
							ValidateListValues(parameterCls2, loop);
						}
						catch (Exception ex5)
						{
							if (dataGridLoop.Rows.Count <= 0)
							{
								AppMessageDialog.Show("Error Calculating List Values" + ex5.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
								return false;
							}
							DialogResult dialogResult2 = AppMessageDialog.Show("Error Calculating List Values.\nDo you want to include default values?", "QSPR - Loop Setup", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, DialogResult.Yes, MessageDialogType.UIWarning);
							if (dialogResult2 != DialogResult.Yes)
							{
								return false;
							}
							flag2 = true;
						}
					}
					else
					{
						flag2 = true;
					}
					try
					{
						if (flag2)
						{
							CreateDefaultValueLoop(loop, parameterCls2, button.Text.Trim());
						}
					}
					catch (Exception ex6)
					{
						AppMessageDialog.Show("Error Calcuating list values " + ex6.Message, "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
						return false;
					}
				}
			}
			else if (radioCount.Checked)
			{
				string loopDetails2 = "";
				loop.LoopType = LoopTypes.BYCOUNT;
				loop.DataType = DataType.Int;
				loop.IgnoreIntermediateResults = chkIgnoreIntermediateResults.Checked;
				if (chkLoopCountFromGV.Checked)
				{
					int result = 0;
					if (cmbLoopCount.Text.Trim().Length != 0)
					{
						string text2 = cmbLoopCount.Text.Trim();
						if (!QTMGlobalVariable.GetGlobalVariable(text2, out var gvValue2) || string.IsNullOrEmpty(gvValue2))
						{
							AppMessageDialog.Show("Global Variable: " + text2 + " has invalid value.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
							return false;
						}
						if (!int.TryParse(gvValue2, out result))
						{
							AppMessageDialog.Show("Global Variable: " + text2 + " does not contain a valid loop count value.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
							return false;
						}
						loop.OriginalValue = result.ToString();
						loopDetails2 = chkLoopCountFromGV.Checked + "@#$%" + cmbLoopCount.Text.Trim();
					}
				}
				else
				{
					if (cmbLoopCount.Text.Trim().Length == 0)
					{
						AppMessageDialog.Show("Count Value cannot be empty.", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
						return false;
					}
					try
					{
						int num = int.MaxValue;
						if (cmbLoopCount.Text.Trim() != "Loop Forever")
						{
							num = int.Parse(cmbLoopCount.Text);
							loop.OriginalValue = num.ToString();
						}
						else
						{
							loop.OriginalValue = "Loop Forever";
						}
					}
					catch (Exception ex7)
					{
						AppMessageDialog.Show("Error Calcuating Count " + ex7.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
						return false;
					}
				}
				loop.LoopDetails = loopDetails2;
			}
			else if (radioTime.Checked)
			{
				string text3 = "";
				loop.LoopType = LoopTypes.BYTIME;
				loop.DataType = DataType.Int;
				loop.IgnoreIntermediateResults = chkIgnoreIntermediateResults.Checked;
				if (chkLoopTimeFromGV.Checked)
				{
					int result2 = 0;
					string text4 = timeTxt.Text.Trim();
					if (!QTMGlobalVariable.GetGlobalVariable(text4, out var gvValue3) || string.IsNullOrEmpty(gvValue3))
					{
						AppMessageDialog.Show("Global Variable: " + text4 + " has invalid value.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
						return false;
					}
					if (!int.TryParse(gvValue3, out result2))
					{
						AppMessageDialog.Show("Global Variable: " + text4 + " does not contain a valid loop count value.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
						return false;
					}
					loop.OriginalValue = result2.ToString();
					text3 = GetSelectedRBValue(groupBoxHoursMinutes) + "@#$%" + chkLoopTimeFromGV.Checked + "@#$%" + timeTxt.Text.Trim();
				}
				else
				{
					try
					{
						loop.OriginalValue = numericUpDownTime.Value.ToString();
						text3 = GetSelectedRBValue(groupBoxHoursMinutes);
					}
					catch (Exception ex8)
					{
						AppMessageDialog.Show("Error In Time: " + ex8.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
						return false;
					}
				}
				loop.LoopDetails = text3;
			}
			if (loop.LoopType != LoopTypes.BYCOUNT && loop.LoopType != LoopTypes.BYTIME)
			{
				loop.TestName = treeTest.SelectedNode.Text;
				loop.ParamName = treeParam.SelectedNode.Text;
				BaseTest baseTest = (BaseTest)treeTest.SelectedNode.Tag;
				loop.TestIndex = baseTest.Index;
				if (txt2DArrayIndex.Visible)
				{
					loop.Array2DIndex = txt2DArrayIndex.Text;
				}
			}
		}
		catch (Exception ex9)
		{
			TraceMessage.Write(ToString(), "ValidateConditions " + ex9.Message, TraceMessageType.Exception);
		}
		return true;
	}

	public static bool IsExceedMaxLoopCount(LoopScenarioValues loopValues)
	{
		try
		{
			if (loopValues != null && loopValues.LoopConditions.Count > 0)
			{
				int num = 0;
				for (int i = 0; i < loopValues.LoopConditions.Count; i++)
				{
					num += ((LoopCondition)loopValues.LoopConditions[i]).LoopValues.Count;
				}
				if (num > 20000)
				{
					return true;
				}
			}
			return false;
		}
		catch (Exception ex)
		{
			TraceMessage.Write("LoopSetup", "IsExceedMaxLoopCount " + ex.Message, TraceMessageType.Exception);
			return false;
		}
	}

	private void ValidateListValues(ParameterCls tParam, LoopCondition loop)
	{
		try
		{
			string text = "";
			textList.Text = textList.Text.Replace("\r\n", ",");
			string[] array = textList.Text.Split(',');
			if (textList.Text.Trim().Length > 0)
			{
				string[] array2 = array;
				foreach (string text2 in array2)
				{
					loop.DataType = tParam.DataType;
					loop.IsNullable = tParam.IsNullable;
					if (!(text2.Trim() == "") && (tParam.DisplayHint == 0 || tParam.DisplayHint == 256))
					{
						switch (loop.DataType)
						{
						case DataType.Int:
							int.Parse(text2.Trim());
							break;
						case DataType.Hex:
							int.Parse(text2.Trim(), NumberStyles.HexNumber);
							break;
						case DataType.Double:
							double.Parse(text2.Trim(), CultureInfo.InvariantCulture);
							break;
						case DataType.Byte:
							byte.Parse(text2.Trim());
							break;
						case DataType.Boolean:
							Convert.ToBoolean(text2.Trim());
							break;
						}
					}
				}
				loop.LoopType = LoopTypes.LIST;
				text = ValidateValues(tParam, textList.Text, loop.LoopType);
			}
			else
			{
				loop.LoopType = LoopTypes.LIST;
				text = ((tParam.NoOfElements != 1) ? "" : tParam.Value);
			}
			if (tParam.NoOfElements > 1)
			{
				if (cmParamterIndex.Text == "All")
				{
					loop.ArrayIndex = -1;
				}
				else
				{
					loop.ArrayIndex = int.Parse(cmParamterIndex.Text);
				}
			}
			else
			{
				loop.ArrayIndex = -2;
			}
			loop.DataType = tParam.DataType;
			loop.IsNullable = tParam.IsNullable;
			loop.OriginalValue = text;
		}
		catch (Exception ex)
		{
			throw new Exception(ex.Message);
		}
	}

	private void Validate2DArryIndex(string loopIndex)
	{
		string[] array = loopIndex.Split(',');
		if (array.GetLength(0) != 2)
		{
			throw new Exception("Array index should be in the format row,col");
		}
		if (int.TryParse(array[0], out var result) && int.TryParse(array[1], out result))
		{
			return;
		}
		throw new Exception("Array index should be in the format row,col");
	}

	private void ValidateSSS(ParameterCls tParam, LoopCondition loop)
	{
		try
		{
			string text = "";
			tParam.Constraints.Split(';');
			if (textSSS.Text.Trim().Length > 0)
			{
				string[] array = textSSS.Text.Trim().Split(',');
				if (array.Length != 3)
				{
					throw new Exception("");
				}
				switch (tParam.DataType)
				{
				case DataType.Int:
					int.Parse(array[0]);
					int.Parse(array[1]);
					int.Parse(array[2]);
					break;
				case DataType.Hex:
					int.Parse(array[0], NumberStyles.HexNumber);
					int.Parse(array[1], NumberStyles.HexNumber);
					int.Parse(array[2], NumberStyles.HexNumber);
					break;
				case DataType.Double:
					double.Parse(array[0], CultureInfo.InvariantCulture);
					double.Parse(array[1], CultureInfo.InvariantCulture);
					double.Parse(array[2], CultureInfo.InvariantCulture);
					break;
				case DataType.Byte:
					byte.Parse(array[0]);
					byte.Parse(array[1]);
					byte.Parse(array[2]);
					break;
				}
				loop.LoopType = LoopTypes.STARTSTOPSTEP;
				text = ValidateValues(tParam, textSSS.Text, loop.LoopType);
			}
			else
			{
				loop.LoopType = LoopTypes.LIST;
				text = ((tParam.NoOfElements != 1) ? "" : tParam.Value);
			}
			if (tParam.NoOfElements > 1)
			{
				if (cmParamterIndex.Text == "All")
				{
					loop.ArrayIndex = -1;
				}
				else
				{
					loop.ArrayIndex = int.Parse(cmParamterIndex.Text);
				}
			}
			else
			{
				loop.ArrayIndex = -2;
			}
			loop.DataType = tParam.DataType;
			loop.IsNullable = tParam.IsNullable;
			loop.OriginalValue = text;
		}
		catch (Exception ex)
		{
			throw new Exception(ex.Message);
		}
	}

	private bool ValidateDataTypeSSS(ParameterCls tParam)
	{
		try
		{
			DataType dataType = tParam.DataType;
			if (dataType == DataType.Boolean)
			{
				return false;
			}
		}
		catch
		{
		}
		return true;
	}

	private string ValidateValues(ParameterCls tParam, string userinput, LoopTypes looptype)
	{
		try
		{
			string text = userinput;
			bool flag = false;
			string[] array = userinput.Split(',');
			try
			{
				double.Parse(array[0], CultureInfo.InvariantCulture);
				flag = true;
			}
			catch
			{
				flag = false;
			}
			string[] array2 = tParam.Constraints.Split(';');
			if (userinput.Length > 0)
			{
				switch (tParam.DisplayHint)
				{
				case 4096:
				{
					text = "";
					for (int num = 0; num < array.Length; num++)
					{
						switch (array[num].ToLower())
						{
						case "1":
							if (!flag)
							{
								string text16 = " - Invalid Value: " + array[num] + ".\n ";
								text16 += "Please enter Yes or No";
								throw new Exception(text16);
							}
							text = ((text.Length <= 0) ? "1" : (text + ",1"));
							break;
						case "yes":
							if (flag)
							{
								string text17 = " - Invalid Value: " + array[num] + ".\n ";
								text17 += "Please enter 0 or 1";
								throw new Exception(text17);
							}
							text = ((text.Length <= 0) ? "1" : (text + ",1"));
							break;
						case "0":
							if (!flag)
							{
								string text15 = " - Invalid Value: " + array[num] + ".\n ";
								text15 += "Please enter Yes or No";
								throw new Exception(text15);
							}
							text = ((text.Length <= 0) ? "0" : (text + ",0"));
							break;
						case "no":
							if (flag)
							{
								string text14 = " - Invalid Value: " + array[num] + ".\n ";
								text14 += "Please enter 0 or 1";
								throw new Exception(text14);
							}
							text = ((text.Length <= 0) ? "0" : (text + ",0"));
							break;
						default:
						{
							string text13 = " - Invalid Value: " + array[num] + ".\n ";
							text13 += "The valid values are: On,Off OR 0,1";
							throw new Exception(text13);
						}
						}
					}
					break;
				}
				case 2:
				case 12288:
				{
					text = "";
					for (int n = 0; n < array.Length; n++)
					{
						switch (array[n].ToLower())
						{
						case "1":
							if (!flag)
							{
								string text11 = " - Invalid Value: " + array[n] + ".\n ";
								text11 += "Please enter True or False";
								throw new Exception(text11);
							}
							text = ((text.Length <= 0) ? "1" : (text + ",1"));
							break;
						case "true":
							if (flag)
							{
								string text12 = " - Invalid Value: " + array[n] + ".\n ";
								text12 += "Please enter 0 or 1";
								throw new Exception(text12);
							}
							text = ((text.Length <= 0) ? "1" : (text + ",1"));
							break;
						case "0":
							if (!flag)
							{
								string text10 = " - Invalid Value: " + array[n] + ".\n ";
								text10 += "Please enter True or False";
								throw new Exception(text10);
							}
							text = ((text.Length <= 0) ? "0" : (text + ",0"));
							break;
						case "false":
							if (flag)
							{
								string text9 = " - Invalid Value: " + array[n] + ".\n ";
								text9 += "Please enter 0 or 1";
								throw new Exception(text9);
							}
							text = ((text.Length <= 0) ? "0" : (text + ",0"));
							break;
						default:
						{
							string text8 = " - Invalid Value: " + array[n] + ".\n ";
							text8 += "The valid values are: True,False OR 1,0";
							throw new Exception(text8);
						}
						}
					}
					break;
				}
				case 8192:
				{
					text = "";
					for (int num13 = 0; num13 < array.Length; num13++)
					{
						switch (array[num13].ToLower())
						{
						case "1":
							if (!flag)
							{
								string text22 = " - Invalid Value: " + array[num13] + ".\n ";
								text22 += "Please enter On or Off";
								throw new Exception(text22);
							}
							text = ((text.Length <= 0) ? "1" : (text + ",1"));
							break;
						case "on":
							if (flag)
							{
								string text23 = " - Invalid Value: " + array[num13] + ".\n ";
								text23 += "Please enter 0 or 1";
								throw new Exception(text23);
							}
							text = ((text.Length <= 0) ? "1" : (text + ",1"));
							break;
						case "0":
							if (!flag)
							{
								string text21 = " - Invalid Value: " + array[num13] + ".\n ";
								text21 += "Please enter Yes or No";
								throw new Exception(text21);
							}
							text = ((text.Length <= 0) ? "0" : (text + ",0"));
							break;
						case "off":
							if (flag)
							{
								string text20 = " - Invalid Value: " + array[num13] + ".\n ";
								text20 += "Please enter 0 or 1";
								throw new Exception(text20);
							}
							text = ((text.Length <= 0) ? "0" : (text + ",0"));
							break;
						default:
						{
							string text19 = " - Invalid Value: " + array[num13] + ".\n ";
							text19 += "The valid values are: On,Off OR 0,1";
							throw new Exception(text19);
						}
						}
					}
					break;
				}
				case 256:
				{
					ArrayList arrayList = new ArrayList();
					if (looptype == LoopTypes.STARTSTOPSTEP)
					{
						try
						{
							int num2 = int.Parse(array[0]);
							int num3 = int.Parse(array[1]);
							int num4 = int.Parse(array[2]);
							for (int num5 = num2; num5 <= num3; num5 += num4)
							{
								arrayList.Add(num5);
							}
						}
						catch
						{
							double num6 = double.Parse(array[0], CultureInfo.InvariantCulture);
							double num7 = double.Parse(array[1], CultureInfo.InvariantCulture);
							double num8 = double.Parse(array[2], CultureInfo.InvariantCulture);
							for (double num9 = num6; num9 <= num7; num9 += num8)
							{
								arrayList.Add(num9);
							}
						}
					}
					else
					{
						for (int num10 = 0; num10 < array.Length; num10++)
						{
							arrayList.Add(array[num10]);
						}
					}
					for (int num11 = 0; num11 < arrayList.Count; num11++)
					{
						bool flag3 = false;
						for (int num12 = 0; num12 < array2.Length; num12++)
						{
							if (!flag)
							{
								if (arrayList[num11].ToString().Trim() == array2[num12].Trim())
								{
									flag3 = true;
									num12 = array2.Length;
								}
								else
								{
									flag3 = false;
								}
							}
							else if (Convert.ToDouble(arrayList[num11]) == Convert.ToDouble(array2[num12]))
							{
								flag3 = true;
								num12 = array2.Length;
							}
							else
							{
								flag3 = false;
							}
						}
						if (!flag3)
						{
							string text18 = " - Invalid Value: " + array[num11] + ".\n ";
							text18 = text18 + "The valid values are: " + tParam.Constraints;
							throw new Exception(text18);
						}
						text = userinput;
					}
					break;
				}
				case 8:
				{
					ParameterCollection.CreateNameValueList(tParam.Constraints, out var names, out var values);
					string text2 = "";
					string text3 = "";
					for (int i = 0; i < names.Count; i++)
					{
						if (i == 0)
						{
							text2 = names[i].ToString();
							text3 = values[i].ToString();
						}
						else
						{
							text2 = text2 + "," + names[i].ToString();
							text3 = text3 + "," + values[i].ToString();
						}
					}
					bool flag2 = false;
					text = "";
					if (!flag)
					{
						for (int j = 0; j < array.Length; j++)
						{
							try
							{
								int.Parse(array[j]);
								string text4 = " - Invalid Value: " + array[j] + ".\n ";
								text4 = text4 + "The valid values are: " + text2;
								throw new Exception(text4);
							}
							catch
							{
							}
							for (int k = 0; k < names.Count; k++)
							{
								if (array[j].Trim().ToLower() == names[k].ToString().Trim().ToLower())
								{
									flag2 = true;
									text = ((text.Length <= 0) ? k.ToString() : (text + "," + values[k].ToString()));
									break;
								}
								flag2 = false;
							}
							if (!flag2)
							{
								string text5 = " - Invalid Value: " + array[j] + ".\n ";
								text5 = text5 + "The valid values are: " + text2;
								throw new Exception(text5);
							}
						}
						break;
					}
					for (int l = 0; l < array.Length; l++)
					{
						try
						{
							if (array[l].Trim() != "")
							{
								int.Parse(array[l]);
							}
						}
						catch
						{
							string text6 = " - Invalid Value: " + array[l] + ".\n ";
							text6 = text6 + "The valid values are: " + text3;
							throw new Exception(text6);
						}
						for (int m = 0; m < values.Count; m++)
						{
							if (array[l].Trim() == "")
							{
								flag2 = true;
								text = ((text.Length <= 0) ? array[l] : (text + "," + array[l]));
								break;
							}
							if (int.Parse(array[l]) == (int)values[m])
							{
								flag2 = true;
								text = ((text.Length <= 0) ? array[l] : (text + "," + array[l]));
								break;
							}
							flag2 = false;
						}
						if (!flag2)
						{
							string text7 = " - Invalid Value: " + array[l] + ".\n ";
							text7 = text7 + "The valid values are: " + text3;
							throw new Exception(text7);
						}
					}
					break;
				}
				}
			}
			else
			{
				text = tParam.Constraints[0].ToString();
			}
			return text;
		}
		catch (Exception ex)
		{
			throw new Exception(ex.Message);
		}
	}

	private void CreateDefaultValueLoop(LoopCondition loop, ParameterCls tParam, string buttonPressed)
	{
		try
		{
			string text = "";
			string text2 = "";
			switch (buttonPressed)
			{
			default:
				return;
			case "UL":
				text2 = tParam.UpperLimit;
				break;
			case "LL":
				text2 = tParam.LowerLimit;
				break;
			}
			if (tParam.IsParamDataTable())
			{
				loop.Array2DIndex = txt2DArrayIndex.Text;
			}
			else if (tParam.NoOfElements > 1)
			{
				if (cmParamterIndex.Text == "All")
				{
					loop.ArrayIndex = -1;
				}
				else
				{
					loop.ArrayIndex = int.Parse(cmParamterIndex.Text);
				}
				string[] array = text2.Split(',');
				int num = 0;
				if (loop.ArrayIndex != -1)
				{
					num = loop.ArrayIndex;
				}
				for (int i = 0; i < dataGridLoop.Rows.Count - 1; i++)
				{
					text = text + array[num] + ",";
				}
				text += array[num];
			}
			else
			{
				loop.ArrayIndex = -2;
				for (int j = 0; j < dataGridLoop.Rows.Count - 1; j++)
				{
					text = text + text2 + ",";
				}
				text += text2;
			}
			loop.LoopType = LoopTypes.LIST;
			loop.OriginalValue = text;
			loop.DataType = tParam.DataType;
			loop.IsNullable = tParam.IsNullable;
		}
		catch (Exception ex)
		{
			throw new Exception(ex.Message);
		}
	}

	private void btnCancel_Click(object sender, EventArgs e)
	{
		if (IsOKToCloseDialog())
		{
			base.DialogResult = DialogResult.Cancel;
			cancelPressed = true;
			Close();
		}
		else
		{
			cancelPressed = false;
		}
	}

	private void btnUpdateList_Click(object sender, EventArgs e)
	{
		LoopScenarioValues loopScenarioValues = new LoopScenarioValues();
		LoopCondition loopCondition = new LoopCondition();
		loopCondition.LoopType = LoopTypes.STARTSTOPSTEP;
		loopCondition.OriginalValue = textSSS.Text;
		loopScenarioValues.LoopConditions.Add(loopCondition);
		if (IsExceedMaxLoopCount(loopScenarioValues))
		{
			AppMessageDialog.Show("Loop conditions exceed max loop count, please add loop conditions manually.", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
			return;
		}
		string strResult = "";
		if (LoopCondition.CalculateListOfValues(textSSS.Text, out var _, out strResult, out var _))
		{
			if (textList.Text.Trim().StartsWith("Comma"))
			{
				textList.Text = strResult;
			}
			else if (textList.Text.Trim().Length > 0)
			{
				TextBox textBox = textList;
				textBox.Text = textBox.Text + "," + strResult;
			}
			else
			{
				textList.Text = strResult;
			}
		}
		radioList.Checked = true;
	}

	private void CheckGridRows(ArrayList list)
	{
		foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
		{
			item.Cells[1].Value = true;
		}
		if (list.Count == dataGridLoop.Rows.Count)
		{
			for (int i = 0; i < list.Count; i++)
			{
				bool flag = true;
				try
				{
					flag = bool.Parse(list[i].ToString());
				}
				catch (FormatException)
				{
				}
				catch (ArgumentNullException)
				{
				}
				if (!flag)
				{
					dataGridLoop.Rows[i].Cells["Selection"].Value = flag;
				}
			}
		}
		try
		{
			dataGridLoop.Update();
		}
		catch (Exception ex3)
		{
			AppMessageDialog.Show(this, ex3.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void AddDescription(ArrayList list)
	{
		try
		{
			int num = 0;
			foreach (string item in list)
			{
				dataGridLoop.Rows[num].Cells[3].Value = item;
				num++;
			}
		}
		catch
		{
		}
	}

	private void AddDontRunCondition(ArrayList list)
	{
		try
		{
			int num = 0;
			foreach (string item in list)
			{
				dataGridLoop.Rows[num].Cells[2].Value = item;
				num++;
			}
		}
		catch
		{
		}
	}

	private bool ProcessScenarioInput(object sender)
	{
		try
		{
			LoopCondition loop = new LoopCondition();
			bool flag = true;
			int iIndex = -1;
			Button button = (Button)sender;
			if (currentCol != null && currLoopCond != null && currLoopCond.TestName == "ALLTests" && (radioSSS.Checked || radioList.Checked))
			{
				if (radioSSS.Checked)
				{
					currLoopCond.LoopType = LoopTypes.STARTSTOPSTEP;
					currLoopCond.OriginalValue = textSSS.Text.Trim();
				}
				else
				{
					currLoopCond.LoopType = LoopTypes.LIST;
					currLoopCond.OriginalValue = textList.Text.Trim();
				}
				loop = currLoopCond;
				flag = false;
				iIndex = 1;
			}
			else
			{
				if (!ValidateConditions(ref loop, button))
				{
					return false;
				}
				if (button.Text.IndexOf("Input") >= 0)
				{
					loop.LoopOnType = LoopOnTypes.INPUTPARAM;
					if (treeParam.SelectedNode != null)
					{
						ParameterCls parameterCls = (ParameterCls)treeParam.SelectedNode.Tag;
						if (parameterCls.IsParamDataTable())
						{
							try
							{
								Validate2DArryIndex(txt2DArrayIndex.Text);
								loop.Array2DIndex = txt2DArrayIndex.Text;
							}
							catch (Exception ex)
							{
								AppMessageDialog.Show(this, ex.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
								return false;
							}
						}
					}
				}
				else if (button.Text.IndexOf("UL") >= 0)
				{
					loop.LoopName += "UL";
					loop.LoopOnType = LoopOnTypes.UL;
				}
				else if (button.Text.IndexOf("LL") >= 0)
				{
					loop.LoopName += "LL";
					loop.LoopOnType = LoopOnTypes.LL;
				}
				if (loop.LoopType != LoopTypes.BYCOUNT && loop.LoopType != LoopTypes.BYTIME && !loopScenario.ValidateLoopParameter(loop))
				{
					return false;
				}
			}
			LoopScenarioValues loopScenarioValues = new LoopScenarioValues();
			loopScenarioValues.LoopConditions.Add(loop);
			if ((loopScenario != null && IsExceedMaxLoopCount(loopScenario) && txtLoopName.Text.Trim() != ((LoopCondition)loopScenario.LoopConditions[0]).LoopName) || (loopScenario.LoopConditions.Count > 0 && IsExceedMaxLoopCount(loopScenarioValues)))
			{
				AppMessageDialog.Show("Loop already exceed max loop conditions, please edit loop conditions to have multiple loops.", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
				return false;
			}
			if (flag && loopScenario.AddLoopCondition(loop, ref iIndex))
			{
				AppendColumn(loop, loop.LoopValues);
				try
				{
					dataGridLoop.Update();
				}
				catch (Exception ex2)
				{
					AppMessageDialog.Show(this, ex2.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
				}
				dataGridLoop.Rows[0].Cells[dataGridLoop.Columns.Count - 1].Selected = true;
			}
			else
			{
				if (iIndex == -1)
				{
					AppMessageDialog.Show("Loop name Already exists", "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Warning);
					return false;
				}
				int index = dataGridLoop.Columns[loop.LoopName].Index;
				loopScenario.LoopConditions[index - 4] = loop;
				UpdateLoopColumn(loop, loop.LoopValues);
				dataGridLoop.Update();
				if (currentCol != null)
				{
					currentCol.HeaderCell.Style.BackColor = dataGridLoop.ColumnHeadersDefaultCellStyle.SelectionBackColor;
					currentCol.HeaderCell.Style.ForeColor = dataGridLoop.ColumnHeadersDefaultCellStyle.SelectionForeColor;
				}
				currentCol = dataGridLoop.Columns[index];
				ColumnChanged(loop.LoopName, index);
			}
			AddRowID();
			LoopChanged = true;
			warningShownForListFromFile = false;
			return true;
		}
		catch (Exception ex3)
		{
			TraceMessage.Write(ToString(), "ProcessScenarioInput " + ex3.Message, TraceMessageType.Exception);
			return false;
		}
	}

	private void ColumnChanged(string colName, int index)
	{
		if (userEdited)
		{
			DialogResult dialogResult = AppMessageDialog.Show("Do you want to lose the currently edited loop condition", "QSPR - Message Center", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, DialogResult.OK, MessageDialogType.UIWarning);
			if (dialogResult == DialogResult.Cancel)
			{
				userEdited = false;
				return;
			}
			userEdited = false;
		}
		if (index < 4)
		{
			return;
		}
		try
		{
			int index2 = index - 4;
			LoopCondition loopCondition = (currLoopCond = (LoopCondition)loopScenario.LoopConditions[index2]);
			cmbLoopCount.Text = "Integer Value";
			textList.Text = "Comma Delimited Value";
			textSSS.Text = "Comma Delimited Value";
			txtFilename.Text = "";
			cmbFileColumnName.Items.Clear();
			chkListFromFile.Checked = false;
			chkFileNameFromGV.Checked = false;
			ResetButtonColors();
			switch (loopCondition.LoopOnType)
			{
			case LoopOnTypes.LL:
				btnLLChange.Font = new Font(btnLLChange.Font, FontStyle.Bold);
				btnLLChange.ForeColor = Color.Crimson;
				break;
			case LoopOnTypes.UL:
				btnULChange.ForeColor = Color.Crimson;
				btnULChange.Font = new Font(btnULChange.Font, FontStyle.Bold);
				break;
			}
			if (loopCondition.TestIndex != null && loopCondition.TestName != "ALLTests")
			{
				if (string.Compare(loopCondition.TestName, "Global Variables") == 0)
				{
					HighlightGV(treeTest.Nodes[0], loopCondition.ParamName);
					applyToAllTestsToolStripMenuItem.Enabled = false;
					btnApplyAllTests.Enabled = false;
				}
				else
				{
					if (loopCondition.LoopType == LoopTypes.BYSEQUENCE)
					{
						HighlightTest(treeTest.Nodes[0], loopCondition.TestIndex, loopCondition.ParamName);
					}
					else
					{
						HighlightTest(treeTest.Nodes[1], loopCondition.TestIndex, loopCondition.ParamName);
					}
					applyToAllTestsToolStripMenuItem.Enabled = true;
					btnApplyAllTests.Enabled = true;
				}
				labelAllTests.Visible = false;
			}
			else
			{
				treeParam.SelectedNode = null;
				treeTest.SelectedNode = null;
				if (!string.IsNullOrEmpty(loopCondition.ParamName))
				{
					labelAllTests.Text = $"Param values for All tests with parameter {loopCondition.ParamName} will be changed.";
					labelAllTests.Visible = true;
				}
			}
			AssignLoopNameValues(loopCondition);
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR : " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void AssignLoopNameValues(LoopCondition loop)
	{
		try
		{
			if (loop.LoopName.EndsWith("UL") || loop.LoopName.EndsWith("LL"))
			{
				txtLoopName.Text = loop.LoopName.Substring(0, loop.LoopName.Length - 2);
			}
			else
			{
				txtLoopName.Text = loop.LoopName;
			}
			switch (loop.LoopType)
			{
			case LoopTypes.STARTSTOPSTEP:
				textSSS.Text = loop.OriginalValue;
				radioSSS.Checked = true;
				break;
			case LoopTypes.BYCOUNT:
				cmbLoopCount.Text = loop.OriginalValue;
				radioCount.Checked = true;
				chkIgnoreIntermediateResults.Checked = loop.IgnoreIntermediateResults;
				try
				{
					string[] array = loop.LoopDetails.Split(new string[1] { "@#$%" }, StringSplitOptions.None);
					if (array.Length == 2)
					{
						chkLoopCountFromGV.Checked = bool.Parse(array[0]);
						chkLoopCountFromGV.Enabled = true;
						btnSelectCountGV.Enabled = true;
						cmbLoopCount.Text = array[1];
						cmbLoopCount.Enabled = false;
					}
				}
				catch
				{
				}
				break;
			case LoopTypes.LIST:
				textList.Text = loop.OriginalValue;
				if (loop.LoopDetails != "")
				{
					chkListFromFile.Checked = true;
					string[] array = loop.LoopDetails.Split(new string[1] { "@#$%" }, StringSplitOptions.None);
					try
					{
						SetSelectedRBValue(groupBoxFileType, array[0]);
						txtFilename.Text = array[1];
						chkFileNameFromGV.Checked = array[3] == "True";
						cmbFileColumnName_DropDown(this, EventArgs.Empty);
						if (!cmbFileColumnName.Items.Contains(array[2]))
						{
							cmbFileColumnName.Items.Clear();
							cmbFileColumnName.Items.Add(array[2]);
							cmbFileColumnName.Text = array[2];
							AppMessageDialog.Show("Column: " + array[2] + " not found in the file: " + array[1], "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
						}
						else
						{
							cmbFileColumnName.Text = array[2];
						}
					}
					catch
					{
					}
				}
				else
				{
					chkListFromFile.Checked = false;
					txtFilename.Text = "";
					cmbFileColumnName.Items.Clear();
				}
				chkListFromFile_CheckedChanged(this, EventArgs.Empty);
				radioList.Checked = true;
				break;
			case LoopTypes.BYTIME:
				radioTime.Checked = true;
				numericUpDownTime.Value = Convert.ToDecimal(loop.OriginalValue);
				chkIgnoreIntermediateResults.Checked = loop.IgnoreIntermediateResults;
				try
				{
					string[] array = loop.LoopDetails.Split(new string[1] { "@#$%" }, StringSplitOptions.None);
					if (array.Length == 1)
					{
						SetSelectedRBValue(groupBoxHoursMinutes, loop.LoopDetails);
						chkLoopTimeFromGV.Checked = false;
						bool flag = userEdited;
						chkLoopTimeFromGV_CheckedChanged(null, null);
						userEdited = flag;
						chkLoopTimeFromGV.Enabled = true;
						btnSelectTimeGV.Enabled = false;
					}
					else
					{
						SetSelectedRBValue(groupBoxHoursMinutes, array[0]);
						chkLoopTimeFromGV.Checked = bool.Parse(array[1]);
						bool flag2 = userEdited;
						chkLoopTimeFromGV_CheckedChanged(null, null);
						userEdited = flag2;
						chkLoopTimeFromGV.Enabled = true;
						btnSelectTimeGV.Enabled = true;
						timeTxt.Text = array[2];
						timeTxt.Enabled = false;
					}
				}
				catch
				{
				}
				break;
			case LoopTypes.BYSEQUENCE:
			{
				radioSequence.Checked = true;
				string[] testIndexList = loop.TestIndex.Split(',');
				foreach (TreeNode node in treeTest.Nodes)
				{
					UpdateFontForCurrentSequence(node, testIndexList);
				}
				break;
			}
			}
			if (loop.ArrayIndex >= -1)
			{
				if (loop.ArrayIndex == -1)
				{
					cmParamterIndex.Text = "All";
				}
				else
				{
					cmParamterIndex.Text = loop.ArrayIndex.ToString();
				}
			}
			if (loop.Array2DIndex != "")
			{
				txt2DArrayIndex.Text = loop.Array2DIndex;
			}
			userEdited = false;
		}
		catch
		{
		}
	}

	private void UpdateFontForCurrentSequence(TreeNode node, string[] testIndexList = null)
	{
		if (testIndexList != null && testIndexList.Contains(((BaseTest)node.Tag).Index))
		{
			node.NodeFont = new Font(treeTest.Font, FontStyle.Bold);
			node.Text = node.Text;
		}
		else
		{
			node.NodeFont = new Font(treeTest.Font, FontStyle.Regular);
			node.Text = node.Text;
		}
		if (!(node.Tag is FolderTest))
		{
			return;
		}
		foreach (TreeNode node2 in node.Nodes)
		{
			UpdateFontForCurrentSequence(node2, testIndexList);
		}
	}

	public void ResetButtonColors()
	{
		btnLLChange.ForeColor = SystemColors.WindowText;
		btnULChange.ForeColor = SystemColors.WindowText;
		btnULChange.Font = new Font(btnULChange.Font, FontStyle.Regular);
		btnLLChange.Font = new Font(btnLLChange.Font, FontStyle.Regular);
	}

	public void ResetTextBoxes()
	{
		if (!radioSequence.Checked)
		{
			txtLoopName.Text = "";
		}
		cmbLoopCount.Text = "Integer Value";
		textList.Text = "Comma Delimited Value";
		textSSS.Text = "Comma Delimited Value";
	}

	private void btnRemove_Click(object sender, EventArgs e)
	{
		DialogResult dialogResult = AppMessageDialog.Show("Delete All Loops?", "QSPR - Message Center", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, DialogResult.OK, MessageDialogType.Warning);
		if (dialogResult == DialogResult.OK)
		{
			Reset();
		}
	}

	private void Reset()
	{
		loopScenario.Clear();
		ResetTextBoxes();
		txtLoopName.Text = "";
		currentCol = null;
		radioSSS.Checked = true;
		ResetDisabledNodes();
		UpdateFontForCurrentSequence(treeTest.Nodes[1]);
		dataGridLoop.Columns.Clear();
		dataGridLoop.Rows.Clear();
	}

	private void ResetColumnHeader()
	{
		if (currentCol != null)
		{
			currentCol.HeaderCell.Style.BackColor = Color.FromArgb(233, 242, 199);
			currentCol.HeaderCell.Style.ForeColor = Color.Black;
			currentCol = null;
		}
	}

	private void btnTutorial_Click(object sender, EventArgs e)
	{
		try
		{
			btnTutorial.Enabled = false;
			Process process = new Process();
			process.StartInfo.FileName = "\\\\host-cts\\QTM\\Help\\Tutorial\\Looping.exe";
			process.EnableRaisingEvents = true;
			process.Exited += p_Exited;
			process.Start();
		}
		catch (Exception ex)
		{
			TraceMessage.Write(ToString(), "btnTutorial_Click " + ex.Message, TraceMessageType.Exception);
		}
	}

	private void p_Exited(object sender, EventArgs e)
	{
		try
		{
			if (btnTutorial.InvokeRequired)
			{
				ExitTutorialDelegate method = p_Exited;
				Invoke(method, sender, e);
			}
			else
			{
				btnTutorial.Enabled = true;
			}
		}
		catch
		{
		}
	}

	private List<TreeNode> GetSelectedNodes(TreeNodeCollection nodes = null)
	{
		if (nodes == null)
		{
			nodes = treeTest.Nodes;
		}
		List<TreeNode> list = new List<TreeNode>();
		foreach (TreeNode node in nodes)
		{
			if (node.Checked && !_disabledNodes.Contains(node))
			{
				list.Add(node);
			}
			if (node.Nodes.Count > 0)
			{
				list.AddRange(GetSelectedNodes(node.Nodes));
			}
		}
		return list;
	}

	private void treeTest_AfterSelect(object sender, TreeViewEventArgs e)
	{
		try
		{
			TreeNode selectedNode = treeTest.SelectedNode;
			UpdateParamListWithSelectedTest(selectedNode);
			txtLoopName.Text = "";
		}
		catch
		{
		}
	}

	private void treeTest_AfterCheck(object sender, TreeViewEventArgs e)
	{
		try
		{
			if (GetSelectedNodes().Count > 1)
			{
				btnGenPermutations.Enabled = true;
			}
			else
			{
				btnGenPermutations.Enabled = false;
			}
		}
		catch
		{
		}
	}

	private void UpdateParamListWithSelectedTest(TreeNode node)
	{
		ultraButtonEditGV.Visible = false;
		if (string.Compare(node.Text, "Global Variables") == 0)
		{
			btnApplyAllTests.Enabled = false;
			ultraButtonEditGV.Visible = true;
			LoadGV();
			treeParam.Refresh();
		}
		treeParam.SelectedNode = null;
		treeParam.Nodes.Clear();
		BaseTest baseTest = (BaseTest)node.Tag;
		ParameterCollection parameters = baseTest.Properties.Parameters;
		if (parameters == null)
		{
			return;
		}
		foreach (ParameterCls item in parameters)
		{
			TreeNode treeNode = treeParam.Nodes.Add(item.Name);
			treeNode.Tag = item;
			if (item.Type == IOType.Input)
			{
				treeNode.ImageIndex = 3;
				treeNode.SelectedImageIndex = 3;
			}
			else
			{
				treeNode.ImageIndex = 4;
				treeNode.SelectedImageIndex = 4;
			}
		}
		treeParam.Refresh();
	}

	private void treeTest_KeyUp(object sender, KeyEventArgs e)
	{
		if (!e.Control)
		{
			ctrlPressed = false;
		}
	}

	private void treeTest_KeyDown(object sender, KeyEventArgs e)
	{
		if (e.Control)
		{
			ctrlPressed = true;
		}
	}

	private void treeTest_BeforeCheck(object sender, TreeViewCancelEventArgs e)
	{
		if (_disabledNodes.Contains(e.Node))
		{
			e.Cancel = true;
		}
	}

	private void treeTest_BeforeSelect(object sender, TreeViewCancelEventArgs e)
	{
		try
		{
			if ((((BaseTest)e.Node.Tag).Properties.LinkNode && ((BaseTest)e.Node.Tag).Properties.IsLinkActive == true) || radioSequence.Checked)
			{
				e.Cancel = true;
			}
		}
		catch
		{
		}
	}

	private void treeTest_MouseDown(object sender, MouseEventArgs e)
	{
		try
		{
			if (userEdited)
			{
				DialogResult dialogResult = AppMessageDialog.Show("Do you want to lose the currently edited loop condition", "QSPR - Message Center", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, DialogResult.OK, MessageDialogType.Warning);
				if (dialogResult == DialogResult.Cancel)
				{
					return;
				}
				userEdited = false;
			}
			ResetButtonColors();
			ResetTextBoxes();
		}
		catch (Exception ex)
		{
			TraceMessage.Write(ToString(), "treeTest_MouseDown " + ex.Message, TraceMessageType.Exception);
		}
	}

	private void treeParam_AfterSelect(object sender, TreeViewEventArgs e)
	{
		try
		{
			ParameterCls parameterCls = (ParameterCls)e.Node.Tag;
			if (txtLoopName.Text.Trim().Length == 0 || !userEdited || previoiuslySelectedLoopName == txtLoopName.Text)
			{
				txtLoopName.Text = parameterCls.Name.Trim();
				textList.Text = "";
				textSSS.Text = "";
				txtFilename.Text = "";
				cmbFileColumnName.Items.Clear();
				chkListFromFile.Checked = false;
				chkFileNameFromGV.Checked = false;
			}
			if (parameterCls.Type == IOType.Input)
			{
				btnInputChange.Visible = true;
				btnULChange.Visible = false;
				btnLLChange.Visible = false;
			}
			else
			{
				btnInputChange.Visible = false;
				btnULChange.Visible = true;
				btnLLChange.Visible = true;
			}
			txt2DArrayIndex.Visible = false;
			if (parameterCls.IsParamDataTable())
			{
				lblIndex.Visible = true;
				txt2DArrayIndex.Visible = true;
			}
			else if (parameterCls.NoOfElements > 1)
			{
				cmParamterIndex.DataSource = null;
				ArrayList arrayList = new ArrayList();
				arrayList.Add("All");
				cmParamterIndex.Visible = true;
				lblIndex.Visible = true;
				for (int i = 0; i < parameterCls.NoOfElements; i++)
				{
					arrayList.Add(i);
				}
				cmParamterIndex.DataSource = arrayList;
				cmParamterIndex.Text = "All";
			}
			else
			{
				lblIndex.Visible = false;
				cmParamterIndex.Visible = false;
				cmParamterIndex.DataSource = null;
			}
			previoiuslySelectedLoopName = parameterCls.Name.Trim();
		}
		catch (Exception ex)
		{
			TraceMessage.Write(ToString(), "treeParam_AfterSelect " + ex.Message, TraceMessageType.Exception);
		}
	}

	private void tree_BeforeCollapse(object sender, TreeViewCancelEventArgs e)
	{
		int imageIndex = e.Node.ImageIndex;
		if (imageIndex == 1)
		{
			e.Node.ImageIndex = 0;
			e.Node.SelectedImageIndex = 0;
		}
	}

	private void tree_BeforeExpand(object sender, TreeViewCancelEventArgs e)
	{
		if (e.Node.ImageIndex == 0)
		{
			e.Node.ImageIndex = 1;
			e.Node.SelectedImageIndex = 1;
		}
	}

	private void treeParam_MouseDown(object sender, MouseEventArgs e)
	{
		if (!txtColumnName.Visible)
		{
			ResetButtonColors();
			ResetColumnHeader();
		}
	}

	private void dataGridLoop_CellClick(object sender, DataGridViewCellEventArgs e)
	{
		try
		{
			if (!dataGridLoop.Columns[e.ColumnIndex].ReadOnly)
			{
				dataGridLoop.BeginEdit(selectAll: true);
			}
		}
		catch (Exception ex)
		{
			TraceMessage.Write(ToString(), "ultraGridInput_ClickCellButton " + ex.Message, TraceMessageType.Exception);
		}
	}

	private void dataGridLoop_CurrentCellDirtyStateChanged(object sender, EventArgs e)
	{
		try
		{
			if (dataGridLoop.CurrentCell.OwningColumn.HeaderText != "Selection")
			{
				LoopChanged = true;
			}
			if (dataGridLoop.CurrentCell is DataGridViewTextBoxCell && dataGridLoop.CurrentCell.Value == null)
			{
				dataGridLoop.CurrentCell.Value = "";
			}
			dataGridLoop.CommitEdit(DataGridViewDataErrorContexts.Commit);
			if (dataGridLoop.CurrentCell != null)
			{
				UpdateScenarioAtIndex(dataGridLoop.CurrentCell.ColumnIndex);
			}
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show(this, ex.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void dataGridLoop_ColumnAdded(object sender, DataGridViewColumnEventArgs e)
	{
		e.Column.SortMode = DataGridViewColumnSortMode.NotSortable;
		switch (e.Column.Index)
		{
		case 0:
			e.Column.Width = 50;
			e.Column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
			break;
		case 1:
			e.Column.Width = 55;
			break;
		case 2:
			e.Column.Width = 120;
			break;
		}
	}

	private void dataGridLoop_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
	{
		for (int i = e.RowIndex; i < e.RowIndex + e.RowCount; i++)
		{
			dataGridLoop.Rows[i].Cells[1].Value = true;
			dataGridLoop.Rows[i].Cells[2].Value = "";
			dataGridLoop.Rows[i].Cells[3].Value = "";
			for (int j = 4; j < dataGridLoop.Columns.Count; j++)
			{
				if (dataGridLoop.Rows[i].Cells[j].Value == null)
				{
					dataGridLoop.Rows[i].Cells[j].Value = "";
				}
			}
		}
	}

	private void dataGridLoop_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
	{
		try
		{
			if (e.ColumnIndex == 1)
			{
				LoopSelectionChanged = true;
			}
			else if (radioSequence.Checked)
			{
				e.Cancel = true;
				return;
			}
			DataGridViewCell currentCell = dataGridLoop.CurrentCell;
			if (currentCell.Value == null)
			{
				currentCell.Value = "";
			}
			if (currentCell.Value.ToString() != "")
			{
				string headerText = currentCell.OwningColumn.HeaderText;
				int index = dataGridLoop.Columns[headerText].Index;
				if (index >= 4)
				{
					LoopCondition loopCondition = (LoopCondition)loopScenario.LoopConditions[index - 4];
					bool flag = true;
					if (loopCondition.LoopType == LoopTypes.BYCOUNT && currentCell.Value.ToString() == "Loop Forever")
					{
						flag = false;
					}
					if (flag)
					{
						switch ((int)loopCondition.DataType)
						{
						case 1:
							double.Parse(currentCell.Value.ToString(), CultureInfo.InvariantCulture);
							break;
						case 0:
							int.Parse(currentCell.Value.ToString());
							break;
						case 6:
							int.Parse(currentCell.Value.ToString(), NumberStyles.HexNumber);
							break;
						case 3:
							short.Parse(currentCell.Value.ToString());
							break;
						case 4:
							byte.Parse(currentCell.Value.ToString());
							break;
						}
					}
					LoopValueChanged = true;
				}
			}
			modified = true;
		}
		catch (Exception ex)
		{
			LoopFolder.Root.Scheduler.SetDebugMessage(ex.Message, Scheduler.SoundLevel.INFO);
			e.Cancel = true;
		}
	}

	private void dataGridLoop_MouseUp(object sender, MouseEventArgs e)
	{
		try
		{
			dataGridLoop.Update();
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show(this, ex.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void dataGridLoop_DataError(object sender, DataGridViewDataErrorEventArgs e)
	{
	}

	private void dataGridLoop_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
	{
		if (dataGridLoop.CurrentCell.ColumnIndex != e.ColumnIndex && e.ColumnIndex >= 4)
		{
			dataGridLoop.CurrentCell = dataGridLoop.Rows[0].Cells[e.ColumnIndex];
		}
	}

	private void dataGridLoop_MouseDown(object sender, MouseEventArgs e)
	{
		try
		{
			if (txtColumnName.Visible || dataGridLoop.Rows == null || dataGridLoop.Rows.Count == 0)
			{
				return;
			}
			DataGridViewColumnHeaderCell dataGridViewColumnHeaderCell = null;
			DataGridView.HitTestInfo hitTestInfo = dataGridLoop.HitTest(e.X, e.Y);
			if (hitTestInfo.Type == DataGridViewHitTestType.ColumnHeader)
			{
				dataGridViewColumnHeaderCell = dataGridLoop.Columns[hitTestInfo.ColumnIndex].HeaderCell;
				if (dataGridLoop.CurrentCell.ColumnIndex != hitTestInfo.ColumnIndex && hitTestInfo.ColumnIndex >= 4)
				{
					dataGridLoop.CurrentCell = dataGridLoop.Rows[0].Cells[hitTestInfo.ColumnIndex];
				}
			}
			if (dataGridViewColumnHeaderCell == null)
			{
				dataGridViewColumnHeaderCell = dataGridLoop.CurrentCell.OwningColumn.HeaderCell;
				DataGridViewCell currentCell = dataGridLoop.CurrentCell;
				if (currentCell != null)
				{
					dataGridViewColumnHeaderCell = currentCell.OwningColumn.HeaderCell;
				}
			}
			if (e.Button != MouseButtons.Right)
			{
				if (dataGridViewColumnHeaderCell != null)
				{
					selectionToolStripMenuItem.Enabled = false;
					deselectAllToolStripMenuItem.Enabled = false;
					selectionToolStripMenuItem.Visible = false;
					btnApplyAllTests.Enabled = false;
					if (dataGridViewColumnHeaderCell.ColumnIndex == 1)
					{
						if (dataGridLoop.Rows.Count > 0)
						{
							selectionToolStripMenuItem.Visible = true;
							dataGridLoop.Update();
							ArrayList checkedRows = GetCheckedRows();
							int num = 0;
							foreach (bool item in checkedRows)
							{
								if (item)
								{
									num++;
								}
							}
							if (num == 0)
							{
								selectionToolStripMenuItem.Enabled = true;
							}
							else if (num == dataGridLoop.Rows.Count)
							{
								deselectAllToolStripMenuItem.Enabled = true;
							}
							else
							{
								selectionToolStripMenuItem.Enabled = true;
								deselectAllToolStripMenuItem.Enabled = true;
							}
						}
					}
					else if (dataGridViewColumnHeaderCell.ColumnIndex != 3 && dataGridViewColumnHeaderCell.ColumnIndex != 2 && dataGridViewColumnHeaderCell.ColumnIndex != 0)
					{
						if (currentCol != null)
						{
							currentCol.HeaderCell.Style.BackColor = dataGridLoop.ColumnHeadersDefaultCellStyle.BackColor;
							currentCol.HeaderCell.Style.ForeColor = dataGridLoop.ColumnHeadersDefaultCellStyle.ForeColor;
						}
						if (loopScenario.Count > 0 && (((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.LIST || ((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.STARTSTOPSTEP))
						{
							btnApplyAllTests.Enabled = true;
						}
						currentCol = dataGridViewColumnHeaderCell.OwningColumn;
						currentCol.HeaderCell.Style.BackColor = dataGridLoop.ColumnHeadersDefaultCellStyle.SelectionBackColor;
						currentCol.HeaderCell.Style.ForeColor = dataGridLoop.ColumnHeadersDefaultCellStyle.SelectionForeColor;
						ColumnChanged(currentCol.Name, currentCol.Index);
					}
				}
			}
			else if (e.Button == MouseButtons.Right)
			{
				CopyType copyType = CopyType.None;
				if (clipBoard != null && clipBoard.Count > 0)
				{
					object obj = clipBoard[0];
					if (obj is ArrayList)
					{
						copyType = CopyType.Row;
					}
					else if (obj is string)
					{
						copyType = CopyType.Cell;
					}
				}
				if (dataGridLoop.SelectedRows.Count > 1)
				{
					deleteRowToolStripMenuItem.Enabled = true;
					insertRowToolStripMenuItem.Enabled = false;
					cutToolStripMenuItem.Enabled = true;
					copyToolStripMenuItem.Enabled = true;
					if (copyType == CopyType.Row)
					{
						pasteToolStripMenuItem.Enabled = true;
						pasteLastToolStripMenuItem.Enabled = true;
					}
					else
					{
						pasteToolStripMenuItem.Enabled = false;
						pasteLastToolStripMenuItem.Enabled = false;
					}
				}
				else if (dataGridLoop.SelectedRows.Count == 1)
				{
					insertRowToolStripMenuItem.Enabled = true;
					deleteRowToolStripMenuItem.Enabled = true;
					cutToolStripMenuItem.Enabled = true;
					copyToolStripMenuItem.Enabled = true;
					if (copyType == CopyType.Row)
					{
						pasteToolStripMenuItem.Enabled = true;
						pasteLastToolStripMenuItem.Enabled = true;
					}
					else
					{
						pasteToolStripMenuItem.Enabled = false;
						pasteLastToolStripMenuItem.Enabled = false;
					}
				}
				else
				{
					insertRowToolStripMenuItem.Enabled = false;
					deleteRowToolStripMenuItem.Enabled = false;
					cutToolStripMenuItem.Enabled = false;
					copyToolStripMenuItem.Enabled = false;
					pasteToolStripMenuItem.Enabled = false;
					pasteLastToolStripMenuItem.Enabled = false;
				}
				if (dataGridViewColumnHeaderCell != null)
				{
					if (currentCol != null && dataGridViewColumnHeaderCell.ColumnIndex >= 4)
					{
						if (loopScenario.Count > 0 && (((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.LIST || ((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.STARTSTOPSTEP))
						{
							btnApplyAllTests.Enabled = true;
						}
						deleteColumnToolStripMenuItem.Enabled = true;
						changeLoopNameToolStripMenuItem.Enabled = true;
						applyToAllTestsToolStripMenuItem.Enabled = true;
						moveLeftToolStripMenuItem.Enabled = true;
						moveRightToolStripMenuItem.Enabled = true;
						btnApplyAllTests.Enabled = true;
						if (dataGridViewColumnHeaderCell.ColumnIndex == 4)
						{
							moveLeftToolStripMenuItem.Enabled = false;
							if (dataGridViewColumnHeaderCell.ColumnIndex == dataGridLoop.Columns.Count - 1)
							{
								moveRightToolStripMenuItem.Enabled = false;
							}
						}
						else if (dataGridViewColumnHeaderCell.ColumnIndex == dataGridLoop.Columns.Count - 1)
						{
							moveRightToolStripMenuItem.Enabled = false;
						}
						if (string.Compare(currLoopCond.TestName, "Global Variables") == 0)
						{
							applyToAllTestsToolStripMenuItem.Enabled = false;
							btnApplyAllTests.Enabled = false;
						}
					}
					else
					{
						if (dataGridViewColumnHeaderCell.ColumnIndex == 1 && dataGridLoop.Rows.Count > 0)
						{
							selectionToolStripMenuItem.Visible = true;
							selectionToolStripMenuItem.Enabled = true;
							dataGridLoop.Update();
							ArrayList checkedRows2 = GetCheckedRows();
							int num2 = 0;
							foreach (bool item2 in checkedRows2)
							{
								if (item2)
								{
									num2++;
								}
							}
							if (num2 == 0)
							{
								selectAllToolStripMenuItem.Enabled = true;
								deselectAllToolStripMenuItem.Enabled = false;
							}
							else if (num2 == dataGridLoop.Rows.Count)
							{
								selectAllToolStripMenuItem.Enabled = false;
								deselectAllToolStripMenuItem.Enabled = true;
							}
							else
							{
								selectionToolStripMenuItem.Enabled = true;
								selectAllToolStripMenuItem.Enabled = true;
								deselectAllToolStripMenuItem.Enabled = true;
							}
						}
						deleteColumnToolStripMenuItem.Enabled = false;
						changeLoopNameToolStripMenuItem.Enabled = false;
						applyToAllTestsToolStripMenuItem.Enabled = false;
						moveLeftToolStripMenuItem.Enabled = false;
						moveRightToolStripMenuItem.Enabled = false;
						btnApplyAllTests.Enabled = false;
					}
				}
				else
				{
					deleteColumnToolStripMenuItem.Enabled = false;
					changeLoopNameToolStripMenuItem.Enabled = false;
					applyToAllTestsToolStripMenuItem.Enabled = false;
					moveLeftToolStripMenuItem.Enabled = false;
					moveRightToolStripMenuItem.Enabled = false;
					btnApplyAllTests.Enabled = false;
				}
				if (dataGridLoop.Rows.Count > 0)
				{
					addRowToolStripMenuItem.Enabled = true;
					removeLoopSetupToolStripMenuItem.Enabled = true;
				}
				else
				{
					addRowToolStripMenuItem.Enabled = false;
					removeLoopSetupToolStripMenuItem.Enabled = false;
				}
			}
			dataGridLoop.Update();
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show(this, ex.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void dataGridLoop_CurrentCellChanged(object sender, EventArgs e)
	{
		try
		{
			if (dataGridLoop.CurrentCell == null)
			{
				return;
			}
			if (!(dataGridLoop.CurrentCell.OwningColumn.Name == "Selection") && !(dataGridLoop.CurrentCell.OwningColumn.Name == "Description") && !(dataGridLoop.CurrentCell.OwningColumn.Name == "Don't Run Condition") && !(dataGridLoop.CurrentCell.OwningColumn.Name == "Row ID"))
			{
				if (currentCol != null)
				{
					currentCol.HeaderCell.Style.BackColor = dataGridLoop.ColumnHeadersDefaultCellStyle.BackColor;
					currentCol.HeaderCell.Style.ForeColor = dataGridLoop.ColumnHeadersDefaultCellStyle.ForeColor;
					dataGridLoop.EnableHeadersVisualStyles = true;
				}
				dataGridLoop.EnableHeadersVisualStyles = false;
				currentCol = dataGridLoop.CurrentCell.OwningColumn;
				currentCol.HeaderCell.Style.BackColor = dataGridLoop.ColumnHeadersDefaultCellStyle.SelectionBackColor;
				currentCol.HeaderCell.Style.ForeColor = dataGridLoop.ColumnHeadersDefaultCellStyle.SelectionForeColor;
				bool flag = ((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.LIST || ((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.STARTSTOPSTEP;
				if (loopScenario.Count > 0 && currentCol.Index >= 4 && flag)
				{
					btnApplyAllTests.Enabled = true;
				}
				ColumnChanged(currentCol.Name, currentCol.Index);
				if (flag)
				{
					CreateDropDownCell(dataGridLoop.CurrentCell);
				}
			}
			dataGridLoop.Update();
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show(this, ex.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void CreateDropDownCell(DataGridViewCell currentCell, string testIndex, string paramName)
	{
		try
		{
			if (currentCell.ColumnIndex >= 4)
			{
				BaseTest baseTest = loopFolder.FindTest(testIndex);
				ParameterCls parameter = baseTest.Properties.Parameters.GetParameter(paramName);
				CreateDropDownCell(parameter, currentCell);
			}
		}
		catch
		{
		}
	}

	private void CreateDropDownCell(DataGridViewCell currentCell)
	{
		try
		{
			if (currentCell.ColumnIndex >= 4)
			{
				BaseTest baseTest = (BaseTest)treeTest.SelectedNode.Tag;
				if (treeParam.SelectedNode != null)
				{
					ParameterCls parameter = baseTest.Properties.Parameters.GetParameter(treeParam.SelectedNode.Text);
					CreateDropDownCell(parameter, currentCell);
				}
			}
		}
		catch
		{
		}
	}

	public bool CreateDropDownCell(ParameterCls param, DataGridViewCell cell)
	{
		try
		{
			if (cell != null)
			{
				HandleDisplayHints(cell, param);
			}
			return true;
		}
		catch (Exception ex)
		{
			TraceMessage.Write("QC.QTMApplication.TTDParamView", "CreateDropDownCell " + ex.Message, TraceMessageType.Exception);
			return false;
		}
	}

	private string GetDefaultValue(ParameterCls tParam)
	{
		string[] array = tParam.Constraints.Trim().Split(';');
		return array[0];
	}

	private void HandleDisplayHints(DataGridViewCell currentCell, ParameterCls tParam)
	{
		string[] hints = tParam.Constraints.Trim().Split(';');
		if ((tParam.DisplayHint & 3) == 3)
		{
			return;
		}
		if ((tParam.DisplayHint & 0x3000) == 12288)
		{
			ApplyDisplayHint(currentCell, GetConstraints(hints, "False;True"), tParam.IsNullable, enumType: true, tParam.DataType);
		}
		else if ((tParam.DisplayHint & 2) == 2)
		{
			string defaultConstraints = "False;True";
			if ((tParam.DisplayHint & 0x1000) == 4096)
			{
				defaultConstraints = "No;Yes";
			}
			else if ((tParam.DisplayHint & 0x2000) == 8192)
			{
				defaultConstraints = "Off;On";
			}
			else if ((tParam.DisplayHint & 0x100) == 256)
			{
				defaultConstraints = "No;Yes";
			}
			ApplyDisplayHint(currentCell, GetConstraints(hints, defaultConstraints), tParam.IsNullable, enumType: true, tParam.DataType);
		}
		else
		{
			if ((tParam.DisplayHint & 1) == 1 || (tParam.DisplayHint & 4) == 4)
			{
				return;
			}
			if ((tParam.DisplayHint & 0x1000) == 4096)
			{
				ApplyDisplayHint(currentCell, GetConstraints(hints, "No;Yes"), tParam.IsNullable, enumType: true, tParam.DataType);
				return;
			}
			if ((tParam.DisplayHint & 0x2000) == 8192)
			{
				ApplyDisplayHint(currentCell, GetConstraints(hints, "Off;On"), tParam.IsNullable, enumType: true, tParam.DataType);
				return;
			}
			if ((tParam.DisplayHint & 0x100) == 256)
			{
				ApplyDisplayHint(currentCell, tParam.Constraints.Trim(), tParam.IsNullable, enumType: false, tParam.DataType);
				return;
			}
			if ((tParam.DisplayHint & 8) == 8)
			{
				ApplyDisplayHint(currentCell, tParam.Constraints.Trim(), tParam.IsNullable, enumType: true, tParam.DataType);
				return;
			}
			_ = tParam.DisplayHint;
			if (0 == 0)
			{
				ApplyDataTypeDisplayHint(currentCell, "False;True", tParam.DataType, tParam.IsNullable);
			}
		}
	}

	private void ApplyDataTypeDisplayHint(DataGridViewCell cell, string constraints, DataType dType, bool isNullable)
	{
		try
		{
			if (dType == DataType.Boolean)
			{
				ApplyDisplayHint(cell, constraints, isNullable, enumType: false, dType);
			}
		}
		catch
		{
		}
	}

	private void ApplyDisplayHint(DataGridViewCell cell, string constraints, bool isNullable, bool enumType, DataType dType)
	{
		try
		{
			if (isNullable)
			{
				ShowDropDown(cell, constraints.Trim() + ";", enumType, dType);
			}
			else
			{
				ShowDropDown(cell, constraints.Trim(), enumType, dType);
			}
		}
		catch (Exception ex)
		{
			TraceMessage.Write(ex.Source, "ApplyDisplayHint " + ex.Message, TraceMessageType.Exception);
		}
	}

	private string GetConstraints(string[] hints, string defaultConstraints)
	{
		if (hints.Length > 1)
		{
			return hints[0].Trim() + ";" + hints[1].Trim();
		}
		return defaultConstraints;
	}

	private void ShowDropDown(DataGridViewCell cell, string constraints, bool enumType, DataType dType)
	{
		try
		{
			string[] array = constraints.Trim().Split(';');
			string text = cell.Value.ToString();
			DataGridView dataGridView = cell.DataGridView;
			int columnIndex = cell.ColumnIndex;
			int rowIndex = cell.RowIndex;
			int num = 0;
			if (array.Length <= 0)
			{
				return;
			}
			new DataGridViewComboBoxCell();
			List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
			if (enumType)
			{
				if (ParameterCollection.CreateNameValueList(constraints, out var names, out var values))
				{
					bool flag = QTMUtility.IsAllConstraintsHaveTwoParts(constraints);
					for (int i = 0; i < names.Count; i++)
					{
						string key = (flag ? $"{values[i].ToString()}  {names[i].ToString()}" : names[i].ToString());
						string value = values[i].ToString();
						list.Add(new KeyValuePair<string, string>(key, value));
						if (text == values[i].ToString())
						{
							num = (int)values[i];
						}
					}
				}
			}
			else
			{
				for (int j = 0; j < array.Length; j++)
				{
					list.Add(new KeyValuePair<string, string>(array[j].Trim(), array[j].Trim()));
				}
			}
			if (dType == DataType.Boolean)
			{
				if (list.Count > 2)
				{
					list.Remove(list[2]);
					list.Add(new KeyValuePair<string, string>("", ""));
				}
				bool result = false;
				text = ((!bool.TryParse(text, out result)) ? "" : result.ToString());
			}
			if (!(dataGridView.Columns[columnIndex] is DataGridViewComboBoxColumn))
			{
				DataGridViewComboBoxColumn dataGridViewComboBoxColumn = new DataGridViewComboBoxColumn();
				dataGridViewComboBoxColumn.Name = cell.OwningColumn.Name;
				dataGridViewComboBoxColumn.DataSource = list;
				dataGridViewComboBoxColumn.DisplayMember = "Key";
				dataGridViewComboBoxColumn.ValueMember = "Value";
				dataGridView.Columns.Insert(columnIndex, dataGridViewComboBoxColumn);
				dataGridView.Columns.RemoveAt(columnIndex + 1);
			}
			if (enumType)
			{
				dataGridView[columnIndex, rowIndex].Value = num.ToString();
			}
			else
			{
				dataGridView[columnIndex, rowIndex].Value = text;
			}
		}
		catch (Exception ex)
		{
			TraceMessage.Write("QC.QTMApplication.TTDParamView", "ShowDropDown " + ex.Message, TraceMessageType.Exception);
		}
	}

	private void radioSSS_MouseDown(object sender, MouseEventArgs e)
	{
		if (textSSS.Text == "Comma Delimited Value")
		{
			textSSS.Text = "";
		}
	}

	private void radioList_MouseDown(object sender, MouseEventArgs e)
	{
		if (textList.Text == "Comma Delimited Value")
		{
			textList.Text = "";
		}
	}

	private void radioCount_MouseDown(object sender, MouseEventArgs e)
	{
		if (cmbLoopCount.Text == "Integer Value")
		{
			cmbLoopCount.Text = "";
		}
	}

	private void btnAddCol_Click(object sender, EventArgs e)
	{
		modified = true;
		userEdited = false;
		LoopChanged = true;
		ProcessScenarioInput(sender);
	}

	private bool IsDontRunConditionValid()
	{
		foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
		{
			string text = "";
			if (item.Cells[2].Value != null)
			{
				text = item.Cells[2].Value.ToString();
			}
			string[] array = "<=,=<,>=,=<,!=,=,<,>".Split(',');
			int num = -1;
			string[] array2 = array;
			foreach (string value in array2)
			{
				num = text.IndexOf(value);
				if (num != -1)
				{
					break;
				}
			}
			if (num == -1 && text.Trim() != "")
			{
				return false;
			}
		}
		return true;
	}

	private void btnOK_Click(object sender, EventArgs e)
	{
		okPressed = false;
		if (!IsDontRunConditionValid())
		{
			AppMessageDialog.Show("Invalid Don't run condition.", "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
			return;
		}
		if (LoopFolder.Properties.RetryCount > 0)
		{
			DialogResult dialogResult = AppMessageDialog.Show("This loop is a retry loop.\nIf you want to modify the number of retries, enter the count into the RetryCount property of the selected test.\n\nIf you continue, it will remove the RetryCount.\nAre you sure you want to proceed?", "QSPR - Message Center", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, DialogResult.Yes, MessageDialogType.Error);
			if (dialogResult != DialogResult.Yes)
			{
				return;
			}
			LoopFolder.Properties.RetryCount = 0;
		}
		if (dataGridLoop.Rows.Count > 0)
		{
			LoopTypes loopType = ((LoopCondition)loopScenario.LoopConditions[0]).LoopType;
			string text = "";
			string text2 = "";
			bool flag = false;
			switch (loopType)
			{
			case LoopTypes.BYCOUNT:
				text = "By Count";
				break;
			case LoopTypes.BYTIME:
				text = "By Time";
				break;
			case LoopTypes.BYSEQUENCE:
				text = "By Sequence";
				break;
			case LoopTypes.LIST:
				text = "List";
				break;
			case LoopTypes.STARTSTOPSTEP:
				text = "Start,Stop,Step";
				break;
			}
			if (radioCount.Checked && loopType != LoopTypes.BYCOUNT)
			{
				text2 = "By Count";
				flag = true;
			}
			else if (radioTime.Checked && loopType != LoopTypes.BYTIME)
			{
				text2 = "By Time";
				flag = true;
			}
			else if (radioSequence.Checked && loopType != LoopTypes.BYSEQUENCE)
			{
				text2 = "By Sequence";
				flag = true;
			}
			else if ((radioSSS.Checked || radioList.Checked) && loopType != LoopTypes.STARTSTOPSTEP && loopType != LoopTypes.LIST)
			{
				text2 = ((!radioSSS.Checked) ? "List" : "Start,Stop,Step");
				flag = true;
			}
			if (flag)
			{
				DialogResult dialogResult2 = AppMessageDialog.Show("The previous loop type cannot be mixed with the newly selected loop type.\n    Previous type:   " + text + "\n    Selected type:   " + text2 + "\n\nDo you want to ignore the changes?", "QSPR - Message Center", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, DialogResult.Cancel, MessageDialogType.UIWarning);
				userEdited = false;
				if (dialogResult2 == DialogResult.Cancel)
				{
					return;
				}
			}
		}
		if (userEdited && dataGridLoop.Rows.Count != 0)
		{
			DialogResult dialogResult3 = ((((LoopCondition)loopScenario.LoopConditions[0]).LoopType != LoopTypes.BYCOUNT) ? AppMessageDialog.Show("Do you want to lose the currently edited loop condition?", "QSPR - Message Center", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, DialogResult.Cancel, MessageDialogType.UIWarning) : AppMessageDialog.Show("Do you want to lose the currently edited loop condition?\n\nHint (Cancel to edit):\n   *Change Loop value by editing in the grid.\n   *Change Loop name by right clicking the grid column", "QSPR - Message Center", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, DialogResult.Cancel, MessageDialogType.UIWarning));
			if (dialogResult3 == DialogResult.Cancel)
			{
				return;
			}
			userEdited = false;
		}
		if (dataGridLoop.Rows.Count == 0)
		{
			loopScenario.Clear();
			if (!CheckForSingleLoop())
			{
				return;
			}
			LoopChanged = true;
			UpdateScenarios();
		}
		else
		{
			ClearBottomEmptyRows();
			UpdateScenarios();
		}
		if (loopScenario.Count != 0)
		{
			LoopFolder.FolderProperties.Scenarios = loopScenario.Clone();
		}
		else
		{
			LoopFolder.FolderProperties.Scenarios = null;
		}
		TreeRegistrationStatus registrationStatus = LoopFolder.Root.Scheduler.GlobalStatus.RegistrationStatus;
		if (LoopChanged)
		{
			registrationStatus.LoopChanged = true;
		}
		if (LoopRowDeleted)
		{
			registrationStatus.LoopRowDeleted = true;
		}
		if (LoopValueChanged)
		{
			registrationStatus.LoopValueChanged = true;
		}
		if (LoopSelectionChanged)
		{
			registrationStatus.LoopSelectionChanged = true;
		}
		base.DialogResult = DialogResult.OK;
		okPressed = true;
		Close();
	}

	private bool CheckUpdateDescription()
	{
		int count = LoopFolder.TestList.Count;
		foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
		{
			string text = item.Cells[3].Value.ToString();
			if (!(text.Trim() != ""))
			{
				continue;
			}
			string[] array = text.Trim().Split(",".ToCharArray()[0]);
			int num = array.Length;
			if (num == count)
			{
				continue;
			}
			string[] array2 = new string[count];
			for (int i = 0; i < count; i++)
			{
				if (i >= num)
				{
					array2[i] = "";
				}
				else
				{
					array2[i] = array[i];
				}
			}
			string text2 = "";
			for (int j = 0; j < count - 1; j++)
			{
				text2 = text2 + array2[j] + ",";
			}
			text2 += array2[count - 1];
			item.Cells[3].Value = text2;
		}
		return true;
	}

	private void txtColumnName_Leave(object sender, EventArgs e)
	{
		if (!bColumnNameChangeUser)
		{
			DialogResult dialogResult = AppMessageDialog.Show("Loop name will not change. Do you want to continue?.", "QSPR - Loop Setup", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, DialogResult.Yes, MessageDialogType.UIWarning);
			if (dialogResult == DialogResult.Yes)
			{
				lblNewColumnName.Visible = false;
				txtColumnName.Visible = false;
			}
			else
			{
				txtColumnName.Focus();
			}
		}
	}

	private void txtColumnName_KeyDown(object sender, KeyEventArgs e)
	{
		if (e.KeyCode == Keys.Return)
		{
			string[] array = txtColumnName.Text.Trim().Split('_');
			if (array.Length > 1)
			{
				AppMessageDialog.Show("Loop name cannot have UNDERSCORE '_'", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
			}
			else
			{
				UpdateColumnName();
			}
		}
		else if (e.KeyCode == Keys.Escape)
		{
			bColumnNameChangeUser = true;
			lblNewColumnName.Visible = false;
			txtColumnName.Visible = false;
			bColumnNameChangeUser = false;
		}
	}

	private void textList_KeyDown(object sender, KeyEventArgs e)
	{
		userEdited = true;
	}

	private void cmbLoopCount_SelectedIndexChanged(object sender, EventArgs e)
	{
		userEdited = true;
	}

	private void numericUpDownTime_ValueChanged(object sender, EventArgs e)
	{
		userEdited = true;
	}

	private void radioHoursMinutes_ValueChanged(object sender, EventArgs e)
	{
		if (loopScenario.LoopConditions != null && loopScenario.LoopConditions.Count > 0 && ((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.BYTIME)
		{
			if (chkLoopTimeFromGV.Checked && !string.IsNullOrWhiteSpace(timeTxt.Text))
			{
				((LoopCondition)loopScenario.LoopConditions[0]).LoopDetails = GetSelectedRBValue(groupBoxHoursMinutes) + "@#$%" + chkLoopTimeFromGV.Checked + "@#$%" + timeTxt.Text.Trim();
			}
			else
			{
				((LoopCondition)loopScenario.LoopConditions[0]).LoopDetails = GetSelectedRBValue(groupBoxHoursMinutes);
			}
		}
	}

	private void cmbLoopCount_KeyDown(object sender, KeyEventArgs e)
	{
		userEdited = true;
	}

	private void textSSS_KeyDown(object sender, KeyEventArgs e)
	{
		userEdited = true;
	}

	private void txtLoopName_KeyDown(object sender, KeyEventArgs e)
	{
		userEdited = true;
	}

	private void UpdateLoopColumn(LoopCondition loop, ArrayList loopValues)
	{
		string loopName = loop.LoopName;
		try
		{
			if (IsExceedMaxLoopCount(loopScenario))
			{
				dataGridLoop.Rows.Clear();
				int index = dataGridLoop.Rows.Add();
				DataGridViewRow dataGridViewRow = dataGridLoop.Rows[index];
				dataGridViewRow.Cells[1].Value = true;
				dataGridViewRow.Cells[loopName].Value = loop.OriginalValue;
				dataGridLoop.Rows.Add(dataGridViewRow);
				if (dataGridLoop.Rows.Count > 0)
				{
					dataGridLoop.Rows[0].Cells[loopName].Selected = true;
					dataGridLoop.Rows[0].Visible = false;
				}
				return;
			}
			if (dataGridLoop != null && dataGridLoop.Rows.Count > 0)
			{
				dataGridLoop.Rows[0].Visible = true;
			}
			if (dataGridLoop.Rows.Count < loopValues.Count)
			{
				int count = dataGridLoop.Rows.Count;
				for (int i = 0; i < loopValues.Count - count; i++)
				{
					int index2 = dataGridLoop.Rows.Add();
					DataGridViewRow dataGridViewRow2 = dataGridLoop.Rows[index2];
					dataGridViewRow2.Cells[1].Value = true;
				}
			}
			for (int j = 0; j < dataGridLoop.Rows.Count; j++)
			{
				try
				{
					dataGridLoop.Rows[j].Cells[loopName].Value = string.Empty;
				}
				catch (Exception ex)
				{
					TraceMessage.Write(ToString(), "UpdateLoopColumn 1: " + ex.Message, TraceMessageType.Exception);
				}
			}
			bool flag = ((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.LIST || ((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.STARTSTOPSTEP;
			for (int k = 0; k < loopValues.Count; k++)
			{
				try
				{
					if (loopValues[k].ToString().Trim() != "")
					{
						dataGridLoop.Rows[k].Cells[loopName].Value = loopValues[k];
						if (flag)
						{
							CreateDropDownCell(dataGridLoop.Rows[k].Cells[loopName]);
						}
					}
				}
				catch (Exception ex2)
				{
					TraceMessage.Write(ToString(), "UpdateLoopColumn 2: " + ex2.Message, TraceMessageType.Exception);
				}
			}
			try
			{
				AddRowID();
				dataGridLoop.Update();
			}
			catch (Exception ex3)
			{
				AppMessageDialog.Show(this, ex3.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
			}
		}
		catch (Exception ex4)
		{
			AppMessageDialog.Show(ex4.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private bool CheckLoopName(string loopName)
	{
		int count = loopScenario.LoopConditions.Count;
		for (int i = 0; i < count; i++)
		{
			if (((LoopCondition)loopScenario.LoopConditions[i]).LoopName.Trim().ToUpper() == loopName.Trim().ToUpper())
			{
				AppMessageDialog.Show("Loop Name : " + loopName + " already exists!", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.UIWarning);
				return false;
			}
		}
		return true;
	}

	private void UpdateColumnName()
	{
		try
		{
			modified = true;
			LoopChanged = true;
			string text = txtColumnName.Text.Trim();
			if (text.ToUpper().EndsWith("UL") || text.ToUpper().EndsWith("LL"))
			{
				text = text.Substring(0, text.Length - 2);
			}
			if (oldColumnName.EndsWith("UL"))
			{
				text += "UL";
			}
			if (oldColumnName.EndsWith("LL"))
			{
				text += "LL";
			}
			if (!txtColumnName.Visible)
			{
				return;
			}
			if (text.Trim() == "" || text.Trim() == "UL" || text.Trim() == "LL")
			{
				bColumnNameChangeUser = true;
				lblNewColumnName.Visible = false;
				txtColumnName.Visible = false;
				bColumnNameChangeUser = false;
			}
			else if (oldColumnName != text)
			{
				if (CheckLoopName(text))
				{
					try
					{
						dataGridLoop.Update();
					}
					catch (Exception ex)
					{
						AppMessageDialog.Show(this, ex.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
					}
					int index;
					try
					{
						index = dataGridLoop.Columns[oldColumnName].Index;
					}
					catch (Exception ex2)
					{
						TraceMessage.Write(ToString(), "UpdateColumnName " + ex2.Message, TraceMessageType.Exception);
						return;
					}
					if (index >= 4)
					{
						((LoopCondition)loopScenario.LoopConditions[index - 4]).LoopName = text;
						string loopName = ((LoopCondition)loopScenario.LoopConditions[index - 4]).LoopName;
						dataGridLoop.Columns[index].Name = loopName;
						currentCol.HeaderText = loopName;
						if (loopName.EndsWith("UL") || loopName.EndsWith("LL"))
						{
							txtLoopName.Text = loopName.Substring(0, loopName.Length - 2);
						}
						else
						{
							txtLoopName.Text = loopName;
						}
						CreateDropDownAllCells();
						if (dataGridLoop.Rows.Count > 0)
						{
							dataGridLoop.Rows[0].Cells[loopName].Selected = true;
						}
					}
					bColumnNameChangeUser = true;
					lblNewColumnName.Visible = false;
					txtColumnName.Visible = false;
					bColumnNameChangeUser = false;
				}
				else
				{
					txtColumnName.Text = oldColumnName;
					txtColumnName.Focus();
				}
			}
			else
			{
				bColumnNameChangeUser = true;
				lblNewColumnName.Visible = false;
				txtColumnName.Visible = false;
				bColumnNameChangeUser = false;
			}
		}
		catch (Exception ex3)
		{
			TraceMessage.Write(ToString(), "UpdateColumnName " + ex3.Message, TraceMessageType.Exception);
		}
	}

	private bool ClearBottomEmptyRows()
	{
		int count = dataGridLoop.Rows.Count;
		if (count == 1)
		{
			return true;
		}
		ArrayList arrayList = new ArrayList();
		bool flag = false;
		for (int num = count - 1; num >= 0; num--)
		{
			for (int i = 4; i < dataGridLoop.Rows[num].Cells.Count; i++)
			{
				DataGridViewCell dataGridViewCell = dataGridLoop.Rows[num].Cells[i];
				if (dataGridViewCell.Value != null && dataGridViewCell.Value.ToString().Trim() != "")
				{
					flag = true;
				}
			}
			if (flag)
			{
				break;
			}
			arrayList.Add(num);
		}
		if (arrayList.Count > 0 && AppMessageDialog.Show("Do you want to clear bottom empty rows?", "Clear Bottom Empty Rows", MessageBoxButtons.YesNo, DialogResult.Yes, MessageDialogType.Warning) == DialogResult.Yes)
		{
			foreach (int item in arrayList)
			{
				dataGridLoop.Rows.RemoveAt(item);
			}
		}
		if (arrayList.Count > 0)
		{
			return true;
		}
		return false;
	}

	private void UpdateScenarios()
	{
		try
		{
			for (int i = 0; i < loopScenario.LoopConditions.Count; i++)
			{
				if (((LoopCondition)loopScenario.LoopConditions[i]).LoopType == LoopTypes.LIST)
				{
					((LoopCondition)loopScenario.LoopConditions[i]).LoopValues = GetColumnValues(i + 4);
					((LoopCondition)loopScenario.LoopConditions[i]).OriginalValue = GetString(GetColumnValues(i + 4));
				}
				else if (((LoopCondition)loopScenario.LoopConditions[i]).LoopType == LoopTypes.BYCOUNT)
				{
					ArrayList columnValues = GetColumnValues(i + 4);
					if (columnValues.Count == 1 && columnValues[0].ToString().Trim() != "")
					{
						((LoopCondition)loopScenario.LoopConditions[i]).LoopValues = GetColumnValues(i + 4);
						((LoopCondition)loopScenario.LoopConditions[i]).OriginalValue = GetString(GetColumnValues(i + 4));
						((LoopCondition)loopScenario.LoopConditions[i]).IgnoreIntermediateResults = chkIgnoreIntermediateResults.Checked;
					}
				}
				else if (((LoopCondition)loopScenario.LoopConditions[i]).LoopType == LoopTypes.BYTIME)
				{
					ArrayList columnValues2 = GetColumnValues(i + 4);
					if (columnValues2.Count == 1 && columnValues2[0].ToString().Trim() != "")
					{
						((LoopCondition)loopScenario.LoopConditions[i]).LoopValues = GetColumnValues(i + 4);
						((LoopCondition)loopScenario.LoopConditions[i]).OriginalValue = GetString(GetColumnValues(i + 4));
						((LoopCondition)loopScenario.LoopConditions[i]).IgnoreIntermediateResults = chkIgnoreIntermediateResults.Checked;
					}
				}
				else if (((LoopCondition)loopScenario.LoopConditions[i]).LoopType == LoopTypes.STARTSTOPSTEP && !CompareStartStepStopValues(i + 4))
				{
					((LoopCondition)loopScenario.LoopConditions[i]).LoopType = LoopTypes.LIST;
					((LoopCondition)loopScenario.LoopConditions[i]).LoopValues = GetColumnValues(i + 4);
					((LoopCondition)loopScenario.LoopConditions[i]).OriginalValue = GetString(GetColumnValues(i + 4));
					((LoopCondition)loopScenario.LoopConditions[i]).IgnoreIntermediateResults = false;
				}
			}
			loopScenario.ConditionCheck = GetCheckedRows();
			loopScenario.Descriptions = GetDescriptions();
			loopScenario.DontRunCondition = GetDontRunCondition();
			loopScenario.SuppressWarnings = chkBoxSuppressWarnings.Checked;
			AddRowID();
			if (currentCol != null)
			{
				ColumnChanged(currentCol.HeaderText, currentCol.Index);
			}
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void UpdateScenarioAtIndex(int iCol)
	{
		try
		{
			if (iCol < 4)
			{
				return;
			}
			if (((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopType == LoopTypes.LIST)
			{
				((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopValues = GetColumnValues(iCol);
				((LoopCondition)loopScenario.LoopConditions[iCol - 4]).OriginalValue = GetString(GetColumnValues(iCol));
				if (((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopDetails.Trim().Length > 0 && !warningShownForListFromFile)
				{
					AppMessageDialog.Show("                Loop values not same as the source file.\nSource file values will be used after a Refresh or tree is Opened again.", "QSPR - Loop Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, DialogResult.OK, MessageDialogType.Warning);
					warningShownForListFromFile = true;
				}
			}
			else if (((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopType == LoopTypes.BYCOUNT)
			{
				ArrayList columnValues = GetColumnValues(iCol);
				if (columnValues.Count == 1 && columnValues[0].ToString().Trim() != "")
				{
					((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopValues = GetColumnValues(iCol);
					((LoopCondition)loopScenario.LoopConditions[iCol - 4]).OriginalValue = GetString(GetColumnValues(iCol));
					((LoopCondition)loopScenario.LoopConditions[iCol - 4]).IgnoreIntermediateResults = chkIgnoreIntermediateResults.Checked;
				}
			}
			else if (((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopType == LoopTypes.STARTSTOPSTEP)
			{
				if (!CompareStartStepStopValues(iCol))
				{
					((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopType = LoopTypes.LIST;
					((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopValues = GetColumnValues(iCol);
					((LoopCondition)loopScenario.LoopConditions[iCol - 4]).OriginalValue = GetString(GetColumnValues(iCol));
				}
			}
			else if (((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopType == LoopTypes.BYTIME)
			{
				ArrayList columnValues2 = GetColumnValues(iCol);
				if (columnValues2.Count == 1 && columnValues2[0].ToString().Trim() != "")
				{
					((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopValues = GetColumnValues(iCol);
					((LoopCondition)loopScenario.LoopConditions[iCol - 4]).OriginalValue = GetString(GetColumnValues(iCol));
					if (chkLoopTimeFromGV.Checked)
					{
						((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopDetails = GetSelectedRBValue(groupBoxHoursMinutes) + "@#$%" + chkLoopTimeFromGV.Checked + "@#$%" + timeTxt.Text.Trim();
					}
					else
					{
						((LoopCondition)loopScenario.LoopConditions[iCol - 4]).LoopDetails = GetSelectedRBValue(groupBoxHoursMinutes);
					}
					((LoopCondition)loopScenario.LoopConditions[iCol - 4]).IgnoreIntermediateResults = chkIgnoreIntermediateResults.Checked;
				}
			}
			if (currentCol != null)
			{
				ColumnChanged(currentCol.HeaderText, currentCol.Index);
			}
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private ArrayList GetCheckedRows()
	{
		try
		{
			ArrayList arrayList = new ArrayList();
			if (IsExceedMaxLoopCount(loopScenario))
			{
				foreach (LoopCondition loopCondition in loopScenario.LoopConditions)
				{
					if (loopCondition.LoopValues.Count > 0)
					{
						for (int i = 0; i < loopCondition.LoopValues.Count; i++)
						{
							arrayList.Add(true);
						}
					}
				}
				return arrayList;
			}
			foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
			{
				if (item.Cells[1].Value.ToString().ToUpper() == "TRUE")
				{
					arrayList.Add(true);
				}
				else
				{
					arrayList.Add(false);
				}
			}
			return arrayList;
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
		return null;
	}

	private ArrayList GetDescriptions()
	{
		try
		{
			ArrayList arrayList = new ArrayList();
			if (IsExceedMaxLoopCount(loopScenario))
			{
				foreach (LoopCondition loopCondition in loopScenario.LoopConditions)
				{
					if (loopCondition.LoopValues.Count > 0)
					{
						for (int i = 0; i < loopCondition.LoopValues.Count; i++)
						{
							arrayList.Add("");
						}
					}
				}
				return arrayList;
			}
			foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
			{
				arrayList.Add(item.Cells[3].Value.ToString());
			}
			return arrayList;
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - GetDescriptions ", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
		return null;
	}

	private ArrayList GetDontRunCondition()
	{
		try
		{
			ArrayList arrayList = new ArrayList();
			if (IsExceedMaxLoopCount(loopScenario))
			{
				foreach (LoopCondition loopCondition in loopScenario.LoopConditions)
				{
					if (loopCondition.LoopValues.Count > 0)
					{
						for (int i = 0; i < loopCondition.LoopValues.Count; i++)
						{
							arrayList.Add("");
						}
					}
				}
				return arrayList;
			}
			foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
			{
				arrayList.Add(item.Cells[2].Value.ToString());
			}
			return arrayList;
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - GetDontRunCondition ", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
		return null;
	}

	private ArrayList GetColumnValues(int colIndex)
	{
		try
		{
			ArrayList arrayList = new ArrayList();
			if (IsExceedMaxLoopCount(loopScenario))
			{
				foreach (LoopCondition loopCondition in loopScenario.LoopConditions)
				{
					if (loopCondition.LoopValues.Count > 0)
					{
						for (int i = 0; i < loopCondition.LoopValues.Count; i++)
						{
							arrayList.Add(loopCondition.LoopValues[i].ToString());
						}
					}
				}
				return arrayList;
			}
			foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
			{
				object value = item.Cells[colIndex].Value;
				if (value == null)
				{
					arrayList.Add("");
				}
				else
				{
					arrayList.Add(value.ToString());
				}
			}
			return arrayList;
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
		return null;
	}

	private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
	{
		try
		{
			switch (e.ClickedItem.Text)
			{
			case "Add Row":
				AddRow();
				break;
			case "Delete Row":
				DeleteRow();
				break;
			case "Insert Row":
				InsertRow();
				break;
			case "Delete Column":
				DeleteColumn();
				break;
			case "Move Left":
				MoveLeft();
				break;
			case "Move Right":
				MoveRight();
				break;
			case "Change Loop Name":
				ChangeLoopName();
				break;
			case "Remove Loop Setup":
				RemoveLoopSetup();
				break;
			case "Cut":
				Cut();
				break;
			case "Copy":
				Copy();
				break;
			case "Paste":
				Paste();
				break;
			case "Paste Last":
				PasteLast();
				break;
			case "Select All":
				SelectAll();
				break;
			case "Deselect All":
				DeselectAll();
				break;
			case "Change For All Tests":
				ApplyForAllTests();
				break;
			}
		}
		catch (Exception ex)
		{
			TraceMessage.Write(ToString(), "contextMenu_ToolClick " + ex.Message, TraceMessageType.Exception);
		}
	}

	private void SelectAll()
	{
		try
		{
			dataGridLoop.EndEdit();
			foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
			{
				item.Cells[1].Value = true;
			}
			dataGridLoop.Update();
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void DeselectAll()
	{
		try
		{
			dataGridLoop.EndEdit();
			foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
			{
				item.Cells[1].Value = false;
			}
			dataGridLoop.Update();
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void Cut()
	{
		try
		{
			if (dataGridLoop.SelectedRows.Count > 0)
			{
				Copy();
				DeleteRow();
			}
			else if (dataGridLoop.SelectedCells.Count > 0)
			{
				Copy();
				dataGridLoop.SelectedCells[0].Value = "";
			}
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void Copy()
	{
		try
		{
			if (dataGridLoop.SelectedRows.Count > 0)
			{
				clipBoard = new ArrayList();
				_ = dataGridLoop.SelectedRows;
				IOrderedEnumerable<DataGridViewRow> orderedEnumerable = from DataGridViewRow row in dataGridLoop.SelectedRows
					orderby row.Index
					select row;
				{
					foreach (DataGridViewRow item in orderedEnumerable)
					{
						ArrayList arrayList = new ArrayList();
						foreach (DataGridViewCell cell in item.Cells)
						{
							arrayList.Add(cell.Value.ToString());
						}
						clipBoard.Add(arrayList);
					}
					return;
				}
			}
			if (dataGridLoop.SelectedCells.Count == 1)
			{
				clipBoard = new ArrayList();
				clipBoard.Add(dataGridLoop.SelectedCells[0].Value.ToString());
			}
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void Paste()
	{
		modified = true;
		try
		{
			if (clipBoard == null)
			{
				return;
			}
			CopyType copyType = CopyType.None;
			if (clipBoard.Count > 0)
			{
				object obj = clipBoard[0];
				if (obj is ArrayList)
				{
					copyType = CopyType.Row;
				}
				else if (obj is string)
				{
					copyType = CopyType.Cell;
				}
			}
			switch (copyType)
			{
			case CopyType.Row:
				if (dataGridLoop.SelectedRows.Count == 1)
				{
					if (((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.BYCOUNT)
					{
						AppMessageDialog.Show("Paste is not a valid operation!\nRemove BY COUNT Loop", "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.UIWarning);
						break;
					}
					int num = dataGridLoop.Rows.IndexOf(dataGridLoop.CurrentRow);
					dataGridLoop.ClearSelection();
					dataGridLoop.Rows.Insert(num, clipBoard.Count);
					int num2 = 0;
					for (int i = num; i < num + clipBoard.Count; i++)
					{
						DataGridViewRow dataGridViewRow = dataGridLoop.Rows[i];
						ArrayList arrayList = (ArrayList)clipBoard[num2];
						int num3 = 0;
						foreach (string item in arrayList)
						{
							dataGridViewRow.Cells[num3].Value = item;
							num3++;
						}
						num2++;
					}
					CreateDropDownAllCells();
					dataGridLoop.CurrentCell = dataGridLoop.Rows[num].Cells[0];
					dataGridLoop.Rows[num].Selected = true;
					LoopChanged = true;
				}
				else if (dataGridLoop.SelectedRows.Count > 1)
				{
					AppMessageDialog.Show("Paste can only be done with 1 row selected.", "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Warning);
				}
				break;
			case CopyType.Cell:
				foreach (DataGridViewCell selectedCell in dataGridLoop.SelectedCells)
				{
					selectedCell.Value = clipBoard[0].ToString();
				}
				dataGridLoop.Update();
				break;
			}
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
		UpdateScenarios();
	}

	private void PasteLast()
	{
		modified = true;
		try
		{
			if (dataGridLoop.SelectedRows.Count == 1)
			{
				if (clipBoard != null)
				{
					if (((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.BYCOUNT)
					{
						AppMessageDialog.Show("Paste is not a valid operation!\nRemove BY COUNT Loop", "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Warning);
					}
					else
					{
						foreach (object item in clipBoard)
						{
							int index = dataGridLoop.Rows.Add();
							DataGridViewRow dataGridViewRow = dataGridLoop.Rows[index];
							int num = 0;
							foreach (string item2 in (ArrayList)item)
							{
								dataGridViewRow.Cells[num].Value = item2;
								num++;
							}
						}
						CreateDropDownAllCells();
						dataGridLoop.Update();
						dataGridLoop.Rows[dataGridLoop.Rows.Count - 1].Selected = true;
						LoopChanged = true;
					}
				}
			}
			else if (dataGridLoop.SelectedRows.Count > 1)
			{
				AppMessageDialog.Show("Paste can only be done with 1 row selected.", "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Warning);
			}
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
		UpdateScenarios();
	}

	private void RemoveLoopSetup()
	{
		if (DialogResult.Yes == AppMessageDialog.Show("Loops will be deleted.\nDo you want to continue?", "QSPR - Loop Setup", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, DialogResult.Yes, MessageDialogType.Warning))
		{
			Reset();
			LoopChanged = true;
		}
	}

	private void AddRow()
	{
		if (IsExceedMaxLoopCount(loopScenario))
		{
			AppMessageDialog.Show("Loop already exceed max loop conditions, please edit loop conditions from above fields.", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
			return;
		}
		modified = true;
		try
		{
			if (dataGridLoop.Columns.Count > 1)
			{
				if (((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.BYCOUNT)
				{
					AppMessageDialog.Show("Adding Loop row is not a valid operation!\nRemove BY COUNT Loop for Adding more Loop rows", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Warning);
				}
				else
				{
					int index = dataGridLoop.Rows.Add();
					DataGridViewRow dataGridViewRow = dataGridLoop.Rows[index];
					dataGridViewRow.Cells[1].Value = true;
					LoopChanged = true;
				}
			}
			else
			{
				AppMessageDialog.Show("No Columns Present for adding Loop rows", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Warning);
			}
			UpdateScenarios();
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void DeleteRow()
	{
		modified = true;
		if (dataGridLoop.Rows.Count > 0)
		{
			int count = dataGridLoop.SelectedRows.Count;
			string text = "";
			if (count > 1)
			{
				text = count + " rows will be deleted";
			}
			else if (count == 1)
			{
				text = "1 row will be deleted";
			}
			DialogResult dialogResult = AppMessageDialog.Show(this, text, "QSPR - Confirm Row Deletion", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, DialogResult.OK, MessageDialogType.Warning);
			if (dialogResult == DialogResult.OK)
			{
				try
				{
					foreach (DataGridViewRow selectedRow in dataGridLoop.SelectedRows)
					{
						dataGridLoop.Rows.RemoveAt(selectedRow.Index);
					}
					LoopRowDeleted = true;
					if (dataGridLoop.Rows.Count == 0)
					{
						Reset();
					}
				}
				catch (Exception ex)
				{
					AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
				}
			}
		}
		UpdateScenarios();
	}

	private void InsertRow()
	{
		modified = true;
		try
		{
			if (dataGridLoop.SelectedRows.Count == 1)
			{
				int index = -1;
				int num = 0;
				if (currentCol != null)
				{
					index = currentCol.Index;
				}
				if (((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.BYCOUNT)
				{
					AppMessageDialog.Show("Adding Loop row not a valid operation!\nRemove BY COUNT Loop for Adding more rows", "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Error);
				}
				else
				{
					num = dataGridLoop.SelectedRows[0].Index;
					dataGridLoop.Rows.Insert(num, new DataGridViewRow());
					dataGridLoop.Rows[num].Selected = true;
					LoopChanged = true;
				}
				CreateDropDownAllCells();
				dataGridLoop.Rows[num].Cells[index].Selected = true;
			}
			else if (dataGridLoop.SelectedRows.Count > 1)
			{
				AppMessageDialog.Show("Insertion is done when only 1 row is selected!", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Warning);
			}
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
		UpdateScenarios();
	}

	private void CreateDropDownAllCells()
	{
		try
		{
			foreach (DataGridViewRow item in (IEnumerable)dataGridLoop.Rows)
			{
				foreach (DataGridViewCell cell in item.Cells)
				{
					int num = cell.ColumnIndex - 4;
					if (num > -1)
					{
						LoopCondition loopCondition = (LoopCondition)loopScenario.LoopConditions[num];
						CreateDropDownCell(cell, loopCondition.TestIndex, loopCondition.ParamName);
					}
				}
			}
		}
		catch
		{
		}
	}

	private void DeleteColumn()
	{
		Cursor.Current = Cursors.WaitCursor;
		modified = true;
		try
		{
			if (currentCol != null)
			{
				DialogResult dialogResult = AppMessageDialog.Show(this, currentCol.HeaderText + " Loop will be DELETED", "Confirm Column Deletion", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, DialogResult.OK, MessageDialogType.Warning);
				if (dialogResult == DialogResult.OK)
				{
					int index = currentCol.Index;
					dataGridLoop.Columns.RemoveAt(index);
					if (index != -1)
					{
						if (((LoopCondition)loopScenario.LoopConditions[0]).LoopType == LoopTypes.BYSEQUENCE)
						{
							string testIndex = ((LoopCondition)loopScenario.LoopConditions[index - 4]).TestIndex;
							string[] indexList = testIndex.Split(',');
							ResetDisabledNodes(indexList);
						}
						loopScenario.DeleteLoopCondition(index - 4);
						ResetTextBoxes();
					}
				}
			}
			if (dataGridLoop.Columns.Count == 4)
			{
				Reset();
			}
			currentCol = null;
			UpdateScenarios();
			if (dataGridLoop.Rows.Count > 0)
			{
				dataGridLoop.Rows[0].Cells[0].Selected = true;
				dataGridLoop.Rows[0].Cells[4].Selected = true;
			}
			if (clipBoard != null && clipBoard.Count > 0)
			{
				object obj = clipBoard[0];
				if (obj is ArrayList)
				{
					clipBoard = null;
				}
			}
			LoopChanged = true;
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
		Cursor.Current = Cursors.Default;
	}

	private void MoveLeft()
	{
		Cursor.Current = Cursors.WaitCursor;
		modified = true;
		try
		{
			if (currentCol != null)
			{
				int index = currentCol.Index;
				if (index != -1)
				{
					loopScenario.MoveConditionLeft(index - 4);
					UpdateGridFromIndex(index - 1);
					ResetTextBoxes();
				}
				dataGridLoop.Rows[0].Cells[index - 1].Selected = true;
				currentCol = dataGridLoop.Rows[0].Cells[index - 1].OwningColumn;
				if (clipBoard != null && clipBoard.Count > 0)
				{
					object obj = clipBoard[0];
					if (obj is ArrayList)
					{
						clipBoard = null;
					}
				}
				LoopChanged = true;
			}
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Move left", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
		Cursor.Current = Cursors.Default;
	}

	private void MoveRight()
	{
		Cursor.Current = Cursors.WaitCursor;
		modified = true;
		try
		{
			if (currentCol != null)
			{
				int index = currentCol.Index;
				if (index != -1)
				{
					loopScenario.MoveConditionRight(index - 4);
					UpdateGridFromIndex(index);
					ResetTextBoxes();
				}
				dataGridLoop.Rows[0].Cells[index + 1].Selected = true;
				currentCol = dataGridLoop.Rows[0].Cells[index + 1].OwningColumn;
				if (clipBoard != null && clipBoard.Count > 0)
				{
					object obj = clipBoard[0];
					if (obj is ArrayList)
					{
						clipBoard = null;
					}
				}
				LoopChanged = true;
			}
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Move right", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
		Cursor.Current = Cursors.Default;
	}

	private bool UpdateGridFromIndex(int Index)
	{
		try
		{
			while (dataGridLoop.Columns.Count > Index)
			{
				dataGridLoop.Columns.RemoveAt(Index);
			}
			for (int i = Index - 4; i < loopScenario.Count; i++)
			{
				LoopCondition loopCondition = (LoopCondition)loopScenario.LoopConditions[i];
				AppendColumn(loopCondition, loopCondition.LoopValues);
			}
			AddRowID();
			return true;
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - UpdateGridFromIndex", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
			return false;
		}
	}

	private void ChangeLoopName()
	{
		try
		{
			modified = true;
			if (dataGridLoop.Columns.Count > 4)
			{
				lblNewColumnName.Visible = true;
				txtColumnName.Visible = true;
				txtColumnName.Focus();
				string loopName = ((LoopCondition)loopScenario.LoopConditions[currentCol.Index - 4]).LoopName;
				if (loopName.EndsWith("UL") || loopName.EndsWith("LL"))
				{
					txtColumnName.Text = loopName.Substring(0, loopName.Length - 2);
				}
				else
				{
					txtColumnName.Text = loopName;
				}
				oldColumnName = loopName;
			}
			else
			{
				AppMessageDialog.Show("No Columns Present!", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Information);
			}
			userEdited = false;
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void ApplyForAllTests()
	{
		try
		{
			modified = true;
			if (dataGridLoop.Columns.Count > 4)
			{
				((LoopCondition)loopScenario.LoopConditions[currentCol.Index - 4]).TestName = "ALLTests";
				AppMessageDialog.Show("This loop has been updated for all tests. ", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Information);
			}
			else
			{
				AppMessageDialog.Show("No Columns Present!", "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Information);
			}
			userEdited = false;
		}
		catch (Exception ex)
		{
			AppMessageDialog.Show("ERROR: " + ex.Message, "QSPR - Loop Setup", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Exception);
		}
	}

	private void btnBreakCondition_Click(object sender, EventArgs e)
	{
		try
		{
			ScenarioConditionDialog scenarioConditionDialog = new ScenarioConditionDialog();
			scenarioConditionDialog.LoopFolder = loopFolder;
			if (loopScenario.Condition != null)
			{
				scenarioConditionDialog.ScenarioConditionMgr = loopScenario.Condition.Clone();
			}
			if (scenarioConditionDialog.ShowDialog(WpfToWin32Window.GetCurrentWin32Window()) == DialogResult.OK)
			{
				loopScenario.Condition = scenarioConditionDialog.ScenarioConditionMgr;
				if (loopScenario.Condition.IsValid)
				{
					pictureBoxBreak.Visible = true;
				}
				else
				{
					pictureBoxBreak.Visible = false;
				}
			}
		}
		catch
		{
		}
	}

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

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

	private void btnLoadFile_Click(object sender, EventArgs e)
	{
		try
		{
			if (chkFileNameFromGV.Checked)
			{
				string text = txtFilename.Text;
				txtFilename.Text = ShowGVDialog(txtFilename.Text);
				if (text != txtFilename.Text)
				{
					userEdited = true;
				}
				return;
			}
			OpenFileDialog openFileDialog = new OpenFileDialog();
			openFileDialog.Filter = "CSV (Comma delimited) (*.csv)|*.csv|Text (Tab delimited)(*.txt)|*.txt|All files (*.*)|*.*";
			openFileDialog.FilterIndex = 1;
			if (GetSelectedRBValue(groupBoxFileType) == "Tab")
			{
				openFileDialog.FilterIndex = 2;
			}
			if (openFileDialog.ShowDialog() == DialogResult.OK)
			{
				txtFilename.Text = openFileDialog.FileName;
				userEdited = true;
			}
		}
		catch
		{
		}
	}

	private void btnSelectCountGV_Click(object sender, EventArgs e)
	{
		if (chkLoopCountFromGV.Checked)
		{
			string text = cmbLoopCount.Text;
			cmbLoopCount.Text = ShowGVDialog(cmbLoopCount.Text);
			if (cmbLoopCount.Text != text)
			{
				userEdited = true;
			}
		}
	}

	private void btnSelectTimeGV_Click(object sender, EventArgs e)
	{
		if (chkLoopTimeFromGV.Checked)
		{
			string text = timeTxt.Text;
			timeTxt.Text = ShowGVDialog(timeTxt.Text);
			if (timeTxt.Text != text)
			{
				userEdited = true;
			}
		}
	}

	private string ShowGVDialog(string currentSelection)
	{
		QTMGlobalVariablesDialog qTMGlobalVariablesDialog = new QTMGlobalVariablesDialog();
		try
		{
			qTMGlobalVariablesDialog.AssociatedObjectName = "Getting global variable";
		}
		catch
		{
		}
		qTMGlobalVariablesDialog.CurrentSelection = currentSelection;
		if (qTMGlobalVariablesDialog.ShowDialog() == DialogResult.OK)
		{
			return qTMGlobalVariablesDialog.CurrentSelection;
		}
		return currentSelection;
	}

	private void chkListFromFile_CheckedChanged(object sender, EventArgs e)
	{
		try
		{
			if (chkListFromFile.Checked && chkListFromFile.Enabled)
			{
				groupBoxFileType.Enabled = true;
				btnLoadFile.Enabled = true;
				txtFilename.Enabled = true;
				cmbFileColumnName.Enabled = true;
				chkFileNameFromGV.Enabled = true;
			}
			else
			{
				groupBoxFileType.Enabled = false;
				btnLoadFile.Enabled = false;
				txtFilename.Enabled = false;
				cmbFileColumnName.Enabled = false;
				chkFileNameFromGV.Enabled = false;
			}
			userEdited = true;
		}
		catch
		{
		}
	}

	private void cmbFileColumnName_DropDown(object sender, EventArgs e)
	{
		try
		{
			Hashtable hashtable = new Hashtable();
			for (int i = 0; i < cmbFileColumnName.Items.Count; i++)
			{
				hashtable[(string)cmbFileColumnName.Items[i]] = (string)cmbFileColumnName.Items[i];
			}
			string text = txtFilename.Text.Trim();
			if (chkFileNameFromGV.Checked)
			{
				if (!QTMGlobalVariable.GetGlobalVariable(text, out var gvValue) || string.IsNullOrEmpty(gvValue) || !File.Exists(gvValue))
				{
					AppMessageDialog.Show($"Global Variable: {text.Trim()} used for the CSV file name doesn't exist or the value is invalid.  \nPlease add or update this global variable with a valid CSV file name.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
					return;
				}
				text = gvValue;
			}
			if (text.Length > 0)
			{
				text = PathUtils.ConvertToAbsolute(LoopFolder.Root.Scheduler.GlobalStatus.TreeName, text);
				if (!File.Exists(text))
				{
					AppMessageDialog.Show("File " + text + " not found.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
					cmbFileColumnName.Items.Clear();
					return;
				}
				ArrayList rowsFromFile = LoopCondition.GetRowsFromFile(text, LoopFolder.Root.Scheduler.GlobalStatus.TreeName);
				char c = ',';
				if (GetSelectedRBValue(groupBoxFileType) == "Tab")
				{
					c = '\t';
				}
				string[] array = ((string)rowsFromFile[0]).Split(c);
				bool flag = false;
				if (array.Length != hashtable.Count)
				{
					flag = true;
				}
				if (!flag)
				{
					string[] array2 = array;
					foreach (string text2 in array2)
					{
						if (!hashtable.ContainsKey(text2.Trim()))
						{
							flag = true;
						}
					}
				}
				if (flag)
				{
					cmbFileColumnName.Items.Clear();
					string[] array3 = array;
					foreach (string text3 in array3)
					{
						cmbFileColumnName.Items.Add(text3.Trim());
					}
				}
			}
			else if (text.Length == 0)
			{
				AppMessageDialog.Show("File Name cannot be empty.", "QSPR - Loop Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, DialogResult.OK, MessageDialogType.Error);
				cmbFileColumnName.Items.Clear();
			}
		}
		catch
		{
		}
	}

	private void txtFilename_MouseDown(object sender, MouseEventArgs e)
	{
		userEdited = true;
	}

	private void cmbFileColumnName_TextChanged(object sender, EventArgs e)
	{
		userEdited = true;
	}

	private void radioFileType_ValueChanged(object sender, EventArgs e)
	{
		userEdited = true;
	}

	private void cmbFileColumnName_SelectedIndexChanged(object sender, EventArgs e)
	{
		userEdited = true;
	}

	private void chkIgnoreIntermediateResults_CheckedChanged(object sender, EventArgs e)
	{
		userEdited = true;
	}

	private void ultraButtonEditGV_Click(object sender, EventArgs e)
	{
		QTMGlobalVariablesDialog qTMGlobalVariablesDialog = new QTMGlobalVariablesDialog();
		if (qTMGlobalVariablesDialog.ShowDialog() == DialogResult.OK && treeTest.SelectedNode != null && string.Compare(treeTest.SelectedNode.Text, "Global Variables") == 0)
		{
			string text = "";
			if (treeParam.SelectedNode != null)
			{
				text = treeParam.SelectedNode.Text;
			}
			UpdateParamListWithSelectedTest(treeTest.Nodes[0]);
			if (currentCol != null)
			{
				ColumnChanged(currentCol.Name, currentCol.Index);
			}
			else if (!string.IsNullOrEmpty(text))
			{
				HighlightGV(treeTest.Nodes[0], text);
			}
		}
	}

	private void chkFileNameFromGV_CheckedChanged(object sender, EventArgs e)
	{
		if (chkFileNameFromGV.Checked)
		{
			lblFileName.Text = "File/GV Name";
		}
		else
		{
			lblFileName.Text = "File Name";
		}
	}

	private void btnApplyAllTests_Click(object sender, EventArgs e)
	{
		ApplyForAllTests();
	}

	private bool IsOKToCloseDialog()
	{
		if (modified || userEdited)
		{
			DialogResult dialogResult = AppMessageDialog.Show("All unsaved information will be lost", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, DialogResult.OK, MessageDialogType.Warning);
			if (dialogResult == DialogResult.OK)
			{
				return true;
			}
			return false;
		}
		return true;
	}

	private void LoopSetup_FormClosing(object sender, FormClosingEventArgs e)
	{
		if (!okPressed && !cancelPressed && !IsOKToCloseDialog())
		{
			e.Cancel = true;
		}
	}

	private void chkLoopCountFromGV_CheckedChanged(object sender, EventArgs e)
	{
		if (chkLoopCountFromGV.Checked)
		{
			cmbLoopCount.Enabled = false;
			btnSelectCountGV.Enabled = true;
		}
		else
		{
			cmbLoopCount.Enabled = true;
			btnSelectCountGV.Enabled = false;
		}
		userEdited = true;
	}

	private void chkLoopTimeFromGV_CheckedChanged(object sender, EventArgs e)
	{
		if (chkLoopTimeFromGV.Checked)
		{
			if (!panelLoopvalue.Controls.Contains(timeTxt))
			{
				panelLoopvalue.Controls.Add(timeTxt);
			}
			numericUpDownTime.Visible = false;
			timeTxt.Size = numericUpDownTime.Size;
			timeTxt.Location = numericUpDownTime.Location;
			timeTxt.Enabled = false;
			timeTxt.Visible = true;
			btnSelectTimeGV.Enabled = true;
		}
		else
		{
			if (panelLoopvalue.Controls.Contains(timeTxt))
			{
				panelLoopvalue.Controls.Remove(timeTxt);
			}
			numericUpDownTime.Visible = true;
			timeTxt.Visible = false;
			btnSelectTimeGV.Enabled = false;
		}
		userEdited = true;
	}

	private void chkBoxSuppressWarnings_CheckedChanged(object sender, EventArgs e)
	{
		userEdited = true;
		modified = true;
	}

	private void btnGenPermutations_Click(object sender, EventArgs e)
	{
		CreateSequenceLoopIfValid();
	}

	private void DisableSelectedNodes()
	{
		if (base.InvokeRequired)
		{
			BeginInvoke((MethodInvoker)delegate
			{
				DisableSelectedNodes();
			});
			return;
		}
		List<TreeNode> selectedNodes = GetSelectedNodes();
		foreach (TreeNode item in selectedNodes)
		{
			if (item.NodeFont == null)
			{
				item.NodeFont = treeTest.Font;
			}
			item.ForeColor = Color.Red;
			item.NodeFont = new Font(item.NodeFont, FontStyle.Bold);
			item.Text = item.Text;
			_disabledNodes.Add(item);
		}
		treeTest.Refresh();
	}

	private void ResetDisabledNodes(string[] indexList = null)
	{
		if (base.InvokeRequired)
		{
			BeginInvoke((MethodInvoker)delegate
			{
				ResetDisabledNodes(indexList);
			});
			return;
		}
		ArrayList nodesToRemove = new ArrayList();
		foreach (TreeNode disabledNode in _disabledNodes)
		{
			if (indexList == null || indexList.Contains(((BaseTest)disabledNode.Tag).Index))
			{
				disabledNode.ForeColor = Color.Black;
				if (disabledNode.NodeFont.Bold)
				{
					disabledNode.NodeFont = new Font(disabledNode.NodeFont, FontStyle.Regular);
				}
				nodesToRemove.Add(disabledNode);
			}
		}
		_disabledNodes.RemoveAll((TreeNode node) => nodesToRemove.Contains(node));
		if (_disabledNodes.Count == 0)
		{
			treeParam.Enabled = true;
			btnApplyAllTests.Visible = true;
		}
	}

	private void moveToToolStripMenuItem_Click(object sender, EventArgs e)
	{
	}

	private void ClearCheckedNodes()
	{
		List<TreeNode> selectedNodes = GetSelectedNodes();
		foreach (TreeNode item in selectedNodes)
		{
			item.Checked = false;
		}
	}

	private void radioSequence_CheckedChanged(object sender, EventArgs e)
	{
		if (radioSequence.Checked)
		{
			txtLoopName.Text = "Sequence";
			btnGenPermutations.Enabled = true;
			treeTest.CheckBoxes = true;
			treeTest.ExpandAll();
			chkIgnoreIntermediateResults.Visible = false;
			btnInputChange.Enabled = false;
			btnULChange.Enabled = false;
			btnLLChange.Enabled = false;
			RemoveGvNode();
			btnBreakCondition.Enabled = false;
			btnGenPermutations.Enabled = false;
		}
		else
		{
			btnGenPermutations.Enabled = false;
			treeTest.CheckBoxes = false;
			treeTest.ExpandAll();
			chkIgnoreIntermediateResults.Visible = true;
			LoadGV();
			btnBreakCondition.Enabled = true;
		}
	}

	private void CreateSequenceLoopIfValid()
	{
		if (loopScenario.LoopConditions.Count > 0 && (loopScenario.LoopConditions[0] as LoopCondition).LoopType != LoopTypes.BYSEQUENCE)
		{
			AppMessageDialog.Show("Another loop type has been selected, you cannot mix loop types.", "Error setting loop", MessageBoxButtons.OK, DialogResult.OK, MessageDialogType.Error);
			return;
		}
		List<TreeNode> selectedNodes = GetSelectedNodes();
		if (selectedNodes.Count < 2)
		{
			AppMessageDialog.Show("The number of selected tests must be greater than 1 for sequence loops.", "Error setting loop", MessageBoxButtons.OK, DialogResult.OK, MessageDialogType.Error);
			return;
		}
		if (selectedNodes.Count > 6)
		{
			AppMessageDialog.Show("Maximum test selection has been exceeded. The number of selected tests must not exceed 6 for sequence loops.", "Error setting loop", MessageBoxButtons.OK, DialogResult.OK, MessageDialogType.Error);
			return;
		}
		if (!IsValidSequenceSelection(selectedNodes))
		{
			AppMessageDialog.Show("Invalid test selections made. Only consecutive tests under the same parent folder can be selected.", "Error setting loop", MessageBoxButtons.OK, DialogResult.OK, MessageDialogType.Error);
			return;
		}
		try
		{
			Cursor.Current = Cursors.WaitCursor;
			LoopCondition loopCondition = new LoopCondition();
			bool flag = true;
			int iIndex = -1;
			int num = 1;
			List<TreeNode> selectedNodes2 = GetSelectedNodes();
			int[] list = Enumerable.Range(0, selectedNodes2.Count).ToArray();
			IEnumerable<IEnumerable<int>> source = Permutation.Permute(list);
			num = source.Count();
			foreach (LoopCondition loopCondition2 in loopScenario.LoopConditions)
			{
				if (loopCondition2.LoopValues.Count > num)
				{
					num = loopCondition2.LoopValues.Count;
				}
			}
			loopCondition.LoopType = LoopTypes.BYSEQUENCE;
			loopCondition.LoopName = ScenarioHandler.GetUniqueLoopName(loopScenario, "Sequence");
			LoopScenarioValues loopScenarioValues = new LoopScenarioValues();
			loopScenarioValues.LoopConditions.Add(loopCondition);
			string[] value = selectedNodes2.Select((TreeNode node) => node.Text).ToArray();
			string[] value2 = selectedNodes2.Select((TreeNode node) => ((BaseTest)node.Tag).Index).ToArray();
			loopCondition.TestName = string.Join("_;_", value);
			loopCondition.TestIndex = string.Join(",", value2);
			for (int i = 0; i < num; i++)
			{
				if (i < source.Count())
				{
					IEnumerable<int> source2 = source.ToArray()[i];
					int[] values = source2.ToArray();
					if (i == 0)
					{
						loopCondition.LoopValuesAsString = string.Join("_", values);
					}
					else
					{
						loopCondition.LoopValuesAsString = loopCondition.LoopValuesAsString + "," + string.Join("_", values);
					}
				}
				else
				{
					loopCondition.LoopValuesAsString += ",";
				}
			}
			if (flag && loopScenario.AddLoopCondition(loopCondition, ref iIndex))
			{
				AppendColumn(loopCondition, loopCondition.LoopValues);
				try
				{
					dataGridLoop.Update();
				}
				catch (Exception ex)
				{
					AppMessageDialog.Show(this, ex.Message, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Exception);
				}
				dataGridLoop.CurrentCell = dataGridLoop.Rows[0].Cells[dataGridLoop.Columns.Count - 1];
			}
			else
			{
				if (iIndex == -1)
				{
					AppMessageDialog.Show("Loop name Already exists", "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, DialogResult.OK, MessageDialogType.Warning);
					return;
				}
				int index = dataGridLoop.Columns[loopCondition.LoopName].Index;
				loopScenario.LoopConditions[index - 4] = loopCondition;
				UpdateLoopColumn(loopCondition, loopCondition.LoopValues);
				dataGridLoop.Update();
				if (currentCol != null)
				{
					currentCol.HeaderCell.Style.BackColor = Color.FromArgb(233, 242, 199);
					currentCol.HeaderCell.Style.ForeColor = Color.Black;
				}
				currentCol = dataGridLoop.Rows[0].Cells[index].OwningColumn;
				currentCol.HeaderCell.Style.BackColor = Color.Black;
				currentCol.HeaderCell.Style.ForeColor = Color.White;
				ColumnChanged(loopCondition.LoopName, index);
			}
			AddRowID();
			LoopChanged = true;
			warningShownForListFromFile = false;
			DisableSelectedNodes();
			btnGenPermutations.Enabled = false;
			treeParam.Enabled = false;
			RemoveGvNode();
			btnApplyAllTests.Visible = false;
		}
		catch (Exception ex2)
		{
			TraceMessage.Write(ToString(), "CreateSequenceLoopIfValid " + ex2.Message, TraceMessageType.Exception);
		}
		finally
		{
			Cursor.Current = Cursors.Default;
		}
	}

	private bool IsValidSequenceSelection(List<TreeNode> checkedNodes)
	{
		TreeNode treeNode = checkedNodes[0].Parent;
		TreeNode treeNode2 = null;
		foreach (TreeNode checkedNode in checkedNodes)
		{
			if (checkedNode.Parent != treeNode)
			{
				return false;
			}
			if (treeNode2 != null && checkedNode.PrevNode != treeNode2)
			{
				return false;
			}
			treeNode2 = checkedNode;
		}
		return true;
	}
}
