using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Timers;
using System.Windows.Forms;
using MultiLanguageManger;

namespace QC.QMSCT;

public class DeviceSetup : UserControl
{
	public delegate void DeviceSetupInProgress(bool started);

	private const string CONNECT_THE_DEVICE = "Connect The Device For Panel:";

	private const string SETUP_COMPLETED = "Setup Completed!";

	private const string SETUP_ABORTED = "Setup Aborted!";

	private int currentPanelToSetup;

	private int currentPortToSetup = 1;

	private USBPortNotification deviceNotification = new USBPortNotification();

	private bool setupCompleted = true;

	private DataGridViewManager dgvManager;

	private PortDetectionSettings portDetectionSettings;

	private System.Timers.Timer timer_DisplayPanelConnect = new System.Timers.Timer();

	private System.Timers.Timer timer_DeviceConnectTimeoutNotification = new System.Timers.Timer();

	private List<PortMapType> lpmts = new List<PortMapType>();

	private bool currentlyVisible = true;

	private bool workingOnSameCell;

	private object notificationLock = new object();

	private object lockUserNotification = new object();

	private bool timeExpiredMessageBeenDisplayed;

	private DateTime startTime;

	private IContainer components;

	private Label label_PanelNumber;

	private GroupBox groupBox_Ports;

	private DataGridView dataGridView_PanelPortMap;

	private TextBox textBox_Status;

	private GroupBox groupBox_Status;

	private CheckBox checkBox_ConfigPanelGV;

	private GroupBox groupBox_Process;

	private GroupBox groupBox_PortSetupOptions;

	private CheckBox checkBox_NetMode;

	private CheckBox checkBox_PhysicalAddressMode;

	private ComboBox comboBox_PortDetectionKeyWord;

	private Label labelPortDetectionKeyWord;

	private CheckBox checkBox_ManualPortSetup;

	private RadioButton radioButton_TwoPortSetup;

	private RadioButton radioButton_SinglePortSetup;

	private GroupBox groupBox_StartProcess;

	private Button button_AbortSetupProcess;

	private Button button_Start;

	private GroupBox groupBox_SkipToPanel;

	private Button button_SkipToPrev;

	private Button button_SkipToNext;

	public int TotalNumberOfPanels
	{
		get
		{
			return dgvManager.TotalNumberOfPanels;
		}
		set
		{
			dgvManager.TotalNumberOfPanels = value;
		}
	}

	public bool DualPortSolution
	{
		get
		{
			return dgvManager.DualPortSolution;
		}
		set
		{
			dgvManager.DualPortSolution = value;
		}
	}

	private bool PanelSpecificGVMode
	{
		get
		{
			return dgvManager.PanelSpecificGVMode;
		}
		set
		{
			dgvManager.PanelSpecificGVMode = value;
		}
	}

	public bool ManualSetup
	{
		get
		{
			return dgvManager.ManualSetup;
		}
		set
		{
			dgvManager.ManualSetup = value;
		}
	}

	public DetectionInstance DetectionInstance
	{
		get
		{
			return dgvManager.DetectionInstance;
		}
		set
		{
			dgvManager.DetectionInstance = value;
		}
	}

	private int LastIndexOfPanelManage => dgvManager.TotalNumberOfPanels - 1;

	private Dictionary<int, PortDataType> PanelPortMap => dgvManager.PortDataManager.PanelPortMap;

	public PortMapType[] PortMapping
	{
		get
		{
			lpmts.Clear();
			foreach (KeyValuePair<int, PortDataType> item in PanelPortMap)
			{
				PortMapType portMapType = new PortMapType();
				portMapType.PanelNumber = item.Key;
				portMapType.PortData = item.Value;
				lpmts.Add(portMapType);
			}
			return lpmts.ToArray();
		}
	}

	public event DeviceSetupInProgress OnDeviceSetupInProgress;

	public DeviceSetup()
	{
		InitializeComponent();
		initializeGUI();
		dgvManager = new DataGridViewManager(dataGridView_PanelPortMap);
		deviceNotification.OnDeviceConnectionChange += deviceNotification_OnDeviceConnectionChange;
		timer_DisplayPanelConnect.Elapsed += timer_Elapsed;
		timer_DisplayPanelConnect.Interval = 1000.0;
		timer_DisplayPanelConnect.Elapsed += timer_DisplayPanelConnect_Elapsed;
		timer_DisplayPanelConnect.Interval = 1000.0;
	}

	public void InitializePage(PortDetectionSettings portdetectsetup, StationConfiguration stationsetup)
	{
		portDetectionSettings = portdetectsetup;
		comboBox_PortDetectionKeyWord.Items.Clear();
		comboBox_PortDetectionKeyWord.Items.Add(portDetectionSettings.EDownloadKeyField + " (" + portDetectionSettings.EDownloadKeyWord + ")");
		comboBox_PortDetectionKeyWord.Items.Add(portDetectionSettings.DiagnosticKeyField + " (" + portDetectionSettings.DiagnosticKeyWord + ")");
		comboBox_PortDetectionKeyWord.SelectedIndex = 0;
		dgvManager.LoadSetupData(stationsetup);
		ResetGuiState();
	}

	public void updateGUI_PanelPortDetectionStyle()
	{
		groupBox_PortSetupOptions.Enabled = false;
		checkBox_ConfigPanelGV.Enabled = false;
		button_Start.Enabled = false;
		button_AbortSetupProcess.Enabled = true;
		if (DualPortSolution)
		{
			if (currentPanelToSetup > 0)
			{
				button_SkipToPrev.Enabled = true;
			}
			else if (currentPortToSetup == 1)
			{
				button_SkipToPrev.Enabled = false;
			}
			else
			{
				button_SkipToPrev.Enabled = true;
			}
			if (currentPanelToSetup < LastIndexOfPanelManage)
			{
				button_SkipToNext.Enabled = true;
			}
			else if (currentPortToSetup == 2)
			{
				button_SkipToNext.Enabled = false;
			}
			else
			{
				button_SkipToPrev.Enabled = true;
			}
		}
		else
		{
			if (currentPanelToSetup > 0)
			{
				button_SkipToPrev.Enabled = true;
			}
			else
			{
				button_SkipToPrev.Enabled = false;
			}
			if (currentPanelToSetup < LastIndexOfPanelManage)
			{
				button_SkipToNext.Enabled = true;
			}
			else
			{
				button_SkipToNext.Enabled = false;
			}
			currentPortToSetup = 1;
		}
		setSelectedDataGridViewCell(currentPanelToSetup, currentPortToSetup);
		label_PanelNumber.Text = currentPanelToSetup.ToString();
	}

	public void ResetGuiState()
	{
		groupBox_Process.Enabled = true;
		groupBox_PortSetupOptions.Enabled = true;
		checkBox_ConfigPanelGV.Enabled = true;
		if (!DualPortSolution)
		{
			radioButton_SinglePortSetup.Checked = true;
		}
		else
		{
			radioButton_TwoPortSetup.Checked = true;
		}
		if (DetectionInstance == DetectionInstance.DETECT_INST_NET_MODE)
		{
			checkBox_NetMode.Checked = true;
			dataGridView_PanelPortMap.ReadOnly = false;
			dataGridView_PanelPortMap.Columns[0].ReadOnly = true;
			dataGridView_PanelPortMap.EditMode = DataGridViewEditMode.EditOnEnter;
			button_Start.Enabled = false;
			button_AbortSetupProcess.Enabled = false;
			button_SkipToPrev.Enabled = false;
			button_SkipToNext.Enabled = false;
			radioButton_SinglePortSetup.Enabled = false;
			radioButton_TwoPortSetup.Enabled = false;
			checkBox_ManualPortSetup.Enabled = false;
			checkBox_PhysicalAddressMode.Enabled = false;
			comboBox_PortDetectionKeyWord.Enabled = false;
		}
		else
		{
			checkBox_NetMode.Checked = false;
			dataGridView_PanelPortMap.EditMode = DataGridViewEditMode.EditProgrammatically;
			checkBox_PhysicalAddressMode.Enabled = true;
			if (DetectionInstance == DetectionInstance.DETECT_INST_PORT_NO)
			{
				checkBox_PhysicalAddressMode.Checked = false;
				checkBox_ManualPortSetup.Enabled = true;
				radioButton_SinglePortSetup.Enabled = true;
				radioButton_TwoPortSetup.Enabled = true;
				if (ManualSetup)
				{
					checkBox_ManualPortSetup.Checked = true;
					button_Start.Enabled = false;
					button_AbortSetupProcess.Enabled = false;
					button_SkipToPrev.Enabled = false;
					button_SkipToNext.Enabled = false;
					comboBox_PortDetectionKeyWord.Enabled = false;
				}
				else
				{
					checkBox_ManualPortSetup.Checked = false;
					button_Start.Enabled = true;
					button_AbortSetupProcess.Enabled = false;
					button_SkipToPrev.Enabled = false;
					button_SkipToNext.Enabled = false;
					comboBox_PortDetectionKeyWord.Enabled = true;
				}
			}
			else
			{
				button_Start.Enabled = true;
				button_AbortSetupProcess.Enabled = false;
				button_SkipToPrev.Enabled = false;
				button_SkipToNext.Enabled = false;
				checkBox_ManualPortSetup.Checked = false;
				checkBox_PhysicalAddressMode.Checked = true;
				checkBox_ManualPortSetup.Enabled = false;
				radioButton_SinglePortSetup.Enabled = false;
				radioButton_TwoPortSetup.Enabled = false;
				comboBox_PortDetectionKeyWord.Enabled = true;
			}
		}
		timer_DisplayPanelConnect.Enabled = false;
		ClearStatus();
		label_PanelNumber.Text = "";
		unselectAllDataGridViewCell();
	}

	public void updateGUI_PanelGVStyle()
	{
		groupBox_Process.Enabled = false;
	}

	public void initializeGUI()
	{
		UpdateLanguage();
	}

	private void button_Start_Click(object sender, EventArgs e)
	{
		ResetDeviceConnectionTime();
		ClearStatus();
		MessageBox.Show(CommonResource.BoxMsgDisconnectDevices);
		StartDeviceSetupProcess();
	}

	public void AbortSetupProcess(bool ignoreConfirmation = false)
	{
		try
		{
			if (ignoreConfirmation || GetUserInputYesNo(CommonResource.BoxMsgAbortPortSetup, CommonResource.BoxTitleAbortPortSetup))
			{
				PortSetupProcessCompleted(aborted: true);
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void button_AbortSetupProcess_Click(object sender, EventArgs e)
	{
		AbortSetupProcess();
	}

	private void button_SkipToNext_Click(object sender, EventArgs e)
	{
		string detailedMessage = "";
		if (DetectionInstance == DetectionInstance.DETECT_INST_PORT_NO && DualPortSolution)
		{
			if (currentPortToSetup == 1)
			{
				currentPortToSetup = 2;
			}
			else if (dgvManager.CheckPortDataDetailed(currentPanelToSetup, ref detailedMessage) || MessageBox.Show(detailedMessage + "\nWould you like to continue?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
			{
				currentPanelToSetup++;
				currentPortToSetup = 1;
			}
		}
		else if (dgvManager.CheckPortDataDetailed(currentPanelToSetup, ref detailedMessage) || MessageBox.Show(detailedMessage + "\nWould you like to continue?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
		{
			currentPanelToSetup++;
		}
		ChangePanelCount();
	}

	private void button_SkipToPrev_Click(object sender, EventArgs e)
	{
		string detailedMessage = "";
		if (DetectionInstance == DetectionInstance.DETECT_INST_PORT_NO && DualPortSolution)
		{
			if (currentPortToSetup == 2)
			{
				currentPortToSetup = 1;
			}
			else if (dgvManager.CheckPortDataDetailed(currentPanelToSetup, ref detailedMessage) || MessageBox.Show(detailedMessage + "\nWould you like to continue?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
			{
				currentPanelToSetup--;
				currentPortToSetup = 2;
			}
		}
		else if (dgvManager.CheckPortDataDetailed(currentPanelToSetup, ref detailedMessage) || MessageBox.Show(detailedMessage + "\nWould you like to continue?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
		{
			currentPanelToSetup--;
		}
		ChangePanelCount();
	}

	private void StartDeviceSetupProcess()
	{
		setupCompleted = false;
		currentPanelToSetup = 0;
		currentPortToSetup = 1;
		timer_DisplayPanelConnect.Enabled = true;
		ChangePanelCount();
		if (this.OnDeviceSetupInProgress != null)
		{
			this.OnDeviceSetupInProgress(started: true);
		}
	}

	private void DeviceUpdatedForCurrentPanel()
	{
		string detailedMessage = "";
		if (DetectionInstance == DetectionInstance.DETECT_INST_PORT_NO && DualPortSolution)
		{
			if (currentPanelToSetup < LastIndexOfPanelManage)
			{
				if (currentPortToSetup == 1)
				{
					currentPortToSetup = 2;
				}
				else if (dgvManager.CheckPortDataDetailed(currentPanelToSetup, ref detailedMessage) || MessageBox.Show(detailedMessage + "\nWould you like to continue?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
				{
					currentPanelToSetup++;
					currentPortToSetup = 1;
				}
				ChangePanelCount();
			}
			else if (currentPortToSetup == 1)
			{
				currentPortToSetup = 2;
				ChangePanelCount();
			}
			else if (dgvManager.CheckPortDataDetailed(currentPanelToSetup, ref detailedMessage) || MessageBox.Show(detailedMessage + "\nWould you like to continue?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
			{
				PortSetupProcessCompleted();
			}
			else
			{
				ChangePanelCount();
			}
		}
		else if (currentPanelToSetup < LastIndexOfPanelManage)
		{
			if (dgvManager.CheckPortDataDetailed(currentPanelToSetup, ref detailedMessage) || MessageBox.Show(detailedMessage + "\nWould you like to continue?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
			{
				currentPanelToSetup++;
			}
			ChangePanelCount();
		}
		else if (dgvManager.CheckPortDataDetailed(currentPanelToSetup, ref detailedMessage) || MessageBox.Show(detailedMessage + "\nWould you like to continue?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
		{
			PortSetupProcessCompleted();
		}
		else
		{
			ChangePanelCount();
		}
	}

	private void PortSetupProcessCompleted(bool aborted = false)
	{
		setupCompleted = true;
		deviceNotification.Stop();
		label_PanelNumber.Text = (aborted ? CommonResource.SetupAborted : CommonResource.SetupCompleted);
		ResetGuiState();
		if (this.OnDeviceSetupInProgress != null)
		{
			this.OnDeviceSetupInProgress(started: false);
		}
	}

	private void ChangePanelCount()
	{
		updateGUI_PanelPortDetectionStyle();
		deviceNotification.Start();
	}

	private void deviceNotification_OnDeviceConnectionChange(bool connected, string portDiff)
	{
		deviceNotification.Stop();
		NonTreeExecution(portDiff);
	}

	private void ManualSetupPortnumber(int row, int column, KeyEventArgs e)
	{
		int num = 0;
		if (e.KeyCode != Keys.Back && e.KeyCode != Keys.Delete && !char.IsDigit((char)e.KeyCode))
		{
			return;
		}
		string text = "";
		switch (column)
		{
		case 1:
			text = dgvManager.PortDataManager.PanelPortMap[row + 1].COMPortAtStart.ToString();
			break;
		case 2:
			text = dgvManager.PortDataManager.PanelPortMap[row + 1].COMPortAfterPowerCycle.ToString();
			break;
		}
		if (e.KeyCode == Keys.Delete)
		{
			num = 0;
		}
		else if (e.KeyCode == Keys.Back)
		{
			num = ((text.Length > 1 && workingOnSameCell) ? Convert.ToInt32(text.Substring(0, text.Length - 1)) : 0);
		}
		else
		{
			char c = (char)e.KeyCode;
			num = ((!workingOnSameCell) ? Convert.ToInt32(c.ToString()) : Convert.ToInt32(text + c));
		}
		if (num > 256)
		{
			MessageBox.Show(CommonResource.BoxMsgMaxPortValue + " " + 256 + ".");
			workingOnSameCell = false;
		}
		else
		{
			switch (column)
			{
			case 1:
				if (DetectionInstance == DetectionInstance.DETECT_INST_PORT_NO && DualPortSolution)
				{
					int cOMPortAfterPowerCycle = dgvManager.PortDataManager.PanelPortMap[row + 1].COMPortAfterPowerCycle;
					dgvManager.PortDataManager.AddPanelPort(row + 1, num, cOMPortAfterPowerCycle);
				}
				else
				{
					dgvManager.PortDataManager.AddPanelPort(row + 1, num);
				}
				break;
			case 2:
			{
				int cOMPortAtStart = dgvManager.PortDataManager.PanelPortMap[row + 1].COMPortAtStart;
				dgvManager.PortDataManager.AddPanelPort(row + 1, cOMPortAtStart, num);
				break;
			}
			}
		}
		dgvManager.UpdateGridView();
		setSelectedDataGridViewCell(row, column);
		workingOnSameCell = true;
	}

	private void EditPanelSpecificGV(int row, KeyEventArgs e)
	{
		if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete || e.KeyCode == Keys.OemMinus || char.IsLetterOrDigit((char)e.KeyCode))
		{
			string text = "";
			text = dgvManager.PortDataManager.PanelPortMap[row + 1].PanelSpecificGV;
			if (e.KeyCode == Keys.Delete)
			{
				text = "";
			}
			else if (e.KeyCode == Keys.Back)
			{
				text = ((text.Length <= 1 || !workingOnSameCell) ? "" : text.Substring(0, text.Length - 1));
			}
			else if (e.KeyCode == Keys.OemMinus)
			{
				char c = '-';
				text = ((!workingOnSameCell) ? c.ToString() : (text + c));
			}
			else
			{
				char c2 = (char)e.KeyCode;
				text = ((!workingOnSameCell) ? c2.ToString() : (text + c2));
			}
			dgvManager.PortDataManager.EditPanelSpecificGV(row + 1, text);
			dgvManager.UpdateGridView();
			setSelectedDataGridViewCell(row, 1);
			workingOnSameCell = true;
		}
	}

	private void dataGridView_PanelPortMap_CellEndEdit(object sender, DataGridViewCellEventArgs e)
	{
		if (DetectionInstance == DetectionInstance.DETECT_INST_NET_MODE)
		{
			string physicalAddress = dataGridView_PanelPortMap.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
			int cOMPortAtStart = dgvManager.PortDataManager.PanelPortMap[e.RowIndex + 1].COMPortAtStart;
			dgvManager.PortDataManager.AddPanelPort(e.RowIndex + 1, cOMPortAtStart, physicalAddress);
		}
	}

	private void timer_Elapsed(object sender, ElapsedEventArgs e)
	{
		try
		{
			UIHelper.InvokeOnUIifRequired(this, delegate
			{
				if (currentPanelToSetup > 0 && ((System.Timers.Timer)sender).Enabled)
				{
					if (currentlyVisible)
					{
						currentlyVisible = false;
						label_PanelNumber.Text = "";
					}
					else
					{
						currentlyVisible = true;
						label_PanelNumber.Text = currentPanelToSetup.ToString();
					}
				}
			});
		}
		catch (Exception ex)
		{
			UpdateStatus(ex.Message);
		}
	}

	private void timer_DisplayPanelConnect_Elapsed(object sender, ElapsedEventArgs e)
	{
		try
		{
			UIHelper.InvokeOnUIifRequired(this, delegate
			{
				if (((System.Timers.Timer)sender).Enabled && !IsDeviceConnectionTimeUnderLimit())
				{
					NotifyUserOfExpiredTime();
				}
			});
		}
		catch (Exception ex)
		{
			UpdateStatus("timer_DisplayPanelConnect: " + ex.Message);
		}
	}

	public bool UpdateAndSave()
	{
		return dgvManager.SaveData();
	}

	private void RecallOriginalSetting()
	{
		dgvManager.RecallOriginalSetting();
		ResetGuiState();
	}

	public void UpdateStatus(string status)
	{
		try
		{
			UIHelper.InvokeOnUIifRequired(this, delegate
			{
				string text = textBox_Status.Text;
				text = text + "\r\n" + status;
				textBox_Status.Text = text;
				textBox_Status.SelectionStart = textBox_Status.TextLength;
				textBox_Status.ScrollToCaret();
			});
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	public void ClearStatus()
	{
		try
		{
			UIHelper.InvokeOnUIifRequired(this, delegate
			{
				textBox_Status.Text = "";
				textBox_Status.SelectionStart = textBox_Status.TextLength;
				textBox_Status.ScrollToCaret();
			});
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	public bool HasGUIBeenModified()
	{
		return dgvManager.HasDataBeenModified();
	}

	private void dataGridView_PanelPortMap_DataSourceChanged(object sender, EventArgs e)
	{
		if (dataGridView_PanelPortMap.Columns.Count == 2)
		{
			dataGridView_PanelPortMap.Columns[0].FillWeight = 30f;
			dataGridView_PanelPortMap.Columns[1].FillWeight = 70f;
		}
		else if (dataGridView_PanelPortMap.Columns.Count == 3)
		{
			dataGridView_PanelPortMap.Columns[0].FillWeight = 30f;
			dataGridView_PanelPortMap.Columns[1].FillWeight = 35f;
			dataGridView_PanelPortMap.Columns[2].FillWeight = 35f;
		}
	}

	private void dataGridView_PanelPortMap_KeyDown(object sender, KeyEventArgs e)
	{
		if (PanelSpecificGVMode)
		{
			EditPanelSpecificGV(currentPanelToSetup, e);
		}
		else if (ManualSetup)
		{
			ManualSetupPortnumber(currentPanelToSetup, currentPortToSetup, e);
		}
	}

	private void UpdateSelection()
	{
		if (!setupCompleted)
		{
			if (currentPanelToSetup != dataGridView_PanelPortMap.CurrentCell.RowIndex || currentPortToSetup != dataGridView_PanelPortMap.CurrentCell.ColumnIndex)
			{
				setSelectedDataGridViewCell(currentPanelToSetup, currentPortToSetup);
			}
		}
		else if (ManualSetup)
		{
			if (DetectionInstance == DetectionInstance.DETECT_INST_PORT_NO && DualPortSolution)
			{
				if (dataGridView_PanelPortMap.CurrentCell.ColumnIndex == 1 || dataGridView_PanelPortMap.CurrentCell.ColumnIndex == 2)
				{
					if (currentPanelToSetup != dataGridView_PanelPortMap.CurrentCell.RowIndex || currentPortToSetup != dataGridView_PanelPortMap.CurrentCell.ColumnIndex)
					{
						currentPanelToSetup = dataGridView_PanelPortMap.CurrentCell.RowIndex;
						currentPortToSetup = dataGridView_PanelPortMap.CurrentCell.ColumnIndex;
					}
				}
				else
				{
					setSelectedDataGridViewCell(currentPanelToSetup, currentPortToSetup);
				}
			}
			else if (dataGridView_PanelPortMap.CurrentCell.ColumnIndex == 1)
			{
				if (currentPanelToSetup != dataGridView_PanelPortMap.CurrentCell.RowIndex || currentPortToSetup != dataGridView_PanelPortMap.CurrentCell.ColumnIndex)
				{
					currentPanelToSetup = dataGridView_PanelPortMap.CurrentCell.RowIndex;
					currentPortToSetup = dataGridView_PanelPortMap.CurrentCell.ColumnIndex;
				}
			}
			else
			{
				currentPortToSetup = 1;
				setSelectedDataGridViewCell(currentPanelToSetup, currentPortToSetup);
			}
			workingOnSameCell = false;
		}
		else if (PanelSpecificGVMode || DetectionInstance == DetectionInstance.DETECT_INST_NET_MODE)
		{
			if (dataGridView_PanelPortMap.CurrentCell.ColumnIndex == 1)
			{
				if (currentPanelToSetup != dataGridView_PanelPortMap.CurrentCell.RowIndex || currentPortToSetup != dataGridView_PanelPortMap.CurrentCell.ColumnIndex)
				{
					currentPanelToSetup = dataGridView_PanelPortMap.CurrentCell.RowIndex;
					currentPortToSetup = dataGridView_PanelPortMap.CurrentCell.ColumnIndex;
				}
			}
			else
			{
				currentPortToSetup = 1;
				setSelectedDataGridViewCell(currentPanelToSetup, currentPortToSetup);
			}
			workingOnSameCell = false;
		}
		else
		{
			unselectAllDataGridViewCell();
		}
	}

	private void dataGridView_PanelPortMap_CellClick(object sender, DataGridViewCellEventArgs e)
	{
		UpdateSelection();
	}

	private void dataGridView_PanelPortMap_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
	{
		UpdateSelection();
	}

	private void checkBox_ManualPortSetup_CheckedChanged(object sender, EventArgs e)
	{
		ManualSetup = checkBox_ManualPortSetup.Checked;
		ResetGuiState();
	}

	private void checkBox_PhysicalAddressMode_CheckedChanged(object sender, EventArgs e)
	{
		if (checkBox_PhysicalAddressMode.Checked)
		{
			DetectionInstance = DetectionInstance.DETECT_INST_PHY_ADDR;
		}
		else
		{
			DetectionInstance = DetectionInstance.DETECT_INST_PORT_NO;
		}
		ResetGuiState();
	}

	private void checkBox_NetMode_CheckedChanged(object sender, EventArgs e)
	{
		if (checkBox_NetMode.Checked)
		{
			DetectionInstance = DetectionInstance.DETECT_INST_NET_MODE;
		}
		else if (checkBox_PhysicalAddressMode.Checked)
		{
			DetectionInstance = DetectionInstance.DETECT_INST_PHY_ADDR;
		}
		else
		{
			DetectionInstance = DetectionInstance.DETECT_INST_PORT_NO;
		}
		ResetGuiState();
	}

	private void checkBox_ConfigPanelGV_CheckedChanged(object sender, EventArgs e)
	{
		PanelSpecificGVMode = checkBox_ConfigPanelGV.Checked;
		if (PanelSpecificGVMode)
		{
			updateGUI_PanelGVStyle();
		}
		else
		{
			ResetGuiState();
		}
	}

	private void radioButton_SinglePortSetup_CheckedChanged(object sender, EventArgs e)
	{
		if (radioButton_SinglePortSetup.Checked)
		{
			DualPortSolution = false;
		}
		else
		{
			DualPortSolution = true;
		}
		ResetGuiState();
	}

	private void setSelectedDataGridViewCell(int row, int column)
	{
		dataGridView_PanelPortMap.CurrentCell = dataGridView_PanelPortMap[column, row];
		dataGridView_PanelPortMap.CurrentCell.Selected = true;
	}

	private void setUnselectedDataGridViewCell(int row, int column)
	{
		dataGridView_PanelPortMap[column, row].Selected = false;
	}

	private void unselectAllDataGridViewCell()
	{
		currentPanelToSetup = 0;
		currentPortToSetup = 1;
		dataGridView_PanelPortMap.ClearSelection();
	}

	private bool GetUserInputYesNo(string message, string caption)
	{
		DialogResult dialogResult = MessageBox.Show(this, message, caption, MessageBoxButtons.YesNo);
		if (dialogResult == DialogResult.No)
		{
			return false;
		}
		return true;
	}

	private void NonTreeExecution(string onPorts)
	{
		try
		{
			PauseDeviceSetupProcess();
			Thread.Sleep(portDetectionSettings.DeviceManagerStabilizationTimeout * 1000);
			string portDetectionKeyword;
			UIHelper.InvokeOnUIifRequired(this, delegate
			{
				lock (notificationLock)
				{
					UpdateStatus($"Port Info Received: {onPorts}");
					if (DetectionInstance == DetectionInstance.DETECT_INST_PORT_NO && DualPortSolution)
					{
						if (currentPortToSetup == 1)
						{
							portDetectionKeyword = portDetectionSettings.EDownloadKeyWord;
						}
						else
						{
							portDetectionKeyword = portDetectionSettings.DiagnosticKeyWord;
						}
					}
					else
					{
						portDetectionKeyword = Convert.ToString(comboBox_PortDetectionKeyWord.SelectedItem);
						portDetectionKeyword = portDetectionKeyword.Substring(portDetectionKeyword.IndexOf("("));
						portDetectionKeyword = portDetectionKeyword.Substring(1, portDetectionKeyword.LastIndexOf(")") - 1);
					}
					string[] array = onPorts.Split(',');
					int num = 0;
					string[] array2 = array;
					foreach (string value in array2)
					{
						num = Convert.ToInt32(value);
						if (IsItCorrectPort(num, portDetectionKeyword))
						{
							UpdateStatus($"Port detected to be {num}");
							break;
						}
						UpdateStatus(string.Format("Port keyword is not " + portDetectionKeyword));
						num = 0;
					}
					if (num == 0)
					{
						MessageBox.Show(string.Format(CommonResource.BoxMsgConfigPortFailed, portDetectionKeyword, onPorts));
					}
					else
					{
						if (DetectionInstance == DetectionInstance.DETECT_INST_PHY_ADDR)
						{
							string physicalAddress = GetPhysicalAddress(num);
							UpdateStatus(string.Format("Port physical address is " + physicalAddress));
							dgvManager.PortDataManager.AddPanelPort(currentPanelToSetup + 1, num, physicalAddress);
						}
						else if (currentPortToSetup == 1)
						{
							dgvManager.PortDataManager.AddPanelPort(currentPanelToSetup + 1, num);
						}
						else
						{
							int cOMPortAtStart = dgvManager.PortDataManager.PanelPortMap[currentPanelToSetup + 1].COMPortAtStart;
							dgvManager.PortDataManager.AddPanelPort(currentPanelToSetup + 1, cOMPortAtStart, num);
						}
						dgvManager.UpdateGridView();
						DeviceUpdatedForCurrentPanel();
					}
				}
			});
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
		finally
		{
			ResumeDeviceSetupProcess();
		}
	}

	private void PauseDeviceSetupProcess()
	{
		ResetDeviceConnectionTime();
		timer_DeviceConnectTimeoutNotification.Enabled = false;
		deviceNotification.Stop();
	}

	private void ResumeDeviceSetupProcess()
	{
		if (!setupCompleted)
		{
			ResetDeviceConnectionTime();
			deviceNotification.Start();
			timer_DeviceConnectTimeoutNotification.Enabled = true;
		}
	}

	private bool IsItCorrectPort(int port, string portDetectionKeyword)
	{
		try
		{
			USBEnumerator uSBEnumerator = new USBEnumerator();
			uSBEnumerator.PortKeyWord.Clear();
			uSBEnumerator.PortKeyWord.Add(portDetectionKeyword);
			List<int> intPortNumberCollection = new List<int>();
			uSBEnumerator.GetPortNumberList(ref intPortNumberCollection);
			return intPortNumberCollection.Contains(port);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
		return false;
	}

	private string GetPhysicalAddress(int port)
	{
		string result = "";
		try
		{
			USBEnumerator uSBEnumerator = new USBEnumerator();
			uSBEnumerator.PortKeyWord.Clear();
			List<string> strPhysicalAddressCollection = new List<string>();
			uSBEnumerator.GetUSBDevicePhysicalAddressByName("(COM" + port + ")", ref strPhysicalAddressCollection);
			if (strPhysicalAddressCollection.Count == 1)
			{
				result = strPhysicalAddressCollection[0];
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
		return result;
	}

	private void NotifyUserOfExpiredTime()
	{
		lock (lockUserNotification)
		{
			try
			{
				if (!timeExpiredMessageBeenDisplayed)
				{
					timeExpiredMessageBeenDisplayed = true;
					PauseDeviceSetupProcess();
					if (!GetUserInputYesNo(CommonResource.BoxMsgTimeExpired, CommonResource.BoxTitleTimeExpired))
					{
						PortSetupProcessCompleted();
					}
					else
					{
						MessageBox.Show(CommonResource.BoxMsgConnectDevice);
						ResumeDeviceSetupProcess();
					}
					timeExpiredMessageBeenDisplayed = false;
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
	}

	private void ResetDeviceConnectionTime()
	{
		startTime = DateTime.Now;
	}

	private bool IsDeviceConnectionTimeUnderLimit()
	{
		bool result = true;
		int portConnectionTimeoutInSec = portDetectionSettings.PortConnectionTimeoutInSec;
		int timePassedInSeconds = GetTimePassedInSeconds();
		if (timePassedInSeconds > portConnectionTimeoutInSec)
		{
			result = false;
		}
		return result;
	}

	private int GetTimePassedInSeconds()
	{
		TimeSpan timeSpan = DateTime.Now.Subtract(startTime);
		if (timeSpan.Seconds > 0)
		{
			return timeSpan.Seconds;
		}
		return 0;
	}

	public void UpdateLanguage()
	{
		groupBox_StartProcess.Text = CommonResource.GroupBox_StartProcess;
		button_Start.Text = CommonResource.Button_Start;
		button_AbortSetupProcess.Text = CommonResource.Button_AbortSetupProcess;
		groupBox_SkipToPanel.Text = CommonResource.GroupBox_SkipToPanel;
		button_SkipToPrev.Text = CommonResource.Button_SkipToPrev;
		button_SkipToNext.Text = CommonResource.Button_SkipToNext;
		groupBox_PortSetupOptions.Text = CommonResource.GroupBox_PortSetupOptions;
		radioButton_SinglePortSetup.Text = CommonResource.RadioButton_SinglePortSetup;
		radioButton_TwoPortSetup.Text = CommonResource.RadioButton_TwoPortSetup;
		checkBox_ManualPortSetup.Text = CommonResource.CheckBox_ManualPortSetup;
		checkBox_PhysicalAddressMode.Text = CommonResource.CheckBox_PhyAddrMode;
		checkBox_NetMode.Text = CommonResource.CheckBox_NetMode;
		labelPortDetectionKeyWord.Text = CommonResource.LabelPortDetectionKeyWord;
		groupBox_Ports.Text = CommonResource.GroupBox_Ports;
		groupBox_Process.Text = CommonResource.GroupBox_Process;
		groupBox_Status.Text = CommonResource.GroupBox_Status;
	}

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

	private void InitializeComponent()
	{
		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.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
		this.label_PanelNumber = new System.Windows.Forms.Label();
		this.groupBox_Ports = new System.Windows.Forms.GroupBox();
		this.checkBox_ConfigPanelGV = new System.Windows.Forms.CheckBox();
		this.dataGridView_PanelPortMap = new System.Windows.Forms.DataGridView();
		this.textBox_Status = new System.Windows.Forms.TextBox();
		this.groupBox_Status = new System.Windows.Forms.GroupBox();
		this.groupBox_Process = new System.Windows.Forms.GroupBox();
		this.groupBox_PortSetupOptions = new System.Windows.Forms.GroupBox();
		this.checkBox_NetMode = new System.Windows.Forms.CheckBox();
		this.checkBox_PhysicalAddressMode = new System.Windows.Forms.CheckBox();
		this.comboBox_PortDetectionKeyWord = new System.Windows.Forms.ComboBox();
		this.labelPortDetectionKeyWord = new System.Windows.Forms.Label();
		this.checkBox_ManualPortSetup = new System.Windows.Forms.CheckBox();
		this.radioButton_TwoPortSetup = new System.Windows.Forms.RadioButton();
		this.radioButton_SinglePortSetup = new System.Windows.Forms.RadioButton();
		this.groupBox_StartProcess = new System.Windows.Forms.GroupBox();
		this.button_AbortSetupProcess = new System.Windows.Forms.Button();
		this.button_Start = new System.Windows.Forms.Button();
		this.groupBox_SkipToPanel = new System.Windows.Forms.GroupBox();
		this.button_SkipToPrev = new System.Windows.Forms.Button();
		this.button_SkipToNext = new System.Windows.Forms.Button();
		this.groupBox_Ports.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.dataGridView_PanelPortMap).BeginInit();
		this.groupBox_Status.SuspendLayout();
		this.groupBox_Process.SuspendLayout();
		this.groupBox_PortSetupOptions.SuspendLayout();
		this.groupBox_StartProcess.SuspendLayout();
		this.groupBox_SkipToPanel.SuspendLayout();
		base.SuspendLayout();
		this.label_PanelNumber.AutoSize = true;
		this.label_PanelNumber.Font = new System.Drawing.Font("Microsoft Sans Serif", 15f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.label_PanelNumber.Location = new System.Drawing.Point(748, -5);
		this.label_PanelNumber.Name = "label_PanelNumber";
		this.label_PanelNumber.Size = new System.Drawing.Size(0, 25);
		this.label_PanelNumber.TabIndex = 5;
		this.groupBox_Ports.Controls.Add(this.checkBox_ConfigPanelGV);
		this.groupBox_Ports.Controls.Add(this.dataGridView_PanelPortMap);
		this.groupBox_Ports.Location = new System.Drawing.Point(3, 22);
		this.groupBox_Ports.Name = "groupBox_Ports";
		this.groupBox_Ports.Size = new System.Drawing.Size(317, 239);
		this.groupBox_Ports.TabIndex = 19;
		this.groupBox_Ports.TabStop = false;
		this.groupBox_Ports.Text = "Ports";
		this.checkBox_ConfigPanelGV.AutoSize = true;
		this.checkBox_ConfigPanelGV.Location = new System.Drawing.Point(15, 212);
		this.checkBox_ConfigPanelGV.Name = "checkBox_ConfigPanelGV";
		this.checkBox_ConfigPanelGV.Size = new System.Drawing.Size(136, 17);
		this.checkBox_ConfigPanelGV.TabIndex = 20;
		this.checkBox_ConfigPanelGV.Text = "Panel GV Configuration";
		this.checkBox_ConfigPanelGV.UseVisualStyleBackColor = true;
		this.checkBox_ConfigPanelGV.CheckedChanged += new System.EventHandler(checkBox_ConfigPanelGV_CheckedChanged);
		this.dataGridView_PanelPortMap.AllowUserToAddRows = false;
		this.dataGridView_PanelPortMap.AllowUserToDeleteRows = false;
		this.dataGridView_PanelPortMap.AllowUserToResizeColumns = false;
		this.dataGridView_PanelPortMap.AllowUserToResizeRows = false;
		dataGridViewCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.BottomCenter;
		this.dataGridView_PanelPortMap.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle;
		this.dataGridView_PanelPortMap.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
		dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
		dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dataGridView_PanelPortMap.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
		this.dataGridView_PanelPortMap.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window;
		dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
		dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText;
		dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
		this.dataGridView_PanelPortMap.DefaultCellStyle = dataGridViewCellStyle3;
		this.dataGridView_PanelPortMap.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
		this.dataGridView_PanelPortMap.Location = new System.Drawing.Point(15, 19);
		this.dataGridView_PanelPortMap.Name = "dataGridView_PanelPortMap";
		this.dataGridView_PanelPortMap.ReadOnly = true;
		dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dataGridView_PanelPortMap.RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
		this.dataGridView_PanelPortMap.RowHeadersVisible = false;
		this.dataGridView_PanelPortMap.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
		this.dataGridView_PanelPortMap.Size = new System.Drawing.Size(283, 187);
		this.dataGridView_PanelPortMap.TabIndex = 19;
		this.dataGridView_PanelPortMap.TabStop = false;
		this.dataGridView_PanelPortMap.DataSourceChanged += new System.EventHandler(dataGridView_PanelPortMap_DataSourceChanged);
		this.dataGridView_PanelPortMap.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(dataGridView_PanelPortMap_CellClick);
		this.dataGridView_PanelPortMap.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(dataGridView_PanelPortMap_CellDoubleClick);
		this.dataGridView_PanelPortMap.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(dataGridView_PanelPortMap_CellEndEdit);
		this.dataGridView_PanelPortMap.KeyDown += new System.Windows.Forms.KeyEventHandler(dataGridView_PanelPortMap_KeyDown);
		this.textBox_Status.Location = new System.Drawing.Point(6, 19);
		this.textBox_Status.Multiline = true;
		this.textBox_Status.Name = "textBox_Status";
		this.textBox_Status.ReadOnly = true;
		this.textBox_Status.ScrollBars = System.Windows.Forms.ScrollBars.Both;
		this.textBox_Status.Size = new System.Drawing.Size(188, 210);
		this.textBox_Status.TabIndex = 15;
		this.groupBox_Status.Controls.Add(this.textBox_Status);
		this.groupBox_Status.Location = new System.Drawing.Point(755, 22);
		this.groupBox_Status.Name = "groupBox_Status";
		this.groupBox_Status.Size = new System.Drawing.Size(200, 239);
		this.groupBox_Status.TabIndex = 21;
		this.groupBox_Status.TabStop = false;
		this.groupBox_Status.Text = "Status";
		this.groupBox_Process.Controls.Add(this.groupBox_PortSetupOptions);
		this.groupBox_Process.Controls.Add(this.groupBox_StartProcess);
		this.groupBox_Process.Controls.Add(this.groupBox_SkipToPanel);
		this.groupBox_Process.Location = new System.Drawing.Point(326, 22);
		this.groupBox_Process.Name = "groupBox_Process";
		this.groupBox_Process.Size = new System.Drawing.Size(416, 239);
		this.groupBox_Process.TabIndex = 20;
		this.groupBox_Process.TabStop = false;
		this.groupBox_Process.Text = "Process";
		this.groupBox_PortSetupOptions.Controls.Add(this.checkBox_NetMode);
		this.groupBox_PortSetupOptions.Controls.Add(this.checkBox_PhysicalAddressMode);
		this.groupBox_PortSetupOptions.Controls.Add(this.comboBox_PortDetectionKeyWord);
		this.groupBox_PortSetupOptions.Controls.Add(this.labelPortDetectionKeyWord);
		this.groupBox_PortSetupOptions.Controls.Add(this.checkBox_ManualPortSetup);
		this.groupBox_PortSetupOptions.Controls.Add(this.radioButton_TwoPortSetup);
		this.groupBox_PortSetupOptions.Controls.Add(this.radioButton_SinglePortSetup);
		this.groupBox_PortSetupOptions.Location = new System.Drawing.Point(9, 136);
		this.groupBox_PortSetupOptions.Name = "groupBox_PortSetupOptions";
		this.groupBox_PortSetupOptions.Size = new System.Drawing.Size(380, 82);
		this.groupBox_PortSetupOptions.TabIndex = 12;
		this.groupBox_PortSetupOptions.TabStop = false;
		this.groupBox_PortSetupOptions.Text = "Port Setup Options";
		this.checkBox_NetMode.Location = new System.Drawing.Point(306, 19);
		this.checkBox_NetMode.Name = "checkBox_NetMode";
		this.checkBox_NetMode.Size = new System.Drawing.Size(53, 30);
		this.checkBox_NetMode.TabIndex = 9;
		this.checkBox_NetMode.Text = "Net \nMode";
		this.checkBox_NetMode.UseVisualStyleBackColor = true;
		this.checkBox_NetMode.CheckedChanged += new System.EventHandler(checkBox_NetMode_CheckedChanged);
		this.checkBox_PhysicalAddressMode.Location = new System.Drawing.Point(221, 20);
		this.checkBox_PhysicalAddressMode.Name = "checkBox_PhysicalAddressMode";
		this.checkBox_PhysicalAddressMode.Size = new System.Drawing.Size(72, 30);
		this.checkBox_PhysicalAddressMode.TabIndex = 8;
		this.checkBox_PhysicalAddressMode.Text = "Phy Addr \nMode";
		this.checkBox_PhysicalAddressMode.UseVisualStyleBackColor = true;
		this.checkBox_PhysicalAddressMode.CheckedChanged += new System.EventHandler(checkBox_PhysicalAddressMode_CheckedChanged);
		this.comboBox_PortDetectionKeyWord.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.comboBox_PortDetectionKeyWord.FormattingEnabled = true;
		this.comboBox_PortDetectionKeyWord.Location = new System.Drawing.Point(191, 57);
		this.comboBox_PortDetectionKeyWord.MaxDropDownItems = 2;
		this.comboBox_PortDetectionKeyWord.Name = "comboBox_PortDetectionKeyWord";
		this.comboBox_PortDetectionKeyWord.Size = new System.Drawing.Size(151, 21);
		this.comboBox_PortDetectionKeyWord.TabIndex = 7;
		this.labelPortDetectionKeyWord.AutoSize = true;
		this.labelPortDetectionKeyWord.Location = new System.Drawing.Point(6, 60);
		this.labelPortDetectionKeyWord.Name = "labelPortDetectionKeyWord";
		this.labelPortDetectionKeyWord.Size = new System.Drawing.Size(128, 13);
		this.labelPortDetectionKeyWord.TabIndex = 6;
		this.labelPortDetectionKeyWord.Text = "Port Detection Key Word:";
		this.checkBox_ManualPortSetup.Location = new System.Drawing.Point(145, 20);
		this.checkBox_ManualPortSetup.Name = "checkBox_ManualPortSetup";
		this.checkBox_ManualPortSetup.Size = new System.Drawing.Size(64, 30);
		this.checkBox_ManualPortSetup.TabIndex = 5;
		this.checkBox_ManualPortSetup.Text = "Manual \nSetup";
		this.checkBox_ManualPortSetup.UseVisualStyleBackColor = true;
		this.checkBox_ManualPortSetup.CheckedChanged += new System.EventHandler(checkBox_ManualPortSetup_CheckedChanged);
		this.radioButton_TwoPortSetup.Location = new System.Drawing.Point(75, 19);
		this.radioButton_TwoPortSetup.Name = "radioButton_TwoPortSetup";
		this.radioButton_TwoPortSetup.Size = new System.Drawing.Size(56, 30);
		this.radioButton_TwoPortSetup.TabIndex = 4;
		this.radioButton_TwoPortSetup.Text = "2 Port \nSetup";
		this.radioButton_TwoPortSetup.UseVisualStyleBackColor = true;
		this.radioButton_SinglePortSetup.Checked = true;
		this.radioButton_SinglePortSetup.Location = new System.Drawing.Point(6, 19);
		this.radioButton_SinglePortSetup.Name = "radioButton_SinglePortSetup";
		this.radioButton_SinglePortSetup.Size = new System.Drawing.Size(56, 30);
		this.radioButton_SinglePortSetup.TabIndex = 3;
		this.radioButton_SinglePortSetup.TabStop = true;
		this.radioButton_SinglePortSetup.Text = "1 Port \nSetup";
		this.radioButton_SinglePortSetup.UseVisualStyleBackColor = true;
		this.radioButton_SinglePortSetup.CheckedChanged += new System.EventHandler(radioButton_SinglePortSetup_CheckedChanged);
		this.groupBox_StartProcess.Controls.Add(this.button_AbortSetupProcess);
		this.groupBox_StartProcess.Controls.Add(this.button_Start);
		this.groupBox_StartProcess.Location = new System.Drawing.Point(9, 23);
		this.groupBox_StartProcess.Name = "groupBox_StartProcess";
		this.groupBox_StartProcess.Size = new System.Drawing.Size(381, 49);
		this.groupBox_StartProcess.TabIndex = 12;
		this.groupBox_StartProcess.TabStop = false;
		this.groupBox_StartProcess.Text = "SetupProcess";
		this.button_AbortSetupProcess.Location = new System.Drawing.Point(191, 19);
		this.button_AbortSetupProcess.Name = "button_AbortSetupProcess";
		this.button_AbortSetupProcess.Size = new System.Drawing.Size(124, 23);
		this.button_AbortSetupProcess.TabIndex = 13;
		this.button_AbortSetupProcess.Text = "Abort Setup Process";
		this.button_AbortSetupProcess.UseVisualStyleBackColor = true;
		this.button_AbortSetupProcess.Click += new System.EventHandler(button_AbortSetupProcess_Click);
		this.button_Start.Location = new System.Drawing.Point(6, 19);
		this.button_Start.Name = "button_Start";
		this.button_Start.Size = new System.Drawing.Size(147, 23);
		this.button_Start.TabIndex = 4;
		this.button_Start.Text = "Start Setup Process";
		this.button_Start.UseVisualStyleBackColor = true;
		this.button_Start.Click += new System.EventHandler(button_Start_Click);
		this.groupBox_SkipToPanel.Controls.Add(this.button_SkipToPrev);
		this.groupBox_SkipToPanel.Controls.Add(this.button_SkipToNext);
		this.groupBox_SkipToPanel.Location = new System.Drawing.Point(9, 79);
		this.groupBox_SkipToPanel.Name = "groupBox_SkipToPanel";
		this.groupBox_SkipToPanel.Size = new System.Drawing.Size(381, 50);
		this.groupBox_SkipToPanel.TabIndex = 9;
		this.groupBox_SkipToPanel.TabStop = false;
		this.groupBox_SkipToPanel.Text = "Select Panel";
		this.button_SkipToPrev.Location = new System.Drawing.Point(6, 19);
		this.button_SkipToPrev.Name = "button_SkipToPrev";
		this.button_SkipToPrev.Size = new System.Drawing.Size(147, 23);
		this.button_SkipToPrev.TabIndex = 6;
		this.button_SkipToPrev.Text = "Previous Panel";
		this.button_SkipToPrev.UseVisualStyleBackColor = true;
		this.button_SkipToPrev.Click += new System.EventHandler(button_SkipToPrev_Click);
		this.button_SkipToNext.Location = new System.Drawing.Point(191, 19);
		this.button_SkipToNext.Name = "button_SkipToNext";
		this.button_SkipToNext.Size = new System.Drawing.Size(124, 23);
		this.button_SkipToNext.TabIndex = 2;
		this.button_SkipToNext.Text = "Next Panel";
		this.button_SkipToNext.UseVisualStyleBackColor = true;
		this.button_SkipToNext.Click += new System.EventHandler(button_SkipToNext_Click);
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.Controls.Add(this.groupBox_Status);
		base.Controls.Add(this.groupBox_Process);
		base.Controls.Add(this.groupBox_Ports);
		base.Controls.Add(this.label_PanelNumber);
		base.Name = "DeviceSetup";
		base.Size = new System.Drawing.Size(956, 270);
		this.groupBox_Ports.ResumeLayout(false);
		this.groupBox_Ports.PerformLayout();
		((System.ComponentModel.ISupportInitialize)this.dataGridView_PanelPortMap).EndInit();
		this.groupBox_Status.ResumeLayout(false);
		this.groupBox_Status.PerformLayout();
		this.groupBox_Process.ResumeLayout(false);
		this.groupBox_PortSetupOptions.ResumeLayout(false);
		this.groupBox_PortSetupOptions.PerformLayout();
		this.groupBox_StartProcess.ResumeLayout(false);
		this.groupBox_SkipToPanel.ResumeLayout(false);
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
