using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Security.Principal;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml.Serialization;
using Multiplex;
using QDART_MFG_CfgEditor.Properties;

namespace QDART_MFG_CfgEditor;

public class QDART_MFG_CfgEditor : Form
{
	private Dictionary<string, int> _targetlist = new Dictionary<string, int>();

	private Dictionary<string, string> ctrlValueMapPre = new Dictionary<string, string>();

	private Dictionary<string, string> ctrlValueMapNow = new Dictionary<string, string>();

	private Root rt = new Root();

	private RootConfig currentConfig = new RootConfig();

	private LanguageDetails currentLang = new LanguageDetails();

	private HelpDialog help = new HelpDialog();

	private Dictionary<int, RFCalVerifyPanel> _instRFCalVerify = new Dictionary<int, RFCalVerifyPanel>();

	private Dictionary<int, RFStationCalSGPMPanel> _instRFStationCal = new Dictionary<int, RFStationCalSGPMPanel>();

	private Dictionary<int, PathLossEditor> _editorRF = new Dictionary<int, PathLossEditor>();

	private Dictionary<int, WCNPanel> _instWCN = new Dictionary<int, WCNPanel>();

	private Dictionary<int, MMIPanel> _MMICfg = new Dictionary<int, MMIPanel>();

	private WCNStationCalPanel _instWCNStationCal;

	private PathLossEditor _editorBTWLAN;

	private QSeqPanel _qseq;

	private MultiplexPanel _multiplex;

	private GpsPanel _gps;

	private LoggingConfigPanel _loggingConfig;

	private int max_dut;

	private int curr_dut;

	private int errnum;

	private int currTarget;

	private bool bExpectTargetChange;

	private bool bFirstRun;

	private bool bQuit;

	private IContainer components;

	private Button btnSave;

	private StatusStrip statusStrip1;

	private ToolStripStatusLabel toolStripStatusLabel1;

	private ToolStrip toolStrip1;

	private ToolStripMenuItem viewHelpToolStripMenuItem;

	private ToolStripMenuItem aboutQRDCfgEditorToolStripMenuItem;

	private ToolStripButton toolStripButton2;

	private ToolStripSeparator toolStripSeparator1;

	private ToolStripDropDownButton toolStripDropDownButton2;

	private ToolStripMenuItem viewHelpToolStripMenuItem1;

	private ToolStripMenuItem aboutQRDCfgEditorToolStripMenuItem1;

	private ToolStripButton btnSet;

	private ToolStripSeparator toolStripSeparator2;

	private ToolStripDropDownButton btnHelp;

	private ToolStripMenuItem viewHelp;

	private ToolStripMenuItem aboutMenu;

	private ToolStripButton btnLanguage;

	private ToolStripSeparator toolStripSeparator3;

	private ErrorProvider errorProvider1;

	private Label lbTarget;

	private ToolStrip multiField;

	private ToolStripButton btnPre;

	private ToolStripButton btnNext;

	private ToolStripLabel lbNow;

	private ToolStripLabel lbDUT;

	private Panel panel2;

	private Panel panel1;

	private Panel panel3;

	private ComboBoxEx cbTarget;

	private Panel panel4;

	private Button btnNextDUT;

	private Panel panel5;

	private Button btnPreDUT;

	private Panel panel6;

	private Panel userPanel;

	private ToolStripDropDownButton btnFile;

	private ToolStripMenuItem openfile;

	private ToolStripMenuItem savefile;

	private ToolStripMenuItem savefileas;

	public ToolStripStatusLabel Status;

	private ToolStripSeparator toolStripSeparator4;

	private ToolStripSeparator toolStripSeparator5;

	private ToolStripDropDownButton toollink;

	private ToolStripMenuItem stationCalToolStripMenuItem;

	private Label lbTargetFile;

	public RootConfig CurrentConfig
	{
		get
		{
			return currentConfig;
		}
		set
		{
			currentConfig = value;
		}
	}

	public int MAX_DUT
	{
		get
		{
			return max_dut;
		}
		set
		{
			max_dut = value;
			if (max_dut == 0)
			{
				curr_dut = 0;
			}
			else if (curr_dut == 0 || curr_dut > max_dut)
			{
				curr_dut = 1;
			}
		}
	}

	public QDART_MFG_CfgEditor(string[] args)
	{
		try
		{
			WindowsPrincipal windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
			if (!windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator))
			{
				DialogResult dialogResult = MessageBox.Show("This application is not running in ‘Administrator’ mode. This is not recommended.\r\n\r\nClick 'OK' to continue.\r\nClick 'Cancel' to quit.", "QDART_MFG_CfgEditor", MessageBoxButtons.OKCancel);
				if (dialogResult == DialogResult.Cancel)
				{
					Environment.Exit(0);
				}
			}
			InitializeComponent();
			bQuit = false;
			Environment.CurrentDirectory = Application.StartupPath;
			CurrentConfig = LoadConfig(Path.Combine(Application.StartupPath, "QDART_MFG_CfgEditor_Link.xml"), out bQuit);
			if (CurrentConfig != null)
			{
				ExternalArgs(args);
				InitGlobalVar();
				currentLang.CurrentLanguage = CurrentConfig.LanguageUsed;
				UpdateLanguage();
				InitUI();
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void ExternalArgs(string[] args)
	{
		string text = "";
		int result = 0;
		try
		{
			if (args.Length != 0)
			{
				text = args[0];
				text = text.Replace("-", "");
				if (!int.TryParse(text, out result))
				{
					MessageBox.Show("External args error! Only number or number prefix with '-' allowed.");
					return;
				}
				PrepareDUTFolders(result);
				CurrentConfig.DUTs = result.ToString();
				SaveConfig(CurrentConfig);
				return;
			}
			bool result2 = false;
			int result3 = 0;
			if (!bool.TryParse(CurrentConfig.MultiDUT, out result2))
			{
				bQuit = true;
			}
			if (!int.TryParse(CurrentConfig.DUTs, out result3))
			{
				bQuit = true;
			}
			if (result2)
			{
				PrepareDUTFolders(result3);
				Text = currentLang.GetData(131) + currentLang.GetData(132);
			}
			else
			{
				Text = currentLang.GetData(131);
			}
		}
		catch
		{
		}
	}

	private void PrepareDUTFolders(int numOfDut)
	{
		if (currTarget == 5)
		{
			PrepareDUTFoldersWCN(numOfDut);
		}
		else
		{
			PrepareDUTFoldersCellular(numOfDut);
		}
	}

	private void PrepareDUTFoldersCellular(int numOfDut)
	{
		string path = Path.Combine(Application.StartupPath, "..\\Databases");
		List<string> list = new List<string>();
		list.Add("equipconfig.xml");
		list.Add("CalDB_NET.xml");
		list.Add("stationconfig.xml");
		list.Add("HTML_QDART_Basic.xsl");
		list.Add("HTML_QDART_Combined.xsl");
		List<string> list2 = list;
		foreach (string item in list2)
		{
			bool flag = false;
			for (int i = 1; i <= numOfDut; i++)
			{
				string path2 = Path.Combine(path, "DUT_" + i);
				if (!Directory.Exists(path2))
				{
					Directory.CreateDirectory(path2);
				}
			}
			if (File.Exists(Path.Combine(path, item)))
			{
				flag = true;
			}
			bool flag2 = false;
			for (int j = 1; j <= numOfDut; j++)
			{
				string text = Path.Combine(path, "DUT_" + j, item);
				if (!File.Exists(text))
				{
					if (flag)
					{
						File.Copy(Path.Combine(path, item), text);
					}
					flag2 = true;
				}
			}
			string text2 = "";
			if (!flag && flag2)
			{
				text2 = text2 + "Skipped copy default file. Due to " + item + " not exist.\n";
			}
			if (text2.Length != 0)
			{
				MessageBox.Show(text2, "Warning");
			}
		}
	}

	private void PrepareDUTFolders()
	{
		ConfigurationFile configurationFile = new ConfigurationFile();
		using (FileStream fileStream = new FileStream(_multiplex.GetResultFilePath(), FileMode.Open, FileAccess.Read, FileShare.Read))
		{
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(ConfigurationFile));
			configurationFile = (ConfigurationFile)xmlSerializer.Deserialize(fileStream);
			fileStream.Close();
		}
		Dictionary<string, string> dictionary = new Dictionary<string, string>();
		for (int i = 0; i < configurationFile.MultiDUTConfigItems.GroupsSection.GroupList.Count; i++)
		{
			for (int j = 0; j < configurationFile.MultiDUTConfigItems.GroupsSection.GroupList[i].DutList.Count; j++)
			{
				dictionary.Add(configurationFile.MultiDUTConfigItems.GroupsSection.GroupList[i].DutList[j].DutID, configurationFile.MultiDUTConfigItems.GroupsSection.GroupList[i].GroupID);
			}
		}
		string path = Path.Combine(Application.StartupPath, "..\\Databases");
		foreach (KeyValuePair<string, string> item in dictionary)
		{
			string path2 = Path.Combine(path, "DUT_" + item.Key);
			if (!Directory.Exists(path2))
			{
				Directory.CreateDirectory(path2);
			}
		}
		List<string> list = new List<string>();
		list.Add("equipconfig.xml");
		list.Add("CalDB_NET.xml");
		list.Add("stationconfig.xml");
		list.Add("HTML_QDART_Basic.xsl");
		list.Add("HTML_QDART_Combined.xsl");
		List<string> list2 = list;
		foreach (string item2 in list2)
		{
			bool flag = false;
			if (File.Exists(Path.Combine(path, item2)))
			{
				flag = true;
			}
			bool flag2 = false;
			foreach (KeyValuePair<string, string> item3 in dictionary)
			{
				string text = Path.Combine(path, "DUT_" + item3.Key, item2);
				if (!File.Exists(text))
				{
					if (flag)
					{
						File.Copy(Path.Combine(path, item2), text);
					}
					flag2 = true;
				}
			}
			string text2 = "";
			if (!flag && flag2)
			{
				text2 = text2 + "Skipped copy default file. Due to " + item2 + " not exist.\n";
			}
			if (text2.Length != 0)
			{
				MessageBox.Show(text2, "Warning");
			}
		}
	}

	private void PrepareDUTFoldersWCN(int numOfDut)
	{
		string path = "";
		RootConfigAllPanel[] panel = CurrentConfig.All[0].Panel;
		foreach (RootConfigAllPanel rootConfigAllPanel in panel)
		{
			if (rootConfigAllPanel.Name == "BTWLAN")
			{
				path = Path.GetDirectoryName(rootConfigAllPanel.File[0].Value);
			}
		}
		List<string> list = new List<string>();
		list.Add("TesterConfig.xml");
		List<string> list2 = list;
		foreach (string item in list2)
		{
			bool flag = false;
			for (int j = 1; j <= numOfDut; j++)
			{
				string path2 = Path.Combine(path, "DUT_" + j);
				if (!Directory.Exists(path2))
				{
					Directory.CreateDirectory(path2);
				}
			}
			if (File.Exists(Path.Combine(path, item)))
			{
				flag = true;
			}
			bool flag2 = false;
			for (int k = 1; k <= numOfDut; k++)
			{
				string text = Path.Combine(path, "DUT_" + k, item);
				if (!File.Exists(text))
				{
					if (flag)
					{
						File.Copy(Path.Combine(path, item), text);
					}
					flag2 = true;
				}
			}
			string text2 = "";
			if (!flag && flag2)
			{
				text2 = text2 + "Skipped copy default file. Due to " + item + " not exist.\n";
			}
			if (text2.Length != 0)
			{
				MessageBox.Show(text2, "Warning");
			}
		}
	}

	private RootConfig LoadConfig(string linkFileName, out bool bQuit)
	{
		try
		{
			RootConfig result = null;
			if (!File.Exists(linkFileName))
			{
				bQuit = true;
			}
			using (FileStream fileStream = new FileStream(linkFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
			{
				XmlSerializer xmlSerializer = new XmlSerializer(typeof(Root));
				rt = (Root)xmlSerializer.Deserialize(fileStream);
				if (rt != null)
				{
					result = (RootConfig)rt.Items[0];
				}
				fileStream.Close();
			}
			bQuit = false;
			return result;
		}
		catch
		{
			bQuit = true;
			return null;
		}
	}

	private void SaveConfig(RootConfig rcf)
	{
		try
		{
			if (File.GetAttributes(Path.Combine(Application.StartupPath, "QDART_MFG_CfgEditor_Link.xml")).ToString().IndexOf("ReadOnly") != -1)
			{
				File.SetAttributes(Path.Combine(Application.StartupPath, "QDART_MFG_CfgEditor_Link.xml"), FileAttributes.Normal);
			}
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(Root));
			using StreamWriter streamWriter = new StreamWriter(Path.Combine(Application.StartupPath, "QDART_MFG_CfgEditor_Link.xml"));
			rt.Items[0] = rcf;
			xmlSerializer.Serialize(streamWriter, rt);
			streamWriter.Close();
		}
		catch
		{
		}
	}

	private void RefreshTargetList()
	{
		_targetlist.Clear();
		_targetlist.Add("RFCalVerify", 0);
		_targetlist.Add("RFStationCal", 1);
		_targetlist.Add("BTWLAN", 5);
		_targetlist.Add("LossEditorBTWLAN", 3);
		_targetlist.Add("QSEQ", 9);
		_targetlist.Add("MultiDUT", 10);
		_targetlist.Add("GPS", 11);
		_targetlist.Add("LogCfg", 12);
		_targetlist.Add("MMICfg", 13);
	}

	private void InitGlobalVar()
	{
		RefreshTargetList();
		bExpectTargetChange = false;
		bFirstRun = true;
		currTarget = -1;
		curr_dut = 1;
		bool result = false;
		bool.TryParse(CurrentConfig.MultiDUT, out result);
		if (result)
		{
			MAX_DUT = Convert.ToInt32(CurrentConfig.DUTs);
		}
		else
		{
			MAX_DUT = 0;
		}
	}

	private void InitUI()
	{
		try
		{
			TargetGroup();
			SwitchStationUI();
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void SwitchStationUI()
	{
		Version version = Environment.OSVersion.Version;
		Version value = new Version("6.2");
		switch (currTarget)
		{
		case 0:
		case 1:
		case 13:
			if (version.CompareTo(value) >= 0)
			{
				base.Width = 960;
				base.Height = 870;
			}
			else
			{
				base.Width = 720;
				base.Height = 700;
			}
			btnSet.Enabled = true;
			btnFile.Enabled = true;
			break;
		case 2:
			if (version.CompareTo(value) >= 0)
			{
				base.Width = 1320;
				base.Height = 1000;
			}
			else
			{
				base.Width = 1000;
				base.Height = 700;
			}
			btnSet.Enabled = true;
			btnFile.Enabled = false;
			break;
		case 3:
			if (version.CompareTo(value) >= 0)
			{
				base.Width = 1360;
				base.Height = 870;
			}
			else
			{
				base.Width = 1000;
				base.Height = 700;
			}
			btnSet.Enabled = false;
			btnFile.Enabled = false;
			break;
		case 9:
			if (version.CompareTo(value) >= 0)
			{
				base.Width = 1360;
				base.Height = 870;
			}
			else
			{
				base.Width = 1000;
				base.Height = 700;
			}
			btnSet.Enabled = false;
			btnFile.Enabled = true;
			break;
		case 10:
			if (version.CompareTo(value) >= 0)
			{
				base.Width = 1360;
				base.Height = 870;
			}
			else
			{
				base.Width = 1000;
				base.Height = 700;
			}
			btnSet.Enabled = false;
			btnFile.Enabled = true;
			break;
		case 5:
			if (version.CompareTo(value) >= 0)
			{
				base.Width = 960;
				base.Height = 910;
			}
			else
			{
				base.Width = 720;
				base.Height = 740;
			}
			btnSet.Enabled = true;
			btnFile.Enabled = true;
			break;
		case 11:
			if (version.CompareTo(value) >= 0)
			{
				base.Width = 960;
				base.Height = 870;
			}
			else
			{
				base.Width = 720;
				base.Height = 700;
			}
			btnSet.Enabled = false;
			btnFile.Enabled = true;
			break;
		case 12:
			if (version.CompareTo(value) >= 0)
			{
				base.Width = 960;
				base.Height = 870;
			}
			else
			{
				base.Width = 720;
				base.Height = 700;
			}
			btnSet.Enabled = false;
			btnFile.Enabled = true;
			break;
		}
		LoadUserPanel();
		bool result = false;
		bool.TryParse(CurrentConfig.MultiDUT, out result);
		if (result)
		{
			MAX_DUT = Convert.ToInt32(CurrentConfig.DUTs);
		}
		else
		{
			MAX_DUT = 0;
		}
		LoadMultiDUTField();
		lbNow.Text = curr_dut.ToString();
		if (currTarget != 12)
		{
			StatusBarFlash();
		}
	}

	private void StatusBarFlash()
	{
	}

	private void TargetGroup()
	{
		try
		{
			List<DictionaryEntry> list = new List<DictionaryEntry>();
			foreach (KeyValuePair<string, int> item2 in _targetlist)
			{
				DictionaryEntry item = new DictionaryEntry(currentLang.GetData(item2.Value), item2.Value);
				list.Add(item);
			}
			cbTarget.DataSource = list;
			cbTarget.DisplayMember = "Key";
			cbTarget.ValueMember = "Value";
			bFirstRun = true;
			bExpectTargetChange = false;
			foreach (KeyValuePair<string, int> item3 in _targetlist)
			{
				if (item3.Key == CurrentConfig.Station)
				{
					cbTarget.SelectedValue = item3.Value;
					bFirstRun = true;
					bExpectTargetChange = true;
				}
			}
			currTarget = (int)cbTarget.SelectedValue;
			bExpectTargetChange = true;
			bFirstRun = false;
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void LoadUserPanel()
	{
		try
		{
			userPanel.Controls.Clear();
			switch (currentConfig.Station)
			{
			case "BTWLAN":
				WirelessConnectTestPanel(curr_dut);
				break;
			case "RFCalVerify":
				RFCalVerifyPanel(curr_dut);
				break;
			case "RFStationCal":
				RFStationCalPanel(curr_dut);
				break;
			case "BTWLANStationCal":
				WirelessConnectStationCalPanel();
				break;
			case "LossEditorRF":
				RFLossEditorPanel(curr_dut);
				break;
			case "LossEditorBTWLAN":
				BTWLANLossEditorPanel();
				Status.Text = "";
				break;
			case "LossEditorRFRadiated":
				RFLossEditorPanel(curr_dut);
				break;
			case "QSEQ":
				QSeqPanel();
				Status.Text = "";
				break;
			case "MultiDUT":
				MultiDUTPanel();
				break;
			case "GPS":
				GPSPanel();
				break;
			case "LogCfg":
				LogCfgPanel();
				break;
			case "MMICfg":
				MMICfgPanel(curr_dut);
				break;
			}
			GetCtrlValueMap(bPre: true);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void RFCalVerifyPanel(int index)
	{
		if (!_instRFCalVerify.ContainsKey(index))
		{
			_instRFCalVerify.Add(index, new RFCalVerifyPanel(CurrentConfig, index));
		}
		else
		{
			_instRFCalVerify[index] = new RFCalVerifyPanel(CurrentConfig, index);
		}
		userPanel.Controls.Add(_instRFCalVerify[index]);
		_instRFCalVerify[index].TargetFileChanged -= FormTargetFileChanged;
		_instRFCalVerify[index].TargetFileChanged += FormTargetFileChanged;
		_instRFCalVerify[index].TickFileChange();
	}

	private void RFStationCalPanel(int index)
	{
		if (!_instRFStationCal.ContainsKey(index))
		{
			_instRFStationCal.Add(index, new RFStationCalSGPMPanel(CurrentConfig, index));
		}
		else
		{
			_instRFStationCal[index] = new RFStationCalSGPMPanel(CurrentConfig, index);
		}
		userPanel.Controls.Add(_instRFStationCal[index]);
		_instRFStationCal[index].TargetFileChanged -= FormTargetFileChanged;
		_instRFStationCal[index].TargetFileChanged += FormTargetFileChanged;
		_instRFStationCal[index].TickFileChange();
	}

	private void WirelessConnectTestPanel(int index)
	{
		try
		{
			if (!_instWCN.ContainsKey(index))
			{
				_instWCN.Add(index, new WCNPanel(CurrentConfig, index));
			}
			else
			{
				_instWCN[index] = new WCNPanel(CurrentConfig, index);
			}
			userPanel.Controls.Add(_instWCN[index]);
			_instWCN[index].TargetFileChanged -= FormTargetFileChanged;
			_instWCN[index].TargetFileChanged += FormTargetFileChanged;
			_instWCN[index].TickFileChange();
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void WirelessConnectStationCalPanel()
	{
		try
		{
			_instWCNStationCal = new WCNStationCalPanel(CurrentConfig);
			userPanel.Controls.Add(_instWCNStationCal);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void RFLossEditorPanel(int index)
	{
		if (!_editorRF.ContainsKey(index))
		{
			_editorRF.Add(index, new PathLossEditor(CurrentConfig, index));
		}
		else
		{
			_editorRF[index] = new PathLossEditor(CurrentConfig, index);
		}
		userPanel.Controls.Add(_editorRF[index]);
	}

	private void BTWLANLossEditorPanel()
	{
		try
		{
			_editorBTWLAN = new PathLossEditor(CurrentConfig);
			userPanel.Controls.Add(_editorBTWLAN);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void MultiDUTPanel()
	{
		try
		{
			_multiplex = new MultiplexPanel(CurrentConfig);
			userPanel.Controls.Add(_multiplex);
			_multiplex.TargetFileChanged -= FormTargetFileChanged;
			_multiplex.TargetFileChanged += FormTargetFileChanged;
			_multiplex.TickFileChange();
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void QSeqPanel()
	{
		try
		{
			_qseq = new QSeqPanel(CurrentConfig);
			userPanel.Controls.Add(_qseq);
			_qseq.TargetFileChanged -= FormTargetFileChanged;
			_qseq.TargetFileChanged += FormTargetFileChanged;
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void LoadMultiDUTField()
	{
		if (max_dut == 0)
		{
			multiField.Visible = false;
			btnPreDUT.Visible = false;
			btnNextDUT.Visible = false;
			return;
		}
		switch (currTarget)
		{
		case 0:
		case 1:
		case 2:
		case 5:
		case 13:
			multiField.Visible = true;
			btnPre.Enabled = curr_dut != 1;
			btnPreDUT.Visible = curr_dut != 1;
			btnNext.Enabled = ((curr_dut != max_dut) ? true : false);
			btnNextDUT.Visible = ((curr_dut != max_dut) ? true : false);
			break;
		default:
			multiField.Visible = false;
			btnPreDUT.Visible = false;
			btnNextDUT.Visible = false;
			break;
		}
	}

	private void GPSPanel()
	{
		try
		{
			_gps = new GpsPanel(CurrentConfig);
			userPanel.Controls.Add(_gps);
			_gps.TargetFileChanged -= FormTargetFileChanged;
			_gps.TargetFileChanged += FormTargetFileChanged;
			_gps.TickFileChange();
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void LogCfgPanel()
	{
		try
		{
			_loggingConfig = new LoggingConfigPanel(CurrentConfig);
			_loggingConfig.TargetFileChanged -= FormTargetFileChanged;
			_loggingConfig.TargetFileChanged += FormTargetFileChanged;
			userPanel.Controls.Add(_loggingConfig);
			_loggingConfig.TickFileChange();
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void MMICfgPanel(int index)
	{
		try
		{
			if (!_MMICfg.ContainsKey(index))
			{
				_MMICfg.Add(index, new MMIPanel(CurrentConfig, index));
			}
			else
			{
				_MMICfg[index] = new MMIPanel(CurrentConfig, index);
			}
			_MMICfg[index].TargetFileChanged -= FormTargetFileChanged;
			_MMICfg[index].TargetFileChanged += FormTargetFileChanged;
			userPanel.Controls.Add(_MMICfg[index]);
			_MMICfg[index].TickFileChange();
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void SetFileReadOnly(string aFilePath)
	{
		File.SetAttributes(aFilePath, FileAttributes.ReadOnly);
	}

	private void SetFileWriteable(string aFilePath)
	{
		if (File.GetAttributes(aFilePath).ToString().IndexOf("ReadOnly") != -1)
		{
			File.SetAttributes(aFilePath, FileAttributes.Normal);
		}
	}

	private bool Save(int index)
	{
		try
		{
			if (ValidateContent(CurrentConfig.Station))
			{
				switch (CurrentConfig.Station)
				{
				case "RFCalVerify":
					_instRFCalVerify[index].SaveResult();
					break;
				case "RFStationCal":
					_instRFStationCal[index].SaveResult();
					break;
				case "BTWLAN":
					_instWCN[index].SaveResult();
					break;
				case "BTWLANStationCal":
					_instWCNStationCal.SaveResult();
					break;
				case "LossEditorRF":
					_editorRF[index].SaveResult();
					break;
				case "LossEditorBTWLAN":
					_editorBTWLAN.SaveResult();
					break;
				case "QSEQ":
					_qseq.SaveResult();
					break;
				case "MultiDUT":
					_multiplex.SaveResult();
					PrepareDUTFolders();
					break;
				case "GPS":
					_gps.SaveResult();
					break;
				case "LogCfg":
					_loggingConfig.SaveResult();
					break;
				case "MMICfg":
					_MMICfg[index].SaveResult();
					break;
				}
				return true;
			}
			return false;
		}
		catch (Exception ex)
		{
			MessageBox.Show("Save fail with exception: " + ex.Message);
			return false;
		}
	}

	private bool SaveAs(int index)
	{
		try
		{
			if (ValidateContent(CurrentConfig.Station))
			{
				switch (CurrentConfig.Station)
				{
				case "RFCalVerify":
					_instRFCalVerify[index].SaveResult(saveResultAs: true);
					break;
				case "RFStationCal":
					_instRFStationCal[index].SaveResult(saveResultAs: true);
					break;
				case "BTWLAN":
					_instWCN[index].SaveResultAs();
					break;
				case "BTWLANStationCal":
					_instWCNStationCal.SaveResult();
					break;
				case "LossEditorRF":
					_editorRF[index].SaveResult();
					break;
				case "LossEditorBTWLAN":
					_editorBTWLAN.SaveResult();
					break;
				case "QSEQ":
					_qseq.SaveResult();
					break;
				case "MultiDUT":
					_multiplex.SaveResultAs();
					PrepareDUTFolders();
					break;
				case "MMICfg":
					_MMICfg[index].SaveResultAs();
					break;
				}
				return true;
			}
			return false;
		}
		catch (Exception ex)
		{
			MessageBox.Show("Save as fail with exception: " + ex.Message);
			return false;
		}
	}

	private void UpdateLanguage()
	{
		btnSave.Text = currentLang.GetData(101);
		btnSet.Text = currentLang.GetData(108);
		btnFile.Text = currentLang.GetData(130);
		btnHelp.Text = currentLang.GetData(109);
		btnLanguage.Text = currentLang.GetData(110);
		lbTarget.Text = currentLang.GetData(116);
		aboutMenu.Text = currentLang.GetData(117);
		viewHelp.Text = currentLang.GetData(125);
		Text = currentLang.GetData(131);
		RefreshTargetList();
		TargetGroup();
	}

	private bool ValidateContent(string Target)
	{
		errnum = 0;
		errorProvider1.Clear();
		int num = 0;
		switch (Target)
		{
		case "MultiDUT":
		case "LogCfg":
			num = 0;
			break;
		default:
			foreach (Control control in userPanel.Controls)
			{
				num += SearchAll(control);
			}
			break;
		}
		if (num != 0)
		{
			return false;
		}
		return true;
	}

	private int SearchAll(Control con)
	{
		foreach (Control control in con.Controls)
		{
			if (control.HasChildren)
			{
				SearchAll(control);
			}
			else
			{
				if (!control.Visible || !control.Enabled)
				{
					continue;
				}
				if (control is TextBox)
				{
					if (!((TextBox)control).ReadOnly)
					{
						TextBox textBox = (TextBox)control;
						Tip ctrlDataSmt = (Tip)textBox.Tag;
						string errorMsg = "";
						if (!ValidateEntry(textBox.Text, ctrlDataSmt, out errorMsg))
						{
							textBox.Focus();
							errnum++;
						}
						errorProvider1.SetError(textBox, errorMsg);
					}
				}
				else if (control is ComboBox)
				{
					ComboBox comboBox = (ComboBox)control;
					string errorMsg2 = "";
					if (!ValidateEntry(comboBox.Text, null, out errorMsg2))
					{
						comboBox.Focus();
						errnum++;
					}
					errorProvider1.SetError(comboBox, errorMsg2);
				}
			}
		}
		return errnum;
	}

	private bool ValidateEntry(string inputText, Tip ctrlDataSmt, out string errorMsg)
	{
		bool result = true;
		errorMsg = "";
		if (inputText == "")
		{
			errorMsg = currentLang.GetData(200);
			return false;
		}
		if (ctrlDataSmt == null)
		{
			return true;
		}
		switch (ctrlDataSmt.CurrentInputType)
		{
		case Tip.TxtContent.IP_ADDRESS:
		{
			string[] array2 = inputText.Split(new char[1] { '.' }, StringSplitOptions.RemoveEmptyEntries);
			if (array2.Length == 4)
			{
				result = true;
				for (int j = 0; j < 4; j++)
				{
					int result2 = 0;
					if (int.TryParse(array2[j], out result2))
					{
						if (255 < result2 || result2 < 0)
						{
							errorMsg = ctrlDataSmt.ErrorMsg;
							result = false;
							break;
						}
						continue;
					}
					errorMsg = ctrlDataSmt.ErrorMsg;
					result = false;
					break;
				}
			}
			else
			{
				errorMsg = ctrlDataSmt.ErrorMsg;
				result = false;
			}
			break;
		}
		case Tip.TxtContent.FILE_PATH:
			if (IsLegalPath(inputText))
			{
				result = true;
				break;
			}
			errorMsg = ctrlDataSmt.ErrorMsg;
			result = false;
			break;
		case Tip.TxtContent.USB_ADDRESS:
			errorMsg = ctrlDataSmt.ErrorMsg;
			result = false;
			break;
		case Tip.TxtContent.BLUETOOTH_ADDRESS:
		{
			string[] array = inputText.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 6)
			{
				result = true;
				string pattern = "^[A-Za-z0-9]+$";
				Regex regex = new Regex(pattern);
				for (int i = 0; i < 6; i++)
				{
					if (array[i].Length == 2)
					{
						if (!regex.IsMatch(array[i]))
						{
							errorMsg = ctrlDataSmt.ErrorMsg;
							result = false;
							break;
						}
						continue;
					}
					errorMsg = ctrlDataSmt.ErrorMsg;
					result = false;
					break;
				}
			}
			else
			{
				errorMsg = ctrlDataSmt.ErrorMsg;
				result = false;
			}
			break;
		}
		}
		return result;
	}

	private bool IsLegalPath(string strPath)
	{
		try
		{
			return Path.IsPathRooted(strPath);
		}
		catch
		{
			return false;
		}
	}

	private void GetCtrlValueMap(bool bPre)
	{
		if (bPre)
		{
			ctrlValueMapPre.Clear();
		}
		else
		{
			ctrlValueMapNow.Clear();
		}
		foreach (Control control in userPanel.Controls)
		{
			SearchAllAddPair(control, bPre);
		}
	}

	private void SearchAllAddPair(Control con, bool bPre)
	{
		foreach (Control control in con.Controls)
		{
			if (control.HasChildren)
			{
				SearchAllAddPair(control, bPre);
			}
			else
			{
				if (!control.Visible || !control.Enabled)
				{
					continue;
				}
				if (control is TextBox)
				{
					if (!((TextBox)control).ReadOnly)
					{
						TextBox textBox = (TextBox)control;
						if (bPre)
						{
							ctrlValueMapPre.Add(textBox.Name, textBox.Text);
						}
						else
						{
							ctrlValueMapNow.Add(textBox.Name, textBox.Text);
						}
					}
				}
				else if (control is ComboBox)
				{
					ComboBox comboBox = (ComboBox)control;
					if (bPre)
					{
						ctrlValueMapPre.Add(comboBox.Name, comboBox.Text);
					}
					else
					{
						ctrlValueMapNow.Add(comboBox.Name, comboBox.Text);
					}
				}
				else if (control is CheckBox)
				{
					CheckBox checkBox = (CheckBox)control;
					if (bPre)
					{
						ctrlValueMapPre.Add(checkBox.Name, checkBox.Checked.ToString());
					}
					else
					{
						ctrlValueMapNow.Add(checkBox.Name, checkBox.Checked.ToString());
					}
				}
			}
		}
	}

	private bool SaveStationToConfigData()
	{
		string station = "";
		foreach (KeyValuePair<string, int> item in _targetlist)
		{
			if (item.Value == (int)cbTarget.SelectedValue)
			{
				station = item.Key;
			}
		}
		currentConfig.Station = station;
		if (cbTarget.SelectedIndex == -1)
		{
			MessageBox.Show("At least one target selected!");
			return false;
		}
		return true;
	}

	private bool UserEdited()
	{
		bool flag = false;
		switch (currTarget)
		{
		case 2:
			return _editorRF[curr_dut].FileEdited;
		case 3:
			return _editorBTWLAN.FileEdited;
		default:
			GetCtrlValueMap(bPre: false);
			return !Common.DictionaryCompare(ctrlValueMapPre, ctrlValueMapNow);
		}
	}

	private void PreFunc()
	{
		Status.Text = "";
		btnSave.Focus();
		curr_dut = Convert.ToInt32(lbNow.Text);
		if (curr_dut <= 1)
		{
			return;
		}
		if (UserEdited())
		{
			switch (MessageBox.Show(currentLang.GetData(114), currentLang.GetData(115), MessageBoxButtons.YesNoCancel))
			{
			case DialogResult.Yes:
				if (!Save(curr_dut))
				{
					MsgForm msgForm = new MsgForm(currentLang);
					msgForm.ShowDialog();
					return;
				}
				break;
			case DialogResult.Cancel:
				return;
			}
		}
		curr_dut--;
		lbNow.Text = curr_dut.ToString();
		LoadUserPanel();
	}

	private void NextFunc()
	{
		Status.Text = "";
		btnSave.Focus();
		curr_dut = Convert.ToInt32(lbNow.Text);
		if (curr_dut >= max_dut)
		{
			return;
		}
		if (UserEdited())
		{
			switch (MessageBox.Show(currentLang.GetData(114), currentLang.GetData(115), MessageBoxButtons.YesNoCancel))
			{
			case DialogResult.Yes:
				if (!Save(curr_dut))
				{
					MsgForm msgForm = new MsgForm(currentLang);
					msgForm.ShowDialog();
					return;
				}
				break;
			case DialogResult.Cancel:
				return;
			}
		}
		curr_dut++;
		lbNow.Text = curr_dut.ToString();
		LoadUserPanel();
	}

	private void Save_Click(object sender, EventArgs e)
	{
		try
		{
			if (!Save(curr_dut))
			{
				MsgForm msgForm = new MsgForm(currentLang);
				msgForm.ShowDialog();
			}
			else
			{
				GetCtrlValueMap(bPre: true);
			}
		}
		catch
		{
			MessageBox.Show("Save fail. Please check you have write access to the file.");
		}
	}

	private void SaveAs_Click(object sender, EventArgs e)
	{
		try
		{
			if (!SaveAs(curr_dut))
			{
				MsgForm msgForm = new MsgForm(currentLang);
				msgForm.ShowDialog();
			}
			else
			{
				GetCtrlValueMap(bPre: true);
			}
		}
		catch
		{
			MessageBox.Show("Save fail. Please check you have write access to the file.");
		}
	}

	private void Settings_Click(object sender, EventArgs e)
	{
		try
		{
			btnSave.Focus();
			if (UserEdited())
			{
				switch (MessageBox.Show(currentLang.GetData(114), currentLang.GetData(115), MessageBoxButtons.YesNoCancel))
				{
				case DialogResult.Yes:
					if (!Save(curr_dut))
					{
						MsgForm msgForm = new MsgForm(currentLang);
						msgForm.ShowDialog();
						return;
					}
					GetCtrlValueMap(bPre: true);
					break;
				case DialogResult.Cancel:
					return;
				}
			}
			using ToolManager toolManager = new ToolManager(currentLang, currTarget);
			if (toolManager.ShowDialog() == DialogResult.OK)
			{
				toolManager.SaveConfigData(out currentConfig);
				bool result = false;
				bool.TryParse(CurrentConfig.MultiDUT, out result);
				if (result)
				{
					MAX_DUT = Convert.ToInt32(CurrentConfig.DUTs);
					PrepareDUTFolders(MAX_DUT);
					Text = currentLang.GetData(131) + currentLang.GetData(132);
				}
				else
				{
					MAX_DUT = 0;
					Text = currentLang.GetData(131);
				}
				LoadUserPanel();
				LoadMultiDUTField();
				lbNow.Text = curr_dut.ToString();
			}
		}
		catch
		{
		}
	}

	private void GoStation(object sender, EventArgs e)
	{
		try
		{
			if (bExpectTargetChange && !bFirstRun)
			{
				if (UserEdited())
				{
					switch (MessageBox.Show(currentLang.GetData(114), currentLang.GetData(115), MessageBoxButtons.YesNoCancel))
					{
					case DialogResult.Yes:
						if (!Save(curr_dut))
						{
							bExpectTargetChange = false;
							cbTarget.SelectedValue = currTarget;
							MsgForm msgForm = new MsgForm(currentLang);
							msgForm.ShowDialog();
							return;
						}
						bExpectTargetChange = true;
						currTarget = (int)cbTarget.SelectedValue;
						if (SaveStationToConfigData())
						{
							SaveConfig(CurrentConfig);
							SwitchStationUI();
						}
						break;
					case DialogResult.Cancel:
						bExpectTargetChange = false;
						cbTarget.SelectedValue = currTarget;
						return;
					}
				}
				bExpectTargetChange = true;
				currTarget = (int)cbTarget.SelectedValue;
				if (SaveStationToConfigData())
				{
					SaveConfig(CurrentConfig);
					if ((currTarget == 5 || currTarget == 0 || currTarget == 1) && CurrentConfig.MultiDUT.ToUpper() == "TRUE")
					{
						PrepareDUTFolders(int.Parse(CurrentConfig.DUTs));
					}
					SwitchStationUI();
				}
			}
			else
			{
				bExpectTargetChange = true;
			}
		}
		catch
		{
		}
	}

	private void btnLanguage_Click(object sender, EventArgs e)
	{
		if (currentLang.CurrentLanguage == LanguageDetails.Language.ENGLISH)
		{
			currentLang.CurrentLanguage = LanguageDetails.Language.CHINESE;
		}
		else
		{
			currentLang.CurrentLanguage = LanguageDetails.Language.ENGLISH;
		}
		UpdateLanguage();
		CurrentConfig.LanguageUsed = currentLang.CurrentLanguage;
		SaveConfig(CurrentConfig);
	}

	private void QRDCfgEditor_Load(object sender, EventArgs e)
	{
		if (bQuit)
		{
			MessageBox.Show("Tool will quit.\r\nMaybe tool link file crashed or not exist:\r\n" + Path.Combine(Application.StartupPath, "QDART_MFG_CfgEditor_Link.xml"), "Warning", MessageBoxButtons.OK);
			Close();
		}
	}

	private void btnNext_Click(object sender, EventArgs e)
	{
		NextFunc();
	}

	private void btnPre_Click(object sender, EventArgs e)
	{
		PreFunc();
	}

	private void btnPreDUT_Click(object sender, EventArgs e)
	{
		PreFunc();
	}

	private void btnNextDUT_Click(object sender, EventArgs e)
	{
		NextFunc();
	}

	private void lbNow_TextChanged(object sender, EventArgs e)
	{
		int.TryParse(lbNow.Text, out var result);
		btnPre.Enabled = result > 1;
		btnPreDUT.Visible = result > 1;
		btnNext.Enabled = ((result != max_dut) ? true : false);
		btnNextDUT.Visible = ((result != max_dut) ? true : false);
	}

	private void QRDCfgEditor_Shown(object sender, EventArgs e)
	{
		GetCtrlValueMap(bPre: true);
	}

	private void QRDCfgEditor_FormClosing(object sender, FormClosingEventArgs e)
	{
		if (UserEdited())
		{
			DialogResult dialogResult = MessageBox.Show(currentLang.GetData(114), currentLang.GetData(115), MessageBoxButtons.YesNo);
			if (dialogResult == DialogResult.Yes && !Save(curr_dut))
			{
				MsgForm msgForm = new MsgForm(currentLang);
				msgForm.ShowDialog();
				e.Cancel = true;
			}
		}
	}

	private void OnHelp(object sender, EventArgs e)
	{
		if (!help.IsDisposed)
		{
			help.Activate();
			help.WindowState = FormWindowState.Normal;
		}
		else
		{
			help = new HelpDialog();
		}
		help.Show();
	}

	private void OnAbout(object sender, EventArgs e)
	{
		AboutForm aboutForm = new AboutForm();
		aboutForm.ShowDialog();
	}

	private void openfile_Click(object sender, EventArgs e)
	{
		switch (CurrentConfig.Station)
		{
		case "RFCalVerify":
			if (_instRFCalVerify[curr_dut].OpenFile())
			{
				max_dut = 0;
				LoadMultiDUTField();
			}
			break;
		case "QSEQ":
			_qseq.OpenFile();
			break;
		case "BTWLAN":
			if (_instWCN[curr_dut].OpenFile())
			{
				max_dut = 0;
				LoadMultiDUTField();
			}
			break;
		case "RFStationCal":
			if (_instRFStationCal[curr_dut].OpenFile())
			{
				max_dut = 0;
				LoadMultiDUTField();
			}
			break;
		case "MultiDUT":
			_multiplex.OpenFile();
			break;
		case "GPS":
			_gps.OpenFile();
			break;
		case "LogCfg":
			_loggingConfig.OpenFile();
			break;
		case "MMICfg":
			if (_MMICfg[curr_dut].OpenFile())
			{
				max_dut = 0;
				LoadMultiDUTField();
			}
			break;
		}
	}

	private void savefile_Click(object sender, EventArgs e)
	{
		switch (CurrentConfig.Station)
		{
		case "RFCalVerify":
			btnSave.Focus();
			Save_Click(null, null);
			break;
		case "QSEQ":
			btnSave.Focus();
			_qseq.SaveResult();
			break;
		case "BTWLAN":
			btnSave.Focus();
			Save_Click(null, null);
			break;
		case "RFStationCal":
			btnSave.Focus();
			Save_Click(null, null);
			break;
		case "MultiDUT":
			btnSave.Focus();
			_multiplex.SaveResult();
			break;
		case "GPS":
			btnSave.Focus();
			_gps.SaveResult();
			break;
		case "LogCfg":
			btnSave.Focus();
			_loggingConfig.SaveResult();
			break;
		case "MMICfg":
			btnSave.Focus();
			Save_Click(null, null);
			break;
		}
		GetCtrlValueMap(bPre: true);
	}

	private void savefileas_Click(object sender, EventArgs e)
	{
		switch (CurrentConfig.Station)
		{
		case "RFCalVerify":
			btnSave.Focus();
			SaveAs_Click(null, null);
			break;
		case "QSEQ":
			btnSave.Focus();
			_qseq.SaveResultAs();
			break;
		case "BTWLAN":
			btnSave.Focus();
			SaveAs_Click(null, null);
			break;
		case "RFStationCal":
			btnSave.Focus();
			SaveAs_Click(null, null);
			break;
		case "MultiDUT":
			btnSave.Focus();
			_multiplex.SaveResultAs();
			break;
		case "GPS":
			btnSave.Focus();
			_gps.SaveResultAs();
			break;
		case "LogCfg":
			btnSave.Focus();
			_loggingConfig.SaveResultAs();
			break;
		case "MMICfg":
			btnSave.Focus();
			SaveAs_Click(null, null);
			break;
		}
	}

	public void FormTargetFileChanged(string str)
	{
		Status.Text = str;
	}

	private void linkToStationCalToolStripMenuItem_Click(object sender, EventArgs e)
	{
		ProcessStartInfo processStartInfo = new ProcessStartInfo("QDART_MFG_StationCal.exe");
		processStartInfo.WorkingDirectory = Application.StartupPath;
		Process.Start(processStartInfo);
	}

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

	private void InitializeComponent()
	{
		System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(global::QDART_MFG_CfgEditor.QDART_MFG_CfgEditor));
		this.btnSave = new System.Windows.Forms.Button();
		this.statusStrip1 = new System.Windows.Forms.StatusStrip();
		this.Status = new System.Windows.Forms.ToolStripStatusLabel();
		this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
		this.toolStrip1 = new System.Windows.Forms.ToolStrip();
		this.btnFile = new System.Windows.Forms.ToolStripDropDownButton();
		this.openfile = new System.Windows.Forms.ToolStripMenuItem();
		this.savefile = new System.Windows.Forms.ToolStripMenuItem();
		this.savefileas = new System.Windows.Forms.ToolStripMenuItem();
		this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
		this.btnSet = new System.Windows.Forms.ToolStripButton();
		this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
		this.toollink = new System.Windows.Forms.ToolStripDropDownButton();
		this.stationCalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
		this.btnHelp = new System.Windows.Forms.ToolStripDropDownButton();
		this.viewHelp = new System.Windows.Forms.ToolStripMenuItem();
		this.aboutMenu = new System.Windows.Forms.ToolStripMenuItem();
		this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
		this.btnLanguage = new System.Windows.Forms.ToolStripButton();
		this.viewHelpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.aboutQRDCfgEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
		this.toolStripDropDownButton2 = new System.Windows.Forms.ToolStripDropDownButton();
		this.viewHelpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
		this.aboutQRDCfgEditorToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
		this.errorProvider1 = new System.Windows.Forms.ErrorProvider();
		this.lbTarget = new System.Windows.Forms.Label();
		this.multiField = new System.Windows.Forms.ToolStrip();
		this.btnPre = new System.Windows.Forms.ToolStripButton();
		this.lbDUT = new System.Windows.Forms.ToolStripLabel();
		this.lbNow = new System.Windows.Forms.ToolStripLabel();
		this.btnNext = new System.Windows.Forms.ToolStripButton();
		this.panel1 = new System.Windows.Forms.Panel();
		this.panel6 = new System.Windows.Forms.Panel();
		this.cbTarget = new System.Windows.Forms.ComboBoxEx();
		this.panel2 = new System.Windows.Forms.Panel();
		this.panel3 = new System.Windows.Forms.Panel();
		this.panel4 = new System.Windows.Forms.Panel();
		this.lbTargetFile = new System.Windows.Forms.Label();
		this.panel5 = new System.Windows.Forms.Panel();
		this.btnPreDUT = new System.Windows.Forms.Button();
		this.btnNextDUT = new System.Windows.Forms.Button();
		this.userPanel = new System.Windows.Forms.Panel();
		this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
		this.statusStrip1.SuspendLayout();
		this.toolStrip1.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.errorProvider1).BeginInit();
		this.multiField.SuspendLayout();
		this.panel1.SuspendLayout();
		this.panel6.SuspendLayout();
		this.panel4.SuspendLayout();
		this.panel5.SuspendLayout();
		base.SuspendLayout();
		this.btnSave.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnSave.Location = new System.Drawing.Point(51, 20);
		this.btnSave.Margin = new System.Windows.Forms.Padding(4);
		this.btnSave.Name = "btnSave";
		this.btnSave.Size = new System.Drawing.Size(191, 95);
		this.btnSave.TabIndex = 3;
		this.btnSave.TabStop = false;
		this.btnSave.Text = "&SAVE";
		this.btnSave.UseVisualStyleBackColor = true;
		this.btnSave.Click += new System.EventHandler(Save_Click);
		this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[1] { this.Status });
		this.statusStrip1.Location = new System.Drawing.Point(0, 793);
		this.statusStrip1.Name = "statusStrip1";
		this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 19, 0);
		this.statusStrip1.Size = new System.Drawing.Size(979, 22);
		this.statusStrip1.TabIndex = 7;
		this.statusStrip1.Text = "statusStrip1";
		this.Status.Name = "Status";
		this.Status.Size = new System.Drawing.Size(0, 17);
		this.Status.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
		this.Status.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage;
		this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
		this.toolStripStatusLabel1.Size = new System.Drawing.Size(611, 17);
		this.toolStripStatusLabel1.Spring = true;
		this.toolStripStatusLabel1.Text = "toolStripStatusLabel1";
		this.toolStripStatusLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
		this.toolStrip1.BackColor = System.Drawing.Color.Transparent;
		this.toolStrip1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
		this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
		this.toolStrip1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[9] { this.btnFile, this.toolStripSeparator4, this.btnSet, this.toolStripSeparator5, this.toollink, this.toolStripSeparator2, this.btnHelp, this.toolStripSeparator3, this.btnLanguage });
		this.toolStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
		this.toolStrip1.Location = new System.Drawing.Point(12, 7);
		this.toolStrip1.Name = "toolStrip1";
		this.toolStrip1.RightToLeft = System.Windows.Forms.RightToLeft.No;
		this.toolStrip1.Size = new System.Drawing.Size(414, 32);
		this.toolStrip1.TabIndex = 10;
		this.toolStrip1.Text = "toolStrip1";
		this.btnFile.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.btnFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[3] { this.openfile, this.savefile, this.savefileas });
		this.btnFile.Image = (System.Drawing.Image)resources.GetObject("btnFile.Image");
		this.btnFile.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.btnFile.Name = "btnFile";
		this.btnFile.Size = new System.Drawing.Size(56, 29);
		this.btnFile.Text = "File";
		this.openfile.Image = QDART_MFG_CfgEditor.Properties.Resources.openHS;
		this.openfile.Name = "openfile";
		this.openfile.ShortcutKeys = System.Windows.Forms.Keys.O | System.Windows.Forms.Keys.Alt;
		this.openfile.Size = new System.Drawing.Size(220, 30);
		this.openfile.Text = "&Open";
		this.openfile.Click += new System.EventHandler(openfile_Click);
		this.savefile.Image = QDART_MFG_CfgEditor.Properties.Resources.saveHS;
		this.savefile.Name = "savefile";
		this.savefile.ShortcutKeys = System.Windows.Forms.Keys.S | System.Windows.Forms.Keys.Alt;
		this.savefile.Size = new System.Drawing.Size(220, 30);
		this.savefile.Text = "&Save";
		this.savefile.Click += new System.EventHandler(savefile_Click);
		this.savefileas.Name = "savefileas";
		this.savefileas.ShortcutKeys = System.Windows.Forms.Keys.A | System.Windows.Forms.Keys.Alt;
		this.savefileas.Size = new System.Drawing.Size(220, 30);
		this.savefileas.Text = "Save &As";
		this.savefileas.Click += new System.EventHandler(savefileas_Click);
		this.toolStripSeparator4.Name = "toolStripSeparator4";
		this.toolStripSeparator4.Size = new System.Drawing.Size(6, 32);
		this.btnSet.Image = QDART_MFG_CfgEditor.Properties.Resources.setting;
		this.btnSet.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.btnSet.Name = "btnSet";
		this.btnSet.Size = new System.Drawing.Size(103, 29);
		this.btnSet.Text = "Settings";
		this.btnSet.Click += new System.EventHandler(Settings_Click);
		this.toolStripSeparator5.Name = "toolStripSeparator5";
		this.toolStripSeparator5.Size = new System.Drawing.Size(6, 32);
		this.toollink.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.toollink.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[1] { this.stationCalToolStripMenuItem });
		this.toollink.Image = (System.Drawing.Image)resources.GetObject("toollink.Image");
		this.toollink.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.toollink.Name = "toollink";
		this.toollink.Size = new System.Drawing.Size(74, 29);
		this.toollink.Text = "Tools";
		this.stationCalToolStripMenuItem.Name = "stationCalToolStripMenuItem";
		this.stationCalToolStripMenuItem.Size = new System.Drawing.Size(180, 30);
		this.stationCalToolStripMenuItem.Text = "Station Cal";
		this.stationCalToolStripMenuItem.Click += new System.EventHandler(linkToStationCalToolStripMenuItem_Click);
		this.toolStripSeparator2.Name = "toolStripSeparator2";
		this.toolStripSeparator2.Size = new System.Drawing.Size(6, 32);
		this.btnHelp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.btnHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[2] { this.viewHelp, this.aboutMenu });
		this.btnHelp.Image = (System.Drawing.Image)resources.GetObject("btnHelp.Image");
		this.btnHelp.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.btnHelp.Name = "btnHelp";
		this.btnHelp.Size = new System.Drawing.Size(65, 29);
		this.btnHelp.Text = "Help";
		this.viewHelp.Image = QDART_MFG_CfgEditor.Properties.Resources.vsHelp;
		this.viewHelp.Name = "viewHelp";
		this.viewHelp.Size = new System.Drawing.Size(387, 30);
		this.viewHelp.Text = "View help";
		this.viewHelp.Click += new System.EventHandler(OnHelp);
		this.aboutMenu.Name = "aboutMenu";
		this.aboutMenu.Size = new System.Drawing.Size(387, 30);
		this.aboutMenu.Text = "About QDART Configuration Editor";
		this.aboutMenu.Click += new System.EventHandler(OnAbout);
		this.toolStripSeparator3.Name = "toolStripSeparator3";
		this.toolStripSeparator3.Size = new System.Drawing.Size(6, 32);
		this.btnLanguage.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.btnLanguage.Name = "btnLanguage";
		this.btnLanguage.Size = new System.Drawing.Size(80, 29);
		this.btnLanguage.Text = "English";
		this.btnLanguage.Click += new System.EventHandler(btnLanguage_Click);
		this.viewHelpToolStripMenuItem.Name = "viewHelpToolStripMenuItem";
		this.viewHelpToolStripMenuItem.Size = new System.Drawing.Size(184, 22);
		this.viewHelpToolStripMenuItem.Text = "View Help";
		this.aboutQRDCfgEditorToolStripMenuItem.Name = "aboutQRDCfgEditorToolStripMenuItem";
		this.aboutQRDCfgEditorToolStripMenuItem.Size = new System.Drawing.Size(184, 22);
		this.aboutQRDCfgEditorToolStripMenuItem.Text = "About QDART_MFG_CfgEditor";
		this.toolStripSeparator1.Name = "toolStripSeparator1";
		this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
		this.toolStripDropDownButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.toolStripDropDownButton2.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[2] { this.viewHelpToolStripMenuItem1, this.aboutQRDCfgEditorToolStripMenuItem1 });
		this.toolStripDropDownButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.toolStripDropDownButton2.Name = "toolStripDropDownButton2";
		this.toolStripDropDownButton2.Size = new System.Drawing.Size(45, 22);
		this.toolStripDropDownButton2.Text = "Help";
		this.viewHelpToolStripMenuItem1.Name = "viewHelpToolStripMenuItem1";
		this.viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(276, 24);
		this.viewHelpToolStripMenuItem1.Text = "View Help";
		this.aboutQRDCfgEditorToolStripMenuItem1.Name = "aboutQRDCfgEditorToolStripMenuItem1";
		this.aboutQRDCfgEditorToolStripMenuItem1.Size = new System.Drawing.Size(276, 24);
		this.aboutQRDCfgEditorToolStripMenuItem1.Text = "About QDART_MFG_CfgEditor";
		this.errorProvider1.ContainerControl = this;
		this.lbTarget.AutoSize = true;
		this.lbTarget.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.lbTarget.Location = new System.Drawing.Point(17, 54);
		this.lbTarget.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.lbTarget.Name = "lbTarget";
		this.lbTarget.Size = new System.Drawing.Size(69, 25);
		this.lbTarget.TabIndex = 16;
		this.lbTarget.Text = "Target";
		this.multiField.BackColor = System.Drawing.Color.Transparent;
		this.multiField.Dock = System.Windows.Forms.DockStyle.None;
		this.multiField.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.multiField.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
		this.multiField.Items.AddRange(new System.Windows.Forms.ToolStripItem[4] { this.btnPre, this.lbDUT, this.lbNow, this.btnNext });
		this.multiField.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
		this.multiField.Location = new System.Drawing.Point(43, 102);
		this.multiField.Name = "multiField";
		this.multiField.Size = new System.Drawing.Size(183, 32);
		this.multiField.TabIndex = 17;
		this.multiField.Text = "toolStrip2";
		this.btnPre.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.btnPre.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnPre.Image = (System.Drawing.Image)resources.GetObject("btnPre.Image");
		this.btnPre.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.btnPre.Name = "btnPre";
		this.btnPre.Size = new System.Drawing.Size(52, 29);
		this.btnPre.Text = "<<<";
		this.btnPre.ToolTipText = "Previous";
		this.btnPre.Click += new System.EventHandler(btnPre_Click);
		this.lbDUT.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.lbDUT.ForeColor = System.Drawing.Color.Red;
		this.lbDUT.Name = "lbDUT";
		this.lbDUT.Size = new System.Drawing.Size(53, 29);
		this.lbDUT.Text = "DUT";
		this.lbDUT.ToolTipText = "Current DUT";
		this.lbNow.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.lbNow.ForeColor = System.Drawing.Color.Red;
		this.lbNow.Name = "lbNow";
		this.lbNow.Size = new System.Drawing.Size(23, 29);
		this.lbNow.Text = "1";
		this.lbNow.ToolTipText = "Current DUT";
		this.lbNow.TextChanged += new System.EventHandler(lbNow_TextChanged);
		this.btnNext.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.btnNext.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnNext.Image = (System.Drawing.Image)resources.GetObject("btnNext.Image");
		this.btnNext.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.btnNext.Name = "btnNext";
		this.btnNext.Size = new System.Drawing.Size(52, 29);
		this.btnNext.Text = ">>>";
		this.btnNext.ToolTipText = "Next";
		this.btnNext.Click += new System.EventHandler(btnNext_Click);
		this.panel1.Controls.Add(this.panel6);
		this.panel1.Controls.Add(this.multiField);
		this.panel1.Controls.Add(this.lbTarget);
		this.panel1.Controls.Add(this.cbTarget);
		this.panel1.Controls.Add(this.toolStrip1);
		this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
		this.panel1.Location = new System.Drawing.Point(0, 0);
		this.panel1.Margin = new System.Windows.Forms.Padding(4);
		this.panel1.Name = "panel1";
		this.panel1.Size = new System.Drawing.Size(979, 135);
		this.panel1.TabIndex = 18;
		this.panel6.Controls.Add(this.btnSave);
		this.panel6.Dock = System.Windows.Forms.DockStyle.Right;
		this.panel6.Location = new System.Drawing.Point(712, 0);
		this.panel6.Margin = new System.Windows.Forms.Padding(4);
		this.panel6.Name = "panel6";
		this.panel6.Size = new System.Drawing.Size(267, 135);
		this.panel6.TabIndex = 18;
		this.cbTarget.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cbTarget.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.cbTarget.FormattingEnabled = true;
		this.cbTarget.Location = new System.Drawing.Point(99, 50);
		this.cbTarget.Margin = new System.Windows.Forms.Padding(4);
		this.cbTarget.Name = "cbTarget";
		this.cbTarget.Size = new System.Drawing.Size(572, 33);
		this.cbTarget.TabIndex = 15;
		this.cbTarget.TabStop = false;
		this.cbTarget.SelectedValueChanged += new System.EventHandler(GoStation);
		this.panel2.Dock = System.Windows.Forms.DockStyle.Right;
		this.panel2.Location = new System.Drawing.Point(948, 135);
		this.panel2.Margin = new System.Windows.Forms.Padding(4);
		this.panel2.Name = "panel2";
		this.panel2.Size = new System.Drawing.Size(31, 658);
		this.panel2.TabIndex = 19;
		this.panel3.Dock = System.Windows.Forms.DockStyle.Left;
		this.panel3.Location = new System.Drawing.Point(0, 135);
		this.panel3.Margin = new System.Windows.Forms.Padding(4);
		this.panel3.Name = "panel3";
		this.panel3.Size = new System.Drawing.Size(23, 658);
		this.panel3.TabIndex = 20;
		this.panel4.Controls.Add(this.lbTargetFile);
		this.panel4.Controls.Add(this.panel5);
		this.panel4.Dock = System.Windows.Forms.DockStyle.Bottom;
		this.panel4.Location = new System.Drawing.Point(23, 747);
		this.panel4.Margin = new System.Windows.Forms.Padding(4);
		this.panel4.Name = "panel4";
		this.panel4.Size = new System.Drawing.Size(925, 46);
		this.panel4.TabIndex = 21;
		this.lbTargetFile.AutoSize = true;
		this.lbTargetFile.Location = new System.Drawing.Point(7, 18);
		this.lbTargetFile.Name = "lbTargetFile";
		this.lbTargetFile.Size = new System.Drawing.Size(0, 17);
		this.lbTargetFile.TabIndex = 2;
		this.panel5.Controls.Add(this.btnPreDUT);
		this.panel5.Controls.Add(this.btnNextDUT);
		this.panel5.Dock = System.Windows.Forms.DockStyle.Right;
		this.panel5.Location = new System.Drawing.Point(592, 0);
		this.panel5.Margin = new System.Windows.Forms.Padding(4);
		this.panel5.Name = "panel5";
		this.panel5.Size = new System.Drawing.Size(333, 46);
		this.panel5.TabIndex = 1;
		this.btnPreDUT.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnPreDUT.Location = new System.Drawing.Point(41, 4);
		this.btnPreDUT.Margin = new System.Windows.Forms.Padding(4);
		this.btnPreDUT.Name = "btnPreDUT";
		this.btnPreDUT.Size = new System.Drawing.Size(125, 38);
		this.btnPreDUT.TabIndex = 0;
		this.btnPreDUT.Text = "Prev DUT";
		this.btnPreDUT.UseVisualStyleBackColor = true;
		this.btnPreDUT.Visible = false;
		this.btnPreDUT.Click += new System.EventHandler(btnPreDUT_Click);
		this.btnNextDUT.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnNextDUT.Location = new System.Drawing.Point(188, 4);
		this.btnNextDUT.Margin = new System.Windows.Forms.Padding(4);
		this.btnNextDUT.Name = "btnNextDUT";
		this.btnNextDUT.Size = new System.Drawing.Size(125, 38);
		this.btnNextDUT.TabIndex = 0;
		this.btnNextDUT.Text = "Next DUT";
		this.btnNextDUT.UseVisualStyleBackColor = true;
		this.btnNextDUT.Click += new System.EventHandler(btnNextDUT_Click);
		this.userPanel.AutoScroll = true;
		this.userPanel.Dock = System.Windows.Forms.DockStyle.Fill;
		this.userPanel.Location = new System.Drawing.Point(23, 135);
		this.userPanel.Margin = new System.Windows.Forms.Padding(4);
		this.userPanel.Name = "userPanel";
		this.userPanel.Size = new System.Drawing.Size(925, 612);
		this.userPanel.TabIndex = 22;
		this.toolStripButton2.Image = QDART_MFG_CfgEditor.Properties.Resources.setting;
		this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.toolStripButton2.Name = "toolStripButton2";
		this.toolStripButton2.Size = new System.Drawing.Size(69, 22);
		this.toolStripButton2.Text = "Settings";
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 16f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		this.BackColor = System.Drawing.SystemColors.Control;
		base.ClientSize = new System.Drawing.Size(979, 815);
		base.Controls.Add(this.userPanel);
		base.Controls.Add(this.panel4);
		base.Controls.Add(this.panel3);
		base.Controls.Add(this.panel2);
		base.Controls.Add(this.panel1);
		base.Controls.Add(this.statusStrip1);
		base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
		base.Location = new System.Drawing.Point(80, 20);
		base.Margin = new System.Windows.Forms.Padding(4);
		base.MaximizeBox = false;
		this.MinimumSize = new System.Drawing.Size(527, 358);
		base.Name = "QDART_MFG_CfgEditor";
		base.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
		this.Text = "QDART Configuration Editor";
		base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(QRDCfgEditor_FormClosing);
		base.Load += new System.EventHandler(QRDCfgEditor_Load);
		base.Shown += new System.EventHandler(QRDCfgEditor_Shown);
		this.statusStrip1.ResumeLayout(false);
		this.statusStrip1.PerformLayout();
		this.toolStrip1.ResumeLayout(false);
		this.toolStrip1.PerformLayout();
		((System.ComponentModel.ISupportInitialize)this.errorProvider1).EndInit();
		this.multiField.ResumeLayout(false);
		this.multiField.PerformLayout();
		this.panel1.ResumeLayout(false);
		this.panel1.PerformLayout();
		this.panel6.ResumeLayout(false);
		this.panel4.ResumeLayout(false);
		this.panel4.PerformLayout();
		this.panel5.ResumeLayout(false);
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
