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

namespace QDART_MFG_CfgEditor;

public class MultiplexerMoveDutForm : Form
{
	private SortedList<int, int> slGroupSet = new SortedList<int, int>();

	private SortedList<int, SortedList<int, int>> slDutSet = new SortedList<int, SortedList<int, int>>();

	private int group;

	private IContainer components;

	private Button btnOK;

	private Button btnCancel;

	private ComboBox cbDutSet;

	private Label label1;

	private ComboBox cbGroupSet;

	private Label label2;

	private Label lbToGroupID;

	private Label label3;

	public MultiplexerMoveDutForm(SortedList<int, int> groupSet, SortedList<int, SortedList<int, int>> dutSet, int toGroup)
	{
		InitializeComponent();
		slGroupSet = groupSet;
		slDutSet = dutSet;
		group = toGroup;
		InitControls(groupSet, toGroup);
	}

	private void InitControls(SortedList<int, int> groupSet, int toGroup)
	{
		for (int i = 0; i < groupSet.Keys.Count; i++)
		{
			if (groupSet.Keys[i] != toGroup)
			{
				cbGroupSet.Items.Add(groupSet.Keys[i]);
			}
		}
		cbGroupSet.SelectedIndex = 0;
		lbToGroupID.Text = toGroup.ToString();
	}

	private void btnCancel_Click(object sender, EventArgs e)
	{
		Close();
	}

	private void btnOK_Click(object sender, EventArgs e)
	{
		if (cbGroupSet.Text != "" && cbDutSet.Text != "")
		{
			base.Tag = cbGroupSet.Text + ";" + cbDutSet.Text;
			base.DialogResult = DialogResult.OK;
		}
		else
		{
			MessageBox.Show("Blank forbided");
		}
	}

	private void cbGroupSet_SelectedIndexChanged(object sender, EventArgs e)
	{
		cbDutSet.Items.Clear();
		foreach (int key in slDutSet[slGroupSet[int.Parse(cbGroupSet.Text)]].Keys)
		{
			cbDutSet.Items.Add(key.ToString());
		}
	}

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

	private void InitializeComponent()
	{
		this.btnOK = new System.Windows.Forms.Button();
		this.btnCancel = new System.Windows.Forms.Button();
		this.cbDutSet = new System.Windows.Forms.ComboBox();
		this.label1 = new System.Windows.Forms.Label();
		this.cbGroupSet = new System.Windows.Forms.ComboBox();
		this.label2 = new System.Windows.Forms.Label();
		this.lbToGroupID = new System.Windows.Forms.Label();
		this.label3 = new System.Windows.Forms.Label();
		base.SuspendLayout();
		this.btnOK.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnOK.Location = new System.Drawing.Point(69, 117);
		this.btnOK.Name = "btnOK";
		this.btnOK.Size = new System.Drawing.Size(80, 37);
		this.btnOK.TabIndex = 5;
		this.btnOK.Text = "OK";
		this.btnOK.UseVisualStyleBackColor = true;
		this.btnOK.Click += new System.EventHandler(btnOK_Click);
		this.btnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnCancel.Location = new System.Drawing.Point(186, 117);
		this.btnCancel.Name = "btnCancel";
		this.btnCancel.Size = new System.Drawing.Size(80, 37);
		this.btnCancel.TabIndex = 5;
		this.btnCancel.Text = "Cancel";
		this.btnCancel.UseVisualStyleBackColor = true;
		this.btnCancel.Click += new System.EventHandler(btnCancel_Click);
		this.cbDutSet.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cbDutSet.FormattingEnabled = true;
		this.cbDutSet.Location = new System.Drawing.Point(242, 34);
		this.cbDutSet.Name = "cbDutSet";
		this.cbDutSet.Size = new System.Drawing.Size(68, 21);
		this.cbDutSet.TabIndex = 7;
		this.label1.AutoSize = true;
		this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.label1.Location = new System.Drawing.Point(12, 34);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(95, 20);
		this.label1.TabIndex = 8;
		this.label1.Text = "From Group";
		this.cbGroupSet.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cbGroupSet.FormattingEnabled = true;
		this.cbGroupSet.Location = new System.Drawing.Point(113, 34);
		this.cbGroupSet.Name = "cbGroupSet";
		this.cbGroupSet.Size = new System.Drawing.Size(68, 21);
		this.cbGroupSet.TabIndex = 7;
		this.cbGroupSet.SelectedIndexChanged += new System.EventHandler(cbGroupSet_SelectedIndexChanged);
		this.label2.AutoSize = true;
		this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.label2.Location = new System.Drawing.Point(12, 73);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(84, 20);
		this.label2.TabIndex = 9;
		this.label2.Text = "To Group: ";
		this.lbToGroupID.AutoSize = true;
		this.lbToGroupID.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.lbToGroupID.Location = new System.Drawing.Point(109, 73);
		this.lbToGroupID.Name = "lbToGroupID";
		this.lbToGroupID.Size = new System.Drawing.Size(0, 20);
		this.lbToGroupID.TabIndex = 9;
		this.label3.AutoSize = true;
		this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.label3.Location = new System.Drawing.Point(194, 35);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(42, 20);
		this.label3.TabIndex = 9;
		this.label3.Text = "DUT";
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(331, 173);
		base.Controls.Add(this.lbToGroupID);
		base.Controls.Add(this.label3);
		base.Controls.Add(this.label2);
		base.Controls.Add(this.label1);
		base.Controls.Add(this.cbGroupSet);
		base.Controls.Add(this.cbDutSet);
		base.Controls.Add(this.btnCancel);
		base.Controls.Add(this.btnOK);
		base.Name = "MultiplexerMoveDutForm";
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
		this.Text = "MoveDutFromAnotherGroup";
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
