using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using QsprMiscShared.Config;

namespace QC.QTMApplication;

public class SuiteParamGvSetup : Form
{
	private IContainer components;

	private DataGridView dataGridView1;

	private Button buttonCancel;

	private Button buttonOk;

	private Button btnAddItem;

	private DataGridViewComboBoxColumn ColumnType;

	private DataGridViewTextBoxColumn ColumnTestName;

	private DataGridViewTextBoxColumn ColumnName;

	private DataGridViewTextBoxColumn ColumnGVName;

	private Button btnDeleteItem;

	public List<SuiteParamGV> SuiteParamGvs
	{
		get
		{
			List<SuiteParamGV> list = new List<SuiteParamGV>();
			foreach (DataGridViewRow item in (IEnumerable)dataGridView1.Rows)
			{
				SuiteParamGV suiteParamGV = new SuiteParamGV();
				suiteParamGV.Type = SuiteValueType.LoopCondition;
				if (item.Cells[0].Value.ToString() == "OutputParam")
				{
					suiteParamGV.Type = SuiteValueType.OutputParam;
				}
				suiteParamGV.TestName = item.Cells[1].Value.ToString();
				suiteParamGV.ParameterName = item.Cells[2].Value.ToString();
				suiteParamGV.GlobalVariableName = item.Cells[3].Value.ToString();
				list.Add(suiteParamGV);
			}
			return list;
		}
	}

	public SuiteParamGvSetup(List<SuiteParamGV> suiteParamGvs)
	{
		InitializeComponent();
		foreach (SuiteParamGV suiteParamGv in suiteParamGvs)
		{
			int index = dataGridView1.Rows.Add();
			dataGridView1.Rows[index].Cells[0].Value = suiteParamGv.Type.ToString();
			dataGridView1.Rows[index].Cells[1].Value = suiteParamGv.TestName.ToString();
			dataGridView1.Rows[index].Cells[2].Value = suiteParamGv.ParameterName.ToString();
			dataGridView1.Rows[index].Cells[3].Value = suiteParamGv.GlobalVariableName.ToString();
		}
		if (dataGridView1.Rows.Count == 0)
		{
			dataGridView1.Rows.Add();
		}
	}

	private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
	{
		dataGridView1.Rows[e.RowIndex].Cells[0].Value = "OutputParam";
		dataGridView1.Rows[e.RowIndex].Cells[1].Value = "ANY";
		dataGridView1.Rows[e.RowIndex].Cells[2].Value = "";
		dataGridView1.Rows[e.RowIndex].Cells[3].Value = "";
	}

	private void btnAddItem_Click(object sender, EventArgs e)
	{
		dataGridView1.Rows.Add();
	}

	private void btnDeleteItem_Click(object sender, EventArgs e)
	{
		foreach (DataGridViewRow selectedRow in dataGridView1.SelectedRows)
		{
			dataGridView1.Rows.Remove(selectedRow);
		}
	}

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

	private void InitializeComponent()
	{
		this.dataGridView1 = new System.Windows.Forms.DataGridView();
		this.buttonCancel = new System.Windows.Forms.Button();
		this.buttonOk = new System.Windows.Forms.Button();
		this.btnAddItem = new System.Windows.Forms.Button();
		this.ColumnType = new System.Windows.Forms.DataGridViewComboBoxColumn();
		this.ColumnTestName = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.ColumnName = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.ColumnGVName = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.btnDeleteItem = new System.Windows.Forms.Button();
		((System.ComponentModel.ISupportInitialize)this.dataGridView1).BeginInit();
		base.SuspendLayout();
		this.dataGridView1.AllowUserToAddRows = false;
		this.dataGridView1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
		this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.dataGridView1.Columns.AddRange(this.ColumnType, this.ColumnTestName, this.ColumnName, this.ColumnGVName);
		this.dataGridView1.Location = new System.Drawing.Point(12, 12);
		this.dataGridView1.Name = "dataGridView1";
		this.dataGridView1.Size = new System.Drawing.Size(551, 153);
		this.dataGridView1.TabIndex = 0;
		this.dataGridView1.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(dataGridView1_RowsAdded);
		this.buttonCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
		this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
		this.buttonCancel.Location = new System.Drawing.Point(488, 180);
		this.buttonCancel.Name = "buttonCancel";
		this.buttonCancel.Size = new System.Drawing.Size(75, 23);
		this.buttonCancel.TabIndex = 1;
		this.buttonCancel.Text = "&Cancel";
		this.buttonCancel.UseVisualStyleBackColor = true;
		this.buttonOk.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
		this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK;
		this.buttonOk.Location = new System.Drawing.Point(407, 180);
		this.buttonOk.Name = "buttonOk";
		this.buttonOk.Size = new System.Drawing.Size(75, 23);
		this.buttonOk.TabIndex = 2;
		this.buttonOk.Text = "&OK";
		this.buttonOk.UseVisualStyleBackColor = true;
		this.btnAddItem.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
		this.btnAddItem.Location = new System.Drawing.Point(13, 180);
		this.btnAddItem.Name = "btnAddItem";
		this.btnAddItem.Size = new System.Drawing.Size(75, 23);
		this.btnAddItem.TabIndex = 3;
		this.btnAddItem.Text = "&Add item";
		this.btnAddItem.UseVisualStyleBackColor = true;
		this.btnAddItem.Click += new System.EventHandler(btnAddItem_Click);
		this.ColumnType.HeaderText = "Type";
		this.ColumnType.Items.AddRange("LoopCondition", "OutputParam");
		this.ColumnType.Name = "ColumnType";
		this.ColumnType.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.ColumnType.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
		this.ColumnType.ToolTipText = "The type of SUITE data to save";
		this.ColumnTestName.HeaderText = "TestName";
		this.ColumnTestName.Name = "ColumnTestName";
		this.ColumnTestName.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.ColumnTestName.ToolTipText = "Optional: Name of the SUITE test whose data will be saved to a global, if blank any test with matching data will be saved to a global";
		this.ColumnName.HeaderText = "Name";
		this.ColumnName.Name = "ColumnName";
		this.ColumnName.ToolTipText = "Required: The name of the loop condition or output parameter to save to a global";
		this.ColumnGVName.HeaderText = "GlobalVariable";
		this.ColumnGVName.Name = "ColumnGVName";
		this.ColumnGVName.ToolTipText = "Required: The name of the Global Variable used to store the data's value";
		this.btnDeleteItem.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
		this.btnDeleteItem.Location = new System.Drawing.Point(94, 180);
		this.btnDeleteItem.Name = "btnDeleteItem";
		this.btnDeleteItem.Size = new System.Drawing.Size(75, 23);
		this.btnDeleteItem.TabIndex = 4;
		this.btnDeleteItem.Text = "&Delete item";
		this.btnDeleteItem.UseVisualStyleBackColor = true;
		this.btnDeleteItem.Click += new System.EventHandler(btnDeleteItem_Click);
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(575, 215);
		base.ControlBox = false;
		base.Controls.Add(this.btnDeleteItem);
		base.Controls.Add(this.btnAddItem);
		base.Controls.Add(this.buttonOk);
		base.Controls.Add(this.buttonCancel);
		base.Controls.Add(this.dataGridView1);
		this.MinimumSize = new System.Drawing.Size(420, 207);
		base.Name = "SuiteParamGvSetup";
		this.Text = "Select Suite Data to Save to Global variables";
		((System.ComponentModel.ISupportInitialize)this.dataGridView1).EndInit();
		base.ResumeLayout(false);
	}
}
