using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.Xml.Linq;
using QC.QSPRSchedulerWrapper;
using QC.QTMInterface;

namespace QC.SmartMatchApp;

public class SmartMatchGUI : Form
{
	private enum XPTAction
	{
		EPT = 1,
		ET
	}

	private enum DelayMode
	{
		ACLR_BASED,
		FW_BASED
	}

	private enum MeasMode
	{
		ACLR_BASED,
		AMAM_BASED
	}

	private enum eButtonState
	{
		SELECT_TECH,
		LOAD_PROFILE,
		EDIT_TRIAL,
		CLEAR_TRIAL,
		AUTOGEN_TRIAL,
		RUNNING,
		STOP,
		DISABLED,
		DEFAULT
	}

	private enum MatchMode
	{
		ANT = 1,
		BC
	}

	private delegate void UpdateTextInfo_Delegate();

	private const string LOGTestName = "MultiMode_QDARTFinalizeDataLogging";

	private const string TempPath = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\";

	private const string KitFilesPath = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\KitValues\\";

	private const string SMARTMATCH_WORKSPACE_CONFIG = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\Workspace.config";

	private const int DEFAULT_FILE_COUNT = 10;

	private const int MAX_NUM_BC_CHECKED = 2;

	private const double PI = Math.PI;

	private const int iMAX_ANT_MATCH_TRIALS = 30;

	private const uint WM_VSCROLL = 277u;

	private const int SB_PAGEBOTTOM = 7;

	private const double maxValue = 99999.0;

	private string LogPath = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\Logs";

	private string TreeDirectory = "";

	private string mruConfigFile = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\treeFiles.txt";

	private string trialDataFolder = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch";

	private string measurementResumeFolder = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\Resume";

	private string FormatDescriptorGV = "LIVE_CHART_FORMAT_DESCRIPTOR";

	private string LimitDescriptorGV = "LIVE_CHART_LIMIT_DESCRIPTOR";

	private string CustomLimitsGV = "LIVE_CHART_CUSTOM_LIMITS";

	private string NumBandsGV = "SMART_QMATCH_NUM_BANDS";

	private string WorstCaseMeasConstraintGV = "SMART_QMATCH_WORST_MEASU_CONSTRAINT_APPLIED";

	private string ResumeModeGV = "SMART_QMATCH_RESUME_TRIAL";

	private string PlaybackTree = "C:\\Program Files (x86)\\QUALCOMM\\QDART\\XTT\\SubSysRFCalibration\\SmartQMatch\\MasterTree\\SmartQMatch_Playback.xtt";

	private string FormatDescriptorName = "C:\\Program Files (x86)\\QUALCOMM\\QDART\\Databases\\SmartQMatch_LiveCharts_FD_4.xml";

	private string LimitDescriptorName = "C:\\Program Files (x86)\\QUALCOMM\\QDART\\Databases\\SmartQMatch_LiveCharts_LD.xml";

	private string tempLimitDescriptorName = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\SmartQMatch_LiveCharts_LD.xml";

	private string tempMaxBias_PAFile = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\RFCAL_PA_PARAM_modified.xml";

	private MruFiles mruTreeFiles;

	private string measurementFolder;

	private QSPRScheduler scheduler = new QSPRScheduler();

	private QSPRTestTree xttTree;

	private QSPRTestTree playbackTree;

	private string MainFormTitle = "Smart QMatch";

	private string strInitializeTestName = "SmartQMatch - Initialize";

	private string strResumeTestName = "SmartQMatch - Resume Trial";

	private string sUnitSN = "";

	private string SelectTech = "LTE";

	private int numRefDesignators;

	private string FormatDescriptor = "";

	private string MasterXttFullPath = string.Empty;

	private string TempFullPath = string.Empty;

	private string TempPlaybackPath = string.Empty;

	private string XTTFilename = string.Empty;

	private string ScenarioFilePathName = string.Empty;

	private string ScenarioFileName = string.Empty;

	private bool bSimulationMode;

	private bool strError;

	private bool bAutoGenPerformed;

	private bool bResumeCompleted;

	private bool bTreeCompleted;

	private bool bResumePassed;

	private bool bTreePassed;

	private bool bUserScenarioLoaded;

	private bool bScenarioModified;

	private bool comboBC_Active;

	private bool validTree;

	private bool bModifyMeasurementSelections;

	private bool bModifyingXptMode;

	private bool bMaxTrialsExceeded;

	private bool bPoutDeltaSatisfied;

	private bool bMeasTargetsSatisfied;

	private bool bAntennaSegmentRun = true;

	private bool bStopButtonPushed;

	private bool bResumeTrialsExist = true;

	private bool isResumeTrial;

	private List<string> bands = new List<string>();

	private List<string> channels = new List<string>();

	private List<string> currentCheckedBCNames = new List<string>();

	private List<string> failedPoutBCNames = new List<string>();

	private List<string> resumeSegmentNames = new List<string>();

	private BandClassInfo currentBCInfoItem;

	private string currentRunningTest = "";

	private string currentRunningBC = "";

	private string lastRunningBC = "";

	private string currentTrialNum = "";

	private string lastSegmentBC = "";

	private string resumeSegmentBC = "";

	private string strBandChannels = "";

	private string strRgiParams;

	private string strDelayValParams5MHz;

	private string strDelayValParams10MHz;

	private string strDelayValParams10MHzStart;

	private string strDelayValParams10MHzStop;

	private string strDelayValParams10MHzStep;

	private string strDelayValParams15MHz;

	private string strDelayValParams20MHz;

	private string strChListParams;

	private XPTAction eXptAction;

	private DelayMode eDelayMode;

	private MeasMode eMeasMode;

	private MatchMode eMatchMode;

	private MatchMode eLastMatchMode;

	private string strPAState;

	private string strRGIStart;

	private string strRGIStop;

	private string strRGIStep;

	private string strDelayType;

	private string strAMAMbasedPinPout;

	private string strRBs;

	private string strPinMax;

	private string strPoutMaxBias = "3.8";

	private string strWorstCaseResult = "";

	private string currentSegment = "Antenna";

	private string lastRunningSegment = "";

	private List<double> StandardValuesC = new List<double>();

	private List<double> StandardValuesL = new List<double>();

	private DataGridView currentSettingGridView;

	private DataGridView CombinedDataGrid;

	private DataGridView dgAntennaGrid;

	private ChannelToFreqCalculator BC_FreqCalc;

	private double f = 1000000000.0;

	private double dCurrentPoutDeltaMax = 9999.0;

	private Dictionary<string, double> bcPoutDelta = new Dictionary<string, double>();

	private double dPoutDeltaMax;

	private double dCurrentPout;

	private double dPoutMin = 15.0;

	private double aScaleFactor = 2.5;

	private double bScaleFactor = 2.0;

	private double cScaleFactor = 1000.0;

	private string strAScaleFactor;

	private string strBScaleFactor;

	private string strCScaleFactor;

	private TrialDataConverter antennaTrialData = new TrialDataConverter();

	private Dictionary<string, TrialDataConverter> bandClassTrialDataItems = new Dictionary<string, TrialDataConverter>();

	private Dictionary<string, KitValuesConverter> customKitValues = new Dictionary<string, KitValuesConverter>();

	private TrialsControl antennaTrialControl = new TrialsControl();

	private Dictionary<string, TrialsControl> bcTrialControls = new Dictionary<string, TrialsControl>();

	private TestResultPlugin liveChartPlugin;

	private Dictionary<string, DataGridView> topMatchGrids = new Dictionary<string, DataGridView>();

	private LanguageDetails currentLang = new LanguageDetails();

	private int currentRunStatus = 10;

	private Dictionary<string, string[]> defaultBandClassChannels = new Dictionary<string, string[]>();

	private Dictionary<string, string[]> userSelectedChannels = new Dictionary<string, string[]>();

	private Label labelTrialGridWarning = new Label
	{
		Text = "Select a technology before entering trial data",
		Size = new Size(1000, 50),
		Location = new Point(40, 200)
	};

	private Dictionary<string, double[]> topMatches = new Dictionary<string, double[]>();

	private Dictionary<string, BandClassInfo> bandClassInfo = new Dictionary<string, BandClassInfo>();

	private bool ignoreBandClassChanges;

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

	private IContainer components;

	private TabControl tabCtrlSmartMatch;

	private TabPage tabPageTrialData;

	private TabPage tabPageConfig;

	private Label label8;

	private GroupBox groupBox4;

	private Label label9;

	private Label label10;

	private Label label11;

	private TextBox tbDelayStep;

	private TextBox tbDelayStop;

	private TextBox tbDelayStart;

	private GroupBox groupBox3;

	private Label label7;

	private Label label6;

	private Label label5;

	private Label label2;

	private TextBox tbRGIStep;

	private TextBox tbRGIStop;

	private TextBox tbRGIStart;

	private Button btnRGI;

	private TextBox tbRGIFile;

	private GroupBox groupBox2;

	private GroupBox groupBox1;

	private CheckBox cbEPT;

	private CheckBox cbET;

	private Label label3;

	private TextBox tbPinPoutMax;

	private Label label1;

	private Button btnPAFile;

	private TextBox tbPAParamsFile;

	private Label label4;

	private Button btnSelectTech;

	private Button btnStop;

	private Button btnStartMatch;

	private Button btnFormatDescriptor;

	private Button btnLogPath;

	private MenuStrip menuStrip1;

	private ToolStripMenuItem toolStripMenuItem1;

	private ToolStripMenuItem tsmFileOpen;

	private ToolStripMenuItem tsmFileSave;

	private ToolStripMenuItem tsmFileSaveAs;

	private ToolStripMenuItem tsmFileExit;

	private GroupBox groupBox5;

	private Label label16;

	private Label label17;

	private TextBox tbChannelStop;

	private TextBox tbChannelStart;

	private GroupBox groupBox6;

	private TabPage tabPageSmartMatch;

	private Label label14;

	private DataGridView DisplayGrid;

	private TabPage tabPageDebug;

	private GroupBox groupBox7;

	private ComboBox cbRBs;

	private TextBox tbXttPath;

	private Label label15;

	private ComboBox cbPAGain;

	private Button btnResumeMatch;

	private Label label18;

	private TextBox tbChannelRef;

	private Label labelTestStatus;

	private Button btnSwitchLang;

	private ListView lvBandClasses;

	private ColumnHeader columnHeader1;

	private Label label22;

	private TextBox tbCScaleFactor;

	private Label label21;

	private TextBox tbBScaleFactor;

	private Label label20;

	private TextBox tbAScaleFactor;

	private Button btnRestoreScaleFactors;

	private MeasurementSelection measurementSelection;

	private TabPage tabPagePlayBack;

	private ToolStripMenuItem tsSimulationMenuItem;

	private ToolStripMenuItem tsEnableSimulationMenuItem;

	private Label label23;

	private Button btnPlaybackLogFiles;

	private TextBox tbPlaybackLogFiles;

	private Button btnPlayback;

	private TableLayoutPanel tableLayoutPanel1;

	public Button btnEditKitValues;

	private DataGridViewTextBoxColumn Column1;

	private DataGridViewTextBoxColumn Column9;

	private DataGridViewTextBoxColumn Column2;

	private DataGridViewTextBoxColumn Column4;

	private DataGridViewTextBoxColumn Column3;

	private DataGridViewTextBoxColumn TxOut;

	private DataGridViewTextBoxColumn Column5;

	private DataGridViewTextBoxColumn Column8;

	private DataGridViewTextBoxColumn Column7;

	private DataGridViewTextBoxColumn Column6;

	private DataGridView dgAntennaTopMatches;

	private DataGridViewTextBoxColumn ColumnRank;

	private DataGridViewTextBoxColumn ColumnTrialNum;

	private DataGridViewTextBoxColumn ColumnFx;

	private Panel panelLiveChartsPlugin;

	private Label label19;

	private Button btnClearDebugText;

	private CheckBox checkBoxAutoScroll;

	private RichTextBox richTextBox1;

	private TabControl tabCtrlTopMatches;

	private TabPage tabPageAntenna;

	private GroupBox groupBox8;

	private Label label12;

	private Label label13;

	private TextBox tbPoutMaxBias;

	public Button btnEditChannels;

	private RichTextBox richTextBox2;

	private GVViewerCtrl gvViewerCtrl;

	public SmartMatchGUI()
	{
		SplashScreen_External splashScreen_External = new SplashScreen_External();
		splashScreen_External.ShowSplash();
		InitializeComponent();
		tabCtrlSmartMatch.TabPages.Remove(tabPagePlayBack);
		tsSimulationMenuItem.Visible = false;
		PreConfigureWorkspaceConfig();
		dgAntennaTopMatches.Rows.Add(3);
		dgAntennaTopMatches.Rows[0].Cells[0].Value = 1;
		dgAntennaTopMatches.Rows[1].Cells[0].Value = 2;
		dgAntennaTopMatches.Rows[2].Cells[0].Value = 3;
		topMatchGrids.Add("Antenna", dgAntennaTopMatches);
		MainFormTitle = "Smart QMatch" + base.ProductVersion;
		Text = MainFormTitle;
		mruTreeFiles = new MruFiles(mruConfigFile);
		scheduler.OnDebugMessage += DebugMessage;
		scheduler.OnRealTimeParamMessage += OnGenericParamMsg;
		scheduler.OnTestMessage += scheduler_OnTestMessage;
		scheduler.LoadWorkspaceConfig("C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\Workspace.config");
		BC_FreqCalc = new ChannelToFreqCalculator();
		antennaTrialData.LoadDefaultData();
		InitializeAntennaGrid();
		EnableTopologyGrids(enable: false);
		GetStandardComponentValues();
		LoadLiveChartPlugin();
		UpdateButtonStatus(eButtonState.DEFAULT);
		UpdateScenarioModifiedStatus(modified: false);
		AddGVsToViewer();
	}

	private void CreateTopMatchTab(string name)
	{
		if (!tabCtrlTopMatches.TabPages.ContainsKey(name))
		{
			tabCtrlTopMatches.TabPages.Add(name, name);
			TabPage tabPage = tabCtrlTopMatches.TabPages[name];
			DataGridView value = CreateTopMatchGrid();
			tabPage.Controls.Add(value);
			topMatchGrids.Add(name, value);
		}
	}

	private DataGridView CreateTopMatchGrid()
	{
		DataGridViewTextBoxColumn dataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
		DataGridViewTextBoxColumn dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
		DataGridViewTextBoxColumn dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
		DataGridView dataGridView = new DataGridView();
		dataGridView.AllowUserToAddRows = false;
		dataGridView.AllowUserToDeleteRows = false;
		dataGridView.AllowUserToResizeRows = false;
		dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
		dataGridView.Columns.AddRange(dataGridViewTextBoxColumn, dataGridViewTextBoxColumn2, dataGridViewTextBoxColumn3);
		dataGridView.Location = new Point(3, 3);
		dataGridView.MultiSelect = false;
		dataGridView.Name = "dataGridTopMatches";
		dataGridView.ReadOnly = true;
		dataGridView.RowHeadersVisible = false;
		dataGridView.ScrollBars = ScrollBars.None;
		dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
		dataGridView.Size = new Size(322, 89);
		dataGridView.TabIndex = 44;
		dataGridViewTextBoxColumn.HeaderText = "Rank";
		dataGridViewTextBoxColumn.Name = "ColumnRank";
		dataGridViewTextBoxColumn.ReadOnly = true;
		dataGridViewTextBoxColumn2.HeaderText = "Trial Number";
		dataGridViewTextBoxColumn2.Name = "ColumnTrialNum";
		dataGridViewTextBoxColumn2.ReadOnly = true;
		dataGridViewTextBoxColumn3.HeaderText = "F(x)";
		dataGridViewTextBoxColumn3.Name = "ColumnFx";
		dataGridViewTextBoxColumn3.ReadOnly = true;
		dataGridView.Rows.Add(3);
		dataGridView.Rows[0].Cells[0].Value = 1;
		dataGridView.Rows[1].Cells[0].Value = 2;
		dataGridView.Rows[2].Cells[0].Value = 3;
		return dataGridView;
	}

	private void EnableTopologyGrids(bool enable)
	{
		if (enable)
		{
			tableLayoutPanel1.Visible = true;
			tabPageTrialData.Controls.Remove(labelTrialGridWarning);
		}
		else
		{
			tableLayoutPanel1.Visible = false;
			labelTrialGridWarning.Font = new Font(labelTrialGridWarning.Font.FontFamily, 28f);
			tabPageTrialData.Controls.Add(labelTrialGridWarning);
		}
	}

	private void InitializeAntennaGrid()
	{
		antennaTrialControl.dgBandTrials.CurrentCellDirtyStateChanged += dataGrid_CurrentCellDirtyStateChanged;
		antennaTrialControl.dgBandTrials.CellValueChanged += dataGrid_CellValueChanged;
		antennaTrialControl.dgBandTrials.CellBeginEdit += dataGrid_CellBeginEdit;
		antennaTrialControl.dgBandTrials.DataError += dataGrid_DataError;
		antennaTrialControl.dgBandTrials.UserAddedRow += dataGrid_UserAddedRow;
		antennaTrialControl.dgBandTrials.UserDeletedRow += dataGrid_UserDeletedRow;
		antennaTrialControl.btnAutoGenBandTrials.Click += btnAutoGenTrials_Click;
		antennaTrialControl.btnClearBandTrials.Click += btnClearTrialData_Click;
		dgAntennaGrid = antennaTrialControl.dgBandTrials;
		LoadDataGrid();
		AddBCTrialGrid(antennaTrialControl);
	}

	private void PreConfigureWorkspaceConfig()
	{
		try
		{
			if (!File.Exists("C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\Workspace.config"))
			{
				string contents = "<?xml version=\"1.0\" encoding=\"utf-8\"?><WorkspaceConfig xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><ListOfSUITELoop>RF Mode,Channel,Temp,Band,RC,Traffic Data Rate,Cell Power,Raw_DAC,Ref Chan,HdetPwrList,AGC,agc,Tx Power,Index,Rx_Gain_Range,LPM,NVMode,RxPM,LNA,LNARange,RxPath,PARange,Technology</ListOfSUITELoop><ResetGlobalVariables>true</ResetGlobalVariables><SuppressSerialNumberDialog>true</SuppressSerialNumberDialog><CreateDebugWindowsOnLoading>true</CreateDebugWindowsOnLoading><ListofDebugWinNames>Debug,Log,Error</ListofDebugWinNames><SuppressResultsDialog>true</SuppressResultsDialog><ShowFailedTests>false</ShowFailedTests><ClearSerialNumber>false</ClearSerialNumber><CustomLinkAppName /><CustomLinkAppArgs /><CustomAppToolTip>Custom Tool. Option is set in Workspaceconfig</CustomAppToolTip><UseDllSearch>true</UseDllSearch><DLLPaths><string>C:\\Program Files (x86)\\QUALCOMM\\QDART\\bin</string></DLLPaths><AlwaysOpenFile /><OpenPreviousFile>false</OpenPreviousFile><SimulationMode>false</SimulationMode><RecentFileListSize>10</RecentFileListSize><PluginDetails><Name>Global Variable View</Name><Load>true</Load></PluginDetails><PluginDetails><Name>HTMLWindow</Name><Load>true</Load></PluginDetails><PluginDetails><Name>QSPRAutomationPlugin</Name><Load>true</Load></PluginDetails><PluginDetails><Name>QSPRTestResultsPlugin</Name><Load>true</Load></PluginDetails><PluginDetails><Name>QSPRWinFormsChartsPlugin</Name><Load>true</Load></PluginDetails><PluginDetails><Name>Registration</Name><Load>false</Load></PluginDetails><PluginDetails><Name>TesterConfigTTD</Name><Load>true</Load></PluginDetails><PluginDetails><Name>TPL3</Name><Load>true</Load></PluginDetails><PluginDetails><Name>XmlForDB</Name><Load>true</Load></PluginDetails><SuppressWarnings>false</SuppressWarnings><SuppressSpashScreen>false</SuppressSpashScreen><VerifyDllVersion>false</VerifyDllVersion><DoubleClickRunsTest>false</DoubleClickRunsTest><MinimizeAtStartup>false</MinimizeAtStartup><AskBeforeStoppingTree>false</AskBeforeStoppingTree><SaveAllDebugWindows>true</SaveAllDebugWindows><MaxDisplayDebugCharacters>1800000</MaxDisplayDebugCharacters><RefreshCurrSettings>false</RefreshCurrSettings><ShowTimeStamp>false</ShowTimeStamp><ShowDateStamp>false</ShowDateStamp><AutoResizeDebugWindows>true</AutoResizeDebugWindows><ShowDebugMessages>true</ShowDebugMessages><ShowToolTips>true</ShowToolTips><IconSize>Small Icons</IconSize><IconType>Office 2003</IconType><EnableTracing>false</EnableTracing><EnableSound>true</EnableSound><EnableHiveTracing>false</EnableHiveTracing><DebugWindowSaveLocation>C:\\Qualcomm\\QSPR\\TestLog\\</DebugWindowSaveLocation><SaveDebugOnlyOnFail>false</SaveDebugOnlyOnFail><SaveInSubFolders>false</SaveInSubFolders><TestResultsSaveLocation>C:\\Qualcomm\\QSPR\\TestLog\\</TestResultsSaveLocation><sFont><FontFamily>Microsoft Sans Serif</FontFamily><GraphicsUnit>Point</GraphicsUnit><Size>10</Size><Style>Regular</Style></sFont><LastUsedSerialNumber /><StartUpTTDPlugin>Tree View</StartUpTTDPlugin><DebugTraceLevel>Verbose</DebugTraceLevel><SeperateTraceLevelWindows>false</SeperateTraceLevelWindows><DebugWindowUpdateOption>Auto Update</DebugWindowUpdateOption><AutoScrollDebugWindows>true</AutoScrollDebugWindows><TestResultMessageProcessingOption>Auto Update</TestResultMessageProcessingOption><EnableSUITEOutParam>true</EnableSUITEOutParam><EnableSuiteGV>false</EnableSuiteGV><SuiteParamGVs /><AllowOperatorRunUnregisteredTrees>true</AllowOperatorRunUnregisteredTrees><AllowOperatorAbortTestRun>true</AllowOperatorAbortTestRun><CustomStartupEvents /><SearchString>LTE Params for RGI Determination and Freq Comp Sweeps</SearchString><CurrentSearchOptions>ParameterName</CurrentSearchOptions><SearchCaseMatch>false</SearchCaseMatch><TreeItemMargin>0</TreeItemMargin><NodeDetailsChoice>31</NodeDetailsChoice><ShowSingleStepTestCaseSteps>false</ShowSingleStepTestCaseSteps><SendAllInputConditions>true</SendAllInputConditions><WarnXmlForDbMissing>true</WarnXmlForDbMissing></WorkspaceConfig>";
				File.WriteAllText("C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\Workspace.config", contents);
				return;
			}
			string text = File.ReadAllText("C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\Workspace.config");
			if (text.Contains("<SendAllInputConditions>false</SendAllInputConditions>"))
			{
				text = text.Replace("<SendAllInputConditions>false</SendAllInputConditions>", "<SendAllInputConditions>true</SendAllInputConditions>");
			}
			if (text.Contains("<EnableSUITEOutParam>false</EnableSUITEOutParam>"))
			{
				text = text.Replace("<EnableSUITEOutParam>false</EnableSUITEOutParam>", "<EnableSUITEOutParam>true</EnableSUITEOutParam>");
			}
			File.WriteAllText("C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\Workspace.config", text);
		}
		catch (Exception)
		{
		}
	}

	private void PreConfigureChartConfig()
	{
		string path = "C:\\Qualcomm\\QSPR\\QSPRConfigurations\\QsprLiveCharts.config";
		if (File.Exists(path))
		{
			string text = File.ReadAllText(path);
			if (text.Contains("<AppendInGoNoGoMode>false</AppendInGoNoGoMode>"))
			{
				text = text.Replace("<AppendInGoNoGoMode>false</AppendInGoNoGoMode>", "<AppendInGoNoGoMode>true</AppendInGoNoGoMode>");
			}
			string newValue = "<LiveChartingOption>0</LiveChartingOption>";
			string text2 = "<LiveChartingOption>1</LiveChartingOption>";
			if (text.Contains(text2))
			{
				text = text.Replace(text2, newValue);
			}
			text2 = "<LiveChartingOption>2</LiveChartingOption>";
			if (text.Contains(text2))
			{
				text = text.Replace(text2, newValue);
			}
			text2 = "<LiveChartingOption>3</LiveChartingOption>";
			if (text.Contains(text2))
			{
				text = text.Replace(text2, newValue);
			}
			text2 = "<LiveChartingOption>4</LiveChartingOption>";
			if (text.Contains(text2))
			{
				text = text.Replace(text2, newValue);
			}
			text2 = "<LiveChartingOption>5</LiveChartingOption>";
			if (text.Contains(text2))
			{
				text = text.Replace(text2, newValue);
			}
			File.WriteAllText(path, text);
		}
		else
		{
			string contents = "<?xml version=\"1.0\" encoding=\"utf-16\"?><ReportSettings xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><DisplayLimits>true</DisplayLimits><ShowSerialNumberInCharts>true</ShowSerialNumberInCharts><GenerateExcelAtEndOfTesting>false</GenerateExcelAtEndOfTesting><GenerateDetailHtmlAtEndOfTesting>false</GenerateDetailHtmlAtEndOfTesting><FormatDescriptor /><CustomLimits /><LiveChartingOption>0</LiveChartingOption><ShowStatisticsCharts>false</ShowStatisticsCharts><AutoScroll>false</AutoScroll><EnableDebugging>false</EnableDebugging><AppendInGoNoGoMode>true</AppendInGoNoGoMode></ReportSettings>";
			File.WriteAllText(path, contents);
		}
	}

	private void LoadLiveChartPlugin()
	{
		try
		{
			PreConfigureChartConfig();
			List<TestResultPlugin> list = scheduler.QSPRPluginMgr.LoadTestResultPlugins(new List<string> { "QsprWebReportViewer" });
			liveChartPlugin = list[0];
			liveChartPlugin.Dock = DockStyle.Fill;
			panelLiveChartsPlugin.Controls.Add(liveChartPlugin);
		}
		catch (Exception)
		{
			MessageBox.Show("Error loading Live Charts plugin.");
		}
	}

	[DllImport("user32.dll")]
	private static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);

	public void DebugMessage(string strWin, string strText, int traceLevel, bool NoEndOfLine)
	{
		if (strWin == "Error")
		{
			strError = true;
		}
		else
		{
			strError = false;
		}
		if (strWin == "Debug" || strWin == "Error")
		{
			UpdateWindow(strText);
		}
	}

	private void UpdateWindow(string message)
	{
		if (richTextBox1.InvokeRequired)
		{
			richTextBox1.BeginInvoke((MethodInvoker)delegate
			{
				UpdateWindow(message);
			});
			return;
		}
		if (strError)
		{
			richTextBox1.SelectionColor = Color.Red;
		}
		else
		{
			richTextBox1.SelectionColor = Color.Blue;
		}
		richTextBox1.SuspendLayout();
		richTextBox1.AppendText(message + Environment.NewLine);
		AutoScrollToBottom();
		richTextBox1.ResumeLayout();
	}

	private void UpdateQSPRMessagePumpLog(string message, bool Highlight)
	{
		if (richTextBox2.InvokeRequired)
		{
			richTextBox2.BeginInvoke((MethodInvoker)delegate
			{
				UpdateQSPRMessagePumpLog(message, Highlight);
			});
			return;
		}
		if (Highlight)
		{
			richTextBox2.SelectionColor = Color.Red;
		}
		else
		{
			richTextBox2.SelectionColor = Color.Black;
		}
		richTextBox2.SuspendLayout();
		richTextBox2.AppendText(message + Environment.NewLine);
		SendMessage(richTextBox2.Handle, 277u, 7, 0);
		richTextBox2.ResumeLayout();
	}

	private void AddGVsToViewer()
	{
		gvViewerCtrl.AddGVToList(NumBandsGV);
		gvViewerCtrl.AddGVToList(WorstCaseMeasConstraintGV);
		gvViewerCtrl.AddGVToList(NumBandsGV);
		gvViewerCtrl.AddGVToList("POUT_DELTA");
		gvViewerCtrl.AddGVToList("POUT_LIMIT");
		gvViewerCtrl.AddGVToList("MATCH_MODE");
		gvViewerCtrl.AddGVToList("EXIT_PART_A");
	}

	private void AutoScrollToBottom()
	{
		if (checkBoxAutoScroll.Checked)
		{
			SendMessage(richTextBox1.Handle, 277u, 7, 0);
		}
	}

	private void btnClearDebugText_Click(object sender, EventArgs e)
	{
		ClearStatusWindow();
	}

	private void OnGenericParamMsg(string messageType, string id, string name = "", string value = "", string units = "", string lowerLimit = "", string upperLimit = "", byte pluginTypes = 7, string pluginNames = "")
	{
		if (!(messageType == "OutputParam"))
		{
			return;
		}
		if (name.Contains("ACLR_MAX"))
		{
			DoUpdateLabel("ACLR", value);
		}
		if (name.Contains("POUT_MIN"))
		{
			dCurrentPout = Convert.ToDouble(value);
			DoUpdateLabel("Pout", value);
		}
		if (name.Contains("PIN_POUT_DELTA"))
		{
			DoUpdateLabel("Pin", value);
		}
		if (name.Contains("POUT_DELTA") && !name.Contains("PIN") && currentRunningTest.Contains("QMatchTool_LTE_B"))
		{
			if (!string.IsNullOrEmpty(currentRunningBC))
			{
				DoUpdateLabel("Pout Delta", value);
			}
			UpdateQSPRMessagePumpLog("OutputParam: " + currentRunningBC + ":  " + name, Highlight: true);
		}
		if (name.Contains("DELAY_DELTA"))
		{
			DoUpdateLabel("Delay", value);
		}
	}

	private void PresetGridColumns(DataGridView dataGrid = null, TrialDataConverter trialData = null)
	{
		if (dataGrid == null)
		{
			dataGrid = dgAntennaGrid;
		}
		if (trialData == null)
		{
			trialData = antennaTrialData;
		}
		dataGrid.Columns.Clear();
		for (int i = 0; i < trialData.TrialDataTable.Columns.Count; i++)
		{
			DataGridViewColumn dataGridViewColumn = null;
			if (trialData.TrialDataTable.Columns[i].DataType == typeof(TrialUnits))
			{
				dataGridViewColumn = new DataGridViewComboBoxColumn();
				(dataGridViewColumn as DataGridViewComboBoxColumn).Items.AddRange(TrialUnits.pF, TrialUnits.nH);
				dataGridViewColumn.DataPropertyName = trialData.TrialDataTable.Columns[i].ColumnName;
				dataGridViewColumn.Width = 50;
			}
			else if (trialData.TrialDataTable.Columns[i].DataType == typeof(TrialTopology))
			{
				dataGridViewColumn = new DataGridViewComboBoxColumn();
				(dataGridViewColumn as DataGridViewComboBoxColumn).Items.AddRange(TrialTopology.SHUNT, TrialTopology.SERIES, TrialTopology.DNI, TrialTopology.SHORT);
				dataGridViewColumn.DataPropertyName = trialData.TrialDataTable.Columns[i].ColumnName;
			}
			else if (trialData.TrialDataTable.Columns[i].DataType == typeof(bool))
			{
				dataGridViewColumn = new DataGridViewCheckBoxColumn();
				dataGridViewColumn.DataPropertyName = trialData.TrialDataTable.Columns[i].ColumnName;
				dataGridViewColumn.Width = 75;
			}
			else
			{
				dataGridViewColumn = new DataGridViewTextBoxColumn();
				dataGridViewColumn.DataPropertyName = trialData.TrialDataTable.Columns[i].ColumnName;
				if (trialData.TrialDataTable.Columns[i].ColumnName != "Ref Designator")
				{
					dataGridViewColumn.DefaultCellStyle.BackColor = Color.Wheat;
				}
			}
			dataGridViewColumn.Name = trialData.TrialDataTable.Columns[i].ColumnName;
			dataGridViewColumn.HeaderText = trialData.TrialDataTable.Columns[i].ColumnName;
			dataGrid.Columns.Add(dataGridViewColumn);
		}
	}

	private void btnSelectTech_Click(object sender, EventArgs e)
	{
		PopupForm popupForm = null;
		TreeDirectory = "C:\\Program Files (x86)\\QUALCOMM\\QDART\\XTT\\SubSysRFCalibration\\SmartQMatch\\MasterTree";
		try
		{
			popupForm = new PopupForm(TreeDirectory, mruTreeFiles, SelectTech, XTTFilename);
			if (!popupForm.Disposing && !popupForm.IsDisposed)
			{
				DialogResult dialogResult = popupForm.ShowDialog();
				if (dialogResult == DialogResult.OK && popupForm.XttPath != "")
				{
					mruTreeFiles.AddFileName(popupForm.XttPath);
					SelectTechnology(popupForm.Tech, popupForm.XttPath);
				}
			}
			UpdateScenarioModifiedStatus(modified: false);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void btnPAFile_Click(object sender, EventArgs e)
	{
		OpenFileDialog openFileDialog = new OpenFileDialog();
		openFileDialog.Filter = "Xml Files | *.xml";
		openFileDialog.DefaultExt = "xml";
		openFileDialog.InitialDirectory = "C:\\Program Files (x86)\\QUALCOMM\\QDART\\XTT\\SubSysRFCalibration\\SmartMatch\\";
		if (openFileDialog.ShowDialog() == DialogResult.OK)
		{
			tbPAParamsFile.Text = openFileDialog.FileName;
		}
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void btnRGI_Click(object sender, EventArgs e)
	{
	}

	private void btnPinPoutMax_Click(object sender, EventArgs e)
	{
	}

	private void tbPinPoutMax_TextChanged(object sender, EventArgs e)
	{
		strPinMax = tbPinPoutMax.Text;
	}

	private void tbPoutMaxBias_TextChanged(object sender, EventArgs e)
	{
		strPoutMaxBias = tbPoutMaxBias.Text;
	}

	private void tbRGIStart_TextChanged(object sender, EventArgs e)
	{
		strRGIStart = tbRGIStart.Text;
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void tbRGIStop_TextChanged(object sender, EventArgs e)
	{
		strRGIStop = tbRGIStop.Text;
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void tbRGIStep_TextChanged(object sender, EventArgs e)
	{
		strRGIStep = tbRGIStep.Text;
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void tbDelayStart_TextChanged(object sender, EventArgs e)
	{
		strDelayValParams10MHzStart = tbDelayStart.Text;
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void tbDelayStop_TextChanged(object sender, EventArgs e)
	{
		strDelayValParams10MHzStop = tbDelayStop.Text;
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void tbDelayStep_TextChanged(object sender, EventArgs e)
	{
		strDelayValParams10MHzStep = tbDelayStep.Text;
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void cbET_CheckedChanged(object sender, EventArgs e)
	{
		if (!bModifyingXptMode)
		{
			SetXPTActionState(XPTAction.ET);
			UpdateScenarioModifiedStatus(modified: true);
		}
	}

	private void cbEPT_CheckedChanged(object sender, EventArgs e)
	{
		if (!bModifyingXptMode)
		{
			SetXPTActionState(XPTAction.EPT);
			UpdateScenarioModifiedStatus(modified: true);
		}
	}

	private void SetXPTActionState(XPTAction xpt)
	{
		bModifyingXptMode = true;
		if (xpt == XPTAction.EPT)
		{
			cbEPT.Checked = true;
			cbET.Checked = false;
			eXptAction = XPTAction.EPT;
			measurementSelection.EnableDelayControls(state: false);
		}
		else
		{
			cbET.Checked = true;
			cbEPT.Checked = false;
			eXptAction = XPTAction.ET;
			if (measurementSelection.strDelayMeasureType.Contains("ACLRBASED_DELAY"))
			{
				eDelayMode = DelayMode.ACLR_BASED;
			}
			else
			{
				eDelayMode = DelayMode.FW_BASED;
			}
			measurementSelection.EnableDelayControls(state: true);
		}
		bModifyMeasurementSelections = true;
		bModifyingXptMode = false;
	}

	private void cbPAGain_SelectedIndexChanged(object sender, EventArgs e)
	{
		strPAState = cbPAGain.Text;
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void SelectTechnology(string tech, string treeFilePath)
	{
		string selectTech = SelectTech;
		string xTTFilename = XTTFilename;
		XTTFilename = Path.GetFileName(treeFilePath);
		MasterXttFullPath = treeFilePath;
		string text = "";
		if (File.Exists(MasterXttFullPath))
		{
			validTree = false;
			TempFullPath = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\" + XTTFilename;
			if (File.Exists(TempFullPath))
			{
				File.SetAttributes(TempFullPath, FileAttributes.Normal);
				File.Delete(TempFullPath);
			}
			text = Path.GetDirectoryName(TempFullPath);
			Directory.CreateDirectory(text);
			File.Copy(MasterXttFullPath, TempFullPath);
			if (File.Exists(TempFullPath))
			{
				OpenTree(TempFullPath);
				if (!validTree)
				{
					MessageBox.Show(TempFullPath + " is not a valid Smart Match Tree.  \n\n\n Please confirm and try your selection again.", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
					return;
				}
				EnableTopologyGrids(enable: true);
				ClearTrialDataGrid();
				GetAllParameters();
				UpdateDefaultBandClassChannels();
				tbXttPath.Text = MasterXttFullPath;
				UpdateButtonStatus(eButtonState.SELECT_TECH);
				bUserScenarioLoaded = false;
			}
			else
			{
				MessageBox.Show("There was a problem copying " + MasterXttFullPath + " to " + TempFullPath, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				TempFullPath = "None";
			}
		}
		else
		{
			MessageBox.Show("Could not find QSPR tree for " + SelectTech + "!\n\n" + MasterXttFullPath, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
			SelectTech = selectTech;
			XTTFilename = xTTFilename;
		}
		DoUpdateLabel("Tech", SelectTech);
		UpdateButtonStatus(eButtonState.SELECT_TECH);
		ClearTrialDataGrid();
	}

	private void OpenTree(string path)
	{
		try
		{
			xttTree = scheduler.OpenXTT(path);
			xttTree.SetParameterValue("Message", "New message");
			scheduler.SetGlobalVariable(FormatDescriptorGV, FormatDescriptorName);
			xttTree.GetAllChildTests("Init", out var tests, out var _);
			string[] array = tests;
			foreach (string text in array)
			{
				if (text == strInitializeTestName)
				{
					validTree = true;
					tbXttPath.Text = path;
				}
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void scheduler_OnTestMessage(int messageType, QSPRTestMessage messageData)
	{
		if (base.InvokeRequired)
		{
			BeginInvoke((MethodInvoker)delegate
			{
				scheduler_OnTestMessage(messageType, messageData);
			});
			return;
		}
		string value = messageData.GetValue("TestName");
		string value2 = messageData.GetValue("TestResult");
		messageData.GetValue("LoopDetails");
		switch ((TestMsgTypes)messageType)
		{
		case TestMsgTypes.ON_TEST_START:
			UpdateQSPRMessagePumpLog("ON_TEST_START " + value, Highlight: false);
			gvViewerCtrl.UpdateGlobalVbleView(scheduler);
			if (value.Contains("SmartQMatch"))
			{
				int startIndex = value.IndexOf('-') + 2;
				string theText = value.Substring(startIndex);
				DoUpdateLabel("Mode", theText);
			}
			if (value.Contains("QMatchTool_LTE_B") && !value.EndsWith("QMatchTool_LTE_Bx"))
			{
				int num2 = value.LastIndexOf("_");
				currentRunningBC = value.Substring(num2 + 1);
				currentRunningTest = value;
			}
			break;
		case TestMsgTypes.ON_TEST_RESULT:
		{
			gvViewerCtrl.UpdateGlobalVbleView(scheduler);
			if (value.Contains("RFCal_GetUUTID"))
			{
				if (value2 == "Failed")
				{
					UpdateWindow("User cancelled GetUUTID test. Test run stopped.");
					xttTree.StopTest();
					bStopButtonPushed = true;
					break;
				}
				scheduler.GetGlobalVariable("SN", out sUnitSN);
			}
			if (value.Contains("UpdateWorstConstraint"))
			{
				scheduler.GetGlobalVariable(WorstCaseMeasConstraintGV, out strWorstCaseResult);
				UpdateBestMatches(currentTrialNum, strWorstCaseResult);
			}
			if (value.Contains("QMatchTool_LTE_B"))
			{
				UpdateQSPRMessagePumpLog("ON_TEST_RESULT " + value, Highlight: false);
				if (!value.EndsWith("QMatchTool_LTE_Bx") && eMatchMode == MatchMode.ANT)
				{
					if (!string.IsNullOrEmpty(currentRunningBC))
					{
						lastRunningBC = currentRunningBC;
					}
					UpdateQSPRMessagePumpLog("TestResult: " + value, Highlight: true);
				}
			}
			else
			{
				List<string> list = new List<string>();
				list.Add("RFCal_GetUUTID");
				list.Add("SmartQMatch - Initialize");
				list.Add("SmartQMatch - Initial Trials");
				list.Add("Shutdown Power Supply");
				list.Add("SmartQMatch - Order Pts, Avg, Calc. Reflected");
				list.Add("SmartQMatch - Process Reflected Pt");
				list.Add("SmartQMatch - Process Expanded Pt");
				list.Add("SmartQMatch - Process Contracted Pt");
				list.Add("SmartQMatch - Process New Simplex Pt");
				list.Add("SmartQMatch - Setup for Next Iteration");
				List<string> list2 = list;
				if (value2 == "Failed" && !list2.Contains(value))
				{
					string text = "The following test failed: " + value + "." + Environment.NewLine + "Would you like to continue?";
					if (MessageBox.Show(text, "Test failed", MessageBoxButtons.YesNo) != DialogResult.Yes)
					{
						UpdateWindow("User aborted test or test failed. Test run stopped.");
						xttTree.StopTest();
						bStopButtonPushed = true;
						break;
					}
				}
			}
			if (value.Contains("SmartQMatch"))
			{
				scheduler.GetGlobalVariable("NELDER_MEAD_TRIAL_NUM", out currentTrialNum);
				if (value2 == "Failed")
				{
					UpdateWindow("User cancelled Next Trial or test failed. Test run stopped.");
					xttTree.StopTest();
					bStopButtonPushed = true;
					UpdateButtonStatus(eButtonState.LOAD_PROFILE);
					break;
				}
				if (currentTrialNum != "")
				{
					DoUpdateLabel("Trial", currentTrialNum);
					lastRunningSegment = currentSegment;
					if (eMatchMode == MatchMode.ANT)
					{
						int num = Convert.ToInt16(currentTrialNum);
						if (num > 30)
						{
							failedPoutBCNames.Add(currentRunningBC);
							UpdateWindow("Exceeded Max # trials for Antenna Match. Test run stopped.");
							xttTree.StopTest();
							bStopButtonPushed = true;
						}
						scheduler.GetGlobalVariable("POUT_DELTA", out var _);
						scheduler.GetGlobalVariable("POUT_LIMIT", out var _);
						scheduler.GetGlobalVariable("NELDER_MEAD_MAX_TRIALS", out var _);
						if (dCurrentPoutDeltaMax < dPoutDeltaMax && dCurrentPout > dPoutMin)
						{
							UpdateWindow("Pout Delta Max tolerance satisfied for Antenna Segment Match.");
							UpdateWindow("Current Pout Delta Max = " + dCurrentPoutDeltaMax);
							UpdateWindow("Current Pout = " + dCurrentPout);
							bPoutDeltaSatisfied = true;
							eLastMatchMode = eMatchMode;
							xttTree.StopTest();
						}
					}
					if (eMatchMode == MatchMode.BC)
					{
						Convert.ToInt16(currentTrialNum);
						scheduler.GetGlobalVariable("NELDER_MEAD_TRIAL_NUM", out var value7);
						scheduler.GetGlobalVariable("NELDER_MEAD_MAX_TRIALS", out var value8);
						if (Convert.ToInt16(value7) > Convert.ToInt16(value8))
						{
							UpdateWindow("Measurement Target Values have been reached, exiting loop.");
							bMeasTargetsSatisfied = true;
							lastRunningBC = currentRunningBC;
							eLastMatchMode = eMatchMode;
							xttTree.StopTest();
						}
					}
				}
			}
			if (value.Contains("Resume Trial"))
			{
				bResumePassed = value2 == "Passed";
				if (bResumePassed)
				{
					bool segmentedRun = true;
					StartMatch(currentCheckedBCNames, segmentedRun);
				}
				else
				{
					UpdateWindow("RESUME TRIALS FAILED. Test run stopped.");
					OnUnitStop(status: false);
				}
			}
			if (value.Contains("NelderMead"))
			{
				scheduler.GetGlobalVariable("NELDER_MEAD_TRIAL_NUM", out var value9);
				if (value9 != "")
				{
					DoUpdateLabel("Trial", value9);
				}
			}
			if (!value.Contains("QMatchTool_LTE"))
			{
				break;
			}
			string[] itemNames = messageData.GetItemNames();
			string[] array = itemNames;
			foreach (string text2 in array)
			{
				if (text2.StartsWith("OutputParam_"))
				{
					messageData.GetValue(text2);
				}
			}
			break;
		}
		case TestMsgTypes.ON_UNIT_END:
		{
			UpdateQSPRMessagePumpLog("ON_TEST_END " + value, Highlight: false);
			string value3 = messageData.GetValue("TestResult");
			bool status = value3 == "Passed";
			if (bPoutDeltaSatisfied && eMatchMode == MatchMode.ANT)
			{
				status = true;
			}
			if (bMeasTargetsSatisfied && eMatchMode == MatchMode.BC)
			{
				status = true;
			}
			bTreePassed = status;
			bTreeCompleted = true;
			OnUnitStop(status);
			break;
		}
		case TestMsgTypes.ON_UNIT_START:
			break;
		}
	}

	private bool IsMeasurementCompleted(string testName)
	{
		if (testName.StartsWith("QMatchTool_LTE_B") && !testName.EndsWith("QMatchTool_LTE_Bx"))
		{
			return true;
		}
		return false;
	}

	private void SaveTree(string path)
	{
		try
		{
			if (File.Exists(path))
			{
				File.SetAttributes(path, FileAttributes.Normal);
			}
			xttTree.SaveTree(path);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void GetAllParameters()
	{
		xttTree.GetAllChildTests("LTE_Char", out var tests, out var _);
		GetMeasurementParams();
		bands.Clear();
		string[] array = tests;
		foreach (string text in array)
		{
			int num = text.LastIndexOf('_');
			string text2 = text.Substring(num + 1);
			if (text2.StartsWith("B"))
			{
				bands.Add(text2);
			}
		}
		try
		{
			comboBC_Active = false;
			UpdateBandClasses();
			comboBC_Active = true;
			UpdateBandClassListView(getTreeParamValues: true);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	public void GetMeasurementParams()
	{
		string paramValue = "";
		string paramValue2 = "";
		string paramValue3 = "";
		xttTree.GetParameterValue(strInitializeTestName, "Measurement Types", out paramValue);
		xttTree.GetParameterValue(strInitializeTestName, "Constraints", out paramValue2);
		xttTree.GetParameterValue(strInitializeTestName, "Measurement Targets", out paramValue3);
		measurementSelection.StrMeasureTypes = paramValue;
		measurementSelection.StrMeasureConstraints = paramValue2;
		measurementSelection.StrMeasureTargets = paramValue3;
		measurementSelection.StrDefaultMeasureTargets = paramValue3;
		measurementSelection.ConfigureMeasurementTypes(LoadingScenario: false);
		measurementSelection.ConfigureDefaultMeasurementTargets();
	}

	public void UpdateMeasurementParams()
	{
		measurementSelection.UpdateMeasurementInfo();
		measurementSelection.UpdateDefaultMeasurementInfo();
		xttTree.SetParameterValue("Measurement Types", measurementSelection.StrMeasureTypes, strInitializeTestName);
		xttTree.SetParameterValue("Constraints", measurementSelection.StrMeasureConstraints, strInitializeTestName);
		if (eMatchMode == MatchMode.ANT)
		{
			xttTree.SetParameterValue("Measurement Targets", measurementSelection.StrDefaultMeasureTargets, strInitializeTestName);
		}
		else
		{
			xttTree.SetParameterValue("Measurement Targets", measurementSelection.StrMeasureTargets, strInitializeTestName);
		}
		bModifyMeasurementSelections = false;
	}

	public string GetParameter(string testName, string parameterName)
	{
		try
		{
			xttTree.GetParameterValue(testName, parameterName, out var paramValue);
			return paramValue;
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
			return ex.Message;
		}
	}

	public bool UpdateParameter(string testName, string parameterName, string parameterValue)
	{
		bool result = true;
		try
		{
			xttTree.SetParameterValue(parameterName, parameterValue, testName);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
			result = false;
		}
		return result;
	}

	private void UpdateScenarioModifiedStatus(bool modified)
	{
		bScenarioModified = modified;
		MainFormTitle = "Smart QMatch" + base.ProductVersion + " -- " + ScenarioFilePathName;
		if (bScenarioModified)
		{
			MainFormTitle += "*";
		}
		Text = MainFormTitle;
	}

	private void UpdateBandClasses()
	{
		ignoreBandClassChanges = true;
		lvBandClasses.Items.Clear();
		foreach (string band in bands)
		{
			lvBandClasses.Items.Add(band);
		}
		lvBandClasses.Items[0].Checked = true;
		lvBandClasses.Items[0].Selected = true;
		currentCheckedBCNames.Add(lvBandClasses.Items[0].Text);
		ignoreBandClassChanges = false;
	}

	private void UpdateQMatchGUI()
	{
		int num = strRgiParams.IndexOf('(');
		string text = strRgiParams.Substring(num + 1, strRgiParams.Length - num - 2);
		string[] array = text.Split(',');
		tbRGIStart.Text = array[0];
		strRGIStart = array[0];
		tbRGIStop.Text = array[1];
		strRGIStop = array[1];
		tbRGIStep.Text = array[2];
		strRGIStep = array[2];
		string text2 = strDelayValParams10MHz.Substring(num + 1, strDelayValParams10MHz.Length - num - 2);
		string[] array2 = text2.Split(',');
		tbDelayStart.Text = array2[0];
		strDelayValParams10MHzStart = array2[0];
		tbDelayStop.Text = array2[1];
		strDelayValParams10MHzStop = array2[1];
		tbDelayStep.Text = array2[2];
		strDelayValParams10MHzStep = array2[2];
		cbPAGain.Text = strPAState;
		SetXPTActionState(eXptAction);
		if (BC_FreqCalc.bcInfoList.ContainsKey(currentCheckedBCNames[0]))
		{
			currentCheckedBCNames.Sort();
			_ = currentCheckedBCNames.Count;
			double num2 = 9E+20;
			double num3 = 0.0;
			foreach (string currentCheckedBCName in currentCheckedBCNames)
			{
				currentBCInfoItem = BC_FreqCalc.bcInfoList[currentCheckedBCName];
				double num4 = Convert.ToDouble(currentBCInfoItem.StrMinFrequency);
				if (num4 < num2)
				{
					num2 = num4;
					tbChannelStart.Text = currentBCInfoItem.StrMinFrequency;
				}
				num4 = Convert.ToDouble(currentBCInfoItem.StrMaxFrequency);
				if (num4 > num3)
				{
					num3 = num4;
					tbChannelStop.Text = currentBCInfoItem.StrMaxFrequency;
				}
			}
			double num5 = (num3 - num2) / 2.0 + num2;
			f = num5 * 1000000.0;
			tbChannelRef.Text = num5.ToString();
		}
		if (strRBs == "0")
		{
			cbRBs.Text = "6 Rbs";
		}
		else if (strRBs == "1")
		{
			cbRBs.Text = "12 Rbs";
		}
		else
		{
			cbRBs.Text = "50 Rbs";
		}
		tbPinPoutMax.Text = strPinMax;
		tbPoutMaxBias.Text = strPoutMaxBias;
	}

	private void UpdateSmartMatchParams_MultipleBCs()
	{
		int num = 1;
		xttTree.SetParameterValue("Min Frequency of Interest", tbChannelStart.Text, strInitializeTestName);
		xttTree.SetParameterValue("Max Frequency of Interest", tbChannelStop.Text, strInitializeTestName);
		xttTree.SetParameterValue("Reference Frequency", tbChannelRef.Text, strInitializeTestName);
		xttTree.SetParameterValue("RF Cal Input Data File", tbPAParamsFile.Text, "InitPAParamsFile");
		xttTree.SetParameterValue("RF Cal Input Data File", tbPAParamsFile.Text, "ReadPAParamsFile");
		xttTree.SetParameterValue("File Path Name", LogPath, "RFCal_QDART_FinalizeDataLogging");
		xttTree.SetParameterValue("Use Fixed LogFile Path Name", "1", "RFCal_QDART_FinalizeDataLogging");
		foreach (string currentCheckedBCName in currentCheckedBCNames)
		{
			UpdateXTTBCInfo(currentCheckedBCName, num);
			xttTree.SelectTestFromFolderToRun("Smart QMatch", "QMatchTool_LTE_" + currentCheckedBCName);
			num++;
		}
		UpdateTopologyInfo(dgAntennaGrid);
	}

	private void UpdateXTTBCInfo(string BandClass, int Loop)
	{
		string text = "";
		text = "QMatchTool_LTE_" + BandClass;
		xttTree.SelectTestFromFolderToRun("Smart QMatch", "QMatchTool_LTE_" + BandClass);
		xttTree.SetParameterValue("Enable logging of Simplex data?", "1", text);
		xttTree.SetParameterValue("Smart QMatch Logging", "1", text);
		strRBs = ((!(cbRBs.Text == "6 Rbs")) ? ((cbRBs.Text == "12 Rbs") ? 1 : 2) : 0).ToString();
		xttTree.SetParameterValue("LTE Params for RGI Determination and Freq Comp Sweeps", strRBs, text);
		xttTree.SetParameterValue("Max Allowed Pin Variation Across The Band", tbPinPoutMax.Text, text);
		strDelayValParams10MHz = "SSS(" + strDelayValParams10MHzStart + "," + strDelayValParams10MHzStop + "," + strDelayValParams10MHzStep + ")";
		xttTree.SetParameterValue("ACLR Delay Char params:List of Default Delay Values", strDelayValParams10MHz, text);
		strRgiParams = "SSS(" + strRGIStart + "," + strRGIStop + "," + strRGIStep + ")";
		xttTree.SetParameterValue("RGI List", strRgiParams, text);
		xttTree.SetParameterValue("PA State", strPAState, text);
		xttTree.SetParameterValue("Low Power PA State", "0", text);
		xttTree.SetParameterValue("Low Power RGI", "40", text);
		xttTree.SetParameterValue("Low Power Bias", "3000", text);
		if (measurementSelection.MeasureCheckBoxes[Convert.ToInt16(MeasurementSelection.eCheckBoxes.CURRENT)])
		{
			xttTree.SetParameterValue("Log Power Supply Current?", "1", text);
		}
		else
		{
			xttTree.SetParameterValue("Log Power Supply Current?", "0", text);
		}
		xttTree.SetParameterValue("Rx Chain", "0", text);
		xttTree.SetParameterValue("DL Level", "-85", text);
		xttTree.SetParameterValue("Frequency Offset", "200", text);
		List<string> list = new List<string>();
		string paramValue = "";
		string paramValue2 = "";
		if (measurementSelection.MeasureCheckBoxes[Convert.ToInt16(MeasurementSelection.eCheckBoxes.POUT_DELTA)])
		{
			xttTree.GetParameterValue(text, "RF Mode", out paramValue);
			xttTree.GetParameterValue(text, "Reference Channel", out paramValue2);
			list.Add(paramValue);
			list.Add(paramValue2);
			list.Add(paramValue2);
			try
			{
				xttTree.SetLoopValuesByRow("Pout MaxBias", Loop, list.ToArray(), list.Count);
			}
			catch (Exception)
			{
				return;
			}
		}
		UpdateTempPAParamsFile(paramValue, tempMaxBias_PAFile);
		list.Clear();
		int num = Convert.ToInt16(eXptAction);
		xttTree.SetParameterValue("XPT Action Type", num.ToString(), text);
		if (measurementSelection.strDelayMeasureType.Contains("ACLRBASED_DELAY"))
		{
			eDelayMode = DelayMode.ACLR_BASED;
		}
		else
		{
			eDelayMode = DelayMode.FW_BASED;
		}
		int num2 = Convert.ToInt16(eDelayMode);
		xttTree.SetParameterValue("Delay Char Technique Type", num2.ToString(), text);
		if (measurementSelection.StrMeasureTypes.Contains("AMAMBASED"))
		{
			eMeasMode = MeasMode.AMAM_BASED;
		}
		else
		{
			eMeasMode = MeasMode.ACLR_BASED;
		}
		int num3 = Convert.ToInt16(eMeasMode);
		xttTree.SetParameterValue("Enable AMAM Based Pin Pout Char?", num3.ToString(), text);
	}

	private void UpdateTopologyInfo()
	{
		numRefDesignators = dgAntennaGrid.RowCount;
		int count = dgAntennaGrid.Columns.Count;
		string text = "";
		string text2 = "";
		string text3 = "";
		string text4 = "";
		string text5 = "";
		string text6 = "";
		string text7 = "";
		string text8 = "";
		List<string> list = new List<string>();
		if (numRefDesignators <= 1)
		{
			return;
		}
		for (int i = 0; i < numRefDesignators - 1; i++)
		{
			text2 = string.Concat(text2, dgAntennaGrid.Rows[i].Cells[0].Value, ",");
			text3 += "double,";
			text5 += "1000,";
			text4 += "-1000,";
			TrialTopology trialTopology = (TrialTopology)dgAntennaGrid.Rows[i].Cells[4].Value;
			text6 = ((trialTopology != 0 && trialTopology != TrialTopology.DNI) ? (text6 + "SHORT,") : (text6 + "DNI,"));
		}
		text2 = text2.Substring(0, text2.Length - 1);
		text3 = text3.Substring(0, text3.Length - 1);
		text5 = text5.Substring(0, text5.Length - 1);
		text4 = text4.Substring(0, text4.Length - 1);
		text6 = text6.Substring(0, text6.Length - 1);
		xttTree.SetParameterValue("Number of Inputs", Convert.ToString(numRefDesignators - 1), strInitializeTestName);
		xttTree.SetParameterValue("Input Data Types", text3, strInitializeTestName);
		xttTree.SetParameterValue("Minimum Values for Inputs", text4, strInitializeTestName);
		xttTree.SetParameterValue("Maximum Values for Inputs", text5, strInitializeTestName);
		xttTree.SetParameterValue("DNI or SHORT", text6, strInitializeTestName);
		xttTree.SetParameterValue("Reference Designators", text2, strInitializeTestName);
		int num = 2;
		int num2 = 1;
		while (num < count)
		{
			text = Convert.ToString(num2);
			for (int j = 0; j < numRefDesignators - 1; j++)
			{
				TrialUnits trialUnits = (TrialUnits)dgAntennaGrid.Rows[j].Cells[num + 1].Value;
				switch ((TrialTopology)dgAntennaGrid.Rows[j].Cells[num + 2].Value)
				{
				case TrialTopology.DNI:
					text8 += "DNI";
					break;
				case TrialTopology.SERIES:
					text8 += "SERIES";
					break;
				case TrialTopology.SHORT:
					text8 += "SHORT";
					break;
				case TrialTopology.SHUNT:
					text8 += "SHUNT";
					break;
				}
				if (trialUnits == TrialUnits.pF)
				{
					text7 = string.Concat(text7, dgAntennaGrid.Rows[j].Cells[num].Value, "e-12;");
					text8 += "_C;";
				}
				else
				{
					text7 = string.Concat(text7, dgAntennaGrid.Rows[j].Cells[num].Value, "e-09;");
					text8 += "_L;";
				}
			}
			text7 = text7.Substring(0, text7.Length - 1);
			text8 = text8.Substring(0, text8.Length - 1);
			xttTree.SetParameterValue("Trial Number", text, strInitializeTestName);
			xttTree.SetParameterValue("Input Values", text7, strInitializeTestName);
			xttTree.SetParameterValue("Topologies", text8, strInitializeTestName);
			list.Add(text);
			list.Add(text7);
			list.Add(text8);
			try
			{
				xttTree.SetLoopValuesByRow("n+1 Input Trials", num2, list.ToArray(), list.Count);
			}
			catch (Exception)
			{
				return;
			}
			text2 = "";
			text7 = "";
			text8 = "";
			list.Clear();
			num += 3;
			num2++;
		}
		int loopRowCount = xttTree.GetLoopRowCount("n+1 Input Trials");
		for (int num3 = loopRowCount; num3 > Convert.ToInt16(text); num3--)
		{
			xttTree.DeleteLoopRow("n+1 Input Trials", num3);
		}
	}

	private void UpdateTopologyInfo(DataGridView dg)
	{
		numRefDesignators = dg.RowCount;
		int count = dg.Columns.Count;
		string text = "";
		string text2 = "";
		string text3 = "";
		string text4 = "";
		string text5 = "";
		string text6 = "";
		string text7 = "";
		string text8 = "";
		List<string> list = new List<string>();
		if (numRefDesignators <= 1)
		{
			return;
		}
		for (int i = 0; i < numRefDesignators - 1; i++)
		{
			text2 = string.Concat(text2, dg.Rows[i].Cells[0].Value, ",");
			text3 += "double,";
			text5 += "1000,";
			text4 += "-1000,";
			TrialTopology trialTopology = (TrialTopology)dg.Rows[i].Cells[4].Value;
			text6 = ((trialTopology != 0 && trialTopology != TrialTopology.DNI) ? (text6 + "SHORT,") : (text6 + "DNI,"));
		}
		text2 = text2.Substring(0, text2.Length - 1);
		text3 = text3.Substring(0, text3.Length - 1);
		text5 = text5.Substring(0, text5.Length - 1);
		text4 = text4.Substring(0, text4.Length - 1);
		text6 = text6.Substring(0, text6.Length - 1);
		xttTree.SetParameterValue("Number of Inputs", Convert.ToString(numRefDesignators - 1), strInitializeTestName);
		xttTree.SetParameterValue("Input Data Types", text3, strInitializeTestName);
		xttTree.SetParameterValue("Minimum Values for Inputs", text4, strInitializeTestName);
		xttTree.SetParameterValue("Maximum Values for Inputs", text5, strInitializeTestName);
		xttTree.SetParameterValue("DNI or SHORT", text6, strInitializeTestName);
		xttTree.SetParameterValue("Reference Designators", text2, strInitializeTestName);
		int num = 2;
		int num2 = 1;
		while (num < count)
		{
			text = Convert.ToString(num2);
			for (int j = 0; j < numRefDesignators - 1; j++)
			{
				TrialUnits trialUnits = (TrialUnits)dg.Rows[j].Cells[num + 1].Value;
				switch ((TrialTopology)dg.Rows[j].Cells[num + 2].Value)
				{
				case TrialTopology.DNI:
					text8 += "DNI";
					break;
				case TrialTopology.SERIES:
					text8 += "SERIES";
					break;
				case TrialTopology.SHORT:
					text8 += "SHORT";
					break;
				case TrialTopology.SHUNT:
					text8 += "SHUNT";
					break;
				}
				if (trialUnits == TrialUnits.pF)
				{
					text7 = string.Concat(text7, dg.Rows[j].Cells[num].Value, "e-12;");
					text8 += "_C;";
				}
				else
				{
					text7 = string.Concat(text7, dg.Rows[j].Cells[num].Value, "e-09;");
					text8 += "_L;";
				}
			}
			text7 = text7.Substring(0, text7.Length - 1);
			text8 = text8.Substring(0, text8.Length - 1);
			xttTree.SetParameterValue("Trial Number", text, strInitializeTestName);
			xttTree.SetParameterValue("Input Values", text7, strInitializeTestName);
			xttTree.SetParameterValue("Topologies", text8, strInitializeTestName);
			list.Add(text);
			list.Add(text7);
			list.Add(text8);
			try
			{
				xttTree.SetLoopValuesByRow("n+1 Input Trials", num2, list.ToArray(), list.Count);
			}
			catch (Exception)
			{
				return;
			}
			text2 = "";
			text7 = "";
			text8 = "";
			list.Clear();
			num += 3;
			num2++;
		}
		int loopRowCount = xttTree.GetLoopRowCount("n+1 Input Trials");
		for (int num3 = loopRowCount; num3 > Convert.ToInt16(text); num3--)
		{
			xttTree.DeleteLoopRow("n+1 Input Trials", num3);
		}
	}

	private void UpdateTopologyInfo_SementedResume(string Segment)
	{
		string text = "";
		DataGridView dgBandTrials;
		if (Segment == "Antenna")
		{
			dgBandTrials = dgAntennaGrid;
		}
		else
		{
			int length = Segment.IndexOf("PA");
			text = Segment.Substring(0, length);
			dgBandTrials = bcTrialControls[text].dgBandTrials;
			Segment = "PA";
		}
		DoUpdateLabel("Segment", Segment);
		numRefDesignators = dgBandTrials.RowCount;
		_ = dgBandTrials.Columns.Count;
		string text2 = "";
		string text3 = "";
		string text4 = "";
		string text5 = "";
		string text6 = "";
		new List<string>();
		if (numRefDesignators > 1)
		{
			for (int i = 0; i < numRefDesignators - 1; i++)
			{
				text2 = string.Concat(text2, dgBandTrials.Rows[i].Cells[0].Value, ",");
				text3 += "double,";
				text5 += "1000,";
				text4 += "-1000,";
				TrialTopology trialTopology = (TrialTopology)dgBandTrials.Rows[i].Cells[4].Value;
				text6 = ((trialTopology != 0 && trialTopology != TrialTopology.DNI) ? (text6 + "SHORT,") : (text6 + "DNI,"));
			}
			text2 = text2.Substring(0, text2.Length - 1);
			text3 = text3.Substring(0, text3.Length - 1);
			text5 = text5.Substring(0, text5.Length - 1);
			text4 = text4.Substring(0, text4.Length - 1);
			text6 = text6.Substring(0, text6.Length - 1);
			xttTree.SetParameterValue("Number of Inputs", Convert.ToString(numRefDesignators - 1), strResumeTestName);
			xttTree.SetParameterValue("Input Data Types", text3, strResumeTestName);
			xttTree.SetParameterValue("Minimum Values for Inputs", text4, strResumeTestName);
			xttTree.SetParameterValue("Maximum Values for Inputs", text5, strResumeTestName);
			xttTree.SetParameterValue("DNI or SHORT", text6, strResumeTestName);
			xttTree.SetParameterValue("Reference Designators", text2, strResumeTestName);
		}
	}

	public void DoUpdateLabel(string name, string theText)
	{
		if (DisplayGrid.InvokeRequired)
		{
			BeginInvoke((MethodInvoker)delegate
			{
				DoUpdateLabel(name, theText);
			});
			return;
		}
		if (name == "ClearStatusGrid")
		{
			DisplayGrid[5, 0].Value = "";
			DisplayGrid[6, 0].Value = "";
			DisplayGrid[7, 0].Value = "";
			DisplayGrid[8, 0].Value = "";
			DisplayGrid[9, 0].Value = "";
		}
		if (name == "ClearTopMatches")
		{
			for (int i = 1; i < 3; i++)
			{
				dgAntennaTopMatches.Rows[0].Cells[i].Value = "";
				dgAntennaTopMatches.Rows[1].Cells[i].Value = "";
				dgAntennaTopMatches.Rows[2].Cells[i].Value = "";
			}
			foreach (DataGridView value in topMatchGrids.Values)
			{
				for (int j = 1; j < 3; j++)
				{
					value.Rows[0].Cells[j].Value = "";
					value.Rows[1].Cells[j].Value = "";
					value.Rows[2].Cells[j].Value = "";
				}
			}
		}
		if (name == "Tech")
		{
			DisplayGrid[0, 0].Value = theText;
		}
		if (name == "Segment")
		{
			DisplayGrid[1, 0].Value = theText;
		}
		if (name == "Band")
		{
			DisplayGrid[2, 0].Value = theText;
		}
		if (name == "Mode")
		{
			DisplayGrid[3, 0].Value = theText;
		}
		if (name == "Trial")
		{
			DisplayGrid[4, 0].Value = theText;
		}
		if (name == "Pout")
		{
			DisplayGrid[5, 0].Value = theText;
		}
		if (name == "ACLR")
		{
			DisplayGrid[6, 0].Value = theText;
		}
		if (name == "Pout Delta")
		{
			DisplayGrid[7, 0].Value = theText;
			UpdatePoutDeltaMax(theText);
		}
		if (name == "Pin")
		{
			DisplayGrid[8, 0].Value = theText;
		}
		if (name == "Delay")
		{
			DisplayGrid[9, 0].Value = theText;
		}
	}

	private void UpdatePoutDeltaMax(string measurement)
	{
		double num = Convert.ToDouble(measurement);
		if (eMatchMode == MatchMode.ANT)
		{
			if (!string.IsNullOrEmpty(currentRunningBC))
			{
				if (!bcPoutDelta.ContainsKey(currentRunningBC))
				{
					bcPoutDelta.Add(currentRunningBC, num);
				}
				else if (num > bcPoutDelta[currentRunningBC])
				{
					UpdateWindow("Updating Pout Delta Max for band Class " + currentRunningBC);
					UpdateWindow("Current Pout Delta Max = " + bcPoutDelta[currentRunningBC]);
					UpdateWindow("Current Pout Delta Max = " + num);
					bcPoutDelta[currentRunningBC] = num;
				}
				UpdateQSPRMessagePumpLog("UpdatePoutDeltaMax for " + currentRunningBC + ".  Value = " + num, Highlight: true);
			}
			foreach (string currentCheckedBCName in currentCheckedBCNames)
			{
				if (bcPoutDelta.ContainsKey(currentCheckedBCName))
				{
					num = bcPoutDelta[currentCheckedBCName];
					if (num > dCurrentPoutDeltaMax || dCurrentPoutDeltaMax == 9999.0)
					{
						UpdateQSPRMessagePumpLog("previous PoutDeltaMax: " + dCurrentPoutDeltaMax, Highlight: false);
						dCurrentPoutDeltaMax = num;
						UpdateQSPRMessagePumpLog("new PoutDeltaMax obtained from " + currentCheckedBCName + ": = " + num, Highlight: false);
					}
				}
			}
		}
		else
		{
			dCurrentPoutDeltaMax = Convert.ToDouble(measurement);
		}
		scheduler.SetGlobalVariable("POUT_DELTA", dCurrentPoutDeltaMax.ToString());
	}

	private void UpdateBestMatches(string trialNumber, string measurement)
	{
		if (DisplayGrid.InvokeRequired)
		{
			BeginInvoke((MethodInvoker)delegate
			{
				UpdateBestMatches(trialNumber, measurement);
			});
			return;
		}
		if (Convert.ToInt16(currentTrialNum) == 1 && string.IsNullOrEmpty(measurement))
		{
			measurement = "999";
		}
		if (string.IsNullOrEmpty(measurement))
		{
			return;
		}
		double num = double.Parse(measurement);
		DataGridView dataGridView = topMatchGrids[lastRunningSegment];
		if (eMatchMode != MatchMode.ANT)
		{
			for (int i = 0; i < 3; i++)
			{
				if (dataGridView.Rows[i].Cells[1].Value == trialNumber)
				{
					return;
				}
			}
		}
		if (!topMatches.ContainsKey(lastRunningSegment))
		{
			topMatches.Add(lastRunningSegment, new double[3] { 99999.0, 99999.0, 99999.0 });
		}
		if (num < topMatches[lastRunningSegment][0])
		{
			topMatches[lastRunningSegment][2] = topMatches[lastRunningSegment][1];
			topMatches[lastRunningSegment][1] = topMatches[lastRunningSegment][0];
			topMatches[lastRunningSegment][0] = num;
			ShiftRow(1, 2, dataGridView);
			ShiftRow(0, 1, dataGridView);
			dataGridView.Rows[0].Cells[1].Value = trialNumber;
			dataGridView.Rows[0].Cells[2].Value = num;
		}
		else if (num < topMatches[lastRunningSegment][1])
		{
			topMatches[lastRunningSegment][2] = topMatches[lastRunningSegment][1];
			topMatches[lastRunningSegment][1] = num;
			ShiftRow(1, 2, dataGridView);
			dataGridView.Rows[1].Cells[1].Value = trialNumber;
			dataGridView.Rows[1].Cells[2].Value = num;
		}
		else if (num < topMatches[lastRunningSegment][2])
		{
			topMatches[lastRunningSegment][2] = num;
			dataGridView.Rows[2].Cells[1].Value = trialNumber;
			dataGridView.Rows[2].Cells[2].Value = num;
		}
	}

	private void ShiftRow(int startIndex, int endIndex, DataGridView dataGrid)
	{
		for (int i = 1; i < dataGrid.Rows[startIndex].Cells.Count; i++)
		{
			object value = dataGrid.Rows[startIndex].Cells[i].Value;
			if (value != DBNull.Value && value != null && !string.IsNullOrEmpty(value.ToString()))
			{
				double.TryParse(value.ToString(), out var result);
				dataGrid.Rows[endIndex].Cells[i].Value = result;
			}
		}
	}

	private void UpdateCurrentSetting()
	{
		if (currentSettingGridView.InvokeRequired)
		{
			BeginInvoke((MethodInvoker)delegate
			{
				UpdateCurrentSetting();
			});
			return;
		}
		if (SelectTech == "")
		{
			currentSettingGridView.Rows[0].Cells[1].Value = "None";
			currentSettingGridView.Rows[1].Cells[1].Value = "None";
		}
		else
		{
			currentSettingGridView.Rows[0].Cells[1].Value = TempFullPath;
			currentSettingGridView.Rows[1].Cells[1].Value = SelectTech;
		}
		if (FormatDescriptor == "")
		{
			currentSettingGridView.Rows[8].Cells[1].Value = "None";
		}
		else
		{
			currentSettingGridView.Rows[8].Cells[1].Value = FormatDescriptor;
		}
	}

	private void ClearStatusWindow()
	{
		if (base.InvokeRequired)
		{
			BeginInvoke((MethodInvoker)delegate
			{
				ClearStatusWindow();
			});
			return;
		}
		richTextBox1.Clear();
		for (int i = 0; i < 8; i++)
		{
			DisplayGrid[4, 0].Value = "";
		}
	}

	private void UpdateButtonStatus(eButtonState state, DataGridView dataGrid = null)
	{
		bool flag = VerifyRefDesignatorOneExists(dataGrid);
		if (dataGrid == null)
		{
			dataGrid = dgAntennaGrid;
		}
		Button btnAutoGenBandTrials = (dataGrid.Parent as TrialsControl).btnAutoGenBandTrials;
		Button btnClearBandTrials = (dataGrid.Parent as TrialsControl).btnClearBandTrials;
		switch (state)
		{
		case eButtonState.SELECT_TECH:
			btnStop.Enabled = false;
			btnStartMatch.Enabled = false;
			btnResumeMatch.Enabled = false;
			btnAutoGenBandTrials.Enabled = false;
			btnClearBandTrials.Enabled = false;
			btnEditChannels.Enabled = true;
			lvBandClasses.Enabled = true;
			btnLogPath.Enabled = true;
			labelTestStatus.Text = currentLang.GetData(10);
			labelTestStatus.ForeColor = Color.Blue;
			currentRunStatus = 10;
			break;
		case eButtonState.LOAD_PROFILE:
			btnStop.Enabled = false;
			btnStartMatch.Enabled = flag;
			btnResumeMatch.Enabled = flag && bResumeTrialsExist;
			btnAutoGenBandTrials.Enabled = flag;
			btnClearBandTrials.Enabled = flag;
			btnEditChannels.Enabled = true;
			lvBandClasses.Enabled = true;
			btnLogPath.Enabled = true;
			labelTestStatus.Text = currentLang.GetData(10);
			labelTestStatus.ForeColor = Color.Blue;
			currentRunStatus = 10;
			break;
		case eButtonState.EDIT_TRIAL:
			btnStop.Enabled = false;
			btnStartMatch.Enabled = flag;
			btnResumeMatch.Enabled = bUserScenarioLoaded;
			btnAutoGenBandTrials.Enabled = flag;
			btnClearBandTrials.Enabled = flag;
			lvBandClasses.Enabled = true;
			btnLogPath.Enabled = true;
			labelTestStatus.Text = currentLang.GetData(10);
			labelTestStatus.ForeColor = Color.Blue;
			currentRunStatus = 10;
			break;
		case eButtonState.CLEAR_TRIAL:
			btnStop.Enabled = false;
			btnStartMatch.Enabled = false;
			btnResumeMatch.Enabled = false;
			btnAutoGenBandTrials.Enabled = false;
			btnClearBandTrials.Enabled = false;
			lvBandClasses.Enabled = true;
			btnLogPath.Enabled = true;
			break;
		case eButtonState.AUTOGEN_TRIAL:
			btnStop.Enabled = false;
			btnStartMatch.Enabled = flag;
			btnResumeMatch.Enabled = bUserScenarioLoaded;
			btnAutoGenBandTrials.Enabled = true;
			btnClearBandTrials.Enabled = true;
			lvBandClasses.Enabled = true;
			btnLogPath.Enabled = true;
			break;
		case eButtonState.RUNNING:
			btnStop.Enabled = true;
			btnStartMatch.Enabled = false;
			btnResumeMatch.Enabled = false;
			btnAutoGenBandTrials.Enabled = false;
			btnClearBandTrials.Enabled = false;
			btnEditChannels.Enabled = false;
			lvBandClasses.Enabled = false;
			btnLogPath.Enabled = false;
			labelTestStatus.Text = currentLang.GetData(9);
			labelTestStatus.ForeColor = Color.Yellow;
			currentRunStatus = 9;
			break;
		case eButtonState.STOP:
			btnStop.Enabled = false;
			btnStartMatch.Enabled = flag;
			btnResumeMatch.Enabled = bUserScenarioLoaded;
			btnAutoGenBandTrials.Enabled = flag;
			btnClearBandTrials.Enabled = flag;
			btnEditChannels.Enabled = true;
			lvBandClasses.Enabled = true;
			btnLogPath.Enabled = true;
			break;
		case eButtonState.DISABLED:
			btnSelectTech.Enabled = false;
			btnLogPath.Enabled = false;
			btnStartMatch.Enabled = false;
			btnStop.Enabled = false;
			btnFormatDescriptor.Enabled = false;
			btnEditChannels.Enabled = false;
			lvBandClasses.Enabled = false;
			break;
		case eButtonState.DEFAULT:
			btnStop.Enabled = false;
			btnStartMatch.Enabled = false;
			btnResumeMatch.Enabled = false;
			btnAutoGenBandTrials.Enabled = false;
			btnClearBandTrials.Enabled = false;
			btnEditChannels.Enabled = false;
			lvBandClasses.Enabled = true;
			btnLogPath.Enabled = true;
			break;
		}
	}

	private void UpdateTextInfo()
	{
		if (base.InvokeRequired)
		{
			BeginInvoke(new UpdateTextInfo_Delegate(UpdateTextInfo), new object[0]);
			return;
		}
		if (currentLang.CurrentLanguage == LanguageDetails.Language.ENGLISH)
		{
			currentLang.CurrentLanguage = LanguageDetails.Language.CHINESE;
			btnSwitchLang.Text = "English";
		}
		else
		{
			currentLang.CurrentLanguage = LanguageDetails.Language.ENGLISH;
			btnSwitchLang.Text = "中国";
		}
		InitButtonText();
	}

	private void btnSwitchLang_Click(object sender, EventArgs e)
	{
		UpdateTextInfo();
	}

	private void InitButtonText()
	{
		btnStartMatch.Text = currentLang.GetData(1);
		btnStop.Text = currentLang.GetData(2);
		btnResumeMatch.Text = currentLang.GetData(3);
		labelTestStatus.Text = currentLang.GetData(currentRunStatus);
	}

	private void tsmFileOpen_Click(object sender, EventArgs e)
	{
		OpenFileDialog openFileDialog = new OpenFileDialog();
		openFileDialog.Filter = "Xml Files | *.xml";
		openFileDialog.DefaultExt = "xml";
		if (openFileDialog.ShowDialog() != DialogResult.OK)
		{
			return;
		}
		EnableTopologyGrids(enable: true);
		comboBC_Active = false;
		ScenarioFilePathName = openFileDialog.FileName;
		SmartMatchConfig smartMatchConfig = new SmartMatchConfig();
		smartMatchConfig.LoadData(openFileDialog.FileName);
		antennaTrialData = new TrialDataConverter(smartMatchConfig.TrialData);
		tableLayoutPanel1.Controls.Clear();
		tableLayoutPanel1.RowCount = 0;
		tableLayoutPanel1.RowStyles.Clear();
		bcTrialControls.Clear();
		bandClassTrialDataItems.Clear();
		foreach (TrialData bandClassTrial in smartMatchConfig.BandClassTrials)
		{
			bandClassTrialDataItems.Add(bandClassTrial.Name, new TrialDataConverter(bandClassTrial));
		}
		if (smartMatchConfig.CustomKitValues.Count > 0)
		{
			customKitValues.Clear();
			foreach (KitValues customKitValue in smartMatchConfig.CustomKitValues)
			{
				customKitValues.Add(customKitValue.RefDesignator, new KitValuesConverter(customKitValue.RefDesignator, customKitValue));
			}
			GenerateKitFiles();
		}
		else
		{
			customKitValues.Clear();
			GetStandardComponentValues();
		}
		if (!ReloadUI(smartMatchConfig.ScenarioData))
		{
			DebugMessage("Error", "Failure occurred loading Scenario", 1, NoEndOfLine: true);
			return;
		}
		comboBC_Active = true;
		bResumeTrialsExist = true;
		UpdateBandClassListView(getTreeParamValues: false);
		UpdateButtonStatus(eButtonState.LOAD_PROFILE);
		DoUpdateLabel("Tech", SelectTech);
		bUserScenarioLoaded = true;
		tsmFileSave.Enabled = true;
		UpdateScenarioModifiedStatus(modified: false);
	}

	private void tsmFileSave_Click(object sender, EventArgs e)
	{
		SaveScenarioData(bSaveAs: false);
	}

	private void tsmFileSaveAs_Click(object sender, EventArgs e)
	{
		SaveScenarioData(bSaveAs: true);
	}

	private void SaveScenarioData(bool bSaveAs)
	{
		CommitGridChanges();
		if (lvBandClasses.CheckedItems.Count < 1)
		{
			MessageBox.Show("At least 1 band class must be selected before saving.", "No band class selected");
			return;
		}
		List<string> missingTrialNames = new List<string>();
		if (TrialDataIsMissing(out missingTrialNames))
		{
			string text = "All topology grids must contain at least one reference designator before saving." + Environment.NewLine + Environment.NewLine + "The following band class trial grids have no reference designators: ";
			foreach (string item in missingTrialNames)
			{
				text = text + item + ", ";
			}
			if (text.EndsWith(", "))
			{
				text = text.Substring(0, text.Length - 2);
			}
			MessageBox.Show(text, "Empty trial data");
			return;
		}
		List<string> invalidTrialNames = new List<string>();
		if (!TrialDataIsValid(out invalidTrialNames))
		{
			if (MessageBox.Show("You must fill in all (N + 1) trial data columns." + Environment.NewLine + "Would you like to Auto-generate the missing values before saving?", "Invalid trial data", MessageBoxButtons.YesNo) != DialogResult.Yes)
			{
				return;
			}
			foreach (string item2 in invalidTrialNames)
			{
				DataGridView dgBandTrials = dgAntennaGrid;
				if (!string.IsNullOrEmpty(item2))
				{
					dgBandTrials = bcTrialControls[item2].dgBandTrials;
				}
				AutoGenTrials(dgBandTrials, item2);
			}
		}
		if (bSaveAs)
		{
			SaveFileDialog saveFileDialog = new SaveFileDialog();
			saveFileDialog.Filter = "Xml Files | *.xml";
			saveFileDialog.DefaultExt = "xml";
			saveFileDialog.AddExtension = true;
			if (saveFileDialog.ShowDialog() != DialogResult.OK)
			{
				return;
			}
			ScenarioFilePathName = saveFileDialog.FileName;
		}
		SmartMatchConfig smartMatchConfig = new SmartMatchConfig();
		smartMatchConfig.TrialData = antennaTrialData.TrialData;
		smartMatchConfig.BandClassTrials = (from t in bandClassTrialDataItems
			orderby t.Key
			select t.Value.TrialData).ToList();
		smartMatchConfig.CustomKitValues = (from t in customKitValues
			orderby t.Key
			select t.Value.KitValues).ToList();
		smartMatchConfig.ScenarioData = GetScenarioData();
		smartMatchConfig.SaveData(ScenarioFilePathName);
		tsmFileSave.Enabled = true;
		UpdateScenarioModifiedStatus(modified: false);
	}

	private void tsmFileExit_Click(object sender, EventArgs e)
	{
		SmartMatchGUI_FormClosing(null, null);
		Dispose();
	}

	private bool ReloadUI(UserScenarioData scenarioData)
	{
		RemoveBCTrialGrid(antennaTrialControl);
		LoadDataGrid();
		AddBCTrialGrid(antennaTrialControl);
		List<string> list = (from t in bandClassTrialDataItems
			orderby t.Key
			select t.Key).ToList();
		foreach (string item in list)
		{
			if (bcTrialControls.ContainsKey(item))
			{
				DataGridView dgBandTrials = bcTrialControls[item].dgBandTrials;
				LoadDataGrid(dgBandTrials, item);
			}
		}
		try
		{
			LoadScenarioData(scenarioData);
		}
		catch (Exception ex)
		{
			DebugMessage("Error", ex.Message, 1, NoEndOfLine: false);
			return false;
		}
		return true;
	}

	private void LoadScenarioData(UserScenarioData scenarioData)
	{
		if (File.Exists(scenarioData.StrTreepath))
		{
			OpenTree(scenarioData.StrTreepath);
			MasterXttFullPath = scenarioData.StrTreepath;
			string fileName = Path.GetFileName(scenarioData.StrTreepath);
			TempFullPath = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\" + fileName;
			SelectTech = scenarioData.StrTech;
			LogPath = scenarioData.StrLogPath;
			ignoreBandClassChanges = true;
			lvBandClasses.Items.Clear();
			new ListViewItem();
			int num = 0;
			string[] strArrayBandClass = scenarioData.StrArrayBandClass;
			foreach (string text in strArrayBandClass)
			{
				if (text != null)
				{
					lvBandClasses.Items.Add(text);
					if (scenarioData.CheckedBandClasses.Contains(text))
					{
						lvBandClasses.Items[num].Checked = true;
						currentCheckedBCNames.Add(text);
					}
					num++;
				}
			}
			ignoreBandClassChanges = false;
			tbPAParamsFile.Text = scenarioData.StrPAParamsFile;
			tbPinPoutMax.Text = scenarioData.StrPinMax;
			tbPoutMaxBias.Text = scenarioData.StrPoutMaxBias;
			strPoutMaxBias = tbPoutMaxBias.Text;
			tbDelayStart.Text = scenarioData.StrACLRDelayStart;
			tbDelayStop.Text = scenarioData.StrACLRDelayStop;
			tbDelayStep.Text = scenarioData.StrACLRDelayStep;
			strDelayValParams10MHzStart = tbDelayStart.Text;
			strDelayValParams10MHzStop = tbDelayStop.Text;
			strDelayValParams10MHzStep = tbDelayStep.Text;
			strDelayValParams10MHz = "SSS(" + strDelayValParams10MHzStart + "," + strDelayValParams10MHzStop + "," + strDelayValParams10MHzStep + ")";
			tbRGIStart.Text = scenarioData.StrRGIStart;
			tbRGIStop.Text = scenarioData.StrRGIStop;
			tbRGIStep.Text = scenarioData.StrRGIStep;
			strRGIStart = tbRGIStart.Text;
			strRGIStop = tbRGIStop.Text;
			strRGIStep = tbRGIStep.Text;
			strRgiParams = "SSS(" + strRGIStart + "," + strRGIStop + "," + strRGIStep + ")";
			cbPAGain.Text = scenarioData.StrPAGainState;
			tbChannelStart.Text = scenarioData.StrChannelStart;
			tbChannelStop.Text = scenarioData.StrChannelStop;
			tbChannelRef.Text = scenarioData.StrChannelRef;
			if (scenarioData.StrXptAction == "EPT")
			{
				SetXPTActionState(XPTAction.EPT);
			}
			else
			{
				SetXPTActionState(XPTAction.ET);
			}
			measurementSelection.StrMeasureTypes = scenarioData.StrMeasureTypes;
			measurementSelection.StrMeasureConstraints = scenarioData.StrMeasureConstraints;
			measurementSelection.StrMeasureTargets = scenarioData.StrMeasureTargets;
			scenarioData.MeasureTypeEnable.CopyTo(measurementSelection.MeasureCheckBoxes, 0);
			measurementSelection.ConfigureMeasurementTypes(LoadingScenario: true);
			string paramValue = "";
			xttTree.GetParameterValue(strInitializeTestName, "Measurement Targets", out paramValue);
			measurementSelection.StrDefaultMeasureTargets = paramValue;
			measurementSelection.ConfigureDefaultMeasurementTargets();
			cbRBs.Text = scenarioData.StrRBs;
			if (cbRBs.Text == "6 Rbs")
			{
				strRBs = "0";
			}
			else if (cbRBs.Text == "12 Rbs")
			{
				strRBs = "1";
			}
			else
			{
				strRBs = "2";
			}
			UpdateDefaultBandClassChannels();
			UpdateUserSelectedChannelsFromScenario(scenarioData);
			return;
		}
		throw new NullReferenceException("Cannot find XTT: " + scenarioData.StrTreepath);
	}

	private UserScenarioData GetScenarioData()
	{
		UserScenarioData userScenarioData = new UserScenarioData();
		userScenarioData.StrTreepath = MasterXttFullPath;
		userScenarioData.StrTech = SelectTech;
		userScenarioData.StrLogPath = LogPath;
		if (lvBandClasses.Items.Count > 0)
		{
			for (int i = 0; i < lvBandClasses.Items.Count; i++)
			{
				userScenarioData.StrArrayBandClass[i] = lvBandClasses.Items[i].Text;
				userScenarioData.CheckedBandClasses = currentCheckedBCNames;
			}
		}
		userScenarioData.StrPAParamsFile = tbPAParamsFile.Text;
		userScenarioData.StrPinMax = tbPinPoutMax.Text;
		userScenarioData.StrPoutMaxBias = tbPoutMaxBias.Text;
		userScenarioData.StrACLRDelayStart = tbDelayStart.Text;
		userScenarioData.StrACLRDelayStop = tbDelayStop.Text;
		userScenarioData.StrACLRDelayStep = tbDelayStep.Text;
		userScenarioData.StrRGIStart = tbRGIStart.Text;
		userScenarioData.StrRGIStep = tbRGIStep.Text;
		userScenarioData.StrRGIStop = tbRGIStop.Text;
		userScenarioData.StrPAGainState = cbPAGain.Text;
		userScenarioData.StrChannelStart = tbChannelStart.Text;
		userScenarioData.StrChannelStop = tbChannelStop.Text;
		userScenarioData.StrChannelRef = tbChannelRef.Text;
		userScenarioData.StrRBs = cbRBs.Text;
		userScenarioData.StrMeasureTypes = measurementSelection.StrMeasureTypes;
		userScenarioData.StrMeasureConstraints = measurementSelection.StrMeasureConstraints;
		userScenarioData.StrMeasureTargets = measurementSelection.StrMeasureTargets;
		measurementSelection.MeasureCheckBoxes.CopyTo(userScenarioData.MeasureTypeEnable, 0);
		if (eXptAction == XPTAction.ET)
		{
			userScenarioData.StrXptAction = "ET";
		}
		else
		{
			userScenarioData.StrXptAction = "EPT";
		}
		UpdateScenarioChannelsFromUserSelection(userScenarioData);
		return userScenarioData;
	}

	private void CommitGridChanges(DataGridView dataGrid = null)
	{
		if (dataGrid == null)
		{
			dataGrid = dgAntennaGrid;
		}
		if (dataGrid.CurrentCell != null)
		{
			int rowIndex = dataGrid.CurrentCell.RowIndex;
			int columnIndex = dataGrid.CurrentCell.ColumnIndex;
			dataGrid.CurrentCell = null;
			dataGrid.CurrentCell = dataGrid.Rows[rowIndex].Cells[columnIndex];
			dataGrid.EndEdit();
		}
	}

	private void btnStartMatch_Click(object sender, EventArgs e)
	{
		isResumeTrial = false;
		scheduler.SetGlobalVariable(ResumeModeGV, "0");
		StartTrialRunDialog startTrialRunDialog = new StartTrialRunDialog(currentCheckedBCNames);
		startTrialRunDialog.StartPosition = FormStartPosition.CenterParent;
		if (startTrialRunDialog.ShowDialog() != DialogResult.OK)
		{
			return;
		}
		bAntennaSegmentRun = startTrialRunDialog.antennaSegmentedRun;
		DoUpdateLabel("ClearTopMatches", "");
		if (startTrialRunDialog.SegmentedRun)
		{
			List<string> list = new List<string>();
			if (startTrialRunDialog.antennaSegmentedRun)
			{
				list.Add("Antenna");
			}
			list.AddRange(startTrialRunDialog.SelectedBandClasses);
			List<string> missingTrialNames = new List<string>();
			List<string> invalidTrialNames = new List<string>();
			if (TrialDataIsMissing(out missingTrialNames))
			{
				if (missingTrialNames.Contains(null))
				{
					missingTrialNames.Remove(null);
					missingTrialNames.Insert(0, "Antenna");
				}
				foreach (string item in missingTrialNames.ToList())
				{
					if (!list.Contains(item))
					{
						missingTrialNames.Remove(item);
					}
				}
				if (missingTrialNames.Count > 0)
				{
					string text = "The following trial grids are missing data:" + Environment.NewLine;
					foreach (string item2 in missingTrialNames)
					{
						text = ((!(item2 != "Antenna")) ? (text + item2 + " ") : (text + item2 + " PA "));
					}
					text = text + Environment.NewLine + "Please enter N + 1 trial data and try again.";
					MessageBox.Show(text);
					return;
				}
			}
			if (!TrialDataIsValid(out invalidTrialNames))
			{
				if (invalidTrialNames.Contains(null))
				{
					invalidTrialNames.Remove(null);
					invalidTrialNames.Insert(0, "Antenna");
				}
				foreach (string item3 in invalidTrialNames.ToList())
				{
					if (!list.Contains(item3))
					{
						invalidTrialNames.Remove(item3);
					}
				}
				if (invalidTrialNames.Count > 0)
				{
					string text2 = "The following trial grids have incomplete data:" + Environment.NewLine;
					foreach (string item4 in invalidTrialNames)
					{
						text2 = ((!(item4 != "Antenna")) ? (text2 + item4 + " ") : (text2 + item4 + " PA "));
					}
					text2 = text2 + Environment.NewLine + "Please fill in N + 1 trial data or press AutoGenerate and try again.";
					MessageBox.Show(text2);
					return;
				}
			}
		}
		StartMatch(startTrialRunDialog.SelectedBandClasses, startTrialRunDialog.SegmentedRun);
	}

	private void btnStop_Click(object sender, EventArgs e)
	{
		xttTree.StopTest();
		btnStop.Enabled = false;
		bStopButtonPushed = true;
		while (!bTreeCompleted)
		{
			Application.DoEvents();
			Thread.Sleep(100);
		}
		UpdateButtonStatus(eButtonState.EDIT_TRIAL);
	}

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

	private void btnSave_Click(object sender, EventArgs e)
	{
		try
		{
			SaveFileDialog saveFileDialog = new SaveFileDialog();
			saveFileDialog.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*";
			saveFileDialog.FilterIndex = 1;
			saveFileDialog.Title = "Qmatch Config File";
			saveFileDialog.ShowDialog();
			_ = 1;
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void btnResumeMatch_Click(object sender, EventArgs e)
	{
		isResumeTrial = true;
		scheduler.SetGlobalVariable(ResumeModeGV, "1");
		currentSegment = "Antenna";
		resumeSegmentNames = GetResumeSegemntDirectoryNames();
		if (resumeSegmentNames.Count == 0)
		{
			MessageBox.Show("Unable to find Resume Folders.  Resume option will be disabled. ", measurementResumeFolder);
			bResumeTrialsExist = false;
			UpdateButtonStatus(eButtonState.LOAD_PROFILE);
			return;
		}
		bResumeTrialsExist = true;
		for (int i = 0; i < resumeSegmentNames.Count; i++)
		{
			resumeSegmentNames[i] = resumeSegmentNames[i].Substring(resumeSegmentNames[i].LastIndexOf("\\") + 1);
		}
		SelectSegmentResumeDialog selectSegmentResumeDialog = new SelectSegmentResumeDialog(resumeSegmentNames);
		if (selectSegmentResumeDialog.ShowDialog() != DialogResult.OK)
		{
			return;
		}
		DoUpdateLabel("ClearTopMatches", "");
		resumeSegmentBC = selectSegmentResumeDialog.SelectedResumeMatchMode;
		if (!MoveMeasurementDataToRestore(resumeSegmentBC))
		{
			return;
		}
		if (resumeSegmentBC != "Antenna")
		{
			currentSegment = "PA";
			bAntennaSegmentRun = false;
			List<string> list = currentCheckedBCNames.ToList();
			foreach (string item in list)
			{
				if (!resumeSegmentBC.Contains(item))
				{
					currentCheckedBCNames.Remove(item);
					continue;
				}
				break;
			}
		}
		UpdateTempLimitDescriptor();
		scheduler.SetGlobalVariable(LimitDescriptorGV, tempLimitDescriptorName);
		int count = currentCheckedBCNames.Count;
		scheduler.SetGlobalVariable(NumBandsGV, count.ToString());
		ClearStatusWindow();
		UpdateTopologyInfo_SementedResume(selectSegmentResumeDialog.SelectedResumeMatchMode);
		UpdateButtonStatus(eButtonState.RUNNING);
		xttTree.RunTest(strResumeTestName);
	}

	private void btnLogPath_Click(object sender, EventArgs e)
	{
		LogPathInfo logPathInfo = null;
		try
		{
			logPathInfo = new LogPathInfo(LogPath);
			if (!logPathInfo.Disposing && !logPathInfo.IsDisposed)
			{
				DialogResult dialogResult = logPathInfo.ShowDialog();
				if (dialogResult == DialogResult.OK && logPathInfo.LogPath != "")
				{
					LogPath = logPathInfo.LogPath;
				}
			}
			UpdateScenarioModifiedStatus(modified: true);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private bool StartMatch(List<string> selectedBandClasses, bool segmentedRun)
	{
		bool flag = false;
		bStopButtonPushed = false;
		if (base.InvokeRequired)
		{
			BeginInvoke((MethodInvoker)delegate
			{
				StartMatch(selectedBandClasses, segmentedRun);
			});
			return true;
		}
		foreach (string selectedBandClass in selectedBandClasses)
		{
			if (bcTrialControls[selectedBandClass].dgBandTrials.Rows[0].Cells[0].Value == DBNull.Value)
			{
				MessageBox.Show("Topology components must be filled in for BC " + selectedBandClass + "before starting matching process", "Missing Topolgy Warning", MessageBoxButtons.OK);
				return false;
			}
			lastSegmentBC = selectedBandClass;
		}
		string Channels = "";
		for (int i = 0; i < lvBandClasses.Items.Count; i++)
		{
			xttTree.SelectTestFromFolderToRun("Smart QMatch", "QMatchTool_LTE_" + lvBandClasses.Items[i].Text, selectedToRun: false);
		}
		string text = tbPAParamsFile.Text;
		if (File.Exists(text))
		{
			File.Copy(text, tempMaxBias_PAFile, overwrite: true);
		}
		if (segmentedRun)
		{
			failedPoutBCNames.Clear();
			bMaxTrialsExceeded = false;
			bPoutDeltaSatisfied = false;
			bMeasTargetsSatisfied = false;
			bool selectedToRun = true;
			dCurrentPoutDeltaMax = 9999.0;
			dCurrentPout = 0.0;
			currentRunningBC = "";
			lastRunningBC = "";
			currentRunningTest = "";
			ClearMeasurementData();
			DoUpdateLabel("ClearStatusGrid", "");
			xttTree.SetParameterValue("Min Frequency of Interest", tbChannelStart.Text, strInitializeTestName);
			xttTree.SetParameterValue("Max Frequency of Interest", tbChannelStop.Text, strInitializeTestName);
			xttTree.SetParameterValue("Reference Frequency", tbChannelRef.Text, strInitializeTestName);
			xttTree.SetParameterValue("RF Cal Input Data File", tbPAParamsFile.Text, "InitPAParamsFile");
			xttTree.SetParameterValue("RF Cal Input Data File", tbPAParamsFile.Text, "ReadPAParamsFile");
			xttTree.SetParameterValue("File Path Name", LogPath, "RFCal_QDART_FinalizeDataLogging");
			xttTree.SetParameterValue("Use Fixed LogFile Path Name", "1", "RFCal_QDART_FinalizeDataLogging");
			DataGridView dg = dgAntennaGrid;
			if (bAntennaSegmentRun)
			{
				currentSegment = "Antenna";
				UpdateTopologyInfo(dg);
				eMatchMode = MatchMode.ANT;
				scheduler.SetGlobalVariable("MATCH_MODE", "ANT");
				DoUpdateLabel("Segment", "Antenna");
				UpdateMeasurementParams();
				dPoutDeltaMax = Convert.ToDouble(measurementSelection.strPoutDeltaMeasureTarget);
				scheduler.SetGlobalVariable("POUT_LIMIT", measurementSelection.strPoutDeltaMeasureTarget);
				bcPoutDelta.Clear();
				scheduler.SetGlobalVariable("POUT_DELTA", dCurrentPoutDeltaMax.ToString());
				string text2 = "";
				int num = 1;
				foreach (string currentCheckedBCName in currentCheckedBCNames)
				{
					UpdateXTTBCInfo(currentCheckedBCName, num);
					text2 = text2 + currentCheckedBCName + "/";
					num++;
					GetUserSelectedBandClassChannels(currentCheckedBCName, out Channels);
					xttTree.SetParameterValue("Channel List", Channels, "QMatchTool_LTE_" + currentCheckedBCName);
					if (string.IsNullOrEmpty(lastRunningBC))
					{
						lastRunningBC = currentCheckedBCName;
					}
				}
				int count = currentCheckedBCNames.Count;
				scheduler.SetGlobalVariable(NumBandsGV, count.ToString());
				scheduler.SetGlobalVariable("POUT_DELTA", "9999");
				if (text2 != "")
				{
					text2 = text2.Substring(0, text2.Length - 1);
				}
				DoUpdateLabel("Band", text2);
				ConfigureScheduler();
				flag = RunTreeAndWaitForFinish();
				selectedToRun = false;
				scheduler.GetGlobalVariable("SN", out sUnitSN);
				MoveMeasurementDataToBackup(clear: true);
				if (!flag && !bMaxTrialsExceeded && bStopButtonPushed)
				{
					return false;
				}
				if (selectedBandClasses.Count == 0)
				{
					bStopButtonPushed = true;
					OnUnitStop(status: true);
				}
			}
			for (int j = 0; j < lvBandClasses.Items.Count; j++)
			{
				xttTree.SelectTestFromFolderToRun("Smart QMatch", "QMatchTool_LTE_" + lvBandClasses.Items[j].Text, selectedToRun: false);
			}
			eMatchMode = MatchMode.BC;
			scheduler.SetGlobalVariable("MATCH_MODE", "PA");
			UpdateMeasurementParams();
			DoUpdateLabel("ClearStatusGrid", "");
			DoUpdateLabel("Segment", "PA");
			int loopRowCount = xttTree.GetLoopRowCount("Pout MaxBias");
			for (int k = 1; k < loopRowCount; k++)
			{
				xttTree.DeleteLoopRow("Pout MaxBias", k);
			}
			foreach (string selectedBandClass2 in selectedBandClasses)
			{
				dg = bcTrialControls[selectedBandClass2].dgBandTrials;
				UpdateTopologyInfo(dg);
				UpdateXTTBCInfo(selectedBandClass2, 1);
				ConfigureScheduler();
				scheduler.SetGlobalVariable(NumBandsGV, "1");
				DoUpdateLabel("Band", selectedBandClass2);
				currentRunningBC = selectedBandClass2;
				currentSegment = "PA_" + selectedBandClass2;
				CreateTopMatchTab(currentSegment);
				string Channels2 = "";
				GetUserSelectedBandClassChannels(selectedBandClass2, out Channels2);
				xttTree.SetParameterValue("Channel List", Channels2, "QMatchTool_LTE_" + selectedBandClass2);
				xttTree.SelectTestFromFolderToRun("Smart QMatch", "RFCal_GetUUTID", selectedToRun);
				flag = RunTreeAndWaitForFinish();
				MoveMeasurementDataToBackup(clear: true);
				if (!flag)
				{
					bStopButtonPushed = true;
					return false;
				}
				DoUpdateLabel("ClearStatusGrid", "");
				xttTree.SelectTestFromFolderToRun("Smart QMatch", "QMatchTool_LTE_" + selectedBandClass2, selectedToRun: false);
				selectedToRun = false;
			}
		}
		else
		{
			CombinedDataGrid = MergeDataGridInfo(selectedBandClasses);
			UpdateTopologyInfo(CombinedDataGrid);
			UpdateSmartMatchParams_MultipleBCs();
			ConfigureScheduler();
			int count2 = selectedBandClasses.Count;
			scheduler.SetGlobalVariable(NumBandsGV, count2.ToString());
			xttTree.RunTree();
		}
		return true;
	}

	private bool RunTreeAndWaitForFinish()
	{
		try
		{
			bTreeCompleted = false;
			xttTree.RunTree();
			while (!bTreeCompleted)
			{
				Application.DoEvents();
				Thread.Sleep(100);
			}
			return bTreePassed;
		}
		catch (Exception ex)
		{
			MessageBox.Show("Exception: " + ex.Message);
			return false;
		}
	}

	private bool ConfigureScheduler()
	{
		bool result = true;
		if (measurementSelection.MeasureCheckBoxes[Convert.ToInt16(MeasurementSelection.eCheckBoxes.POUT_DELTA)])
		{
			xttTree.SelectTestFromFolderToRun("Smart QMatch", "Pout MaxBias");
			xttTree.SetParameterValue("RF Cal Input Data File", tempMaxBias_PAFile, "MaxBias_PAParamsFile");
			xttTree.SetParameterValue("RGI List", strRgiParams, "QMatchTool_LTE_Bx");
			xttTree.SetParameterValue("PA State", strPAState, "QMatchTool_LTE_Bx");
			xttTree.SetParameterValue("LTE Params for RGI Determination and Freq Comp Sweeps", strRBs, "QMatchTool_LTE_Bx");
			xttTree.SetParameterValue("ACLR Delay Char params:List of Default Delay Values", strDelayValParams10MHz, "QMatchTool_LTE_Bx");
			int num = Convert.ToInt16(eXptAction);
			xttTree.SetParameterValue("XPT Action Type", num.ToString(), "QMatchTool_LTE_Bx");
			int num2 = Convert.ToInt16(eDelayMode);
			xttTree.SetParameterValue("Delay Char Technique Type", num2.ToString(), "QMatchTool_LTE_Bx");
			int num3 = Convert.ToInt16(eMeasMode);
			xttTree.SetParameterValue("Enable AMAM Based Pin Pout Char?", num3.ToString(), "QMatchTool_LTE_Bx");
		}
		SaveTree(TempFullPath);
		UpdateTempLimitDescriptor();
		scheduler.SetGlobalVariable(LimitDescriptorGV, tempLimitDescriptorName);
		ClearStatusWindow();
		richTextBox2.Clear();
		UpdateButtonStatus(eButtonState.RUNNING);
		return result;
	}

	private void OnUnitStop(bool status)
	{
		if (base.InvokeRequired)
		{
			BeginInvoke((MethodInvoker)delegate
			{
				OnUnitStop(status);
			});
			return;
		}
		string text = DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss");
		xttTree.GetParameterValue("RFCal_GetUUTID", "UUT ID", out sUnitSN);
		scheduler.GetGlobalVariable("SN", out sUnitSN);
		if (!Directory.Exists(LogPath))
		{
			Directory.CreateDirectory(LogPath);
		}
		richTextBox1.SaveFile(LogPath + "\\" + sUnitSN + "_DebugWindow_" + text + ".txt");
		richTextBox2.SaveFile(LogPath + "\\QSPR Message Pump" + text + ".txt");
		if ((eLastMatchMode != MatchMode.ANT || bStopButtonPushed) && (eMatchMode != MatchMode.BC || !(lastRunningBC != lastSegmentBC) || bStopButtonPushed))
		{
			if (status)
			{
				labelTestStatus.ForeColor = Color.Green;
				labelTestStatus.Text = currentLang.GetData(4);
			}
			else
			{
				labelTestStatus.ForeColor = Color.Red;
				labelTestStatus.Text = currentLang.GetData(5);
			}
			UpdateButtonStatus(eButtonState.STOP);
		}
	}

	private void lvBandClasses_ItemChecked(object sender, ItemCheckedEventArgs e)
	{
		try
		{
			UpdateBandClassListView(getTreeParamValues: true);
			UpdateBandTrialControls(e);
			if (!ignoreBandClassChanges)
			{
				UpdateBandClassChannelLists();
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void UpdateBandClassChannelLists()
	{
		List<string> list = new List<string>();
		foreach (ListViewItem checkedItem in lvBandClasses.CheckedItems)
		{
			list.Add(checkedItem.Text);
		}
		foreach (string item in list)
		{
			if (!defaultBandClassChannels.ContainsKey(item))
			{
				UpdateDefaultBandClassChannels(new List<string> { item });
			}
		}
		List<string> list2 = userSelectedChannels.Keys.ToList();
		foreach (string item2 in list2)
		{
			if (!list.Contains(item2))
			{
				userSelectedChannels.Remove(item2);
			}
		}
		foreach (string item3 in list)
		{
			if (!userSelectedChannels.ContainsKey(item3))
			{
				userSelectedChannels.Add(item3, defaultBandClassChannels[item3].Clone() as string[]);
			}
		}
	}

	private void UpdateBandClassListView(bool getTreeParamValues)
	{
		if (!comboBC_Active)
		{
			return;
		}
		string text = "";
		ListView.CheckedListViewItemCollection checkedItems = lvBandClasses.CheckedItems;
		if (checkedItems.Count > 2)
		{
			MessageBox.Show("You have more than two Band Classes Selected.", "Num BCs Warning", MessageBoxButtons.OK);
			bool flag = false;
			{
				foreach (ListViewItem item in checkedItems)
				{
					if (!currentCheckedBCNames.Contains(item.Text))
					{
						item.Checked = false;
					}
				}
				return;
			}
		}
		currentCheckedBCNames.Clear();
		foreach (ListViewItem item2 in checkedItems)
		{
			currentCheckedBCNames.Add(item2.Text);
			text = text + item2.Text + "/";
		}
		if (text != "")
		{
			text = text.Substring(0, text.Length - 1);
		}
		DoUpdateLabel("Band", text);
		if (currentCheckedBCNames.Count > 0)
		{
			_ = currentCheckedBCNames[0];
		}
		else
		{
			currentCheckedBCNames.Add("B1");
		}
		string testName = "QMatchTool_LTE_" + currentCheckedBCNames[0];
		if (getTreeParamValues)
		{
			strDelayValParams5MHz = GetParameter(testName, "ACLR Delay Char params:List of Delay Values for LTE 5MHz");
			strDelayValParams10MHz = GetParameter(testName, "ACLR Delay Char params:List of Default Delay Values");
			if (strDelayValParams10MHz == "")
			{
				strDelayValParams10MHz = "SSS(400,1200,100)";
			}
			strDelayValParams15MHz = GetParameter(testName, "ACLR Delay Char params:List of Delay Values for LTE15 MHz");
			strDelayValParams20MHz = GetParameter(testName, "ACLR Delay Char params:List of Delay Values for LTE 20MHz");
			strChListParams = GetParameter(testName, "Channel List");
			string parameter = GetParameter(testName, "XPT Action Type");
			if (parameter == "1")
			{
				eXptAction = XPTAction.EPT;
			}
			else
			{
				eXptAction = XPTAction.ET;
			}
			strDelayType = GetParameter(testName, "Delay Char Technique Type");
			if (strDelayType == "1")
			{
				eDelayMode = DelayMode.FW_BASED;
			}
			else
			{
				eDelayMode = DelayMode.ACLR_BASED;
			}
			strAMAMbasedPinPout = GetParameter(testName, "Enable AMAM Based Pin Pout Char?");
			if (strAMAMbasedPinPout == "1")
			{
				eMeasMode = MeasMode.AMAM_BASED;
			}
			else
			{
				eMeasMode = MeasMode.ACLR_BASED;
			}
			strRgiParams = GetParameter(testName, "RGI List");
			strPAState = GetParameter(testName, "PA State");
			strRBs = GetParameter(testName, "LTE Params for RGI Determination and Freq Comp Sweeps");
			strPinMax = GetParameter(testName, "Max Allowed Pin Variation Across The Band");
			strBandChannels = GetParameter(testName, "Channel List");
		}
		UpdateQMatchGUI();
		if (bAutoGenPerformed)
		{
			CalculateTrialAValues_Course();
		}
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void UpdateBandTrialControls(ItemCheckedEventArgs e)
	{
		if (e.Item.Checked)
		{
			if (bcTrialControls.ContainsKey(e.Item.Text))
			{
				AddBCTrialGrid(bcTrialControls[e.Item.Text]);
				return;
			}
			if (!bandClassTrialDataItems.ContainsKey(e.Item.Text))
			{
				TrialDataConverter trialDataConverter = new TrialDataConverter(e.Item.Text);
				trialDataConverter.LoadDefaultData(e.Item.Text);
				bandClassTrialDataItems.Add(e.Item.Text, trialDataConverter);
			}
			TrialsControl trialsControl = new TrialsControl(e.Item.Text);
			trialsControl.dgBandTrials.CurrentCellDirtyStateChanged += dataGrid_CurrentCellDirtyStateChanged;
			trialsControl.dgBandTrials.CellValueChanged += dataGrid_CellValueChanged;
			trialsControl.dgBandTrials.CellBeginEdit += dataGrid_CellBeginEdit;
			trialsControl.dgBandTrials.DataError += dataGrid_DataError;
			trialsControl.dgBandTrials.UserAddedRow += dataGrid_UserAddedRow;
			trialsControl.dgBandTrials.UserDeletedRow += dataGrid_UserDeletedRow;
			trialsControl.btnAutoGenBandTrials.Click += btnAutoGenTrials_Click;
			trialsControl.btnClearBandTrials.Click += btnClearTrialData_Click;
			bcTrialControls.Add(e.Item.Text, trialsControl);
			LoadDataGrid(trialsControl.dgBandTrials, e.Item.Text);
			AddBCTrialGrid(trialsControl);
		}
		else if (bcTrialControls.ContainsKey(e.Item.Text))
		{
			RemoveBCTrialGrid(bcTrialControls[e.Item.Text]);
		}
	}

	private void AddBCTrialGrid(TrialsControl bcTrialControl)
	{
		if (tableLayoutPanel1.Controls.Contains(bcTrialControl))
		{
			return;
		}
		SuspendLayout();
		tableLayoutPanel1.Controls.Add(bcTrialControl, 0, tableLayoutPanel1.RowCount);
		tableLayoutPanel1.RowCount++;
		tableLayoutPanel1.RowStyles.Add(new RowStyle());
		bcTrialControl.Dock = DockStyle.Fill;
		foreach (RowStyle item in (IEnumerable)tableLayoutPanel1.RowStyles)
		{
			item.SizeType = SizeType.Percent;
			item.Height = 100f / (float)tableLayoutPanel1.RowCount;
		}
		bcTrialControl.Height = 0;
		ResumeLayout();
	}

	private void RemoveBCTrialGrid(TrialsControl bcTrialControl)
	{
		if (!tableLayoutPanel1.Controls.Contains(bcTrialControl))
		{
			return;
		}
		SuspendLayout();
		int row = tableLayoutPanel1.GetRow(bcTrialControl);
		tableLayoutPanel1.Controls.Remove(bcTrialControl);
		for (int i = row + 1; i < tableLayoutPanel1.RowCount; i++)
		{
			for (int j = 0; j < tableLayoutPanel1.ColumnCount; j++)
			{
				Control controlFromPosition = tableLayoutPanel1.GetControlFromPosition(j, i);
				if (controlFromPosition != null)
				{
					tableLayoutPanel1.SetRow(controlFromPosition, i - 1);
				}
			}
		}
		tableLayoutPanel1.RowStyles.RemoveAt(tableLayoutPanel1.RowCount - 1);
		tableLayoutPanel1.RowCount--;
		ResumeLayout();
	}

	private Point GetNewBCTrialControlLocation()
	{
		int num = 20;
		Point location = dgAntennaGrid.Location;
		location.Y += dgAntennaGrid.Size.Height + num;
		if (bcTrialControls.Values.Select((TrialsControl t) => t.Visible).Count() > 0)
		{
			List<TrialsControl> list = bcTrialControls.Values.OrderBy((TrialsControl t) => t.Location.Y).ToList();
			location = list[0].Location;
			foreach (TrialsControl value in bcTrialControls.Values)
			{
				if (value.Visible)
				{
					location.Y += value.Height + num;
				}
			}
		}
		return location;
	}

	private void GetUserSelectedBandClassChannels(string BandClass, out string Channels)
	{
		string text = "";
		if (!userSelectedChannels.ContainsKey(BandClass))
		{
			userSelectedChannels.Add(BandClass, defaultBandClassChannels[BandClass]);
		}
		string[] array = userSelectedChannels[BandClass];
		foreach (string text2 in array)
		{
			text = text + text2 + ",";
		}
		text = text.Substring(0, text.Length - 1);
		Channels = text;
	}

	private void dataGrid_DataError(object sender, DataGridViewDataErrorEventArgs e)
	{
	}

	private void LoadDataGrid()
	{
		PresetGridColumns();
		dgAntennaGrid.DataSource = antennaTrialData.TrialDataTable;
	}

	private void LoadDataGrid(DataGridView dataGrid, string bandClass)
	{
		PresetGridColumns(dataGrid, bandClassTrialDataItems[bandClass]);
		dataGrid.DataSource = bandClassTrialDataItems[bandClass].TrialDataTable;
	}

	private void dataGrid_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
	{
		DataGridView dataGridView = sender as DataGridView;
		if (e.ColumnIndex != 0 && string.IsNullOrWhiteSpace(dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString()))
		{
			MessageBox.Show("Invalid Ref Designator specified at row index " + e.RowIndex + "." + Environment.NewLine + "Please enter a reference designator before filling in trial data.");
			e.Cancel = true;
		}
	}

	private void dataGrid_UserAddedRow(object sender, DataGridViewRowEventArgs e)
	{
		DataGridView dataGridView = e.Row.DataGridView;
		numRefDesignators = dataGridView.RowCount - 1;
		string text = Convert.ToString(numRefDesignators + 1);
		if (numRefDesignators > 1)
		{
			dataGridView.Columns.Add("Trial" + text + " Val", "Trial" + text + " Value");
			DataGridViewColumn lastColumn = dataGridView.Columns.GetLastColumn(DataGridViewElementStates.None, DataGridViewElementStates.None);
			lastColumn.Width = 100;
			lastColumn.DefaultCellStyle.BackColor = Color.Wheat;
			lastColumn.DataPropertyName = "Trial" + text + " Value";
			DataGridViewComboBoxColumn dataGridViewComboBoxColumn = new DataGridViewComboBoxColumn();
			dataGridViewComboBoxColumn.Name = "Trial" + text + " Units";
			dataGridViewComboBoxColumn.HeaderText = "Trial" + text + "\nUnits";
			dataGridViewComboBoxColumn.Items.AddRange(TrialUnits.pF, TrialUnits.nH);
			dataGridView.Columns.Add(dataGridViewComboBoxColumn);
			lastColumn = dataGridView.Columns.GetLastColumn(DataGridViewElementStates.None, DataGridViewElementStates.None);
			lastColumn.Width = 50;
			lastColumn.DataPropertyName = "Trial" + text + " Units";
			DataGridViewComboBoxColumn dataGridViewComboBoxColumn2 = new DataGridViewComboBoxColumn();
			dataGridViewComboBoxColumn2.Name = "Trial" + text + " Topology";
			dataGridViewComboBoxColumn2.HeaderText = "Trial" + text + " Topology";
			dataGridViewComboBoxColumn2.Items.AddRange(TrialTopology.SHUNT, TrialTopology.SERIES, TrialTopology.DNI, TrialTopology.SHORT);
			dataGridView.Columns.Add(dataGridViewComboBoxColumn2);
			lastColumn = dataGridView.Columns.GetLastColumn(DataGridViewElementStates.None, DataGridViewElementStates.None);
			lastColumn.Width = 100;
			lastColumn.DataPropertyName = "Trial" + text + " Topology";
			UpdateScenarioModifiedStatus(modified: true);
		}
	}

	private void dataGrid_UserDeletedRow(object sender, DataGridViewRowEventArgs e)
	{
		DataGridView dataGridView = sender as DataGridView;
		numRefDesignators = dataGridView.RowCount - 1;
		UpdateButtonStatus(eButtonState.EDIT_TRIAL);
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void dataGrid_CurrentCellDirtyStateChanged(object sender, EventArgs e)
	{
		DataGridView dataGridView = sender as DataGridView;
		if (dataGridView.CurrentCell.ColumnIndex == 1)
		{
			dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
		}
	}

	private void dataGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e)
	{
		DataGridView dataGridView = sender as DataGridView;
		(dataGridView.Parent as TrialsControl).btnAutoGenBandTrials.Enabled = VerifyRefDesignatorOneExists(dataGridView);
		if (dataGridView.CurrentCell != null && dataGridView.CurrentCell.ColumnIndex == 1)
		{
			string text = dataGridView.CurrentCell.OwningRow.Cells[0].Value.ToString();
			if ((bool)(dataGridView.CurrentCell as DataGridViewCheckBoxCell).Value)
			{
				if (!customKitValues.ContainsKey(text))
				{
					customKitValues.Add(text, new KitValuesConverter(text, new KitValues
					{
						RefDesignator = text,
						InductorValues = new List<double>(),
						CapacitorValues = new List<double>()
					}));
				}
				ShowKitValueDialog(text);
			}
			else
			{
				GenerateKitFiles();
			}
		}
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void AppendDataGrid(DataGridView combinedDataGrid, DataGridView dgToAppend)
	{
		if (combinedDataGrid.Columns.Count < dgToAppend.Columns.Count)
		{
			for (int i = combinedDataGrid.Columns.Count; i < dgToAppend.Columns.Count; i++)
			{
				combinedDataGrid.Columns.Add(dgToAppend.Columns[i].Clone() as DataGridViewColumn);
			}
		}
		DataGridViewRow dataGridViewRow = new DataGridViewRow();
		foreach (DataGridViewRow item in (IEnumerable)dgToAppend.Rows)
		{
			if (!item.IsNewRow)
			{
				dataGridViewRow = item.Clone() as DataGridViewRow;
				for (int j = 0; j < item.Cells.Count; j++)
				{
					dataGridViewRow.Cells[j].Value = item.Cells[j].Value;
				}
				combinedDataGrid.Rows.Add(dataGridViewRow);
			}
		}
	}

	private DataGridView MergeDataGridInfo(List<string> BandClasses)
	{
		DataGridView dataGridView = new DataGridView();
		dataGridView.AllowUserToAddRows = false;
		AppendDataGrid(dataGridView, dgAntennaGrid);
		foreach (string BandClass in BandClasses)
		{
			AppendDataGrid(dataGridView, bcTrialControls[BandClass].dgBandTrials);
		}
		AutoGenTrials(dataGridView, null, isCombinedGrid: true);
		return dataGridView;
	}

	private void btnAutoGenTrials_Click(object sender, EventArgs e)
	{
		DataGridView dgBandTrials = dgAntennaGrid;
		string bandClassName = null;
		if ((sender as Button).Parent is TrialsControl)
		{
			dgBandTrials = ((sender as Button).Parent as TrialsControl).dgBandTrials;
			bandClassName = ((sender as Button).Parent as TrialsControl).BandClassName;
		}
		AutoGenTrials(dgBandTrials, bandClassName);
	}

	private void AutoGenTrials(DataGridView dataGrid, string bandClassName, bool isCombinedGrid = false)
	{
		try
		{
			CommitGridChanges(dataGrid);
			aScaleFactor = Convert.ToDouble(strAScaleFactor);
			bScaleFactor = Convert.ToDouble(strBScaleFactor);
			cScaleFactor = Convert.ToDouble(strCScaleFactor);
			if (isCombinedGrid)
			{
				CalculateTrialAValues_Course(bandClassName, dataGrid, isCombinedGrid);
			}
			else
			{
				CalculateTrialAValues_Course(bandClassName);
			}
			if (!isCombinedGrid)
			{
				UpdateButtonStatus(eButtonState.AUTOGEN_TRIAL, dataGrid);
				bAutoGenPerformed = true;
				UpdateScenarioModifiedStatus(modified: true);
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private void btnClearTrialData_Click(object sender, EventArgs e)
	{
		string bandClassName = null;
		if ((sender as Button).Parent is TrialsControl trialsControl)
		{
			bandClassName = trialsControl.BandClassName;
		}
		ClearTrialDataGrid(bandClassName);
		UpdateScenarioModifiedStatus(modified: true);
	}

	private void GetStandardComponentValues()
	{
		string text = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\KitValues\\";
		StreamReader streamReader = null;
		string[] array = new string[50];
		string[] array2 = new string[50];
		string text2 = "0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.5,1.8,2.0,2.2,2.7,3.0,3.3,3.9,4.0,4.7,5.0,5.6,6.0,6.8,7.0,8.0,8.2,9.0,10,12,15,18,22,27,33";
		string text3 = "0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.3,4.7,5.1,5.6,6.8,8.2,10,12,15,18,22";
		string text4 = text + "KitValues_capacitors.csv";
		string text5 = text + "KitValues_inductors.csv";
		if (File.Exists(text4))
		{
			streamReader = new StreamReader(text4);
		}
		if (streamReader == null)
		{
			MessageBox.Show("Error opening " + text4 + " can't get a list of standard capacitance values! Using defaulted kit values.", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
			array = text2.Split(',');
		}
		else
		{
			while (streamReader.Peek() >= 0)
			{
				text2 = streamReader.ReadLine();
				array = text2.Split(',');
			}
			streamReader.Close();
		}
		for (int i = 0; i < array.Length; i++)
		{
			StandardValuesC.Add(Convert.ToDouble(array[i].ToString()));
		}
		if (File.Exists(text5))
		{
			streamReader = new StreamReader(text5);
		}
		if (streamReader == null)
		{
			MessageBox.Show("Error opening " + text5 + " can't get a list of standard inductor values! Using defaulted kit values.", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
			array2 = text3.Split(',');
		}
		else
		{
			while (streamReader.Peek() >= 0)
			{
				text3 = streamReader.ReadLine();
				array2 = text3.Split(',');
			}
			streamReader.Close();
		}
		for (int j = 0; j < array2.Length; j++)
		{
			StandardValuesL.Add(Convert.ToDouble(array2[j].ToString()));
		}
		customKitValues.Add("", new KitValuesConverter("", new KitValues
		{
			CapacitorValues = StandardValuesC,
			InductorValues = StandardValuesL
		}));
	}

	public void CalculateTrialAValues()
	{
		int num = dgAntennaGrid.RowCount - 1;
		int count = dgAntennaGrid.Columns.Count;
		string text = "";
		string text2 = "";
		double num2 = aScaleFactor * (Math.Sqrt((double)num + 1.0) + (double)(num - 1)) / ((double)num * Math.Sqrt(bScaleFactor));
		double num3 = num2 / cScaleFactor;
		double num4 = aScaleFactor * (Math.Sqrt((double)num + 1.0) - 1.0) / ((double)num * Math.Sqrt(bScaleFactor));
		double num5 = num4 / cScaleFactor;
		double num6 = num4;
		double num7 = num5;
		int num8 = 1;
		if (dgAntennaGrid.Rows[0].Cells[2].Value.ToString() == "")
		{
			return;
		}
		antennaTrialData.BeginEditing();
		int num9 = 0;
		while (num9 < num)
		{
			int num10 = 2;
			int num11 = 1;
			while (num10 < count - 3)
			{
				double result = 0.0;
				if (!double.TryParse(dgAntennaGrid.Rows[num9].Cells[num10].Value.ToString(), out result))
				{
					throw new NullReferenceException("Invalid Trial Value entered for Trial 1, row " + num9);
				}
				if (dgAntennaGrid.Rows[num9].Cells[num10 + 1].Value != DBNull.Value)
				{
					TrialUnits trialUnits = (TrialUnits)dgAntennaGrid.Rows[num9].Cells[num10 + 1].Value;
					if (dgAntennaGrid.Rows[num9].Cells[num10 + 2].Value == DBNull.Value)
					{
						throw new NullReferenceException("Invalid Trial Topology entered for Trial 1, row " + num9);
					}
					switch ((TrialTopology)dgAntennaGrid.Rows[num9].Cells[num10 + 2].Value)
					{
					case TrialTopology.DNI:
						text2 = "DNI";
						break;
					case TrialTopology.SERIES:
						text2 = "SERIES";
						break;
					case TrialTopology.SHORT:
						text2 = "SHORT";
						break;
					case TrialTopology.SHUNT:
						text2 = "SHUNT";
						break;
					}
					if (trialUnits == TrialUnits.pF)
					{
						text = string.Concat(dgAntennaGrid.Rows[num9].Cells[num10].Value, "e-12");
						text2 += "_C";
					}
					else
					{
						text = string.Concat(dgAntennaGrid.Rows[num9].Cells[num10].Value, "e-09");
						text2 += "_L";
					}
					if (num11 == num8)
					{
						num6 = num2;
						num7 = num3;
					}
					else
					{
						num6 = num4;
						num7 = num5;
					}
					double num12;
					TrialTopology trialTopology;
					TrialUnits trialUnits2;
					switch (text2)
					{
					case "SHUNT_C":
						num12 = ((!(text == "0e-12")) ? (Math.PI * 2.0 * f * Convert.ToDouble(text) + num7) : (Convert.ToDouble(text) + num7));
						trialTopology = TrialTopology.SHUNT;
						trialUnits2 = ((!(num12 > 0.0)) ? TrialUnits.nH : TrialUnits.pF);
						break;
					case "SERIES_C":
						num12 = ((!(text == "0e-12")) ? (-1.0 / (Math.PI * 2.0 * f * Convert.ToDouble(text)) + num6) : (Convert.ToDouble(text) + num6));
						trialTopology = TrialTopology.SERIES;
						trialUnits2 = ((num12 > 0.0) ? TrialUnits.nH : TrialUnits.pF);
						break;
					case "SHUNT_L":
						num12 = ((!(text == "0e-9")) ? (-1.0 / (Math.PI * 2.0 * f * Convert.ToDouble(text)) + num7) : (Convert.ToDouble(text) + num7));
						trialTopology = TrialTopology.SHUNT;
						trialUnits2 = ((!(num12 > 0.0)) ? TrialUnits.nH : TrialUnits.pF);
						break;
					case "SERIES_L":
						num12 = ((!(text == "0e-9")) ? (Math.PI * 2.0 * f * Convert.ToDouble(text) + num6) : (Convert.ToDouble(text) + num6));
						trialTopology = TrialTopology.SERIES;
						trialUnits2 = ((num12 > 0.0) ? TrialUnits.nH : TrialUnits.pF);
						break;
					case "SHORT_C":
						num12 = ((!(text == "0e-12")) ? (Math.PI * 2.0 * f * Convert.ToDouble(text) + num6) : (Convert.ToDouble(text) + num6));
						trialTopology = TrialTopology.SERIES;
						trialUnits2 = ((num12 > 0.0) ? TrialUnits.nH : TrialUnits.pF);
						break;
					case "SHORT_L":
						num12 = ((!(text == "0e-9")) ? (Math.PI * 2.0 * f * Convert.ToDouble(text) + num6) : (Convert.ToDouble(text) + num6));
						trialTopology = TrialTopology.SERIES;
						trialUnits2 = ((num12 > 0.0) ? TrialUnits.nH : TrialUnits.pF);
						break;
					case "DNI_C":
						num12 = ((!(text == "0e-12")) ? (Math.PI * 2.0 * f * Convert.ToDouble(text) + num7) : (Convert.ToDouble(text) + num7));
						trialTopology = TrialTopology.SHUNT;
						trialUnits2 = ((!(num12 > 0.0)) ? TrialUnits.nH : TrialUnits.pF);
						break;
					case "DNI_L":
						num12 = ((!(text == "0e-9")) ? (Math.PI * 2.0 * f * Convert.ToDouble(text) + num7) : (Convert.ToDouble(text) + num7));
						trialTopology = TrialTopology.SHUNT;
						trialUnits2 = ((!(num12 > 0.0)) ? TrialUnits.nH : TrialUnits.pF);
						break;
					default:
						throw new Exception("Unknown Topology entered");
					}
					double num13 = ((trialUnits2 == TrialUnits.pF) ? 1000000000000.0 : 1000000000.0);
					bool selectC = false;
					if (num13 == 1000000000000.0)
					{
						selectC = true;
					}
					double num14 = ((!(num12 > 0.0)) ? Math.Abs(1.0 / (num12 * 2.0 * Math.PI * f)) : (num12 / (Math.PI * 2.0 * f)));
					num14 *= num13;
					CalculateKitValues(selectC, num14, out var KitValue);
					dgAntennaGrid.Rows[num9].Cells[num10 + 3].Value = $"{KitValue:N4}";
					dgAntennaGrid.Rows[num9].Cells[num10 + 4].Value = trialUnits2;
					dgAntennaGrid.Rows[num9].Cells[num10 + 5].Value = trialTopology;
					num10 += 3;
					num11++;
					continue;
				}
				throw new NullReferenceException("Invalid Trial Units entered for Trial 1, row " + num9);
			}
			num9++;
			num8++;
		}
		antennaTrialData.EndEditing();
	}

	private void GenerateKitFiles()
	{
		string[] files = Directory.GetFiles("C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\KitValues\\", "*_KitValues_capacitors.csv");
		string[] files2 = Directory.GetFiles("C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\KitValues\\", "*_KitValues_inductors.csv");
		string[] array = files;
		foreach (string path in array)
		{
			File.Delete(path);
		}
		string[] array2 = files2;
		foreach (string path2 in array2)
		{
			File.Delete(path2);
		}
		List<string> allCustomRefDesignators = GetAllCustomRefDesignators();
		foreach (KitValuesConverter value in customKitValues.Values)
		{
			string text = "";
			string text2 = "";
			if (!string.IsNullOrWhiteSpace(value.KitValues.RefDesignator))
			{
				if (!allCustomRefDesignators.Contains(value.KitValues.RefDesignator))
				{
					continue;
				}
				text = string.Format("{0}{1}_KitValues_capacitors.csv", "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\KitValues\\", value.KitValues.RefDesignator);
				text2 = string.Format("{0}{1}_KitValues_inductors.csv", "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\KitValues\\", value.KitValues.RefDesignator);
			}
			else
			{
				text = string.Format("{0}KitValues_capacitors.csv", "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\KitValues\\");
				text2 = string.Format("{0}KitValues_inductors.csv", "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\KitValues\\");
				File.Delete(text);
				File.Delete(text2);
			}
			if (value.KitValues.CapacitorValues.Count > 0)
			{
				value.KitValues.CapacitorValues = value.KitValues.CapacitorValues.Distinct().ToList();
				value.KitValues.CapacitorValues.Sort();
				string contents = string.Join(",", value.KitValues.CapacitorValues.ToArray());
				File.WriteAllText(text, contents);
			}
			if (value.KitValues.InductorValues.Count > 0)
			{
				value.KitValues.InductorValues = value.KitValues.InductorValues.Distinct().ToList();
				value.KitValues.InductorValues.Sort();
				string contents2 = string.Join(",", value.KitValues.InductorValues.Distinct().ToArray());
				File.WriteAllText(text2, contents2);
			}
			value.ReloadKitValueTables();
		}
	}

	public void CalculateTrialAValues_Course(string bandClassName = null, DataGridView dg = null, bool isCombinedGrid = false)
	{
		TrialDataConverter trialDataConverter = antennaTrialData;
		DataGridView dataGridView = dgAntennaGrid;
		if (dg != null)
		{
			dataGridView = dg;
		}
		else if (!string.IsNullOrWhiteSpace(bandClassName))
		{
			trialDataConverter = bandClassTrialDataItems[bandClassName];
			dataGridView = bcTrialControls[bandClassName].dgBandTrials;
		}
		int num = dataGridView.RowCount - 1;
		int count = dataGridView.Columns.Count;
		if (isCombinedGrid)
		{
			num = dataGridView.RowCount;
		}
		string text = "";
		if (dataGridView.Rows[0].Cells[2].Value.ToString() == "")
		{
			return;
		}
		trialDataConverter.BeginEditing();
		for (int i = 0; i < num; i++)
		{
			double result = 0.0;
			if (!double.TryParse(dataGridView.Rows[i].Cells[2].Value.ToString(), out result))
			{
				throw new NullReferenceException("Invalid Trial Value entered for Trial 1, row " + i);
			}
			if (dataGridView.Rows[i].Cells[3].Value != DBNull.Value)
			{
				TrialUnits trialUnits = (TrialUnits)dataGridView.Rows[i].Cells[3].Value;
				if (dataGridView.Rows[i].Cells[4].Value != DBNull.Value)
				{
					TrialTopology trialTopology = (TrialTopology)dataGridView.Rows[i].Cells[4].Value;
					switch (trialTopology)
					{
					case TrialTopology.DNI:
						text = "DNI";
						break;
					case TrialTopology.SERIES:
						text = "SERIES";
						break;
					case TrialTopology.SHORT:
						text = "SHORT";
						break;
					case TrialTopology.SHUNT:
						text = "SHUNT";
						break;
					}
					text = ((trialUnits != 0) ? (text + "_L") : (text + "_C"));
					int num2 = 2;
					int num3 = 1;
					while (num2 < count - 3)
					{
						double num4;
						TrialTopology trialTopology2;
						TrialUnits trialUnits2;
						if (num3 < i + 1)
						{
							num4 = result;
							trialTopology2 = trialTopology;
							trialUnits2 = trialUnits;
						}
						else
						{
							switch (text)
							{
							case "SHUNT_C":
								num4 = 0.0;
								trialTopology2 = TrialTopology.DNI;
								trialUnits2 = TrialUnits.pF;
								break;
							case "SERIES_C":
								num4 = 39.0;
								trialTopology2 = TrialTopology.SERIES;
								trialUnits2 = TrialUnits.pF;
								break;
							case "SHUNT_L":
								num4 = 0.0;
								trialTopology2 = TrialTopology.DNI;
								trialUnits2 = TrialUnits.pF;
								break;
							case "SERIES_L":
								num4 = 39.0;
								trialTopology2 = TrialTopology.SERIES;
								trialUnits2 = TrialUnits.pF;
								break;
							case "SHORT_C":
								num4 = 0.5;
								trialTopology2 = TrialTopology.SERIES;
								trialUnits2 = TrialUnits.pF;
								break;
							case "SHORT_L":
								num4 = 22.0;
								trialTopology2 = TrialTopology.SERIES;
								trialUnits2 = TrialUnits.pF;
								break;
							case "DNI_C":
								num4 = 0.5;
								trialTopology2 = TrialTopology.SHUNT;
								trialUnits2 = TrialUnits.pF;
								break;
							case "DNI_L":
								num4 = 0.5;
								trialTopology2 = TrialTopology.SHUNT;
								trialUnits2 = TrialUnits.pF;
								break;
							default:
								throw new Exception("Unknown Topology entered");
							}
						}
						dataGridView.Rows[i].Cells[num2 + 3].Value = $"{num4:N2}";
						dataGridView.Rows[i].Cells[num2 + 4].Value = trialUnits2;
						dataGridView.Rows[i].Cells[num2 + 5].Value = trialTopology2;
						num2 += 3;
						num3++;
					}
					continue;
				}
				throw new NullReferenceException("Invalid Trial Topology entered for Trial 1, row " + i);
			}
			throw new NullReferenceException("Invalid Trial Units entered for Trial 1, row " + i);
		}
		trialDataConverter.EndEditing();
	}

	private void ClearTrialDataGrid(string bandClassName = null)
	{
		TrialDataConverter trialDataConverter = antennaTrialData;
		DataGridView dgBandTrials = dgAntennaGrid;
		if (!string.IsNullOrWhiteSpace(bandClassName))
		{
			trialDataConverter = bandClassTrialDataItems[bandClassName];
			dgBandTrials = bcTrialControls[bandClassName].dgBandTrials;
		}
		trialDataConverter.LoadDefaultData(bandClassName);
		dgBandTrials.DataSource = trialDataConverter.TrialDataTable;
		UpdateButtonStatus(eButtonState.CLEAR_TRIAL);
	}

	private void CalculateKitValues(bool selectC, double partValue, out double KitValue)
	{
		int index = 0;
		partValue = Math.Abs(partValue);
		double num;
		if (selectC)
		{
			_ = StandardValuesC.Count;
			if (partValue <= StandardValuesC[0])
			{
				KitValue = StandardValuesC[0];
				return;
			}
			if (partValue >= StandardValuesC[StandardValuesC.Count - 1])
			{
				KitValue = StandardValuesC[StandardValuesC.Count - 1];
				return;
			}
			num = Math.Abs(partValue - StandardValuesC[0]);
			for (int i = 0; i < StandardValuesC.Count; i++)
			{
				if (num > Math.Abs(partValue - StandardValuesC[i]))
				{
					num = Math.Abs(partValue - StandardValuesC[i]);
					index = i;
				}
			}
			KitValue = Math.Round(StandardValuesC[index], 1);
			return;
		}
		_ = StandardValuesL.Count;
		if (partValue <= StandardValuesL[0])
		{
			KitValue = StandardValuesL[0];
			return;
		}
		if (partValue >= StandardValuesL[StandardValuesL.Count - 1])
		{
			KitValue = StandardValuesL[StandardValuesL.Count - 1];
			return;
		}
		num = Math.Abs(partValue - StandardValuesL[0]);
		for (int j = 0; j < StandardValuesL.Count; j++)
		{
			if (num > Math.Abs(partValue - StandardValuesL[j]))
			{
				num = Math.Abs(partValue - StandardValuesL[j]);
				index = j;
			}
		}
		KitValue = Math.Round(StandardValuesL[index], 1);
	}

	private bool VerifyRefDesignatorOneExists(DataGridView dataGrid = null)
	{
		if (dataGrid == null)
		{
			dataGrid = dgAntennaGrid;
		}
		object value = dataGrid.Rows[0].Cells[0].Value;
		if (value != null && value.ToString() != "")
		{
			return true;
		}
		return false;
	}

	private bool TrialDataIsMissing(out List<string> missingTrialNames)
	{
		missingTrialNames = new List<string>();
		if (antennaTrialData.TrialData.RefDesignators.Count == 0)
		{
			missingTrialNames.Add("Antenna");
		}
		else if (antennaTrialData.TrialData.RefDesignators.Count == 1 && antennaTrialData.TrialData.RefDesignators[0] == null)
		{
			missingTrialNames.Add("Antenna");
		}
		foreach (ListViewItem checkedItem in lvBandClasses.CheckedItems)
		{
			string text = checkedItem.Text;
			if (bandClassTrialDataItems[text].TrialData.RefDesignators.Count == 0)
			{
				missingTrialNames.Add(text);
			}
			else if (bandClassTrialDataItems[text].TrialData.RefDesignators.Count == 1 && bandClassTrialDataItems[text].TrialData.RefDesignators[0] == null)
			{
				missingTrialNames.Add(text);
			}
		}
		return missingTrialNames.Count > 0;
	}

	private bool TrialDataIsValid(out List<string> invalidTrialNames)
	{
		invalidTrialNames = new List<string>();
		if (!IsTrialValid(antennaTrialData))
		{
			invalidTrialNames.Add(null);
		}
		foreach (ListViewItem checkedItem in lvBandClasses.CheckedItems)
		{
			string text = checkedItem.Text;
			if (!IsTrialValid(bandClassTrialDataItems[text]))
			{
				invalidTrialNames.Add(text);
			}
		}
		return invalidTrialNames.Count == 0;
	}

	private bool IsTrialValid(TrialDataConverter trialDataConv)
	{
		if (trialDataConv.TrialData.Trials.Count != trialDataConv.TrialData.RefDesignators.Count + 1)
		{
			return false;
		}
		int count = trialDataConv.TrialData.Trials.Count;
		for (int i = 0; i < count; i++)
		{
			if (trialDataConv.TrialData.Trials[i].Value.Where((double? t) => !t.HasValue).Count() > 0 || trialDataConv.TrialData.Trials[i].Units.Where((TrialUnits? t) => !t.HasValue).Count() > 0 || trialDataConv.TrialData.Trials[i].Topology.Where((TrialTopology? t) => !t.HasValue).Count() > 0)
			{
				return false;
			}
		}
		return true;
	}

	private void RestoreTrialData(string trialFolderName)
	{
		string text = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\";
		string sourceFolder = Path.Combine(text, trialFolderName);
		CopyTrialSubDirectories(sourceFolder, text);
	}

	private void CopyTrialSubDirectories(string sourceFolder, string destinationFolder)
	{
		string[] directories = Directory.GetDirectories(sourceFolder);
		string[] array = directories;
		foreach (string text in array)
		{
			string text2 = Path.Combine(destinationFolder, text.Substring(text.LastIndexOf("\\") + 1));
			if (Directory.Exists(text2))
			{
				Directory.Delete(text2, recursive: true);
			}
			Directory.CreateDirectory(text2);
			string[] files = Directory.GetFiles(text);
			string[] array2 = files;
			foreach (string text3 in array2)
			{
				string destFileName = Path.Combine(text2, Path.GetFileName(text3));
				File.Copy(text3, destFileName);
			}
		}
	}

	private List<string> GetResumeSegemntDirectoryNames()
	{
		List<string> list = new List<string>();
		if (Directory.Exists(measurementResumeFolder))
		{
			string[] directories = Directory.GetDirectories(measurementResumeFolder);
			string[] array = directories;
			foreach (string text in array)
			{
				if (text.ToLower().EndsWith("\\antenna"))
				{
					list.Add(text);
				}
				else if (text.ToLower().EndsWith("pa"))
				{
					list.Add(text);
				}
			}
		}
		return list;
	}

	private void MoveMeasurementDataToBackup(bool clear)
	{
		string text = "";
		string text2 = "";
		int num = antennaTrialData.TrialData.Trials.Count();
		if (string.IsNullOrWhiteSpace(currentTrialNum))
		{
			return;
		}
		num = Convert.ToInt16(currentTrialNum);
		DateTime now = DateTime.Now;
		text = ((eMatchMode != MatchMode.ANT) ? (currentRunningBC + "PA") : "Antenna");
		string text3 = Path.Combine(trialDataFolder, sUnitSN);
		Directory.CreateDirectory(text3);
		measurementFolder = Path.Combine(text3, text + now.ToString("yyMMdd_HHmmss"));
		Directory.CreateDirectory(measurementFolder);
		text2 = Path.Combine(measurementResumeFolder, text);
		Directory.CreateDirectory(text2);
		string[] directories = Directory.GetDirectories(text2);
		string[] array = directories;
		foreach (string path in array)
		{
			Directory.Delete(path, recursive: true);
		}
		bool flag = false;
		for (int j = 1; j <= num; j++)
		{
			string path2 = Path.Combine(trialDataFolder, "Trial" + j);
			if (Directory.Exists(path2))
			{
				flag = true;
				string text4 = Path.Combine(measurementFolder, "Trial" + j);
				Directory.CreateDirectory(text4);
				string text5 = Path.Combine(text2, "Trial" + j);
				Directory.CreateDirectory(text5);
				string[] files = Directory.GetFiles(path2);
				string[] array2 = files;
				foreach (string text6 in array2)
				{
					string fileName = Path.GetFileName(text6);
					string destFileName = Path.Combine(text4, fileName);
					File.Copy(text6, destFileName, overwrite: true);
					string destFileName2 = Path.Combine(text5, fileName);
					File.Copy(text6, destFileName2, overwrite: true);
				}
			}
		}
		if (!flag)
		{
			Directory.Delete(measurementFolder);
		}
		if (clear)
		{
			ClearMeasurementData();
		}
	}

	private bool MoveMeasurementDataToRestore(string SelectedResumeMatchMode)
	{
		string text = "";
		_ = DateTime.Now;
		int num;
		if (resumeSegmentBC == "Antenna")
		{
			num = antennaTrialData.TrialData.Trials.Count();
		}
		else
		{
			int length = SelectedResumeMatchMode.IndexOf("PA");
			SelectedResumeMatchMode.Substring(0, length);
		}
		text = Path.Combine(measurementResumeFolder, SelectedResumeMatchMode);
		if (!Directory.Exists(text))
		{
			MessageBox.Show("Unable to find Resume Folder.  Resume option will be disabled. ", measurementResumeFolder);
			bResumeTrialsExist = false;
			UpdateButtonStatus(eButtonState.LOAD_PROFILE);
			return false;
		}
		string[] directories = Directory.GetDirectories(text);
		num = GetTrialCount(directories);
		if (num < 1)
		{
			MessageBox.Show("Unable to find Resume Trial Data. Resume option will be disabled. ", trialDataFolder);
			bResumeTrialsExist = false;
			UpdateButtonStatus(eButtonState.LOAD_PROFILE);
			return false;
		}
		if (Directory.Exists(trialDataFolder))
		{
			string[] directories2 = Directory.GetDirectories(trialDataFolder);
			string[] array = directories2;
			foreach (string text2 in array)
			{
				if (text2.Contains("Trial"))
				{
					string[] files = Directory.GetFiles(text2);
					string[] array2 = files;
					foreach (string path in array2)
					{
						string fileName = Path.GetFileName(path);
						File.Delete(fileName);
					}
				}
			}
			for (int k = 1; k <= num; k++)
			{
				string text3 = Path.Combine(text, "Trial" + k);
				string path2 = Path.Combine(trialDataFolder, "Trial" + k);
				if (Directory.Exists(text3))
				{
					string[] files2 = Directory.GetFiles(text3);
					if (files2.Length == 0)
					{
						MessageBox.Show("Unable to find Resume Trial Data. Resume option will be disabled. ", trialDataFolder);
						bResumeTrialsExist = false;
						UpdateButtonStatus(eButtonState.LOAD_PROFILE);
						return false;
					}
					string[] array3 = files2;
					foreach (string text4 in array3)
					{
						string fileName2 = Path.GetFileName(text4);
						string destFileName = Path.Combine(path2, fileName2);
						File.Copy(text4, destFileName, overwrite: true);
					}
					continue;
				}
				MessageBox.Show("Unable to find Resume Trial Data. Resume option will be disabled. ", text3);
				bResumeTrialsExist = false;
				UpdateButtonStatus(eButtonState.LOAD_PROFILE);
				return false;
			}
			return true;
		}
		MessageBox.Show("Unable to delete old Trial Data. Resume option will be disabled. ", trialDataFolder);
		bResumeTrialsExist = false;
		UpdateButtonStatus(eButtonState.LOAD_PROFILE);
		return false;
	}

	private int GetTrialCount(string[] resumeFolders)
	{
		int num = 0;
		foreach (string path in resumeFolders)
		{
			if (Directory.Exists(path) && Directory.GetFiles(path).Count() > 0)
			{
				num++;
				continue;
			}
			return num;
		}
		return num;
	}

	private void ClearMeasurementData()
	{
		string text = "";
		string text2 = "";
		if (!Directory.Exists(trialDataFolder))
		{
			return;
		}
		if (!isResumeTrial)
		{
			string[] directories = Directory.GetDirectories(trialDataFolder);
			string[] array = directories;
			foreach (string text3 in array)
			{
				if (text3.Contains("Trial"))
				{
					text2 = Path.Combine(trialDataFolder, text3);
					string[] files = Directory.GetFiles(text3);
					string[] array2 = files;
					foreach (string path in array2)
					{
						string fileName = Path.GetFileName(path);
						text = Path.Combine(text2, fileName);
						File.Delete(text);
					}
				}
			}
		}
		string[] files2 = Directory.GetFiles(trialDataFolder);
		string[] array3 = files2;
		foreach (string text4 in array3)
		{
			if (text4.Contains("Iteration_") || text4.Contains("SmartQMatch_Measurement_Trials"))
			{
				string fileName = Path.GetFileName(text4);
				text = Path.Combine(trialDataFolder, fileName);
				File.Delete(text);
			}
		}
	}

	private void UpdateTempPAParamsFile(string bc, string tempFile)
	{
		XDocument xDocument = XDocument.Load(tempFile);
		string selectedMode = bc;
		string value = tbPoutMaxBias.Text;
		if (string.IsNullOrEmpty(selectedMode))
		{
			IEnumerable<XElement> enumerable = from c in xDocument.Elements("RFCal_Data").Elements("PA").Elements("XptInput_V1")
					.Elements("StaticPinPoutCharVmax_table")
				select (c);
			foreach (XElement item in enumerable)
			{
				item.Attribute("StaticPinPoutCharVmax").Value = value;
			}
		}
		else
		{
			IEnumerable<XElement> enumerable2 = from c in xDocument.Elements("RFCal_Data").Elements("PA").Elements("XptInput_V1")
				where (string)c.Attribute("rf_mode") == selectedMode
				select c;
			foreach (XElement item2 in enumerable2)
			{
				IEnumerable<XElement> enumerable3 = from c in item2.Elements("StaticPinPoutCharVmax_table")
					select (c);
				foreach (XElement item3 in enumerable3)
				{
					item3.Attribute("StaticPinPoutCharVmax").Value = value;
				}
			}
		}
		xDocument.Save(tempFile);
	}

	private void UpdateTempLimitDescriptor()
	{
		XDocument xDocument = XDocument.Load(LimitDescriptorName);
		string value = "";
		if (!string.IsNullOrEmpty(value))
		{
			return;
		}
		IEnumerable<XElement> enumerable = from c in xDocument.Elements("LimitDefinition").Elements("OutputGroupLimitDescriptor").Elements("Result")
			select (c);
		foreach (XElement item in enumerable)
		{
			if (item.Attribute("resID").Value == "\tSelected Delay")
			{
				IEnumerable<XElement> enumerable2 = from c in item.Elements("Limits").Elements("Low")
					select (c);
				foreach (XElement item2 in enumerable2)
				{
					item2.Attribute("value").Value = "-" + measurementSelection.strDelayMeasureTarget;
				}
				IEnumerable<XElement> enumerable3 = from c in item.Elements("Limits").Elements("High")
					select (c);
				foreach (XElement item3 in enumerable3)
				{
					item3.Attribute("value").Value = measurementSelection.strDelayMeasureTarget;
				}
			}
			if (item.Attribute("resID").Value == "Pin_SPinPoutAlign")
			{
				IEnumerable<XElement> enumerable4 = from c in item.Elements("Limits").Elements("Low")
					select (c);
				foreach (XElement item4 in enumerable4)
				{
					item4.Attribute("value").Value = "-" + measurementSelection.strPinMeasureTarget;
				}
				IEnumerable<XElement> enumerable5 = from c in item.Elements("Limits").Elements("High")
					select (c);
				foreach (XElement item5 in enumerable5)
				{
					item5.Attribute("value").Value = measurementSelection.strPinMeasureTarget;
				}
			}
			if (item.Attribute("resID").Value == "Pout_SPinPoutAlign")
			{
				string text = ((measurementSelection.strPoutMeasureConstraint == "<") ? "High" : "Low");
				IEnumerable<XElement> enumerable6 = from c in item.Elements("Limits").Elements(text)
					select (c);
				foreach (XElement item6 in enumerable6)
				{
					item6.Attribute("value").Value = measurementSelection.strPoutMeasureTarget;
				}
			}
			if (!(item.Attribute("resID").Value == "Aclr_SPinPoutAlign"))
			{
				continue;
			}
			string text2 = ((measurementSelection.strAclrMeasureConstraint == "<") ? "High" : "Low");
			IEnumerable<XElement> enumerable7 = from c in item.Elements("Limits").Elements(text2)
				select (c);
			foreach (XElement item7 in enumerable7)
			{
				item7.Attribute("value").Value = measurementSelection.strAclrMeasureTarget;
			}
		}
		xDocument.Save(tempLimitDescriptorName);
	}

	private void SmartMatchGUI_FormClosing(object sender, FormClosingEventArgs e)
	{
		mruTreeFiles.SaveMruFiles();
		if (bScenarioModified)
		{
			switch (MessageBox.Show("You have made changes, would you like to save them?", "Save Changes", MessageBoxButtons.YesNo))
			{
			case DialogResult.Yes:
			{
				bool bSaveAs = ScenarioFilePathName == "";
				SaveScenarioData(bSaveAs);
				break;
			}
			}
		}
		scheduler.Close();
	}

	private void tbAScaleFactor_TextChanged(object sender, EventArgs e)
	{
		strAScaleFactor = tbAScaleFactor.Text;
	}

	private void tbBScaleFactor_TextChanged(object sender, EventArgs e)
	{
		strBScaleFactor = tbBScaleFactor.Text;
	}

	private void tbCScaleFactor_TextChanged(object sender, EventArgs e)
	{
		strCScaleFactor = tbCScaleFactor.Text;
	}

	private void btnRestoreScaleFactors_Click(object sender, EventArgs e)
	{
		aScaleFactor = 2.5;
		bScaleFactor = 2.0;
		cScaleFactor = 1000.0;
		tbAScaleFactor.Text = aScaleFactor.ToString();
		tbBScaleFactor.Text = bScaleFactor.ToString();
		tbCScaleFactor.Text = cScaleFactor.ToString();
		strAScaleFactor = tbAScaleFactor.Text;
		strBScaleFactor = tbBScaleFactor.Text;
		strCScaleFactor = tbCScaleFactor.Text;
	}

	private void tsEnableSimulationMenuItem_Click(object sender, EventArgs e)
	{
		if (bSimulationMode)
		{
			tsEnableSimulationMenuItem.Checked = false;
			bSimulationMode = false;
			tsSimulationMenuItem.BackColor = SystemColors.Control;
		}
		else
		{
			tsEnableSimulationMenuItem.Checked = true;
			bSimulationMode = true;
			tsSimulationMenuItem.BackColor = Color.Red;
		}
	}

	private void btnPlaybackLogFiles_Click(object sender, EventArgs e)
	{
		OpenFileDialog openFileDialog = new OpenFileDialog();
		openFileDialog.Filter = "Xml Files | *.xml";
		openFileDialog.DefaultExt = "xml";
		openFileDialog.InitialDirectory = "C:\\Qualcomm\\QDART\\SmartMatch\\Temp\\";
		if (openFileDialog.ShowDialog() == DialogResult.OK)
		{
			tbPlaybackLogFiles.Text = openFileDialog.FileName;
		}
	}

	private void btnPlayback_Click(object sender, EventArgs e)
	{
		if (File.Exists(tbPlaybackLogFiles.Text) && File.Exists(PlaybackTree))
		{
			string fileName = Path.GetFileName(PlaybackTree);
			TempPlaybackPath = "C:\\Qualcomm\\QDART\\Temp\\SmartQMatch\\" + fileName;
			if (File.Exists(TempPlaybackPath))
			{
				File.SetAttributes(TempPlaybackPath, FileAttributes.Normal);
				File.Delete(TempPlaybackPath);
			}
			File.Copy(PlaybackTree, TempPlaybackPath);
			if (File.Exists(TempPlaybackPath))
			{
				playbackTree = scheduler.OpenXTT(TempPlaybackPath);
				playbackTree.SetParameterValue("Message", "New message");
				scheduler.SetGlobalVariable(FormatDescriptorGV, FormatDescriptorName);
				scheduler.SetGlobalVariable(LimitDescriptorGV, LimitDescriptorName);
			}
		}
		StartPlayback();
	}

	private bool StartPlayback()
	{
		if (base.InvokeRequired)
		{
			BeginInvoke((MethodInvoker)delegate
			{
				StartPlayback();
			});
			return true;
		}
		playbackTree.SetParameterValue("suiteFilePath", tbPlaybackLogFiles.Text);
		try
		{
			playbackTree.SaveTree(TempPlaybackPath);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
		playbackTree.RunTree();
		return true;
	}

	private void cbRBs_SelectedIndexChanged(object sender, EventArgs e)
	{
	}

	private List<string> GetAllRefDesignators()
	{
		List<string> result = new List<string>();
		if (antennaTrialData.TrialData.RefDesignators.Count == 1 && antennaTrialData.TrialData.RefDesignators[0] == null)
		{
			return result;
		}
		result = antennaTrialData.TrialData.RefDesignators.ToList();
		foreach (List<string> item in bandClassTrialDataItems.Values.Select((TrialDataConverter t) => t.TrialData.RefDesignators).ToList())
		{
			result.AddRange(item);
		}
		return result;
	}

	private List<string> GetAllCustomRefDesignators()
	{
		List<string> list = new List<string>();
		list = antennaTrialData.GetCustomKitRefDesList().ToList();
		foreach (TrialDataConverter value in bandClassTrialDataItems.Values)
		{
			list.AddRange(value.GetCustomKitRefDesList());
		}
		return list;
	}

	private void ShowKitValueDialog(string selectedTab = null)
	{
		Dictionary<string, KitValuesConverter> dictionary = new Dictionary<string, KitValuesConverter>();
		foreach (KeyValuePair<string, KitValuesConverter> customKitValue in customKitValues)
		{
			KitValuesConverter value = new KitValuesConverter(customKitValue.Value);
			dictionary.Add(customKitValue.Key.Clone().ToString(), value);
		}
		EditKitValuesDialog editKitValuesDialog = new EditKitValuesDialog(GetAllRefDesignators(), dictionary, selectedTab);
		if (editKitValuesDialog.ShowDialog() == DialogResult.OK)
		{
			customKitValues = editKitValuesDialog.KitValues;
			HandleRemoveKitValues(editKitValuesDialog.RemovedItems);
			HandleAddedKitValues(editKitValuesDialog.AddedItems);
			GenerateKitFiles();
			UpdateScenarioModifiedStatus(modified: true);
		}
	}

	private void HandleAddedKitValues(List<string> addedItems)
	{
		if (addedItems.Count <= 0)
		{
			return;
		}
		foreach (string addedItem in addedItems)
		{
			if (antennaTrialData.TrialData.RefDesignators.Contains(addedItem))
			{
				int index = antennaTrialData.TrialData.RefDesignators.IndexOf(addedItem);
				antennaTrialData.TrialDataTable.Rows[index][1] = true;
				dgAntennaGrid.CancelEdit();
				continue;
			}
			foreach (TrialDataConverter trialData in bandClassTrialDataItems.Values)
			{
				if (trialData.TrialData.RefDesignators.Contains(addedItem))
				{
					int index2 = trialData.TrialData.RefDesignators.IndexOf(addedItem);
					trialData.TrialDataTable.Rows[index2][1] = true;
					(from t in bcTrialControls
						where t.Key == trialData.TrialData.Name
						select t.Value).FirstOrDefault().dgBandTrials.CancelEdit();
					break;
				}
			}
		}
	}

	private void HandleRemoveKitValues(List<string> removedItems)
	{
		if (removedItems.Count <= 0)
		{
			return;
		}
		List<string> list = customKitValues.Select((KeyValuePair<string, KitValuesConverter> t) => t.Key).ToList();
		foreach (string removedItem in removedItems)
		{
			if (list.Contains(removedItem))
			{
				continue;
			}
			if (antennaTrialData.TrialData.RefDesignators.Contains(removedItem))
			{
				int index = antennaTrialData.TrialData.RefDesignators.IndexOf(removedItem);
				antennaTrialData.TrialDataTable.Rows[index][1] = false;
				dgAntennaGrid.CancelEdit();
				continue;
			}
			foreach (TrialDataConverter trialData in bandClassTrialDataItems.Values)
			{
				if (trialData.TrialData.RefDesignators.Contains(removedItem))
				{
					int index2 = trialData.TrialData.RefDesignators.IndexOf(removedItem);
					trialData.TrialDataTable.Rows[index2][1] = false;
					(from t in bcTrialControls
						where t.Key == trialData.TrialData.Name
						select t.Value).FirstOrDefault().dgBandTrials.CancelEdit();
					break;
				}
			}
		}
	}

	private void btnEditKitValues_Click(object sender, EventArgs e)
	{
		ShowKitValueDialog();
	}

	private void ShowChannelEditDialog()
	{
		mandatoryChannels = GetReferenceChannelsPerBand();
		EditBandChannels editBandChannels = new EditBandChannels(currentCheckedBCNames, userSelectedChannels, defaultBandClassChannels, mandatoryChannels);
		if (editBandChannels.ShowDialog() != DialogResult.OK || editBandChannels.BandsChanged.Count <= 0)
		{
			return;
		}
		UpdateScenarioModifiedStatus(modified: true);
		userSelectedChannels = editBandChannels.UserSelectedChannels;
		foreach (string item in editBandChannels.BandsChanged)
		{
			string[] value = editBandChannels.UserSelectedChannels[item];
			string paramvalue = string.Join(",", value);
			string testname = "QMatchTool_LTE_" + item;
			xttTree.SetParameterValue("Channel List", paramvalue, testname);
		}
	}

	private Dictionary<string, string> GetReferenceChannelsPerBand()
	{
		Dictionary<string, string> dictionary = new Dictionary<string, string>();
		foreach (string currentCheckedBCName in currentCheckedBCNames)
		{
			string testName = "QMatchTool_LTE_" + currentCheckedBCName;
			string paramValue = "";
			xttTree.GetParameterValue(testName, "Reference Channel", out paramValue);
			dictionary.Add(currentCheckedBCName, paramValue);
		}
		return dictionary;
	}

	private void btnEditChannels_Click(object sender, EventArgs e)
	{
		ShowChannelEditDialog();
	}

	private void UpdateDefaultBandClassChannels(List<string> addedBandClasses = null)
	{
		if (addedBandClasses == null)
		{
			defaultBandClassChannels.Clear();
			addedBandClasses = bandClassTrialDataItems.Keys.ToList();
		}
		foreach (string addedBandClass in addedBandClasses)
		{
			string paramValue = "";
			string testName = "QMatchTool_LTE_" + addedBandClass;
			try
			{
				xttTree.GetParameterValue(testName, "Channel List", out paramValue);
				string[] array = paramValue.Split(new string[1] { "," }, StringSplitOptions.RemoveEmptyEntries);
				if (array.Length > 0)
				{
					if (!defaultBandClassChannels.ContainsKey(addedBandClass))
					{
						defaultBandClassChannels.Add(addedBandClass, array);
					}
					else
					{
						defaultBandClassChannels[addedBandClass] = array;
					}
				}
			}
			catch
			{
			}
		}
	}

	private void UpdateUserSelectedChannelsFromScenario(UserScenarioData scenarioData)
	{
		userSelectedChannels.Clear();
		List<string> selectedBandClasses = new List<string>();
		foreach (ListViewItem checkedItem in lvBandClasses.CheckedItems)
		{
			string item = checkedItem.Text;
			selectedBandClasses.Add(item);
		}
		List<BandClassInfo> list = scenarioData.BandClassesInfo.Where((BandClassInfo t) => !selectedBandClasses.Contains(t.StrBandClass)).ToList();
		foreach (BandClassInfo item2 in list)
		{
			scenarioData.BandClassesInfo.Remove(item2);
		}
		foreach (string bandClass in selectedBandClasses)
		{
			List<BandClassInfo> bandClassesInfo = scenarioData.BandClassesInfo;
			Func<BandClassInfo, bool> predicate = (BandClassInfo t) => t.StrBandClass == bandClass;
			BandClassInfo bandClassInfo = bandClassesInfo.Where(predicate).FirstOrDefault();
			if (bandClassInfo == null)
			{
				scenarioData.BandClassesInfo.Add(new BandClassInfo
				{
					StrBandClass = bandClass,
					StrChannels = defaultBandClassChannels[bandClass]
				});
			}
			else if (bandClassInfo.StrChannels.Length < 1)
			{
				bandClassInfo.StrChannels = defaultBandClassChannels[bandClass];
			}
			userSelectedChannels.Add(bandClass, (string[])bandClassInfo.StrChannels.Clone());
		}
	}

	private void UpdateScenarioChannelsFromUserSelection(UserScenarioData scenarioData)
	{
		scenarioData.BandClassesInfo.Clear();
		List<string> selectedBandClasses = new List<string>();
		foreach (ListViewItem checkedItem in lvBandClasses.CheckedItems)
		{
			string item = checkedItem.Text;
			selectedBandClasses.Add(item);
		}
		List<string> list = (from t in userSelectedChannels
			where !selectedBandClasses.Contains(t.Key)
			select t.Key).ToList();
		foreach (string item2 in list)
		{
			userSelectedChannels.Remove(item2);
		}
		foreach (string item3 in selectedBandClasses)
		{
			if (userSelectedChannels.ContainsKey(item3))
			{
				if (userSelectedChannels[item3].Length < 1)
				{
					userSelectedChannels[item3] = defaultBandClassChannels[item3];
				}
			}
			else
			{
				userSelectedChannels.Add(item3, defaultBandClassChannels[item3]);
			}
			scenarioData.BandClassesInfo.Add(new BandClassInfo
			{
				StrBandClass = item3,
				StrChannels = (string[])userSelectedChannels[item3].Clone()
			});
		}
	}

	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();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
		System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QC.SmartMatchApp.SmartMatchGUI));
		this.tabCtrlSmartMatch = new System.Windows.Forms.TabControl();
		this.tabPageSmartMatch = new System.Windows.Forms.TabPage();
		this.groupBox8 = new System.Windows.Forms.GroupBox();
		this.tabCtrlTopMatches = new System.Windows.Forms.TabControl();
		this.tabPageAntenna = new System.Windows.Forms.TabPage();
		this.dgAntennaTopMatches = new System.Windows.Forms.DataGridView();
		this.ColumnRank = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.ColumnTrialNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.ColumnFx = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.panelLiveChartsPlugin = new System.Windows.Forms.Panel();
		this.tabPageTrialData = new System.Windows.Forms.TabPage();
		this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
		this.btnRestoreScaleFactors = new System.Windows.Forms.Button();
		this.label22 = new System.Windows.Forms.Label();
		this.tbCScaleFactor = new System.Windows.Forms.TextBox();
		this.label21 = new System.Windows.Forms.Label();
		this.tbBScaleFactor = new System.Windows.Forms.TextBox();
		this.label20 = new System.Windows.Forms.Label();
		this.tbAScaleFactor = new System.Windows.Forms.TextBox();
		this.tabPageConfig = new System.Windows.Forms.TabPage();
		this.label12 = new System.Windows.Forms.Label();
		this.label13 = new System.Windows.Forms.Label();
		this.tbPoutMaxBias = new System.Windows.Forms.TextBox();
		this.groupBox7 = new System.Windows.Forms.GroupBox();
		this.cbRBs = new System.Windows.Forms.ComboBox();
		this.groupBox6 = new System.Windows.Forms.GroupBox();
		this.measurementSelection = new QC.SmartMatchApp.MeasurementSelection();
		this.groupBox5 = new System.Windows.Forms.GroupBox();
		this.label18 = new System.Windows.Forms.Label();
		this.tbChannelRef = new System.Windows.Forms.TextBox();
		this.label16 = new System.Windows.Forms.Label();
		this.label17 = new System.Windows.Forms.Label();
		this.tbChannelStop = new System.Windows.Forms.TextBox();
		this.tbChannelStart = new System.Windows.Forms.TextBox();
		this.label8 = new System.Windows.Forms.Label();
		this.groupBox4 = new System.Windows.Forms.GroupBox();
		this.label9 = new System.Windows.Forms.Label();
		this.label10 = new System.Windows.Forms.Label();
		this.label11 = new System.Windows.Forms.Label();
		this.tbDelayStep = new System.Windows.Forms.TextBox();
		this.tbDelayStop = new System.Windows.Forms.TextBox();
		this.tbDelayStart = new System.Windows.Forms.TextBox();
		this.groupBox3 = new System.Windows.Forms.GroupBox();
		this.label7 = new System.Windows.Forms.Label();
		this.label6 = new System.Windows.Forms.Label();
		this.label5 = new System.Windows.Forms.Label();
		this.label2 = new System.Windows.Forms.Label();
		this.tbRGIStep = new System.Windows.Forms.TextBox();
		this.tbRGIStop = new System.Windows.Forms.TextBox();
		this.tbRGIStart = new System.Windows.Forms.TextBox();
		this.btnRGI = new System.Windows.Forms.Button();
		this.tbRGIFile = new System.Windows.Forms.TextBox();
		this.groupBox2 = new System.Windows.Forms.GroupBox();
		this.cbPAGain = new System.Windows.Forms.ComboBox();
		this.groupBox1 = new System.Windows.Forms.GroupBox();
		this.cbEPT = new System.Windows.Forms.CheckBox();
		this.cbET = new System.Windows.Forms.CheckBox();
		this.label3 = new System.Windows.Forms.Label();
		this.tbPinPoutMax = new System.Windows.Forms.TextBox();
		this.label1 = new System.Windows.Forms.Label();
		this.btnPAFile = new System.Windows.Forms.Button();
		this.tbPAParamsFile = new System.Windows.Forms.TextBox();
		this.tabPageDebug = new System.Windows.Forms.TabPage();
		this.gvViewerCtrl = new QC.SmartMatchApp.GVViewerCtrl();
		this.richTextBox2 = new System.Windows.Forms.RichTextBox();
		this.label19 = new System.Windows.Forms.Label();
		this.btnClearDebugText = new System.Windows.Forms.Button();
		this.checkBoxAutoScroll = new System.Windows.Forms.CheckBox();
		this.richTextBox1 = new System.Windows.Forms.RichTextBox();
		this.tabPagePlayBack = new System.Windows.Forms.TabPage();
		this.btnPlayback = new System.Windows.Forms.Button();
		this.label23 = new System.Windows.Forms.Label();
		this.btnPlaybackLogFiles = new System.Windows.Forms.Button();
		this.tbPlaybackLogFiles = new System.Windows.Forms.TextBox();
		this.label14 = new System.Windows.Forms.Label();
		this.DisplayGrid = new System.Windows.Forms.DataGridView();
		this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.TxOut = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.btnEditKitValues = new System.Windows.Forms.Button();
		this.label4 = new System.Windows.Forms.Label();
		this.btnSelectTech = new System.Windows.Forms.Button();
		this.btnStop = new System.Windows.Forms.Button();
		this.btnStartMatch = new System.Windows.Forms.Button();
		this.btnFormatDescriptor = new System.Windows.Forms.Button();
		this.btnLogPath = new System.Windows.Forms.Button();
		this.menuStrip1 = new System.Windows.Forms.MenuStrip();
		this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
		this.tsmFileOpen = new System.Windows.Forms.ToolStripMenuItem();
		this.tsmFileSave = new System.Windows.Forms.ToolStripMenuItem();
		this.tsmFileSaveAs = new System.Windows.Forms.ToolStripMenuItem();
		this.tsmFileExit = new System.Windows.Forms.ToolStripMenuItem();
		this.tsSimulationMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.tsEnableSimulationMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.tbXttPath = new System.Windows.Forms.TextBox();
		this.label15 = new System.Windows.Forms.Label();
		this.btnResumeMatch = new System.Windows.Forms.Button();
		this.labelTestStatus = new System.Windows.Forms.Label();
		this.btnSwitchLang = new System.Windows.Forms.Button();
		this.lvBandClasses = new System.Windows.Forms.ListView();
		this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
		this.btnEditChannels = new System.Windows.Forms.Button();
		this.tabCtrlSmartMatch.SuspendLayout();
		this.tabPageSmartMatch.SuspendLayout();
		this.groupBox8.SuspendLayout();
		this.tabCtrlTopMatches.SuspendLayout();
		this.tabPageAntenna.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.dgAntennaTopMatches).BeginInit();
		this.tabPageTrialData.SuspendLayout();
		this.tabPageConfig.SuspendLayout();
		this.groupBox7.SuspendLayout();
		this.groupBox6.SuspendLayout();
		this.groupBox5.SuspendLayout();
		this.groupBox4.SuspendLayout();
		this.groupBox3.SuspendLayout();
		this.groupBox2.SuspendLayout();
		this.groupBox1.SuspendLayout();
		this.tabPageDebug.SuspendLayout();
		this.tabPagePlayBack.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.DisplayGrid).BeginInit();
		this.menuStrip1.SuspendLayout();
		base.SuspendLayout();
		this.tabCtrlSmartMatch.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.tabCtrlSmartMatch.Controls.Add(this.tabPageSmartMatch);
		this.tabCtrlSmartMatch.Controls.Add(this.tabPageTrialData);
		this.tabCtrlSmartMatch.Controls.Add(this.tabPageConfig);
		this.tabCtrlSmartMatch.Controls.Add(this.tabPageDebug);
		this.tabCtrlSmartMatch.Controls.Add(this.tabPagePlayBack);
		this.tabCtrlSmartMatch.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.tabCtrlSmartMatch.Location = new System.Drawing.Point(153, 123);
		this.tabCtrlSmartMatch.Name = "tabCtrlSmartMatch";
		this.tabCtrlSmartMatch.SelectedIndex = 0;
		this.tabCtrlSmartMatch.Size = new System.Drawing.Size(931, 575);
		this.tabCtrlSmartMatch.TabIndex = 28;
		this.tabPageSmartMatch.BackColor = System.Drawing.Color.Transparent;
		this.tabPageSmartMatch.Controls.Add(this.groupBox8);
		this.tabPageSmartMatch.Controls.Add(this.panelLiveChartsPlugin);
		this.tabPageSmartMatch.Location = new System.Drawing.Point(4, 25);
		this.tabPageSmartMatch.Name = "tabPageSmartMatch";
		this.tabPageSmartMatch.Padding = new System.Windows.Forms.Padding(3);
		this.tabPageSmartMatch.Size = new System.Drawing.Size(923, 546);
		this.tabPageSmartMatch.TabIndex = 2;
		this.tabPageSmartMatch.Text = "Smart Match";
		this.groupBox8.Controls.Add(this.tabCtrlTopMatches);
		this.groupBox8.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.groupBox8.Location = new System.Drawing.Point(6, 6);
		this.groupBox8.Name = "groupBox8";
		this.groupBox8.Size = new System.Drawing.Size(352, 153);
		this.groupBox8.TabIndex = 47;
		this.groupBox8.TabStop = false;
		this.groupBox8.Text = "Top Matches";
		this.tabCtrlTopMatches.Controls.Add(this.tabPageAntenna);
		this.tabCtrlTopMatches.Location = new System.Drawing.Point(6, 23);
		this.tabCtrlTopMatches.Name = "tabCtrlTopMatches";
		this.tabCtrlTopMatches.SelectedIndex = 0;
		this.tabCtrlTopMatches.Size = new System.Drawing.Size(339, 128);
		this.tabCtrlTopMatches.TabIndex = 46;
		this.tabPageAntenna.Controls.Add(this.dgAntennaTopMatches);
		this.tabPageAntenna.Location = new System.Drawing.Point(4, 25);
		this.tabPageAntenna.Name = "tabPageAntenna";
		this.tabPageAntenna.Padding = new System.Windows.Forms.Padding(3);
		this.tabPageAntenna.Size = new System.Drawing.Size(331, 99);
		this.tabPageAntenna.TabIndex = 0;
		this.tabPageAntenna.Text = "Antenna";
		this.dgAntennaTopMatches.AllowUserToAddRows = false;
		this.dgAntennaTopMatches.AllowUserToDeleteRows = false;
		this.dgAntennaTopMatches.AllowUserToResizeRows = false;
		this.dgAntennaTopMatches.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
		this.dgAntennaTopMatches.Columns.AddRange(this.ColumnRank, this.ColumnTrialNum, this.ColumnFx);
		this.dgAntennaTopMatches.Location = new System.Drawing.Point(3, 3);
		this.dgAntennaTopMatches.MultiSelect = false;
		this.dgAntennaTopMatches.Name = "dgAntennaTopMatches";
		this.dgAntennaTopMatches.ReadOnly = true;
		this.dgAntennaTopMatches.RowHeadersVisible = false;
		this.dgAntennaTopMatches.ScrollBars = System.Windows.Forms.ScrollBars.None;
		this.dgAntennaTopMatches.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
		this.dgAntennaTopMatches.Size = new System.Drawing.Size(322, 89);
		this.dgAntennaTopMatches.TabIndex = 44;
		this.ColumnRank.HeaderText = "Rank";
		this.ColumnRank.Name = "ColumnRank";
		this.ColumnRank.ReadOnly = true;
		this.ColumnTrialNum.HeaderText = "Trial Number";
		this.ColumnTrialNum.Name = "ColumnTrialNum";
		this.ColumnTrialNum.ReadOnly = true;
		this.ColumnFx.HeaderText = "F(x)";
		this.ColumnFx.Name = "ColumnFx";
		this.ColumnFx.ReadOnly = true;
		this.panelLiveChartsPlugin.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.panelLiveChartsPlugin.Location = new System.Drawing.Point(6, 163);
		this.panelLiveChartsPlugin.Name = "panelLiveChartsPlugin";
		this.panelLiveChartsPlugin.Size = new System.Drawing.Size(911, 377);
		this.panelLiveChartsPlugin.TabIndex = 43;
		this.tabPageTrialData.AutoScroll = true;
		this.tabPageTrialData.Controls.Add(this.tableLayoutPanel1);
		this.tabPageTrialData.Controls.Add(this.btnRestoreScaleFactors);
		this.tabPageTrialData.Controls.Add(this.label22);
		this.tabPageTrialData.Controls.Add(this.tbCScaleFactor);
		this.tabPageTrialData.Controls.Add(this.label21);
		this.tabPageTrialData.Controls.Add(this.tbBScaleFactor);
		this.tabPageTrialData.Controls.Add(this.label20);
		this.tabPageTrialData.Controls.Add(this.tbAScaleFactor);
		this.tabPageTrialData.Location = new System.Drawing.Point(4, 25);
		this.tabPageTrialData.Name = "tabPageTrialData";
		this.tabPageTrialData.Padding = new System.Windows.Forms.Padding(3);
		this.tabPageTrialData.Size = new System.Drawing.Size(923, 546);
		this.tabPageTrialData.TabIndex = 0;
		this.tabPageTrialData.Text = "Part A Trial";
		this.tabPageTrialData.UseVisualStyleBackColor = true;
		this.tableLayoutPanel1.AutoScroll = true;
		this.tableLayoutPanel1.ColumnCount = 1;
		this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f));
		this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.tableLayoutPanel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3);
		this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
		this.tableLayoutPanel1.Name = "tableLayoutPanel1";
		this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20f));
		this.tableLayoutPanel1.Size = new System.Drawing.Size(900, 1341);
		this.tableLayoutPanel1.TabIndex = 50;
		this.btnRestoreScaleFactors.Location = new System.Drawing.Point(636, 1324);
		this.btnRestoreScaleFactors.Margin = new System.Windows.Forms.Padding(0);
		this.btnRestoreScaleFactors.Name = "btnRestoreScaleFactors";
		this.btnRestoreScaleFactors.Size = new System.Drawing.Size(99, 22);
		this.btnRestoreScaleFactors.TabIndex = 49;
		this.btnRestoreScaleFactors.Text = "Restore Defaults";
		this.btnRestoreScaleFactors.UseVisualStyleBackColor = true;
		this.btnRestoreScaleFactors.Visible = false;
		this.btnRestoreScaleFactors.Click += new System.EventHandler(btnRestoreScaleFactors_Click);
		this.label22.AutoSize = true;
		this.label22.Location = new System.Drawing.Point(473, 1310);
		this.label22.Margin = new System.Windows.Forms.Padding(0);
		this.label22.Name = "label22";
		this.label22.Size = new System.Drawing.Size(88, 16);
		this.label22.TabIndex = 48;
		this.label22.Text = "cScaleFactor";
		this.label22.Visible = false;
		this.tbCScaleFactor.Location = new System.Drawing.Point(468, 1325);
		this.tbCScaleFactor.Margin = new System.Windows.Forms.Padding(0);
		this.tbCScaleFactor.Name = "tbCScaleFactor";
		this.tbCScaleFactor.Size = new System.Drawing.Size(103, 22);
		this.tbCScaleFactor.TabIndex = 47;
		this.tbCScaleFactor.Text = "1000";
		this.tbCScaleFactor.Visible = false;
		this.tbCScaleFactor.TextChanged += new System.EventHandler(tbCScaleFactor_TextChanged);
		this.label21.AutoSize = true;
		this.label21.Location = new System.Drawing.Point(314, 1310);
		this.label21.Margin = new System.Windows.Forms.Padding(0);
		this.label21.Name = "label21";
		this.label21.Size = new System.Drawing.Size(89, 16);
		this.label21.TabIndex = 46;
		this.label21.Text = "bScaleFactor";
		this.label21.Visible = false;
		this.tbBScaleFactor.Location = new System.Drawing.Point(309, 1325);
		this.tbBScaleFactor.Margin = new System.Windows.Forms.Padding(0);
		this.tbBScaleFactor.Name = "tbBScaleFactor";
		this.tbBScaleFactor.Size = new System.Drawing.Size(103, 22);
		this.tbBScaleFactor.TabIndex = 45;
		this.tbBScaleFactor.Text = "2.0";
		this.tbBScaleFactor.Visible = false;
		this.tbBScaleFactor.TextChanged += new System.EventHandler(tbBScaleFactor_TextChanged);
		this.label20.AutoSize = true;
		this.label20.Location = new System.Drawing.Point(154, 1310);
		this.label20.Margin = new System.Windows.Forms.Padding(0);
		this.label20.Name = "label20";
		this.label20.Size = new System.Drawing.Size(89, 16);
		this.label20.TabIndex = 44;
		this.label20.Text = "aScaleFactor";
		this.label20.Visible = false;
		this.tbAScaleFactor.Location = new System.Drawing.Point(149, 1325);
		this.tbAScaleFactor.Margin = new System.Windows.Forms.Padding(0);
		this.tbAScaleFactor.Name = "tbAScaleFactor";
		this.tbAScaleFactor.Size = new System.Drawing.Size(103, 22);
		this.tbAScaleFactor.TabIndex = 43;
		this.tbAScaleFactor.Text = "2.5";
		this.tbAScaleFactor.Visible = false;
		this.tbAScaleFactor.TextChanged += new System.EventHandler(tbAScaleFactor_TextChanged);
		this.tabPageConfig.Controls.Add(this.label12);
		this.tabPageConfig.Controls.Add(this.label13);
		this.tabPageConfig.Controls.Add(this.tbPoutMaxBias);
		this.tabPageConfig.Controls.Add(this.groupBox7);
		this.tabPageConfig.Controls.Add(this.groupBox6);
		this.tabPageConfig.Controls.Add(this.groupBox5);
		this.tabPageConfig.Controls.Add(this.label8);
		this.tabPageConfig.Controls.Add(this.groupBox4);
		this.tabPageConfig.Controls.Add(this.groupBox3);
		this.tabPageConfig.Controls.Add(this.groupBox2);
		this.tabPageConfig.Controls.Add(this.groupBox1);
		this.tabPageConfig.Controls.Add(this.label3);
		this.tabPageConfig.Controls.Add(this.tbPinPoutMax);
		this.tabPageConfig.Controls.Add(this.label1);
		this.tabPageConfig.Controls.Add(this.btnPAFile);
		this.tabPageConfig.Controls.Add(this.tbPAParamsFile);
		this.tabPageConfig.Location = new System.Drawing.Point(4, 25);
		this.tabPageConfig.Name = "tabPageConfig";
		this.tabPageConfig.Padding = new System.Windows.Forms.Padding(3);
		this.tabPageConfig.Size = new System.Drawing.Size(923, 546);
		this.tabPageConfig.TabIndex = 1;
		this.tabPageConfig.Text = "QMatch Config";
		this.tabPageConfig.UseVisualStyleBackColor = true;
		this.label12.AutoSize = true;
		this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.label12.Location = new System.Drawing.Point(512, 150);
		this.label12.Name = "label12";
		this.label12.Size = new System.Drawing.Size(14, 13);
		this.label12.TabIndex = 66;
		this.label12.Text = "V";
		this.label13.AutoSize = true;
		this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.label13.Location = new System.Drawing.Point(438, 132);
		this.label13.Name = "label13";
		this.label13.Size = new System.Drawing.Size(75, 13);
		this.label13.TabIndex = 65;
		this.label13.Text = "Pout Max Bias";
		this.tbPoutMaxBias.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.tbPoutMaxBias.Location = new System.Drawing.Point(437, 147);
		this.tbPoutMaxBias.Name = "tbPoutMaxBias";
		this.tbPoutMaxBias.Size = new System.Drawing.Size(68, 20);
		this.tbPoutMaxBias.TabIndex = 64;
		this.tbPoutMaxBias.Text = "3.8";
		this.tbPoutMaxBias.TextChanged += new System.EventHandler(tbPoutMaxBias_TextChanged);
		this.groupBox7.Controls.Add(this.cbRBs);
		this.groupBox7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.groupBox7.Location = new System.Drawing.Point(437, 239);
		this.groupBox7.Name = "groupBox7";
		this.groupBox7.Size = new System.Drawing.Size(144, 65);
		this.groupBox7.TabIndex = 63;
		this.groupBox7.TabStop = false;
		this.groupBox7.Text = "RBs";
		this.cbRBs.Enabled = false;
		this.cbRBs.FormattingEnabled = true;
		this.cbRBs.Items.AddRange(new object[3] { "6 Rbs", "12 Rbs", "50 Rbs" });
		this.cbRBs.Location = new System.Drawing.Point(9, 26);
		this.cbRBs.Name = "cbRBs";
		this.cbRBs.Size = new System.Drawing.Size(125, 21);
		this.cbRBs.TabIndex = 0;
		this.cbRBs.SelectedIndexChanged += new System.EventHandler(cbRBs_SelectedIndexChanged);
		this.groupBox6.Controls.Add(this.measurementSelection);
		this.groupBox6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.groupBox6.Location = new System.Drawing.Point(36, 312);
		this.groupBox6.Name = "groupBox6";
		this.groupBox6.Size = new System.Drawing.Size(625, 221);
		this.groupBox6.TabIndex = 62;
		this.groupBox6.TabStop = false;
		this.groupBox6.Text = "Smart Match Measurement Setup";
		this.measurementSelection.Location = new System.Drawing.Point(8, 23);
		this.measurementSelection.Margin = new System.Windows.Forms.Padding(4);
		this.measurementSelection.Name = "measurementSelection";
		this.measurementSelection.Size = new System.Drawing.Size(801, 224);
		this.measurementSelection.TabIndex = 0;
		this.groupBox5.Controls.Add(this.label18);
		this.groupBox5.Controls.Add(this.tbChannelRef);
		this.groupBox5.Controls.Add(this.label16);
		this.groupBox5.Controls.Add(this.label17);
		this.groupBox5.Controls.Add(this.tbChannelStop);
		this.groupBox5.Controls.Add(this.tbChannelStart);
		this.groupBox5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.groupBox5.Location = new System.Drawing.Point(51, 18);
		this.groupBox5.Name = "groupBox5";
		this.groupBox5.Size = new System.Drawing.Size(214, 100);
		this.groupBox5.TabIndex = 60;
		this.groupBox5.TabStop = false;
		this.groupBox5.Text = "Frequency";
		this.label18.AutoSize = true;
		this.label18.Location = new System.Drawing.Point(148, 36);
		this.label18.Name = "label18";
		this.label18.Size = new System.Drawing.Size(24, 13);
		this.label18.TabIndex = 28;
		this.label18.Text = "Ref";
		this.tbChannelRef.Enabled = false;
		this.tbChannelRef.Location = new System.Drawing.Point(143, 52);
		this.tbChannelRef.Name = "tbChannelRef";
		this.tbChannelRef.Size = new System.Drawing.Size(50, 20);
		this.tbChannelRef.TabIndex = 27;
		this.tbChannelRef.Text = "1950";
		this.label16.AutoSize = true;
		this.label16.Location = new System.Drawing.Point(75, 36);
		this.label16.Name = "label16";
		this.label16.Size = new System.Drawing.Size(29, 13);
		this.label16.TabIndex = 26;
		this.label16.Text = "Stop";
		this.label17.AutoSize = true;
		this.label17.Location = new System.Drawing.Point(6, 36);
		this.label17.Name = "label17";
		this.label17.Size = new System.Drawing.Size(29, 13);
		this.label17.TabIndex = 25;
		this.label17.Text = "Start";
		this.tbChannelStop.Enabled = false;
		this.tbChannelStop.Location = new System.Drawing.Point(70, 52);
		this.tbChannelStop.Name = "tbChannelStop";
		this.tbChannelStop.Size = new System.Drawing.Size(50, 20);
		this.tbChannelStop.TabIndex = 23;
		this.tbChannelStop.Text = "1980";
		this.tbChannelStart.Enabled = false;
		this.tbChannelStart.Location = new System.Drawing.Point(4, 52);
		this.tbChannelStart.Name = "tbChannelStart";
		this.tbChannelStart.Size = new System.Drawing.Size(50, 20);
		this.tbChannelStart.TabIndex = 22;
		this.tbChannelStart.Text = "1920";
		this.label8.AutoSize = true;
		this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.label8.Location = new System.Drawing.Point(653, 150);
		this.label8.Name = "label8";
		this.label8.Size = new System.Drawing.Size(14, 13);
		this.label8.TabIndex = 59;
		this.label8.Text = "V";
		this.label8.Visible = false;
		this.groupBox4.Controls.Add(this.label9);
		this.groupBox4.Controls.Add(this.label10);
		this.groupBox4.Controls.Add(this.label11);
		this.groupBox4.Controls.Add(this.tbDelayStep);
		this.groupBox4.Controls.Add(this.tbDelayStop);
		this.groupBox4.Controls.Add(this.tbDelayStart);
		this.groupBox4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.groupBox4.Location = new System.Drawing.Point(435, 18);
		this.groupBox4.Name = "groupBox4";
		this.groupBox4.Size = new System.Drawing.Size(208, 100);
		this.groupBox4.TabIndex = 58;
		this.groupBox4.TabStop = false;
		this.groupBox4.Text = "Delay Sweep";
		this.label9.AutoSize = true;
		this.label9.Location = new System.Drawing.Point(140, 36);
		this.label9.Name = "label9";
		this.label9.Size = new System.Drawing.Size(29, 13);
		this.label9.TabIndex = 27;
		this.label9.Text = "Step";
		this.label10.AutoSize = true;
		this.label10.Location = new System.Drawing.Point(75, 36);
		this.label10.Name = "label10";
		this.label10.Size = new System.Drawing.Size(29, 13);
		this.label10.TabIndex = 26;
		this.label10.Text = "Stop";
		this.label11.AutoSize = true;
		this.label11.Location = new System.Drawing.Point(6, 36);
		this.label11.Name = "label11";
		this.label11.Size = new System.Drawing.Size(29, 13);
		this.label11.TabIndex = 25;
		this.label11.Text = "Start";
		this.tbDelayStep.Location = new System.Drawing.Point(143, 52);
		this.tbDelayStep.Name = "tbDelayStep";
		this.tbDelayStep.Size = new System.Drawing.Size(50, 20);
		this.tbDelayStep.TabIndex = 24;
		this.tbDelayStep.Text = "5";
		this.tbDelayStep.TextChanged += new System.EventHandler(tbDelayStep_TextChanged);
		this.tbDelayStop.Location = new System.Drawing.Point(70, 52);
		this.tbDelayStop.Name = "tbDelayStop";
		this.tbDelayStop.Size = new System.Drawing.Size(50, 20);
		this.tbDelayStop.TabIndex = 23;
		this.tbDelayStop.Text = "1400";
		this.tbDelayStop.TextChanged += new System.EventHandler(tbDelayStop_TextChanged);
		this.tbDelayStart.Location = new System.Drawing.Point(4, 52);
		this.tbDelayStart.Name = "tbDelayStart";
		this.tbDelayStart.Size = new System.Drawing.Size(50, 20);
		this.tbDelayStart.TabIndex = 22;
		this.tbDelayStart.Text = "1100";
		this.tbDelayStart.TextChanged += new System.EventHandler(tbDelayStart_TextChanged);
		this.groupBox3.Controls.Add(this.label7);
		this.groupBox3.Controls.Add(this.label6);
		this.groupBox3.Controls.Add(this.label5);
		this.groupBox3.Controls.Add(this.label2);
		this.groupBox3.Controls.Add(this.tbRGIStep);
		this.groupBox3.Controls.Add(this.tbRGIStop);
		this.groupBox3.Controls.Add(this.tbRGIStart);
		this.groupBox3.Controls.Add(this.btnRGI);
		this.groupBox3.Controls.Add(this.tbRGIFile);
		this.groupBox3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.groupBox3.Location = new System.Drawing.Point(51, 147);
		this.groupBox3.Name = "groupBox3";
		this.groupBox3.Size = new System.Drawing.Size(346, 148);
		this.groupBox3.TabIndex = 57;
		this.groupBox3.TabStop = false;
		this.groupBox3.Text = "RGI Settings";
		this.label7.AutoSize = true;
		this.label7.Location = new System.Drawing.Point(6, 90);
		this.label7.Name = "label7";
		this.label7.Size = new System.Drawing.Size(93, 13);
		this.label7.TabIndex = 28;
		this.label7.Text = "AMSS Source File";
		this.label7.Visible = false;
		this.label6.AutoSize = true;
		this.label6.Location = new System.Drawing.Point(140, 36);
		this.label6.Name = "label6";
		this.label6.Size = new System.Drawing.Size(29, 13);
		this.label6.TabIndex = 27;
		this.label6.Text = "Step";
		this.label5.AutoSize = true;
		this.label5.Location = new System.Drawing.Point(75, 36);
		this.label5.Name = "label5";
		this.label5.Size = new System.Drawing.Size(29, 13);
		this.label5.TabIndex = 26;
		this.label5.Text = "Stop";
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(6, 36);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(29, 13);
		this.label2.TabIndex = 25;
		this.label2.Text = "Start";
		this.tbRGIStep.Location = new System.Drawing.Point(143, 52);
		this.tbRGIStep.Name = "tbRGIStep";
		this.tbRGIStep.Size = new System.Drawing.Size(50, 20);
		this.tbRGIStep.TabIndex = 24;
		this.tbRGIStep.Text = "1";
		this.tbRGIStep.TextChanged += new System.EventHandler(tbRGIStep_TextChanged);
		this.tbRGIStop.Location = new System.Drawing.Point(70, 52);
		this.tbRGIStop.Name = "tbRGIStop";
		this.tbRGIStop.Size = new System.Drawing.Size(50, 20);
		this.tbRGIStop.TabIndex = 23;
		this.tbRGIStop.Text = "96";
		this.tbRGIStop.TextChanged += new System.EventHandler(tbRGIStop_TextChanged);
		this.tbRGIStart.Location = new System.Drawing.Point(4, 52);
		this.tbRGIStart.Name = "tbRGIStart";
		this.tbRGIStart.Size = new System.Drawing.Size(50, 20);
		this.tbRGIStart.TabIndex = 22;
		this.tbRGIStart.Text = "70";
		this.tbRGIStart.TextChanged += new System.EventHandler(tbRGIStart_TextChanged);
		this.btnRGI.Enabled = false;
		this.btnRGI.Location = new System.Drawing.Point(273, 106);
		this.btnRGI.Name = "btnRGI";
		this.btnRGI.Size = new System.Drawing.Size(41, 23);
		this.btnRGI.TabIndex = 7;
		this.btnRGI.Text = "...";
		this.btnRGI.UseVisualStyleBackColor = true;
		this.btnRGI.Visible = false;
		this.tbRGIFile.Enabled = false;
		this.tbRGIFile.Location = new System.Drawing.Point(4, 106);
		this.tbRGIFile.Name = "tbRGIFile";
		this.tbRGIFile.Size = new System.Drawing.Size(256, 20);
		this.tbRGIFile.TabIndex = 5;
		this.tbRGIFile.Visible = false;
		this.groupBox2.Controls.Add(this.cbPAGain);
		this.groupBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.groupBox2.Location = new System.Drawing.Point(657, 46);
		this.groupBox2.Name = "groupBox2";
		this.groupBox2.Size = new System.Drawing.Size(156, 72);
		this.groupBox2.TabIndex = 56;
		this.groupBox2.TabStop = false;
		this.groupBox2.Text = "PA Gain State";
		this.cbPAGain.FormattingEnabled = true;
		this.cbPAGain.Items.AddRange(new object[8] { "0", "1", "2", "3", "4", "5", "6", "7" });
		this.cbPAGain.Location = new System.Drawing.Point(16, 28);
		this.cbPAGain.Name = "cbPAGain";
		this.cbPAGain.Size = new System.Drawing.Size(121, 21);
		this.cbPAGain.TabIndex = 64;
		this.cbPAGain.SelectedIndexChanged += new System.EventHandler(cbPAGain_SelectedIndexChanged);
		this.groupBox1.Controls.Add(this.cbEPT);
		this.groupBox1.Controls.Add(this.cbET);
		this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.groupBox1.Location = new System.Drawing.Point(661, 244);
		this.groupBox1.Name = "groupBox1";
		this.groupBox1.Size = new System.Drawing.Size(137, 60);
		this.groupBox1.TabIndex = 55;
		this.groupBox1.TabStop = false;
		this.groupBox1.Text = "Power Tracking Mode";
		this.cbEPT.AutoSize = true;
		this.cbEPT.Location = new System.Drawing.Point(69, 30);
		this.cbEPT.Name = "cbEPT";
		this.cbEPT.Size = new System.Drawing.Size(47, 17);
		this.cbEPT.TabIndex = 17;
		this.cbEPT.Text = "EPT";
		this.cbEPT.UseVisualStyleBackColor = true;
		this.cbEPT.CheckedChanged += new System.EventHandler(cbEPT_CheckedChanged);
		this.cbET.AutoSize = true;
		this.cbET.Checked = true;
		this.cbET.CheckState = System.Windows.Forms.CheckState.Checked;
		this.cbET.Location = new System.Drawing.Point(15, 30);
		this.cbET.Name = "cbET";
		this.cbET.Size = new System.Drawing.Size(40, 17);
		this.cbET.TabIndex = 16;
		this.cbET.Text = "ET";
		this.cbET.UseVisualStyleBackColor = true;
		this.cbET.CheckedChanged += new System.EventHandler(cbET_CheckedChanged);
		this.label3.AutoSize = true;
		this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.label3.Location = new System.Drawing.Point(579, 132);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(45, 13);
		this.label3.TabIndex = 50;
		this.label3.Text = "Pin Max";
		this.label3.Visible = false;
		this.tbPinPoutMax.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.tbPinPoutMax.Location = new System.Drawing.Point(578, 147);
		this.tbPinPoutMax.Name = "tbPinPoutMax";
		this.tbPinPoutMax.Size = new System.Drawing.Size(68, 20);
		this.tbPinPoutMax.TabIndex = 49;
		this.tbPinPoutMax.Text = "2.5";
		this.tbPinPoutMax.Visible = false;
		this.tbPinPoutMax.TextChanged += new System.EventHandler(tbPinPoutMax_TextChanged);
		this.label1.AutoSize = true;
		this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.label1.Location = new System.Drawing.Point(432, 180);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(78, 13);
		this.label1.TabIndex = 48;
		this.label1.Text = "PA Params File";
		this.btnPAFile.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnPAFile.Location = new System.Drawing.Point(704, 199);
		this.btnPAFile.Name = "btnPAFile";
		this.btnPAFile.Size = new System.Drawing.Size(41, 23);
		this.btnPAFile.TabIndex = 47;
		this.btnPAFile.Text = "...";
		this.btnPAFile.UseVisualStyleBackColor = true;
		this.btnPAFile.Click += new System.EventHandler(btnPAFile_Click);
		this.tbPAParamsFile.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.tbPAParamsFile.Location = new System.Drawing.Point(435, 199);
		this.tbPAParamsFile.Name = "tbPAParamsFile";
		this.tbPAParamsFile.ReadOnly = true;
		this.tbPAParamsFile.Size = new System.Drawing.Size(256, 20);
		this.tbPAParamsFile.TabIndex = 46;
		this.tbPAParamsFile.Text = "..\\RFCalInput\\RFCAL_PA_PARAM_v1.xml";
		this.tabPageDebug.Controls.Add(this.gvViewerCtrl);
		this.tabPageDebug.Controls.Add(this.richTextBox2);
		this.tabPageDebug.Controls.Add(this.label19);
		this.tabPageDebug.Controls.Add(this.btnClearDebugText);
		this.tabPageDebug.Controls.Add(this.checkBoxAutoScroll);
		this.tabPageDebug.Controls.Add(this.richTextBox1);
		this.tabPageDebug.Location = new System.Drawing.Point(4, 25);
		this.tabPageDebug.Name = "tabPageDebug";
		this.tabPageDebug.Padding = new System.Windows.Forms.Padding(3);
		this.tabPageDebug.Size = new System.Drawing.Size(923, 546);
		this.tabPageDebug.TabIndex = 4;
		this.tabPageDebug.Text = "Debug";
		this.gvViewerCtrl.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.gvViewerCtrl.Location = new System.Drawing.Point(781, 399);
		this.gvViewerCtrl.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6);
		this.gvViewerCtrl.Name = "gvViewerCtrl";
		this.gvViewerCtrl.Size = new System.Drawing.Size(427, 273);
		this.gvViewerCtrl.TabIndex = 53;
		this.richTextBox2.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.richTextBox2.Location = new System.Drawing.Point(10, 324);
		this.richTextBox2.Name = "richTextBox2";
		this.richTextBox2.Size = new System.Drawing.Size(564, 205);
		this.richTextBox2.TabIndex = 51;
		this.richTextBox2.Text = "";
		this.label19.AutoSize = true;
		this.label19.Font = new System.Drawing.Font("Microsoft Sans Serif", 14f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
		this.label19.Location = new System.Drawing.Point(6, 5);
		this.label19.Name = "label19";
		this.label19.Size = new System.Drawing.Size(172, 24);
		this.label19.TabIndex = 50;
		this.label19.Text = "Debug Messages";
		this.btnClearDebugText.Location = new System.Drawing.Point(103, 37);
		this.btnClearDebugText.Name = "btnClearDebugText";
		this.btnClearDebugText.Size = new System.Drawing.Size(75, 23);
		this.btnClearDebugText.TabIndex = 49;
		this.btnClearDebugText.Text = "Clear Text";
		this.btnClearDebugText.UseVisualStyleBackColor = true;
		this.btnClearDebugText.Click += new System.EventHandler(btnClearDebugText_Click);
		this.checkBoxAutoScroll.AutoSize = true;
		this.checkBoxAutoScroll.Checked = true;
		this.checkBoxAutoScroll.CheckState = System.Windows.Forms.CheckState.Checked;
		this.checkBoxAutoScroll.Location = new System.Drawing.Point(7, 41);
		this.checkBoxAutoScroll.Name = "checkBoxAutoScroll";
		this.checkBoxAutoScroll.Size = new System.Drawing.Size(88, 20);
		this.checkBoxAutoScroll.TabIndex = 48;
		this.checkBoxAutoScroll.Text = "AutoScroll";
		this.checkBoxAutoScroll.UseVisualStyleBackColor = true;
		this.richTextBox1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.richTextBox1.Location = new System.Drawing.Point(10, 66);
		this.richTextBox1.Name = "richTextBox1";
		this.richTextBox1.Size = new System.Drawing.Size(896, 242);
		this.richTextBox1.TabIndex = 47;
		this.richTextBox1.Text = "";
		this.tabPagePlayBack.Controls.Add(this.btnPlayback);
		this.tabPagePlayBack.Controls.Add(this.label23);
		this.tabPagePlayBack.Controls.Add(this.btnPlaybackLogFiles);
		this.tabPagePlayBack.Controls.Add(this.tbPlaybackLogFiles);
		this.tabPagePlayBack.Location = new System.Drawing.Point(4, 25);
		this.tabPagePlayBack.Name = "tabPagePlayBack";
		this.tabPagePlayBack.Padding = new System.Windows.Forms.Padding(3);
		this.tabPagePlayBack.Size = new System.Drawing.Size(923, 546);
		this.tabPagePlayBack.TabIndex = 5;
		this.tabPagePlayBack.Text = "PlayBack";
		this.tabPagePlayBack.UseVisualStyleBackColor = true;
		this.btnPlayback.Location = new System.Drawing.Point(42, 111);
		this.btnPlayback.Name = "btnPlayback";
		this.btnPlayback.Size = new System.Drawing.Size(89, 48);
		this.btnPlayback.TabIndex = 52;
		this.btnPlayback.Text = "Playback";
		this.btnPlayback.UseVisualStyleBackColor = true;
		this.btnPlayback.Click += new System.EventHandler(btnPlayback_Click);
		this.label23.AutoSize = true;
		this.label23.Location = new System.Drawing.Point(38, 34);
		this.label23.Name = "label23";
		this.label23.Size = new System.Drawing.Size(63, 16);
		this.label23.TabIndex = 51;
		this.label23.Text = "Log Files";
		this.label23.Visible = false;
		this.btnPlaybackLogFiles.Location = new System.Drawing.Point(310, 53);
		this.btnPlaybackLogFiles.Name = "btnPlaybackLogFiles";
		this.btnPlaybackLogFiles.Size = new System.Drawing.Size(41, 23);
		this.btnPlaybackLogFiles.TabIndex = 50;
		this.btnPlaybackLogFiles.Text = "...";
		this.btnPlaybackLogFiles.UseVisualStyleBackColor = true;
		this.btnPlaybackLogFiles.Click += new System.EventHandler(btnPlaybackLogFiles_Click);
		this.tbPlaybackLogFiles.Enabled = false;
		this.tbPlaybackLogFiles.Location = new System.Drawing.Point(41, 53);
		this.tbPlaybackLogFiles.Name = "tbPlaybackLogFiles";
		this.tbPlaybackLogFiles.Size = new System.Drawing.Size(256, 22);
		this.tbPlaybackLogFiles.TabIndex = 49;
		this.tbPlaybackLogFiles.Text = "C:\\Qualcomm\\QDART\\SmartMatch\\Temp\\";
		this.label14.AutoSize = true;
		this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 14f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
		this.label14.Location = new System.Drawing.Point(153, 41);
		this.label14.Margin = new System.Windows.Forms.Padding(0);
		this.label14.Name = "label14";
		this.label14.Size = new System.Drawing.Size(110, 24);
		this.label14.TabIndex = 42;
		this.label14.Text = "Run Status";
		this.DisplayGrid.AllowUserToDeleteRows = false;
		this.DisplayGrid.AllowUserToResizeColumns = false;
		this.DisplayGrid.AllowUserToResizeRows = false;
		dataGridViewCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
		dataGridViewCellStyle.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle.SelectionBackColor = System.Drawing.SystemColors.Window;
		dataGridViewCellStyle.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
		this.DisplayGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle;
		this.DisplayGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
		this.DisplayGrid.Columns.AddRange(this.Column1, this.Column9, this.Column2, this.Column4, this.Column3, this.TxOut, this.Column5, this.Column8, this.Column7, this.Column6);
		dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
		dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
		dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Window;
		dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
		this.DisplayGrid.DefaultCellStyle = dataGridViewCellStyle2;
		this.DisplayGrid.Enabled = false;
		this.DisplayGrid.Location = new System.Drawing.Point(153, 65);
		this.DisplayGrid.Margin = new System.Windows.Forms.Padding(0);
		this.DisplayGrid.MultiSelect = false;
		this.DisplayGrid.Name = "DisplayGrid";
		this.DisplayGrid.ReadOnly = true;
		dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
		dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Window;
		dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.DisplayGrid.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
		this.DisplayGrid.RowHeadersVisible = false;
		this.DisplayGrid.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
		dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.Transparent;
		dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.Transparent;
		this.DisplayGrid.RowsDefaultCellStyle = dataGridViewCellStyle4;
		this.DisplayGrid.RowTemplate.ReadOnly = true;
		this.DisplayGrid.ScrollBars = System.Windows.Forms.ScrollBars.None;
		this.DisplayGrid.Size = new System.Drawing.Size(890, 46);
		this.DisplayGrid.TabIndex = 41;
		this.DisplayGrid.TabStop = false;
		dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.White;
		dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White;
		this.Column1.DefaultCellStyle = dataGridViewCellStyle5;
		this.Column1.HeaderText = "Tech";
		this.Column1.Name = "Column1";
		this.Column1.ReadOnly = true;
		this.Column1.Resizable = System.Windows.Forms.DataGridViewTriState.False;
		this.Column1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.Column9.HeaderText = "Segment";
		this.Column9.Name = "Column9";
		this.Column9.ReadOnly = true;
		dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.White;
		dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White;
		this.Column2.DefaultCellStyle = dataGridViewCellStyle6;
		this.Column2.HeaderText = "Band";
		this.Column2.Name = "Column2";
		this.Column2.ReadOnly = true;
		this.Column2.Resizable = System.Windows.Forms.DataGridViewTriState.False;
		this.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle7.SelectionBackColor = System.Drawing.Color.White;
		dataGridViewCellStyle7.SelectionForeColor = System.Drawing.Color.White;
		this.Column4.DefaultCellStyle = dataGridViewCellStyle7;
		this.Column4.HeaderText = "Mode";
		this.Column4.Name = "Column4";
		this.Column4.ReadOnly = true;
		this.Column4.Resizable = System.Windows.Forms.DataGridViewTriState.False;
		this.Column4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.Column4.Width = 140;
		dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.White;
		dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.White;
		this.Column3.DefaultCellStyle = dataGridViewCellStyle8;
		this.Column3.HeaderText = "Trial";
		this.Column3.Name = "Column3";
		this.Column3.ReadOnly = true;
		this.Column3.Resizable = System.Windows.Forms.DataGridViewTriState.False;
		this.Column3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.Column3.Width = 50;
		this.TxOut.HeaderText = "Tx Power";
		this.TxOut.Name = "TxOut";
		this.TxOut.ReadOnly = true;
		this.TxOut.Width = 80;
		this.Column5.HeaderText = "ACLR";
		this.Column5.Name = "Column5";
		this.Column5.ReadOnly = true;
		this.Column5.Width = 80;
		this.Column8.HeaderText = "POut Delta";
		this.Column8.Name = "Column8";
		this.Column8.ReadOnly = true;
		this.Column8.Width = 80;
		this.Column7.HeaderText = "Pin";
		this.Column7.Name = "Column7";
		this.Column7.ReadOnly = true;
		this.Column7.Width = 80;
		this.Column6.HeaderText = "Delay";
		this.Column6.Name = "Column6";
		this.Column6.ReadOnly = true;
		this.Column6.Width = 80;
		this.btnEditKitValues.Location = new System.Drawing.Point(12, 608);
		this.btnEditKitValues.Name = "btnEditKitValues";
		this.btnEditKitValues.Size = new System.Drawing.Size(105, 36);
		this.btnEditKitValues.TabIndex = 64;
		this.btnEditKitValues.Text = "Edit KitValues";
		this.btnEditKitValues.UseVisualStyleBackColor = true;
		this.btnEditKitValues.Click += new System.EventHandler(btnEditKitValues_Click);
		this.label4.AutoSize = true;
		this.label4.Location = new System.Drawing.Point(16, 107);
		this.label4.Name = "label4";
		this.label4.Size = new System.Drawing.Size(60, 13);
		this.label4.TabIndex = 55;
		this.label4.Text = "Band Class";
		this.btnSelectTech.Location = new System.Drawing.Point(12, 48);
		this.btnSelectTech.Name = "btnSelectTech";
		this.btnSelectTech.Size = new System.Drawing.Size(125, 51);
		this.btnSelectTech.TabIndex = 53;
		this.btnSelectTech.Text = "Select Tech";
		this.btnSelectTech.UseVisualStyleBackColor = true;
		this.btnSelectTech.Click += new System.EventHandler(btnSelectTech_Click);
		this.btnStop.Enabled = false;
		this.btnStop.FlatStyle = System.Windows.Forms.FlatStyle.System;
		this.btnStop.Location = new System.Drawing.Point(15, 356);
		this.btnStop.Name = "btnStop";
		this.btnStop.Size = new System.Drawing.Size(105, 36);
		this.btnStop.TabIndex = 57;
		this.btnStop.Text = "Stop";
		this.btnStop.UseVisualStyleBackColor = true;
		this.btnStop.Click += new System.EventHandler(btnStop_Click);
		this.btnStartMatch.Enabled = false;
		this.btnStartMatch.FlatStyle = System.Windows.Forms.FlatStyle.System;
		this.btnStartMatch.Location = new System.Drawing.Point(15, 310);
		this.btnStartMatch.Name = "btnStartMatch";
		this.btnStartMatch.Size = new System.Drawing.Size(105, 36);
		this.btnStartMatch.TabIndex = 56;
		this.btnStartMatch.Text = "Start";
		this.btnStartMatch.UseVisualStyleBackColor = true;
		this.btnStartMatch.Click += new System.EventHandler(btnStartMatch_Click);
		this.btnFormatDescriptor.Enabled = false;
		this.btnFormatDescriptor.FlatStyle = System.Windows.Forms.FlatStyle.System;
		this.btnFormatDescriptor.Location = new System.Drawing.Point(12, 650);
		this.btnFormatDescriptor.Name = "btnFormatDescriptor";
		this.btnFormatDescriptor.Size = new System.Drawing.Size(105, 36);
		this.btnFormatDescriptor.TabIndex = 59;
		this.btnFormatDescriptor.Text = "Format Desciptor";
		this.btnFormatDescriptor.UseVisualStyleBackColor = true;
		this.btnFormatDescriptor.Visible = false;
		this.btnLogPath.FlatStyle = System.Windows.Forms.FlatStyle.System;
		this.btnLogPath.Location = new System.Drawing.Point(12, 566);
		this.btnLogPath.Name = "btnLogPath";
		this.btnLogPath.Size = new System.Drawing.Size(105, 36);
		this.btnLogPath.TabIndex = 58;
		this.btnLogPath.Text = "Log Path";
		this.btnLogPath.UseVisualStyleBackColor = true;
		this.btnLogPath.Click += new System.EventHandler(btnLogPath_Click);
		this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[2] { this.toolStripMenuItem1, this.tsSimulationMenuItem });
		this.menuStrip1.Location = new System.Drawing.Point(0, 0);
		this.menuStrip1.Name = "menuStrip1";
		this.menuStrip1.Size = new System.Drawing.Size(1096, 24);
		this.menuStrip1.TabIndex = 60;
		this.menuStrip1.Text = "File";
		this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[4] { this.tsmFileOpen, this.tsmFileSave, this.tsmFileSaveAs, this.tsmFileExit });
		this.toolStripMenuItem1.Name = "toolStripMenuItem1";
		this.toolStripMenuItem1.Size = new System.Drawing.Size(37, 20);
		this.toolStripMenuItem1.Text = "File";
		this.tsmFileOpen.Name = "tsmFileOpen";
		this.tsmFileOpen.Size = new System.Drawing.Size(129, 22);
		this.tsmFileOpen.Text = "Open";
		this.tsmFileOpen.Click += new System.EventHandler(tsmFileOpen_Click);
		this.tsmFileSave.Enabled = false;
		this.tsmFileSave.Name = "tsmFileSave";
		this.tsmFileSave.Size = new System.Drawing.Size(129, 22);
		this.tsmFileSave.Text = "Save";
		this.tsmFileSave.Click += new System.EventHandler(tsmFileSave_Click);
		this.tsmFileSaveAs.Name = "tsmFileSaveAs";
		this.tsmFileSaveAs.Size = new System.Drawing.Size(129, 22);
		this.tsmFileSaveAs.Text = "Save As ....";
		this.tsmFileSaveAs.Click += new System.EventHandler(tsmFileSaveAs_Click);
		this.tsmFileExit.Name = "tsmFileExit";
		this.tsmFileExit.Size = new System.Drawing.Size(129, 22);
		this.tsmFileExit.Text = "Exit";
		this.tsmFileExit.Click += new System.EventHandler(tsmFileExit_Click);
		this.tsSimulationMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[1] { this.tsEnableSimulationMenuItem });
		this.tsSimulationMenuItem.Name = "tsSimulationMenuItem";
		this.tsSimulationMenuItem.Size = new System.Drawing.Size(76, 20);
		this.tsSimulationMenuItem.Text = "Simulation";
		this.tsEnableSimulationMenuItem.Name = "tsEnableSimulationMenuItem";
		this.tsEnableSimulationMenuItem.Size = new System.Drawing.Size(109, 22);
		this.tsEnableSimulationMenuItem.Text = "Enable";
		this.tbXttPath.Location = new System.Drawing.Point(198, 12);
		this.tbXttPath.Name = "tbXttPath";
		this.tbXttPath.ReadOnly = true;
		this.tbXttPath.Size = new System.Drawing.Size(474, 20);
		this.tbXttPath.TabIndex = 62;
		this.label15.AutoSize = true;
		this.label15.Location = new System.Drawing.Point(154, 19);
		this.label15.Name = "label15";
		this.label15.Size = new System.Drawing.Size(28, 13);
		this.label15.TabIndex = 63;
		this.label15.Text = "XTT";
		this.btnResumeMatch.Enabled = false;
		this.btnResumeMatch.FlatStyle = System.Windows.Forms.FlatStyle.System;
		this.btnResumeMatch.Location = new System.Drawing.Point(15, 268);
		this.btnResumeMatch.Name = "btnResumeMatch";
		this.btnResumeMatch.Size = new System.Drawing.Size(105, 36);
		this.btnResumeMatch.TabIndex = 64;
		this.btnResumeMatch.Text = "Resume";
		this.btnResumeMatch.UseVisualStyleBackColor = true;
		this.btnResumeMatch.Click += new System.EventHandler(btnResumeMatch_Click);
		this.labelTestStatus.BackColor = System.Drawing.Color.FromArgb(192, 192, 255);
		this.labelTestStatus.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
		this.labelTestStatus.Font = new System.Drawing.Font("Arial Black", 12f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
		this.labelTestStatus.ForeColor = System.Drawing.Color.Black;
		this.labelTestStatus.Location = new System.Drawing.Point(-3, 409);
		this.labelTestStatus.Name = "labelTestStatus";
		this.labelTestStatus.Size = new System.Drawing.Size(157, 83);
		this.labelTestStatus.TabIndex = 65;
		this.labelTestStatus.Text = "等待开始";
		this.labelTestStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
		this.btnSwitchLang.Location = new System.Drawing.Point(31, 495);
		this.btnSwitchLang.Name = "btnSwitchLang";
		this.btnSwitchLang.Size = new System.Drawing.Size(75, 23);
		this.btnSwitchLang.TabIndex = 66;
		this.btnSwitchLang.Text = "中国";
		this.btnSwitchLang.UseVisualStyleBackColor = true;
		this.btnSwitchLang.Click += new System.EventHandler(btnSwitchLang_Click);
		this.lvBandClasses.Alignment = System.Windows.Forms.ListViewAlignment.Left;
		this.lvBandClasses.CheckBoxes = true;
		this.lvBandClasses.Columns.AddRange(new System.Windows.Forms.ColumnHeader[1] { this.columnHeader1 });
		this.lvBandClasses.Location = new System.Drawing.Point(15, 123);
		this.lvBandClasses.Name = "lvBandClasses";
		this.lvBandClasses.Size = new System.Drawing.Size(122, 131);
		this.lvBandClasses.TabIndex = 68;
		this.lvBandClasses.UseCompatibleStateImageBehavior = false;
		this.lvBandClasses.View = System.Windows.Forms.View.List;
		this.lvBandClasses.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(lvBandClasses_ItemChecked);
		this.columnHeader1.Width = 50;
		this.btnEditChannels.Enabled = false;
		this.btnEditChannels.Location = new System.Drawing.Point(12, 524);
		this.btnEditChannels.Name = "btnEditChannels";
		this.btnEditChannels.Size = new System.Drawing.Size(105, 36);
		this.btnEditChannels.TabIndex = 69;
		this.btnEditChannels.Text = "Edit Band Channels";
		this.btnEditChannels.UseVisualStyleBackColor = true;
		this.btnEditChannels.Click += new System.EventHandler(btnEditChannels_Click);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
		base.ClientSize = new System.Drawing.Size(1096, 710);
		base.Controls.Add(this.btnEditChannels);
		base.Controls.Add(this.btnEditKitValues);
		base.Controls.Add(this.lvBandClasses);
		base.Controls.Add(this.btnSwitchLang);
		base.Controls.Add(this.label14);
		base.Controls.Add(this.DisplayGrid);
		base.Controls.Add(this.labelTestStatus);
		base.Controls.Add(this.btnResumeMatch);
		base.Controls.Add(this.label15);
		base.Controls.Add(this.tbXttPath);
		base.Controls.Add(this.btnFormatDescriptor);
		base.Controls.Add(this.btnLogPath);
		base.Controls.Add(this.btnStop);
		base.Controls.Add(this.btnStartMatch);
		base.Controls.Add(this.label4);
		base.Controls.Add(this.btnSelectTech);
		base.Controls.Add(this.tabCtrlSmartMatch);
		base.Controls.Add(this.menuStrip1);
		base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
		base.MainMenuStrip = this.menuStrip1;
		base.Name = "SmartMatchGUI";
		this.Text = "Smart QMatch";
		base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(SmartMatchGUI_FormClosing);
		this.tabCtrlSmartMatch.ResumeLayout(false);
		this.tabPageSmartMatch.ResumeLayout(false);
		this.groupBox8.ResumeLayout(false);
		this.tabCtrlTopMatches.ResumeLayout(false);
		this.tabPageAntenna.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.dgAntennaTopMatches).EndInit();
		this.tabPageTrialData.ResumeLayout(false);
		this.tabPageTrialData.PerformLayout();
		this.tabPageConfig.ResumeLayout(false);
		this.tabPageConfig.PerformLayout();
		this.groupBox7.ResumeLayout(false);
		this.groupBox6.ResumeLayout(false);
		this.groupBox5.ResumeLayout(false);
		this.groupBox5.PerformLayout();
		this.groupBox4.ResumeLayout(false);
		this.groupBox4.PerformLayout();
		this.groupBox3.ResumeLayout(false);
		this.groupBox3.PerformLayout();
		this.groupBox2.ResumeLayout(false);
		this.groupBox1.ResumeLayout(false);
		this.groupBox1.PerformLayout();
		this.tabPageDebug.ResumeLayout(false);
		this.tabPageDebug.PerformLayout();
		this.tabPagePlayBack.ResumeLayout(false);
		this.tabPagePlayBack.PerformLayout();
		((System.ComponentModel.ISupportInitialize)this.DisplayGrid).EndInit();
		this.menuStrip1.ResumeLayout(false);
		this.menuStrip1.PerformLayout();
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
