using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using QC.GlobalVariableManager;
using QC.QsprTestObjects.Parameters;
using QC.QsprTestObjects.Tests.Base;
using QC.QTMInterface;

namespace QC.QsprTestObjects.Metadata;

public class MetadataDialog : Form
{
	private const int FOLDER_IMAGE = 0;

	private const int SCENARIO_IMAGE = 0;

	private const int FOLDER_SELECTED_IMAGE = 1;

	private const int SCENARIO_SELECTED_IMAGE = 1;

	private const int ROOT_IMAGE = 2;

	private const int TEST_IMAGE = 3;

	private const int INPUT_IMAGE = 4;

	private const int OUTPUT_IMAGE = 5;

	private const int TYPE_INDEX_TEST_PARAM = 0;

	private const int TYPE_INDEX_GLOBAL_VAR = 1;

	private const string SAVE_BUTTON_TEXT = "Save &Item";

	private const string UPDATE_BUTTON_TEXT = "Update &Item";

	private BaseTest currentSelectedTest;

	private MetadataItem metaItemToModify;

	private Hashtable testNodeCollection = new Hashtable();

	private bool currentNodeFound;

	private string currentSelectedIndex = "";

	private MetadataItems metadata;

	private bool currentItemAdded;

	private IContainer components;

	private DataGridView gridMetadataItems;

	private DataGridViewTextBoxColumn colCondition;

	private DataGridViewTextBoxColumn colName;

	private DataGridViewTextBoxColumn colType;

	private DataGridViewTextBoxColumn colSource;

	private Button buttonRemove;

	private Button buttonOk;

	private Button buttonCancel;

	private GroupBox groupBox1;

	private GroupBox groupBox2;

	private Label label3;

	private ComboBox comboBoxType;

	private TextBox textBoxName;

	private Label label2;

	private TreeView treeViewTests;

	private Panel panelNameType;

	private Panel panelValueSelection;

	private TreeView treeViewParameter;

	private Button buttonSave;

	private ComboBox comboBoxIndex;

	private Label labelIndex;

	private Button buttonNew;

	private ImageList imageList;

	private Button buttonEditGVs;

	private Button buttonRemoveAll;

	public MetadataItems Metadata
	{
		get
		{
			return metadata;
		}
		set
		{
			metadata = value;
		}
	}

	public MetadataDialog(BaseTest currentTest)
	{
		InitializeComponent();
		currentSelectedTest = currentTest;
		currentSelectedIndex = currentTest.Index;
		Text = Text + " - " + currentTest.Properties.TestName;
	}

	private void MetadataDialog_Load(object sender, EventArgs e)
	{
		LoadTestTree();
		LoadMetaItemGrid();
		if (metadata != null && gridMetadataItems.Rows.Count > 0)
		{
			if (metadata.Items[0].Type == MetadataItem.MetadataType.TestParameter && metadata.Items[0].TestIndex != null)
			{
				treeViewTests.SelectedNode = testNodeCollection[metadata.Items[0].TestIndex] as TreeNode;
			}
			treeViewParameter.SelectedNode = treeViewParameter.Nodes[metadata.Items[0].SourceName];
		}
	}

	private void LoadTestTree()
	{
		RootTest root = currentSelectedTest.Root;
		TreeNode treeNode = treeViewTests.Nodes.Add("", root.Properties.TestName);
		treeNode.Tag = root;
		treeNode.ImageIndex = 2;
		treeNode.SelectedImageIndex = 2;
		testNodeCollection.Add(root.Index, treeNode);
		LoadTree(root, treeNode);
	}

	private void LoadTree(FolderTest folder, TreeNode parentNode)
	{
		try
		{
			foreach (BaseTest test in folder.TestList)
			{
				if (currentNodeFound)
				{
					break;
				}
				TreeNode treeNode = parentNode.Nodes.Add("", test.Properties.TestName);
				treeNode.Tag = test;
				if (test is FolderTest)
				{
					treeNode.ImageIndex = 0;
					treeNode.SelectedImageIndex = 1;
				}
				else
				{
					treeNode.ImageIndex = 3;
					treeNode.SelectedImageIndex = 3;
				}
				testNodeCollection.Add(test.Index, treeNode);
				if (currentSelectedIndex == test.Index)
				{
					currentNodeFound = true;
					treeNode.ForeColor = Color.Gray;
				}
				if (currentNodeFound)
				{
					break;
				}
				if (test is FolderTest)
				{
					LoadTree((FolderTest)test, treeNode);
					FolderTest folderTest = test as FolderTest;
					if (folderTest.FolderProperties.Expanded)
					{
						treeNode.Expand();
					}
				}
			}
		}
		catch
		{
		}
	}

	private void LoadMetaItemGrid()
	{
		gridMetadataItems.Rows.Clear();
		if (Metadata == null)
		{
			return;
		}
		foreach (MetadataItem item in Metadata.Items)
		{
			string text = "";
			if (item.Type == MetadataItem.MetadataType.TestParameter)
			{
				BaseTest baseTest = currentSelectedTest.Root.FindTest(item.TestIndex);
				if (baseTest != null)
				{
					text = $"Test: {baseTest.Properties.TestName}, Parameter: {item.SourceName}";
				}
			}
			else if (item.Type == MetadataItem.MetadataType.GlobalVariable)
			{
				text = $"Global Variable: {item.SourceName}";
			}
			gridMetadataItems.Rows.Add(item, item.Name, item.Type, text);
		}
	}

	private void LoadEditControls()
	{
		if (metaItemToModify == null)
		{
			textBoxName.Text = "";
			comboBoxType.SelectedIndex = -1;
			treeViewTests.SelectedNode = null;
			treeViewParameter.Nodes.Clear();
			comboBoxIndex.SelectedIndex = -1;
			comboBoxIndex.Enabled = false;
			buttonEditGVs.Enabled = false;
			return;
		}
		textBoxName.Text = metaItemToModify.Name;
		if (metaItemToModify.Type == MetadataItem.MetadataType.TestParameter)
		{
			TreeNode selectedNode = (TreeNode)testNodeCollection[metaItemToModify.TestIndex];
			treeViewTests.SelectedNode = selectedNode;
			comboBoxType.SelectedIndex = 0;
			treeViewParameter.SelectedNode = treeViewParameter.Nodes[metaItemToModify.SourceName];
			comboBoxIndex.SelectedIndex = metaItemToModify.ArrayIndex;
			buttonEditGVs.Enabled = false;
		}
		else if (metaItemToModify.Type == MetadataItem.MetadataType.GlobalVariable)
		{
			treeViewTests.SelectedNode = null;
			treeViewTests.Enabled = false;
			comboBoxType.SelectedIndex = 1;
			comboBoxIndex.SelectedIndex = -1;
			treeViewParameter.SelectedNode = treeViewParameter.Nodes[metaItemToModify.SourceName];
			treeViewParameter.Focus();
			buttonEditGVs.Enabled = true;
		}
	}

	private void LoadParamTree()
	{
		comboBoxIndex.SelectedIndex = -1;
		comboBoxIndex.Enabled = false;
		buttonEditGVs.Enabled = false;
		if (comboBoxType.SelectedIndex == 0)
		{
			LoadAsParamTree();
		}
		else if (comboBoxType.SelectedIndex == 1)
		{
			LoadAsGlobalTree();
		}
	}

	private void LoadAsParamTree()
	{
		treeViewParameter.Nodes.Clear();
		if (treeViewTests.SelectedNode == null || !(treeViewTests.SelectedNode.Tag is BaseTest baseTest))
		{
			return;
		}
		foreach (ParameterCls parameter in baseTest.Properties.Parameters)
		{
			switch (parameter.Type)
			{
			case IOType.Input:
				if (parameter.IsInput)
				{
					TreeNode treeNode2 = treeViewParameter.Nodes.Add(parameter.Name, parameter.Name);
					treeNode2.Tag = parameter;
					treeNode2.ImageIndex = 4;
					treeNode2.SelectedImageIndex = 4;
				}
				break;
			case IOType.Output:
				if (parameter.IsOutput)
				{
					TreeNode treeNode = treeViewParameter.Nodes.Add(parameter.Name, parameter.Name);
					treeNode.Tag = parameter;
					treeNode.ImageIndex = 5;
					treeNode.SelectedImageIndex = 5;
				}
				break;
			}
		}
	}

	private void LoadAsGlobalTree()
	{
		treeViewParameter.Nodes.Clear();
		foreach (string sortedGVName in QTMGlobalVariable.SortedGVNames)
		{
			TreeNode treeNode = treeViewParameter.Nodes.Add(sortedGVName, sortedGVName);
			treeNode.ImageIndex = 4;
			treeNode.SelectedImageIndex = 4;
		}
		buttonEditGVs.Enabled = true;
	}

	private void ResetEditControls()
	{
		gridMetadataItems.ClearSelection();
		gridMetadataItems.CurrentCell = null;
		groupBox2.Enabled = true;
		currentItemAdded = false;
		metaItemToModify = null;
		buttonSave.Text = "Save &Item";
		UpdateEditControls();
	}

	private void UpdateEditControls()
	{
		bool flag = gridMetadataItems.SelectedRows.Count > 0;
		buttonRemove.Enabled = flag;
		if (flag)
		{
			if (gridMetadataItems.SelectedRows[0].Cells[0].Value is MetadataItem metadataItem)
			{
				groupBox2.Enabled = flag;
				metaItemToModify = metadataItem;
			}
			buttonSave.Text = "Update &Item";
		}
		LoadEditControls();
	}

	private void buttonEditGVs_Click(object sender, EventArgs e)
	{
		QTMGlobalVariablesDialog qTMGlobalVariablesDialog = new QTMGlobalVariablesDialog();
		if (treeViewParameter.SelectedNode != null && treeViewParameter.SelectedNode.Text != "")
		{
			qTMGlobalVariablesDialog.CurrentSelection = treeViewParameter.SelectedNode.Text;
		}
		if (qTMGlobalVariablesDialog.ShowDialog() == DialogResult.OK)
		{
			LoadParamTree();
			TreeNode selectedNode = treeViewParameter.Nodes[qTMGlobalVariablesDialog.CurrentSelection];
			treeViewParameter.SelectedNode = selectedNode;
		}
	}

	private void buttonNew_Click(object sender, EventArgs e)
	{
		ResetEditControls();
	}

	private void buttonRemove_Click(object sender, EventArgs e)
	{
		if (gridMetadataItems.SelectedRows[0].Cells[0].Value is MetadataItem item)
		{
			Metadata.Items.Remove(item);
		}
		if (Metadata.Items.Count == 0)
		{
			Metadata = null;
		}
		LoadMetaItemGrid();
		ResetEditControls();
	}

	private void buttonRemoveAll_Click(object sender, EventArgs e)
	{
		Metadata = null;
		LoadMetaItemGrid();
		ResetEditControls();
	}

	private void buttonSave_Click(object sender, EventArgs e)
	{
		string errorMessage = "";
		if (IsItemConfigured(out errorMessage))
		{
			if (metaItemToModify == null)
			{
				metaItemToModify = new MetadataItem();
			}
			metaItemToModify.Name = textBoxName.Text;
			metaItemToModify.SourceName = treeViewParameter.SelectedNode.Text;
			if (comboBoxType.SelectedIndex == 0)
			{
				metaItemToModify.Type = MetadataItem.MetadataType.TestParameter;
				metaItemToModify.TestIndex = (treeViewTests.SelectedNode.Tag as BaseTest).Index;
				if (comboBoxIndex.Enabled)
				{
					metaItemToModify.ArrayIndex = comboBoxIndex.SelectedIndex;
				}
				else
				{
					metaItemToModify.ArrayIndex = -1;
				}
			}
			else if (comboBoxType.SelectedIndex == 1)
			{
				metaItemToModify.Type = MetadataItem.MetadataType.GlobalVariable;
			}
			if (Metadata == null)
			{
				Metadata = new MetadataItems();
			}
			if (!Metadata.Items.Contains(metaItemToModify) && ItemIsValid(metaItemToModify, out errorMessage))
			{
				Metadata.Items.Add(metaItemToModify);
				currentItemAdded = true;
			}
			int num = Metadata.Items.IndexOf(metaItemToModify);
			LoadMetaItemGrid();
			if (num >= 0 && gridMetadataItems.Rows.Count > num)
			{
				gridMetadataItems.Rows[num].Selected = true;
			}
		}
		if (!string.IsNullOrEmpty(errorMessage))
		{
			MessageBox.Show($"Metadata is invalid and cannot be saved:{Environment.NewLine}{errorMessage}");
		}
	}

	private void comboBoxType_SelectedIndexChanged(object sender, EventArgs e)
	{
		treeViewTests.Enabled = comboBoxType.SelectedIndex == 0;
		LoadParamTree();
	}

	private void gridMetadataItems_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
	{
		if (gridMetadataItems.Rows.Count > 0)
		{
			buttonRemoveAll.Enabled = true;
		}
	}

	private void gridMetadataItems_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
	{
		if (gridMetadataItems.Rows.Count == 0)
		{
			buttonRemoveAll.Enabled = false;
		}
	}

	private void gridMetadataItems_SelectionChanged(object sender, EventArgs e)
	{
		UpdateEditControls();
	}

	private void treeViewParameter_AfterSelect(object sender, TreeViewEventArgs e)
	{
		if (comboBoxType.SelectedIndex == 0)
		{
			comboBoxIndex.Enabled = false;
			if (!currentItemAdded)
			{
				textBoxName.Text = $"{treeViewTests.SelectedNode.Text}.{treeViewParameter.SelectedNode.Text}";
			}
			if (!(treeViewTests.SelectedNode.Tag is BaseTest baseTest))
			{
				return;
			}
			ParameterCls parameterCls = baseTest.Properties.Parameters.FindParam(treeViewParameter.SelectedNode.Text);
			if ((parameterCls != null && parameterCls.NoOfElements > 1) || parameterCls.IsDynamicArray)
			{
				comboBoxIndex.Enabled = true;
				comboBoxIndex.Items.Clear();
				comboBoxIndex.Items.Add(0);
				for (int i = 1; i < parameterCls.NoOfElements; i++)
				{
					comboBoxIndex.Items.Add(i);
				}
				comboBoxIndex.SelectedIndex = 0;
			}
		}
		else if (comboBoxType.SelectedIndex == 1)
		{
			textBoxName.Text = treeViewParameter.SelectedNode.Text;
		}
	}

	private void treeViewTests_AfterSelect(object sender, TreeViewEventArgs e)
	{
		LoadParamTree();
	}

	private void treeViewTests_BeforeSelect(object sender, TreeViewCancelEventArgs e)
	{
		if (e.Node.Tag == currentSelectedTest)
		{
			e.Cancel = true;
		}
	}

	private void treeViewTests_DrawNode(object sender, DrawTreeNodeEventArgs e)
	{
		if (e.Node != null)
		{
			if (e.Node.IsSelected && !treeViewTests.Focused)
			{
				Font font = e.Node.NodeFont ?? treeViewTests.Font;
				e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
				TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, SystemColors.HighlightText, TextFormatFlags.Default);
			}
			else
			{
				e.DrawDefault = true;
			}
		}
	}

	private bool IsItemConfigured(out string errorMessage)
	{
		errorMessage = "";
		if (string.IsNullOrEmpty(textBoxName.Text.Trim()))
		{
			errorMessage = "Name is empty";
			return false;
		}
		if (comboBoxType.SelectedIndex < 0)
		{
			errorMessage = "Type is not selected";
			return false;
		}
		if (comboBoxType.SelectedIndex == 0)
		{
			if (treeViewTests.SelectedNode == null)
			{
				errorMessage = "No test node is selected";
				return false;
			}
			if (comboBoxIndex.Enabled && comboBoxIndex.SelectedIndex < 0)
			{
				errorMessage = "No parameter array index is selected";
				return false;
			}
		}
		if (treeViewParameter.SelectedNode == null)
		{
			errorMessage = "No parameter/global is selected";
			return false;
		}
		return true;
	}

	private bool ItemIsValid(MetadataItem metaItemToModify, out string errorMessage)
	{
		errorMessage = "";
		if (Metadata == null)
		{
			return true;
		}
		if (Metadata.ContainsName(metaItemToModify.Name))
		{
			errorMessage = "Duplicate item name";
			return false;
		}
		if (Metadata.ContainsParameter(metaItemToModify.SourceName, metaItemToModify.TestIndex, metaItemToModify.ArrayIndex))
		{
			errorMessage = "Duplicate parameter name";
			return false;
		}
		if (Metadata.ContainsGlobalVariable(metaItemToModify.SourceName))
		{
			errorMessage = "Duplicate global name";
			return false;
		}
		return true;
	}

	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.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
		System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QC.QsprTestObjects.Metadata.MetadataDialog));
		this.gridMetadataItems = new System.Windows.Forms.DataGridView();
		this.colCondition = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colName = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colType = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colSource = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.buttonRemove = new System.Windows.Forms.Button();
		this.buttonOk = new System.Windows.Forms.Button();
		this.buttonCancel = new System.Windows.Forms.Button();
		this.groupBox1 = new System.Windows.Forms.GroupBox();
		this.buttonRemoveAll = new System.Windows.Forms.Button();
		this.buttonNew = new System.Windows.Forms.Button();
		this.groupBox2 = new System.Windows.Forms.GroupBox();
		this.treeViewTests = new System.Windows.Forms.TreeView();
		this.imageList = new System.Windows.Forms.ImageList(this.components);
		this.panelNameType = new System.Windows.Forms.Panel();
		this.textBoxName = new System.Windows.Forms.TextBox();
		this.label2 = new System.Windows.Forms.Label();
		this.comboBoxType = new System.Windows.Forms.ComboBox();
		this.label3 = new System.Windows.Forms.Label();
		this.panelValueSelection = new System.Windows.Forms.Panel();
		this.buttonEditGVs = new System.Windows.Forms.Button();
		this.treeViewParameter = new System.Windows.Forms.TreeView();
		this.buttonSave = new System.Windows.Forms.Button();
		this.comboBoxIndex = new System.Windows.Forms.ComboBox();
		this.labelIndex = new System.Windows.Forms.Label();
		((System.ComponentModel.ISupportInitialize)this.gridMetadataItems).BeginInit();
		this.groupBox1.SuspendLayout();
		this.groupBox2.SuspendLayout();
		this.panelNameType.SuspendLayout();
		this.panelValueSelection.SuspendLayout();
		base.SuspendLayout();
		this.gridMetadataItems.AllowUserToAddRows = false;
		this.gridMetadataItems.AllowUserToDeleteRows = false;
		this.gridMetadataItems.AllowUserToResizeRows = false;
		this.gridMetadataItems.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.gridMetadataItems.BackgroundColor = System.Drawing.SystemColors.Window;
		this.gridMetadataItems.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
		dataGridViewCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
		dataGridViewCellStyle.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		dataGridViewCellStyle.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.gridMetadataItems.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle;
		this.gridMetadataItems.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.gridMetadataItems.Columns.AddRange(this.colCondition, this.colName, this.colType, this.colSource);
		dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
		dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
		dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
		dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
		this.gridMetadataItems.DefaultCellStyle = dataGridViewCellStyle2;
		this.gridMetadataItems.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
		this.gridMetadataItems.GridColor = System.Drawing.SystemColors.Window;
		this.gridMetadataItems.Location = new System.Drawing.Point(6, 19);
		this.gridMetadataItems.MultiSelect = false;
		this.gridMetadataItems.Name = "gridMetadataItems";
		this.gridMetadataItems.ReadOnly = true;
		dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
		dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.gridMetadataItems.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
		this.gridMetadataItems.RowHeadersVisible = false;
		this.gridMetadataItems.RowHeadersWidth = 18;
		this.gridMetadataItems.RowTemplate.Height = 17;
		this.gridMetadataItems.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
		this.gridMetadataItems.Size = new System.Drawing.Size(468, 95);
		this.gridMetadataItems.StandardTab = true;
		this.gridMetadataItems.TabIndex = 8;
		this.gridMetadataItems.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(gridMetadataItems_RowsAdded);
		this.gridMetadataItems.RowsRemoved += new System.Windows.Forms.DataGridViewRowsRemovedEventHandler(gridMetadataItems_RowsRemoved);
		this.gridMetadataItems.SelectionChanged += new System.EventHandler(gridMetadataItems_SelectionChanged);
		this.colCondition.HeaderText = "MetadataObject";
		this.colCondition.Name = "colCondition";
		this.colCondition.ReadOnly = true;
		this.colCondition.Resizable = System.Windows.Forms.DataGridViewTriState.False;
		this.colCondition.Visible = false;
		this.colName.HeaderText = "Name";
		this.colName.Name = "colName";
		this.colName.ReadOnly = true;
		this.colName.Resizable = System.Windows.Forms.DataGridViewTriState.False;
		this.colType.HeaderText = "Type";
		this.colType.Name = "colType";
		this.colType.ReadOnly = true;
		this.colSource.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colSource.HeaderText = "Source";
		this.colSource.Name = "colSource";
		this.colSource.ReadOnly = true;
		this.colSource.Resizable = System.Windows.Forms.DataGridViewTriState.False;
		this.buttonRemove.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
		this.buttonRemove.Enabled = false;
		this.buttonRemove.Location = new System.Drawing.Point(318, 120);
		this.buttonRemove.Name = "buttonRemove";
		this.buttonRemove.Size = new System.Drawing.Size(75, 23);
		this.buttonRemove.TabIndex = 11;
		this.buttonRemove.Text = "&Remove";
		this.buttonRemove.UseVisualStyleBackColor = true;
		this.buttonRemove.Click += new System.EventHandler(buttonRemove_Click);
		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(336, 572);
		this.buttonOk.Name = "buttonOk";
		this.buttonOk.Size = new System.Drawing.Size(75, 23);
		this.buttonOk.TabIndex = 12;
		this.buttonOk.Text = "&OK";
		this.buttonOk.UseVisualStyleBackColor = true;
		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(417, 572);
		this.buttonCancel.Name = "buttonCancel";
		this.buttonCancel.Size = new System.Drawing.Size(75, 23);
		this.buttonCancel.TabIndex = 13;
		this.buttonCancel.Text = "&Cancel";
		this.buttonCancel.UseVisualStyleBackColor = true;
		this.groupBox1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.groupBox1.Controls.Add(this.buttonRemoveAll);
		this.groupBox1.Controls.Add(this.buttonNew);
		this.groupBox1.Controls.Add(this.gridMetadataItems);
		this.groupBox1.Controls.Add(this.buttonRemove);
		this.groupBox1.Location = new System.Drawing.Point(12, 12);
		this.groupBox1.Name = "groupBox1";
		this.groupBox1.Size = new System.Drawing.Size(480, 152);
		this.groupBox1.TabIndex = 14;
		this.groupBox1.TabStop = false;
		this.groupBox1.Text = "Assigned Metadata Items";
		this.buttonRemoveAll.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
		this.buttonRemoveAll.Enabled = false;
		this.buttonRemoveAll.Location = new System.Drawing.Point(399, 120);
		this.buttonRemoveAll.Name = "buttonRemoveAll";
		this.buttonRemoveAll.Size = new System.Drawing.Size(75, 23);
		this.buttonRemoveAll.TabIndex = 13;
		this.buttonRemoveAll.Text = "Remove &All";
		this.buttonRemoveAll.UseVisualStyleBackColor = true;
		this.buttonRemoveAll.Click += new System.EventHandler(buttonRemoveAll_Click);
		this.buttonNew.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
		this.buttonNew.Location = new System.Drawing.Point(237, 120);
		this.buttonNew.Name = "buttonNew";
		this.buttonNew.Size = new System.Drawing.Size(75, 23);
		this.buttonNew.TabIndex = 12;
		this.buttonNew.Text = "&New";
		this.buttonNew.UseVisualStyleBackColor = true;
		this.buttonNew.Click += new System.EventHandler(buttonNew_Click);
		this.groupBox2.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.groupBox2.Controls.Add(this.treeViewTests);
		this.groupBox2.Controls.Add(this.panelNameType);
		this.groupBox2.Controls.Add(this.panelValueSelection);
		this.groupBox2.Enabled = false;
		this.groupBox2.Location = new System.Drawing.Point(12, 170);
		this.groupBox2.Name = "groupBox2";
		this.groupBox2.Size = new System.Drawing.Size(480, 396);
		this.groupBox2.TabIndex = 15;
		this.groupBox2.TabStop = false;
		this.groupBox2.Text = "Edit item";
		this.treeViewTests.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.treeViewTests.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
		this.treeViewTests.Enabled = false;
		this.treeViewTests.HideSelection = false;
		this.treeViewTests.ImageIndex = 0;
		this.treeViewTests.ImageList = this.imageList;
		this.treeViewTests.Location = new System.Drawing.Point(6, 67);
		this.treeViewTests.Name = "treeViewTests";
		this.treeViewTests.SelectedImageIndex = 0;
		this.treeViewTests.Size = new System.Drawing.Size(468, 154);
		this.treeViewTests.TabIndex = 26;
		this.treeViewTests.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(treeViewTests_DrawNode);
		this.treeViewTests.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(treeViewTests_BeforeSelect);
		this.treeViewTests.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeViewTests_AfterSelect);
		this.imageList.ImageStream = (System.Windows.Forms.ImageListStreamer)resources.GetObject("imageList.ImageStream");
		this.imageList.TransparentColor = System.Drawing.Color.Transparent;
		this.imageList.Images.SetKeyName(0, "folder-closed.png");
		this.imageList.Images.SetKeyName(1, "folder-open.png");
		this.imageList.Images.SetKeyName(2, "Root.png");
		this.imageList.Images.SetKeyName(3, "TestTreeTest.png");
		this.imageList.Images.SetKeyName(4, "In.bmp");
		this.imageList.Images.SetKeyName(5, "Out.bmp");
		this.panelNameType.Controls.Add(this.textBoxName);
		this.panelNameType.Controls.Add(this.label2);
		this.panelNameType.Controls.Add(this.comboBoxType);
		this.panelNameType.Controls.Add(this.label3);
		this.panelNameType.Location = new System.Drawing.Point(6, 19);
		this.panelNameType.Name = "panelNameType";
		this.panelNameType.Size = new System.Drawing.Size(468, 45);
		this.panelNameType.TabIndex = 33;
		this.textBoxName.Location = new System.Drawing.Point(47, 11);
		this.textBoxName.Name = "textBoxName";
		this.textBoxName.Size = new System.Drawing.Size(211, 20);
		this.textBoxName.TabIndex = 19;
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(3, 14);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(38, 13);
		this.label2.TabIndex = 18;
		this.label2.Text = "Name:";
		this.comboBoxType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.comboBoxType.FormattingEnabled = true;
		this.comboBoxType.Items.AddRange(new object[2] { "Test Parameter", "Global Variable" });
		this.comboBoxType.Location = new System.Drawing.Point(321, 11);
		this.comboBoxType.Name = "comboBoxType";
		this.comboBoxType.Size = new System.Drawing.Size(140, 21);
		this.comboBoxType.TabIndex = 20;
		this.comboBoxType.SelectedIndexChanged += new System.EventHandler(comboBoxType_SelectedIndexChanged);
		this.label3.AutoSize = true;
		this.label3.Location = new System.Drawing.Point(281, 15);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(34, 13);
		this.label3.TabIndex = 21;
		this.label3.Text = "Type:";
		this.panelValueSelection.Controls.Add(this.buttonEditGVs);
		this.panelValueSelection.Controls.Add(this.treeViewParameter);
		this.panelValueSelection.Controls.Add(this.buttonSave);
		this.panelValueSelection.Controls.Add(this.comboBoxIndex);
		this.panelValueSelection.Controls.Add(this.labelIndex);
		this.panelValueSelection.Location = new System.Drawing.Point(6, 227);
		this.panelValueSelection.Name = "panelValueSelection";
		this.panelValueSelection.Size = new System.Drawing.Size(468, 163);
		this.panelValueSelection.TabIndex = 31;
		this.buttonEditGVs.Enabled = false;
		this.buttonEditGVs.Location = new System.Drawing.Point(167, 134);
		this.buttonEditGVs.Name = "buttonEditGVs";
		this.buttonEditGVs.Size = new System.Drawing.Size(75, 23);
		this.buttonEditGVs.TabIndex = 31;
		this.buttonEditGVs.Text = "&Edit Globals";
		this.buttonEditGVs.UseVisualStyleBackColor = true;
		this.buttonEditGVs.Click += new System.EventHandler(buttonEditGVs_Click);
		this.treeViewParameter.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.treeViewParameter.HideSelection = false;
		this.treeViewParameter.ImageIndex = 0;
		this.treeViewParameter.ImageList = this.imageList;
		this.treeViewParameter.Location = new System.Drawing.Point(3, 7);
		this.treeViewParameter.MaximumSize = new System.Drawing.Size(307, 127);
		this.treeViewParameter.Name = "treeViewParameter";
		this.treeViewParameter.SelectedImageIndex = 0;
		this.treeViewParameter.ShowRootLines = false;
		this.treeViewParameter.Size = new System.Drawing.Size(301, 123);
		this.treeViewParameter.TabIndex = 28;
		this.treeViewParameter.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeViewParameter_AfterSelect);
		this.buttonSave.Location = new System.Drawing.Point(321, 7);
		this.buttonSave.Name = "buttonSave";
		this.buttonSave.Size = new System.Drawing.Size(75, 23);
		this.buttonSave.TabIndex = 30;
		this.buttonSave.Text = "Save &Item";
		this.buttonSave.UseVisualStyleBackColor = true;
		this.buttonSave.Click += new System.EventHandler(buttonSave_Click);
		this.comboBoxIndex.DisplayMember = "Key";
		this.comboBoxIndex.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.comboBoxIndex.Enabled = false;
		this.comboBoxIndex.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.comboBoxIndex.Location = new System.Drawing.Point(59, 136);
		this.comboBoxIndex.Name = "comboBoxIndex";
		this.comboBoxIndex.Size = new System.Drawing.Size(80, 21);
		this.comboBoxIndex.TabIndex = 29;
		this.comboBoxIndex.ValueMember = "Value";
		this.labelIndex.Location = new System.Drawing.Point(13, 136);
		this.labelIndex.Name = "labelIndex";
		this.labelIndex.Size = new System.Drawing.Size(40, 18);
		this.labelIndex.TabIndex = 27;
		this.labelIndex.Text = "Index:";
		this.labelIndex.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		this.AutoScroll = true;
		base.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
		this.BackColor = System.Drawing.SystemColors.Control;
		base.ClientSize = new System.Drawing.Size(504, 607);
		base.Controls.Add(this.groupBox2);
		base.Controls.Add(this.groupBox1);
		base.Controls.Add(this.buttonCancel);
		base.Controls.Add(this.buttonOk);
		base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
		this.MaximumSize = new System.Drawing.Size(520, 645);
		this.MinimumSize = new System.Drawing.Size(520, 284);
		base.Name = "MetadataDialog";
		base.ShowIcon = false;
		base.ShowInTaskbar = false;
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
		this.Text = "Edit metadata items";
		base.Load += new System.EventHandler(MetadataDialog_Load);
		((System.ComponentModel.ISupportInitialize)this.gridMetadataItems).EndInit();
		this.groupBox1.ResumeLayout(false);
		this.groupBox2.ResumeLayout(false);
		this.panelNameType.ResumeLayout(false);
		this.panelNameType.PerformLayout();
		this.panelValueSelection.ResumeLayout(false);
		base.ResumeLayout(false);
	}
}
