using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Xml.Serialization;
using QC.QTMInterface;

namespace QC.TestResultsLite;

public class ConfigurationUI : Form
{
	private Button btnCancel;

	private Button btnOk;

	private ImageList imageList;

	private FolderBrowserDialog folderBrowser;

	private OpenFileDialog openFile;

	private IContainer components;

	private SerialConfig CurrentConfig;

	private TabPage tabPageExcel;

	private Panel panelExcel;

	private CheckBox chkAutoLogCsv;

	private Label labelKeepXLines;

	private ComboBox comboBoxLinesToKeep;

	private GroupBox radioFormatType;

	private RadioButton rbNoExcelLogging;

	private RadioButton rbAllUnitsView;

	private RadioButton rbSingleUnitWideView;

	private RadioButton rbSingleUnitView;

	private CheckBox chkShowLinkedTreeNameColumn;

	private CheckBox chkEnableVisibleArraySize;

	private CheckBox chkShowTestsWithoutParameters;

	private CheckBox chkAutoScrollGrid;

	private Label label7;

	private NumericUpDown numUpDownMaxArraySize;

	private CheckBox chkEnableGrid;

	private Label lblMaxVisibleArraySize;

	private Label ultraLabel9;

	private Panel panelFormat;

	private Panel panelControls;

	private CheckBox chkOpenExcelAfterRun;

	private CheckBox chkColorExcelCells;

	private Panel panelAllUnits;

	private GroupBox radioAllUnitsType;

	private RadioButton rbLongWideView;

	private RadioButton rbLongView;

	private RadioButton rbWideView;

	private Label label2;

	private CheckBox chkBoxPromptInvalidMap;

	private CheckBox chkBoxShowCharValue;

	private Label ultraLabel3;

	private Label label4;

	private Label ultraLabel2;

	private TextBox txtExcelFileName;

	private Button btnExcelFileName;

	private Label label3;

	private Label ultraLabel1;

	private TextBox txtGroupName;

	private Label ultraLabel8;

	private TextBox txtExcelTemplateName;

	private Button btnExcelTemplate;

	private Label label5;

	private Label ultraLabel7;

	private Panel panelSingleUnit;

	private GroupBox radioFile;

	private RadioButton rbCreateAppendWorkBook;

	private RadioButton rbNewWorkBook;

	private Button btnFileLocation;

	private Label ultraLabel4;

	private TextBox txtLocation;

	private Label ultraLabel5;

	private TextBox txtAppendFileName;

	private Button btnAppendFile;

	private Panel panelPicture;

	private PictureBox pictureBox;

	private Label label1;

	private Label ultraLabel6;

	private Label label8;

	private TabControl ultraTabControl1;

	private static string CONFIG_FILE = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), Path.Combine(GlobalInformation.RunTimeConfig.configDirectory, "Ultra.config")));

	public ConfigurationUI()
	{
		InitializeComponent();
	}

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

	private void InitializeComponent()
	{
		this.components = new System.ComponentModel.Container();
		System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QC.TestResultsLite.ConfigurationUI));
		this.btnCancel = new System.Windows.Forms.Button();
		this.btnOk = new System.Windows.Forms.Button();
		this.imageList = new System.Windows.Forms.ImageList(this.components);
		this.folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
		this.openFile = new System.Windows.Forms.OpenFileDialog();
		this.tabPageExcel = new System.Windows.Forms.TabPage();
		this.panelExcel = new System.Windows.Forms.Panel();
		this.label8 = new System.Windows.Forms.Label();
		this.ultraLabel6 = new System.Windows.Forms.Label();
		this.label1 = new System.Windows.Forms.Label();
		this.panelFormat = new System.Windows.Forms.Panel();
		this.panelPicture = new System.Windows.Forms.Panel();
		this.pictureBox = new System.Windows.Forms.PictureBox();
		this.panelControls = new System.Windows.Forms.Panel();
		this.panelSingleUnit = new System.Windows.Forms.Panel();
		this.btnAppendFile = new System.Windows.Forms.Button();
		this.txtAppendFileName = new System.Windows.Forms.TextBox();
		this.ultraLabel5 = new System.Windows.Forms.Label();
		this.txtLocation = new System.Windows.Forms.TextBox();
		this.ultraLabel4 = new System.Windows.Forms.Label();
		this.btnFileLocation = new System.Windows.Forms.Button();
		this.radioFile = new System.Windows.Forms.GroupBox();
		this.rbNewWorkBook = new System.Windows.Forms.RadioButton();
		this.rbCreateAppendWorkBook = new System.Windows.Forms.RadioButton();
		this.panelAllUnits = new System.Windows.Forms.Panel();
		this.ultraLabel7 = new System.Windows.Forms.Label();
		this.label5 = new System.Windows.Forms.Label();
		this.btnExcelTemplate = new System.Windows.Forms.Button();
		this.txtExcelTemplateName = new System.Windows.Forms.TextBox();
		this.ultraLabel8 = new System.Windows.Forms.Label();
		this.txtGroupName = new System.Windows.Forms.TextBox();
		this.ultraLabel1 = new System.Windows.Forms.Label();
		this.label3 = new System.Windows.Forms.Label();
		this.btnExcelFileName = new System.Windows.Forms.Button();
		this.txtExcelFileName = new System.Windows.Forms.TextBox();
		this.ultraLabel2 = new System.Windows.Forms.Label();
		this.label4 = new System.Windows.Forms.Label();
		this.ultraLabel3 = new System.Windows.Forms.Label();
		this.chkBoxShowCharValue = new System.Windows.Forms.CheckBox();
		this.chkBoxPromptInvalidMap = new System.Windows.Forms.CheckBox();
		this.label2 = new System.Windows.Forms.Label();
		this.radioAllUnitsType = new System.Windows.Forms.GroupBox();
		this.rbWideView = new System.Windows.Forms.RadioButton();
		this.rbLongView = new System.Windows.Forms.RadioButton();
		this.rbLongWideView = new System.Windows.Forms.RadioButton();
		this.chkColorExcelCells = new System.Windows.Forms.CheckBox();
		this.chkOpenExcelAfterRun = new System.Windows.Forms.CheckBox();
		this.ultraLabel9 = new System.Windows.Forms.Label();
		this.lblMaxVisibleArraySize = new System.Windows.Forms.Label();
		this.chkEnableGrid = new System.Windows.Forms.CheckBox();
		this.numUpDownMaxArraySize = new System.Windows.Forms.NumericUpDown();
		this.label7 = new System.Windows.Forms.Label();
		this.chkAutoScrollGrid = new System.Windows.Forms.CheckBox();
		this.chkShowTestsWithoutParameters = new System.Windows.Forms.CheckBox();
		this.chkEnableVisibleArraySize = new System.Windows.Forms.CheckBox();
		this.chkShowLinkedTreeNameColumn = new System.Windows.Forms.CheckBox();
		this.radioFormatType = new System.Windows.Forms.GroupBox();
		this.rbSingleUnitView = new System.Windows.Forms.RadioButton();
		this.rbSingleUnitWideView = new System.Windows.Forms.RadioButton();
		this.rbAllUnitsView = new System.Windows.Forms.RadioButton();
		this.rbNoExcelLogging = new System.Windows.Forms.RadioButton();
		this.comboBoxLinesToKeep = new System.Windows.Forms.ComboBox();
		this.labelKeepXLines = new System.Windows.Forms.Label();
		this.chkAutoLogCsv = new System.Windows.Forms.CheckBox();
		this.ultraTabControl1 = new System.Windows.Forms.TabControl();
		this.tabPageExcel.SuspendLayout();
		this.panelExcel.SuspendLayout();
		this.panelFormat.SuspendLayout();
		this.panelPicture.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.pictureBox).BeginInit();
		this.panelControls.SuspendLayout();
		this.panelSingleUnit.SuspendLayout();
		this.radioFile.SuspendLayout();
		this.panelAllUnits.SuspendLayout();
		this.radioAllUnitsType.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.numUpDownMaxArraySize).BeginInit();
		this.radioFormatType.SuspendLayout();
		this.ultraTabControl1.SuspendLayout();
		base.SuspendLayout();
		this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
		this.btnCancel.Location = new System.Drawing.Point(513, 511);
		this.btnCancel.Name = "btnCancel";
		this.btnCancel.Size = new System.Drawing.Size(75, 23);
		this.btnCancel.TabIndex = 1;
		this.btnCancel.Text = "Cancel";
		this.btnCancel.UseVisualStyleBackColor = true;
		this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
		this.btnOk.Location = new System.Drawing.Point(594, 511);
		this.btnOk.Name = "btnOk";
		this.btnOk.Size = new System.Drawing.Size(75, 23);
		this.btnOk.TabIndex = 2;
		this.btnOk.Text = "Ok";
		this.btnOk.UseVisualStyleBackColor = true;
		this.btnOk.Click += new System.EventHandler(btnOk_Click);
		this.imageList.ImageStream = (System.Windows.Forms.ImageListStreamer)resources.GetObject("imageList.ImageStream");
		this.imageList.TransparentColor = System.Drawing.Color.Transparent;
		this.imageList.Images.SetKeyName(0, "");
		this.imageList.Images.SetKeyName(1, "");
		this.imageList.Images.SetKeyName(2, "");
		this.openFile.RestoreDirectory = true;
		this.tabPageExcel.Controls.Add(this.panelExcel);
		this.tabPageExcel.Location = new System.Drawing.Point(4, 22);
		this.tabPageExcel.Name = "tabPageExcel";
		this.tabPageExcel.Size = new System.Drawing.Size(663, 467);
		this.tabPageExcel.TabIndex = 0;
		this.tabPageExcel.Text = "Configuration";
		this.panelExcel.BackColor = System.Drawing.Color.White;
		this.panelExcel.Controls.Add(this.chkAutoLogCsv);
		this.panelExcel.Controls.Add(this.labelKeepXLines);
		this.panelExcel.Controls.Add(this.comboBoxLinesToKeep);
		this.panelExcel.Controls.Add(this.radioFormatType);
		this.panelExcel.Controls.Add(this.chkShowLinkedTreeNameColumn);
		this.panelExcel.Controls.Add(this.chkEnableVisibleArraySize);
		this.panelExcel.Controls.Add(this.chkShowTestsWithoutParameters);
		this.panelExcel.Controls.Add(this.chkAutoScrollGrid);
		this.panelExcel.Controls.Add(this.label7);
		this.panelExcel.Controls.Add(this.numUpDownMaxArraySize);
		this.panelExcel.Controls.Add(this.chkEnableGrid);
		this.panelExcel.Controls.Add(this.lblMaxVisibleArraySize);
		this.panelExcel.Controls.Add(this.ultraLabel9);
		this.panelExcel.Controls.Add(this.panelFormat);
		this.panelExcel.Controls.Add(this.label1);
		this.panelExcel.Controls.Add(this.ultraLabel6);
		this.panelExcel.Controls.Add(this.label8);
		this.panelExcel.Dock = System.Windows.Forms.DockStyle.Fill;
		this.panelExcel.Location = new System.Drawing.Point(0, 0);
		this.panelExcel.Name = "panelExcel";
		this.panelExcel.Size = new System.Drawing.Size(663, 467);
		this.panelExcel.TabIndex = 0;
		this.label8.ForeColor = System.Drawing.SystemColors.GrayText;
		this.label8.Location = new System.Drawing.Point(140, 113);
		this.label8.Name = "label8";
		this.label8.Size = new System.Drawing.Size(456, 16);
		this.label8.TabIndex = 43;
		this.label8.Text = resources.GetString("label8.Text");
		this.ultraLabel6.Location = new System.Drawing.Point(12, 133);
		this.ultraLabel6.Name = "ultraLabel6";
		this.ultraLabel6.Size = new System.Drawing.Size(120, 16);
		this.ultraLabel6.TabIndex = 25;
		this.ultraLabel6.Text = "Choose Excel Format";
		this.label1.ForeColor = System.Drawing.SystemColors.GrayText;
		this.label1.Location = new System.Drawing.Point(15, 99);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(629, 14);
		this.label1.TabIndex = 26;
		this.label1.Text = resources.GetString("label1.Text");
		this.panelFormat.Controls.Add(this.panelControls);
		this.panelFormat.Controls.Add(this.panelPicture);
		this.panelFormat.Dock = System.Windows.Forms.DockStyle.Bottom;
		this.panelFormat.Location = new System.Drawing.Point(0, 171);
		this.panelFormat.Name = "panelFormat";
		this.panelFormat.Size = new System.Drawing.Size(663, 296);
		this.panelFormat.TabIndex = 27;
		this.panelPicture.Controls.Add(this.pictureBox);
		this.panelPicture.Dock = System.Windows.Forms.DockStyle.Right;
		this.panelPicture.Location = new System.Drawing.Point(388, 0);
		this.panelPicture.Name = "panelPicture";
		this.panelPicture.Size = new System.Drawing.Size(275, 296);
		this.panelPicture.TabIndex = 0;
		this.pictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
		this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
		this.pictureBox.Location = new System.Drawing.Point(0, 0);
		this.pictureBox.Name = "pictureBox";
		this.pictureBox.Size = new System.Drawing.Size(275, 296);
		this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
		this.pictureBox.TabIndex = 0;
		this.pictureBox.TabStop = false;
		this.panelControls.Controls.Add(this.chkOpenExcelAfterRun);
		this.panelControls.Controls.Add(this.chkColorExcelCells);
		this.panelControls.Controls.Add(this.panelAllUnits);
		this.panelControls.Controls.Add(this.panelSingleUnit);
		this.panelControls.Dock = System.Windows.Forms.DockStyle.Fill;
		this.panelControls.Location = new System.Drawing.Point(0, 0);
		this.panelControls.Name = "panelControls";
		this.panelControls.Size = new System.Drawing.Size(388, 296);
		this.panelControls.TabIndex = 1;
		this.panelSingleUnit.Controls.Add(this.radioFile);
		this.panelSingleUnit.Controls.Add(this.btnFileLocation);
		this.panelSingleUnit.Controls.Add(this.ultraLabel4);
		this.panelSingleUnit.Controls.Add(this.txtLocation);
		this.panelSingleUnit.Controls.Add(this.ultraLabel5);
		this.panelSingleUnit.Controls.Add(this.txtAppendFileName);
		this.panelSingleUnit.Controls.Add(this.btnAppendFile);
		this.panelSingleUnit.Location = new System.Drawing.Point(9, 8);
		this.panelSingleUnit.Name = "panelSingleUnit";
		this.panelSingleUnit.Size = new System.Drawing.Size(372, 235);
		this.panelSingleUnit.TabIndex = 1;
		this.btnAppendFile.Location = new System.Drawing.Point(264, 72);
		this.btnAppendFile.Name = "btnAppendFile";
		this.btnAppendFile.Size = new System.Drawing.Size(32, 23);
		this.btnAppendFile.TabIndex = 37;
		this.btnAppendFile.Text = "...";
		this.btnAppendFile.Click += new System.EventHandler(btnAppendFile_Click);
		this.txtAppendFileName.Location = new System.Drawing.Point(16, 72);
		this.txtAppendFileName.Name = "txtAppendFileName";
		this.txtAppendFileName.Size = new System.Drawing.Size(248, 20);
		this.txtAppendFileName.TabIndex = 38;
		this.ultraLabel5.Location = new System.Drawing.Point(0, 48);
		this.ultraLabel5.Name = "ultraLabel5";
		this.ultraLabel5.Size = new System.Drawing.Size(88, 16);
		this.ultraLabel5.TabIndex = 39;
		this.ultraLabel5.Text = "Excel File Name";
		this.txtLocation.Location = new System.Drawing.Point(16, 144);
		this.txtLocation.Name = "txtLocation";
		this.txtLocation.Size = new System.Drawing.Size(248, 20);
		this.txtLocation.TabIndex = 41;
		this.ultraLabel4.Location = new System.Drawing.Point(0, 112);
		this.ultraLabel4.Name = "ultraLabel4";
		this.ultraLabel4.Size = new System.Drawing.Size(160, 16);
		this.ultraLabel4.TabIndex = 42;
		this.ultraLabel4.Text = "File Location (Directory name)";
		this.btnFileLocation.Location = new System.Drawing.Point(264, 144);
		this.btnFileLocation.Name = "btnFileLocation";
		this.btnFileLocation.Size = new System.Drawing.Size(32, 23);
		this.btnFileLocation.TabIndex = 49;
		this.btnFileLocation.Text = "...";
		this.btnFileLocation.Click += new System.EventHandler(btnFileLocation_Click);
		this.radioFile.Controls.Add(this.rbCreateAppendWorkBook);
		this.radioFile.Controls.Add(this.rbNewWorkBook);
		this.radioFile.Location = new System.Drawing.Point(5, 8);
		this.radioFile.Name = "radioFile";
		this.radioFile.Size = new System.Drawing.Size(329, 37);
		this.radioFile.TabIndex = 50;
		this.radioFile.TabStop = false;
		this.rbNewWorkBook.AutoSize = true;
		this.rbNewWorkBook.Location = new System.Drawing.Point(13, 14);
		this.rbNewWorkBook.Name = "rbNewWorkBook";
		this.rbNewWorkBook.Size = new System.Drawing.Size(101, 17);
		this.rbNewWorkBook.TabIndex = 0;
		this.rbNewWorkBook.TabStop = true;
		this.rbNewWorkBook.Tag = "0";
		this.rbNewWorkBook.Text = "New WorkBook";
		this.rbNewWorkBook.UseVisualStyleBackColor = true;
		this.rbNewWorkBook.CheckedChanged += new System.EventHandler(radioFile_ValueChanged);
		this.rbCreateAppendWorkBook.AutoSize = true;
		this.rbCreateAppendWorkBook.Location = new System.Drawing.Point(135, 14);
		this.rbCreateAppendWorkBook.Name = "rbCreateAppendWorkBook";
		this.rbCreateAppendWorkBook.Size = new System.Drawing.Size(157, 17);
		this.rbCreateAppendWorkBook.TabIndex = 1;
		this.rbCreateAppendWorkBook.TabStop = true;
		this.rbCreateAppendWorkBook.Tag = "1";
		this.rbCreateAppendWorkBook.Text = "Create / Append Workbook";
		this.rbCreateAppendWorkBook.UseVisualStyleBackColor = true;
		this.rbCreateAppendWorkBook.CheckedChanged += new System.EventHandler(radioFile_ValueChanged);
		this.panelAllUnits.Controls.Add(this.radioAllUnitsType);
		this.panelAllUnits.Controls.Add(this.label2);
		this.panelAllUnits.Controls.Add(this.chkBoxPromptInvalidMap);
		this.panelAllUnits.Controls.Add(this.chkBoxShowCharValue);
		this.panelAllUnits.Controls.Add(this.ultraLabel3);
		this.panelAllUnits.Controls.Add(this.label4);
		this.panelAllUnits.Controls.Add(this.ultraLabel2);
		this.panelAllUnits.Controls.Add(this.txtExcelFileName);
		this.panelAllUnits.Controls.Add(this.btnExcelFileName);
		this.panelAllUnits.Controls.Add(this.label3);
		this.panelAllUnits.Controls.Add(this.ultraLabel1);
		this.panelAllUnits.Controls.Add(this.txtGroupName);
		this.panelAllUnits.Controls.Add(this.ultraLabel8);
		this.panelAllUnits.Controls.Add(this.txtExcelTemplateName);
		this.panelAllUnits.Controls.Add(this.btnExcelTemplate);
		this.panelAllUnits.Controls.Add(this.label5);
		this.panelAllUnits.Controls.Add(this.ultraLabel7);
		this.panelAllUnits.Location = new System.Drawing.Point(12, 8);
		this.panelAllUnits.Name = "panelAllUnits";
		this.panelAllUnits.Size = new System.Drawing.Size(369, 250);
		this.panelAllUnits.TabIndex = 2;
		this.panelAllUnits.Visible = false;
		this.ultraLabel7.Location = new System.Drawing.Point(24, 8);
		this.ultraLabel7.Name = "ultraLabel7";
		this.ultraLabel7.Size = new System.Drawing.Size(116, 16);
		this.ultraLabel7.TabIndex = 52;
		this.ultraLabel7.Text = "Choose View Format";
		this.label5.ForeColor = System.Drawing.SystemColors.GrayText;
		this.label5.Location = new System.Drawing.Point(31, 181);
		this.label5.Name = "label5";
		this.label5.Size = new System.Drawing.Size(240, 16);
		this.label5.TabIndex = 49;
		this.label5.Text = "___________________________________________________________________________________________________________________________";
		this.btnExcelTemplate.Location = new System.Drawing.Point(256, 57);
		this.btnExcelTemplate.Name = "btnExcelTemplate";
		this.btnExcelTemplate.Size = new System.Drawing.Size(32, 23);
		this.btnExcelTemplate.TabIndex = 37;
		this.btnExcelTemplate.Text = "...";
		this.btnExcelTemplate.UseVisualStyleBackColor = true;
		this.btnExcelTemplate.Click += new System.EventHandler(btnExcelTemplate_Click);
		this.txtExcelTemplateName.Location = new System.Drawing.Point(8, 58);
		this.txtExcelTemplateName.Name = "txtExcelTemplateName";
		this.txtExcelTemplateName.Size = new System.Drawing.Size(248, 20);
		this.txtExcelTemplateName.TabIndex = 38;
		this.ultraLabel8.Location = new System.Drawing.Point(0, 31);
		this.ultraLabel8.Name = "ultraLabel8";
		this.ultraLabel8.Size = new System.Drawing.Size(88, 16);
		this.ultraLabel8.TabIndex = 39;
		this.ultraLabel8.Text = "Excel Template";
		this.txtGroupName.Location = new System.Drawing.Point(8, 105);
		this.txtGroupName.Name = "txtGroupName";
		this.txtGroupName.Size = new System.Drawing.Size(280, 20);
		this.txtGroupName.TabIndex = 41;
		this.ultraLabel1.Location = new System.Drawing.Point(0, 81);
		this.ultraLabel1.Name = "ultraLabel1";
		this.ultraLabel1.Size = new System.Drawing.Size(88, 16);
		this.ultraLabel1.TabIndex = 42;
		this.ultraLabel1.Text = "Sheet Name";
		this.label3.ForeColor = System.Drawing.SystemColors.GrayText;
		this.label3.Location = new System.Drawing.Point(80, 81);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(224, 16);
		this.label3.TabIndex = 43;
		this.label3.Text = "___________________________________________________________________________________________________________________________";
		this.btnExcelFileName.Location = new System.Drawing.Point(256, 156);
		this.btnExcelFileName.Name = "btnExcelFileName";
		this.btnExcelFileName.Size = new System.Drawing.Size(32, 23);
		this.btnExcelFileName.TabIndex = 44;
		this.btnExcelFileName.Text = "...";
		this.btnExcelFileName.UseVisualStyleBackColor = true;
		this.btnExcelFileName.Click += new System.EventHandler(btnExcelFileName_Click);
		this.txtExcelFileName.Location = new System.Drawing.Point(7, 157);
		this.txtExcelFileName.Name = "txtExcelFileName";
		this.txtExcelFileName.Size = new System.Drawing.Size(249, 20);
		this.txtExcelFileName.TabIndex = 45;
		this.ultraLabel2.Location = new System.Drawing.Point(-1, 133);
		this.ultraLabel2.Name = "ultraLabel2";
		this.ultraLabel2.Size = new System.Drawing.Size(88, 16);
		this.ultraLabel2.TabIndex = 46;
		this.ultraLabel2.Text = "Output File";
		this.label4.ForeColor = System.Drawing.SystemColors.GrayText;
		this.label4.Location = new System.Drawing.Point(79, 133);
		this.label4.Name = "label4";
		this.label4.Size = new System.Drawing.Size(224, 16);
		this.label4.TabIndex = 47;
		this.label4.Text = "___________________________________________________________________________________________________________________________";
		this.ultraLabel3.Location = new System.Drawing.Point(-1, 181);
		this.ultraLabel3.Name = "ultraLabel3";
		this.ultraLabel3.Size = new System.Drawing.Size(72, 16);
		this.ultraLabel3.TabIndex = 48;
		this.ultraLabel3.Text = "User Mode";
		this.chkBoxShowCharValue.Checked = true;
		this.chkBoxShowCharValue.CheckState = System.Windows.Forms.CheckState.Checked;
		this.chkBoxShowCharValue.Location = new System.Drawing.Point(15, 230);
		this.chkBoxShowCharValue.Name = "chkBoxShowCharValue";
		this.chkBoxShowCharValue.Size = new System.Drawing.Size(168, 20);
		this.chkBoxShowCharValue.TabIndex = 55;
		this.chkBoxShowCharValue.Text = "Show Char Value";
		this.chkBoxPromptInvalidMap.Checked = true;
		this.chkBoxPromptInvalidMap.CheckState = System.Windows.Forms.CheckState.Checked;
		this.chkBoxPromptInvalidMap.Location = new System.Drawing.Point(15, 205);
		this.chkBoxPromptInvalidMap.Name = "chkBoxPromptInvalidMap";
		this.chkBoxPromptInvalidMap.Size = new System.Drawing.Size(168, 20);
		this.chkBoxPromptInvalidMap.TabIndex = 50;
		this.chkBoxPromptInvalidMap.Text = "Prompt Invalid Sheet Name";
		this.label2.ForeColor = System.Drawing.SystemColors.GrayText;
		this.label2.Location = new System.Drawing.Point(83, 31);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(213, 16);
		this.label2.TabIndex = 40;
		this.label2.Text = "___________________________________________________________________________________________________________________________";
		this.radioAllUnitsType.Controls.Add(this.rbLongWideView);
		this.radioAllUnitsType.Controls.Add(this.rbLongView);
		this.radioAllUnitsType.Controls.Add(this.rbWideView);
		this.radioAllUnitsType.Location = new System.Drawing.Point(127, 8);
		this.radioAllUnitsType.Name = "radioAllUnitsType";
		this.radioAllUnitsType.Size = new System.Drawing.Size(231, 31);
		this.radioAllUnitsType.TabIndex = 56;
		this.radioAllUnitsType.TabStop = false;
		this.rbWideView.AutoSize = true;
		this.rbWideView.Location = new System.Drawing.Point(10, 8);
		this.rbWideView.Name = "rbWideView";
		this.rbWideView.Size = new System.Drawing.Size(76, 17);
		this.rbWideView.TabIndex = 0;
		this.rbWideView.TabStop = true;
		this.rbWideView.Tag = "0";
		this.rbWideView.Text = "Wide View";
		this.rbWideView.UseVisualStyleBackColor = true;
		this.rbWideView.CheckedChanged += new System.EventHandler(radioAllUnitsType_ValueChanged);
		this.rbLongView.AutoSize = true;
		this.rbLongView.Location = new System.Drawing.Point(84, 8);
		this.rbLongView.Name = "rbLongView";
		this.rbLongView.Size = new System.Drawing.Size(75, 17);
		this.rbLongView.TabIndex = 1;
		this.rbLongView.TabStop = true;
		this.rbLongView.Tag = "1";
		this.rbLongView.Text = "Long View";
		this.rbLongView.UseVisualStyleBackColor = true;
		this.rbLongView.CheckedChanged += new System.EventHandler(radioAllUnitsType_ValueChanged);
		this.rbLongWideView.AutoSize = true;
		this.rbLongWideView.Location = new System.Drawing.Point(157, 8);
		this.rbLongWideView.Name = "rbLongWideView";
		this.rbLongWideView.Size = new System.Drawing.Size(103, 17);
		this.rbLongWideView.TabIndex = 2;
		this.rbLongWideView.TabStop = true;
		this.rbLongWideView.Tag = "2";
		this.rbLongWideView.Text = "Long Wide View";
		this.rbLongWideView.UseVisualStyleBackColor = true;
		this.rbLongWideView.CheckedChanged += new System.EventHandler(radioAllUnitsType_ValueChanged);
		this.chkColorExcelCells.AutoSize = true;
		this.chkColorExcelCells.Checked = true;
		this.chkColorExcelCells.CheckState = System.Windows.Forms.CheckState.Checked;
		this.chkColorExcelCells.Location = new System.Drawing.Point(27, 265);
		this.chkColorExcelCells.Name = "chkColorExcelCells";
		this.chkColorExcelCells.Size = new System.Drawing.Size(104, 17);
		this.chkColorExcelCells.TabIndex = 3;
		this.chkColorExcelCells.Text = "Color Excel Cells";
		this.chkColorExcelCells.UseVisualStyleBackColor = true;
		this.chkOpenExcelAfterRun.AutoSize = true;
		this.chkOpenExcelAfterRun.Checked = true;
		this.chkOpenExcelAfterRun.CheckState = System.Windows.Forms.CheckState.Checked;
		this.chkOpenExcelAfterRun.Location = new System.Drawing.Point(149, 265);
		this.chkOpenExcelAfterRun.Name = "chkOpenExcelAfterRun";
		this.chkOpenExcelAfterRun.Size = new System.Drawing.Size(194, 17);
		this.chkOpenExcelAfterRun.TabIndex = 4;
		this.chkOpenExcelAfterRun.Text = "Open Excel after test run completes";
		this.chkOpenExcelAfterRun.UseVisualStyleBackColor = true;
		this.ultraLabel9.Location = new System.Drawing.Point(12, 9);
		this.ultraLabel9.Name = "ultraLabel9";
		this.ultraLabel9.Size = new System.Drawing.Size(120, 16);
		this.ultraLabel9.TabIndex = 33;
		this.ultraLabel9.Text = "Grid Properties";
		this.lblMaxVisibleArraySize.AutoSize = true;
		this.lblMaxVisibleArraySize.Location = new System.Drawing.Point(282, 57);
		this.lblMaxVisibleArraySize.Name = "lblMaxVisibleArraySize";
		this.lblMaxVisibleArraySize.Size = new System.Drawing.Size(110, 13);
		this.lblMaxVisibleArraySize.TabIndex = 30;
		this.lblMaxVisibleArraySize.Text = "Max Visible Array Size";
		this.chkEnableGrid.Location = new System.Drawing.Point(27, 31);
		this.chkEnableGrid.Name = "chkEnableGrid";
		this.chkEnableGrid.Size = new System.Drawing.Size(88, 20);
		this.chkEnableGrid.TabIndex = 29;
		this.chkEnableGrid.Text = "Enable Grid.";
		this.chkEnableGrid.CheckedChanged += new System.EventHandler(chkEnableGrid_CheckedChanged);
		this.numUpDownMaxArraySize.Enabled = false;
		this.numUpDownMaxArraySize.Increment = new decimal(new int[4] { 10, 0, 0, 0 });
		this.numUpDownMaxArraySize.Location = new System.Drawing.Point(411, 55);
		this.numUpDownMaxArraySize.Maximum = new decimal(new int[4] { 4000, 0, 0, 0 });
		this.numUpDownMaxArraySize.Minimum = new decimal(new int[4] { 1, 0, 0, 0 });
		this.numUpDownMaxArraySize.Name = "numUpDownMaxArraySize";
		this.numUpDownMaxArraySize.Size = new System.Drawing.Size(59, 20);
		this.numUpDownMaxArraySize.TabIndex = 31;
		this.numUpDownMaxArraySize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.numUpDownMaxArraySize.Value = new decimal(new int[4] { 10, 0, 0, 0 });
		this.label7.ForeColor = System.Drawing.SystemColors.GrayText;
		this.label7.Location = new System.Drawing.Point(140, 3);
		this.label7.Name = "label7";
		this.label7.Size = new System.Drawing.Size(456, 16);
		this.label7.TabIndex = 34;
		this.label7.Text = resources.GetString("label7.Text");
		this.chkAutoScrollGrid.AutoSize = true;
		this.chkAutoScrollGrid.Enabled = false;
		this.chkAutoScrollGrid.Location = new System.Drawing.Point(149, 33);
		this.chkAutoScrollGrid.Name = "chkAutoScrollGrid";
		this.chkAutoScrollGrid.Size = new System.Drawing.Size(99, 17);
		this.chkAutoScrollGrid.TabIndex = 35;
		this.chkAutoScrollGrid.Text = "Auto Scroll Grid";
		this.chkAutoScrollGrid.UseVisualStyleBackColor = true;
		this.chkShowTestsWithoutParameters.AutoSize = true;
		this.chkShowTestsWithoutParameters.Enabled = false;
		this.chkShowTestsWithoutParameters.Location = new System.Drawing.Point(268, 33);
		this.chkShowTestsWithoutParameters.Name = "chkShowTestsWithoutParameters";
		this.chkShowTestsWithoutParameters.Size = new System.Drawing.Size(195, 17);
		this.chkShowTestsWithoutParameters.TabIndex = 36;
		this.chkShowTestsWithoutParameters.Text = "Show Tests Without Output Params";
		this.chkShowTestsWithoutParameters.UseVisualStyleBackColor = true;
		this.chkEnableVisibleArraySize.AutoSize = true;
		this.chkEnableVisibleArraySize.Enabled = false;
		this.chkEnableVisibleArraySize.Location = new System.Drawing.Point(27, 56);
		this.chkEnableVisibleArraySize.Name = "chkEnableVisibleArraySize";
		this.chkEnableVisibleArraySize.Size = new System.Drawing.Size(239, 17);
		this.chkEnableVisibleArraySize.TabIndex = 37;
		this.chkEnableVisibleArraySize.Text = "Enable Maximum Visible Array Size Constraint";
		this.chkEnableVisibleArraySize.UseVisualStyleBackColor = true;
		this.chkEnableVisibleArraySize.CheckedChanged += new System.EventHandler(chkEnableVisibleArraySize_CheckedChanged);
		this.chkEnableVisibleArraySize.EnabledChanged += new System.EventHandler(chkEnableVisibleArraySize_EnabledChanged);
		this.chkShowLinkedTreeNameColumn.AutoSize = true;
		this.chkShowLinkedTreeNameColumn.Enabled = false;
		this.chkShowLinkedTreeNameColumn.Location = new System.Drawing.Point(472, 31);
		this.chkShowLinkedTreeNameColumn.Name = "chkShowLinkedTreeNameColumn";
		this.chkShowLinkedTreeNameColumn.Size = new System.Drawing.Size(182, 17);
		this.chkShowLinkedTreeNameColumn.TabIndex = 44;
		this.chkShowLinkedTreeNameColumn.Text = "Show Linked Tree Name Column";
		this.chkShowLinkedTreeNameColumn.UseVisualStyleBackColor = true;
		this.radioFormatType.Controls.Add(this.rbNoExcelLogging);
		this.radioFormatType.Controls.Add(this.rbAllUnitsView);
		this.radioFormatType.Controls.Add(this.rbSingleUnitWideView);
		this.radioFormatType.Controls.Add(this.rbSingleUnitView);
		this.radioFormatType.Location = new System.Drawing.Point(129, 116);
		this.radioFormatType.Name = "radioFormatType";
		this.radioFormatType.Size = new System.Drawing.Size(481, 37);
		this.radioFormatType.TabIndex = 45;
		this.radioFormatType.TabStop = false;
		this.rbSingleUnitView.AutoSize = true;
		this.rbSingleUnitView.Location = new System.Drawing.Point(9, 15);
		this.rbSingleUnitView.Name = "rbSingleUnitView";
		this.rbSingleUnitView.Size = new System.Drawing.Size(96, 17);
		this.rbSingleUnitView.TabIndex = 0;
		this.rbSingleUnitView.TabStop = true;
		this.rbSingleUnitView.Tag = "0";
		this.rbSingleUnitView.Text = "SingleUnitView";
		this.rbSingleUnitView.UseVisualStyleBackColor = true;
		this.rbSingleUnitView.CheckedChanged += new System.EventHandler(radioFormatType_ValueChanged);
		this.rbSingleUnitWideView.AutoSize = true;
		this.rbSingleUnitWideView.Location = new System.Drawing.Point(111, 14);
		this.rbSingleUnitWideView.Name = "rbSingleUnitWideView";
		this.rbSingleUnitWideView.Size = new System.Drawing.Size(130, 17);
		this.rbSingleUnitWideView.TabIndex = 3;
		this.rbSingleUnitWideView.TabStop = true;
		this.rbSingleUnitWideView.Tag = "3";
		this.rbSingleUnitWideView.Text = "Single Unit Wide View";
		this.rbSingleUnitWideView.UseVisualStyleBackColor = true;
		this.rbSingleUnitWideView.CheckedChanged += new System.EventHandler(radioFormatType_ValueChanged);
		this.rbAllUnitsView.AutoSize = true;
		this.rbAllUnitsView.Location = new System.Drawing.Point(246, 15);
		this.rbAllUnitsView.Name = "rbAllUnitsView";
		this.rbAllUnitsView.Size = new System.Drawing.Size(92, 17);
		this.rbAllUnitsView.TabIndex = 1;
		this.rbAllUnitsView.TabStop = true;
		this.rbAllUnitsView.Tag = "1";
		this.rbAllUnitsView.Text = " All Units View";
		this.rbAllUnitsView.UseVisualStyleBackColor = true;
		this.rbAllUnitsView.CheckedChanged += new System.EventHandler(radioFormatType_ValueChanged);
		this.rbNoExcelLogging.AutoSize = true;
		this.rbNoExcelLogging.Location = new System.Drawing.Point(343, 14);
		this.rbNoExcelLogging.Name = "rbNoExcelLogging";
		this.rbNoExcelLogging.Size = new System.Drawing.Size(109, 17);
		this.rbNoExcelLogging.TabIndex = 2;
		this.rbNoExcelLogging.TabStop = true;
		this.rbNoExcelLogging.Tag = "2";
		this.rbNoExcelLogging.Text = "No Excel Logging";
		this.rbNoExcelLogging.UseVisualStyleBackColor = true;
		this.rbNoExcelLogging.CheckedChanged += new System.EventHandler(radioFormatType_ValueChanged);
		this.comboBoxLinesToKeep.FormattingEnabled = true;
		this.comboBoxLinesToKeep.Items.AddRange(new object[1] { "ALL" });
		this.comboBoxLinesToKeep.Location = new System.Drawing.Point(143, 77);
		this.comboBoxLinesToKeep.Name = "comboBoxLinesToKeep";
		this.comboBoxLinesToKeep.Size = new System.Drawing.Size(105, 21);
		this.comboBoxLinesToKeep.TabIndex = 47;
		this.labelKeepXLines.AutoSize = true;
		this.labelKeepXLines.Location = new System.Drawing.Point(24, 80);
		this.labelKeepXLines.Name = "labelKeepXLines";
		this.labelKeepXLines.Size = new System.Drawing.Size(105, 13);
		this.labelKeepXLines.TabIndex = 48;
		this.labelKeepXLines.Text = "Lines to keep in grid:";
		this.chkAutoLogCsv.AutoSize = true;
		this.chkAutoLogCsv.Location = new System.Drawing.Point(268, 79);
		this.chkAutoLogCsv.Name = "chkAutoLogCsv";
		this.chkAutoLogCsv.Size = new System.Drawing.Size(127, 17);
		this.chkAutoLogCsv.TabIndex = 51;
		this.chkAutoLogCsv.Text = "Auto Create CSV Log";
		this.chkAutoLogCsv.UseVisualStyleBackColor = true;
		this.ultraTabControl1.Controls.Add(this.tabPageExcel);
		this.ultraTabControl1.Location = new System.Drawing.Point(3, 12);
		this.ultraTabControl1.Name = "ultraTabControl1";
		this.ultraTabControl1.SelectedIndex = 0;
		this.ultraTabControl1.Size = new System.Drawing.Size(671, 493);
		this.ultraTabControl1.TabIndex = 0;
		base.AcceptButton = this.btnOk;
		this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
		this.BackColor = System.Drawing.SystemColors.ControlLight;
		base.CancelButton = this.btnCancel;
		base.ClientSize = new System.Drawing.Size(676, 557);
		base.Controls.Add(this.btnOk);
		base.Controls.Add(this.btnCancel);
		base.Controls.Add(this.ultraTabControl1);
		base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
		base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
		base.MaximizeBox = false;
		base.MinimizeBox = false;
		base.Name = "ConfigurationUI";
		base.ShowIcon = false;
		base.ShowInTaskbar = false;
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
		this.Text = "Ultra Results Configuration";
		base.Closing += new System.ComponentModel.CancelEventHandler(ConfigurationUI_Closing);
		base.Load += new System.EventHandler(ConfigurationUI_Load);
		this.tabPageExcel.ResumeLayout(false);
		this.panelExcel.ResumeLayout(false);
		this.panelExcel.PerformLayout();
		this.panelFormat.ResumeLayout(false);
		this.panelPicture.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.pictureBox).EndInit();
		this.panelControls.ResumeLayout(false);
		this.panelControls.PerformLayout();
		this.panelSingleUnit.ResumeLayout(false);
		this.panelSingleUnit.PerformLayout();
		this.radioFile.ResumeLayout(false);
		this.radioFile.PerformLayout();
		this.panelAllUnits.ResumeLayout(false);
		this.panelAllUnits.PerformLayout();
		this.radioAllUnitsType.ResumeLayout(false);
		this.radioAllUnitsType.PerformLayout();
		((System.ComponentModel.ISupportInitialize)this.numUpDownMaxArraySize).EndInit();
		this.radioFormatType.ResumeLayout(false);
		this.radioFormatType.PerformLayout();
		this.ultraTabControl1.ResumeLayout(false);
		base.ResumeLayout(false);
	}

	private void radioFormatType_ValueChanged(object sender, EventArgs e)
	{
		try
		{
			switch ((SerialConfig.ViewTypes)GetSelectedRBValue(radioFormatType))
			{
			case SerialConfig.ViewTypes.SingleUnitView:
			case SerialConfig.ViewTypes.SingleUnitWideView:
				panelAllUnits.Visible = false;
				panelSingleUnit.Visible = true;
				chkColorExcelCells.Visible = true;
				chkOpenExcelAfterRun.Visible = true;
				pictureBox.Image = imageList.Images[0];
				break;
			case SerialConfig.ViewTypes.AllUnitsInOneSheet:
				panelAllUnits.Visible = true;
				panelSingleUnit.Visible = false;
				chkColorExcelCells.Visible = true;
				chkOpenExcelAfterRun.Visible = true;
				switch ((SerialConfig.AllUnitsFormatOptions)GetSelectedRBValue(radioAllUnitsType))
				{
				case SerialConfig.AllUnitsFormatOptions.WideFormat:
					pictureBox.Image = imageList.Images[1];
					break;
				case SerialConfig.AllUnitsFormatOptions.LongWideFormat:
					pictureBox.Image = imageList.Images[1];
					break;
				case SerialConfig.AllUnitsFormatOptions.LongFormat:
					pictureBox.Image = imageList.Images[2];
					break;
				}
				break;
			case SerialConfig.ViewTypes.NoExcelLogging:
				panelAllUnits.Visible = false;
				panelSingleUnit.Visible = false;
				pictureBox.Image = null;
				chkColorExcelCells.Visible = false;
				chkOpenExcelAfterRun.Visible = false;
				break;
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
	}

	private int GetSelectedRBValue(GroupBox groupBox)
	{
		RadioButton radioButton = groupBox.Controls.OfType<RadioButton>().FirstOrDefault((RadioButton n) => n.Checked);
		return int.Parse(radioButton.Tag.ToString());
	}

	private void SetSelectedRBValue(GroupBox groupBox, int RBTag)
	{
		RadioButton radioButton = groupBox.Controls.OfType<RadioButton>().FirstOrDefault((RadioButton n) => int.Parse(n.Tag as string) == RBTag);
		radioButton.Checked = true;
	}

	private void ConfigurationUI_Load(object sender, EventArgs e)
	{
		try
		{
			try
			{
				CurrentConfig = TestResultsLite.DataLoggingConfig;
			}
			catch
			{
				CurrentConfig = new SerialConfig();
			}
			txtAppendFileName.Text = CurrentConfig.ExcelFileName;
			txtExcelFileName.Text = CurrentConfig.OutputFile;
			txtExcelTemplateName.Text = CurrentConfig.ExcelTemplate;
			txtGroupName.Text = CurrentConfig.GroupName;
			txtLocation.Text = CurrentConfig.FileLocation;
			SetSelectedRBValue(radioAllUnitsType, (int)CurrentConfig.AllUnitsFormatOption);
			SetSelectedRBValue(radioFormatType, (int)CurrentConfig.ViewType);
			SetSelectedRBValue(radioFile, (int)CurrentConfig.FileOption);
			chkBoxPromptInvalidMap.Checked = CurrentConfig.PromptInvalidGroupName;
			chkBoxShowCharValue.Checked = CurrentConfig.ShowCharValue;
			chkEnableGrid.Checked = CurrentConfig.EnableGrid;
			chkColorExcelCells.Checked = CurrentConfig.EnableExcelCellColoring;
			chkOpenExcelAfterRun.Checked = CurrentConfig.OpenExcelAfterTestRun;
			numUpDownMaxArraySize.Value = Convert.ToDecimal(CurrentConfig.MaxVisibleArraySize);
			chkAutoScrollGrid.Checked = CurrentConfig.AutoScrollGrid;
			chkShowTestsWithoutParameters.Checked = CurrentConfig.ShowTestsWithoutParameters;
			chkEnableVisibleArraySize.Checked = CurrentConfig.EnableVisibleArraySize;
			chkShowLinkedTreeNameColumn.Checked = CurrentConfig.ShowLinkedTreeNameColumn;
			comboBoxLinesToKeep.Text = CurrentConfig.LinesToKeep;
			chkAutoLogCsv.Checked = CurrentConfig.EnableCSVLog;
		}
		catch (Exception)
		{
		}
	}

	public static SerialConfig LoadDataLogConfigFile()
	{
		FileStream fileStream = null;
		SerialConfig result = null;
		try
		{
			string cONFIG_FILE = CONFIG_FILE;
			if (File.Exists(cONFIG_FILE))
			{
				XmlSerializer xmlSerializer = new XmlSerializer(typeof(SerialConfig));
				fileStream = new FileStream(cONFIG_FILE, FileMode.Open);
				if (fileStream != null)
				{
					try
					{
						result = (SerialConfig)xmlSerializer.Deserialize(fileStream);
					}
					catch
					{
						result = new SerialConfig();
					}
					fileStream.Close();
				}
			}
			else
			{
				result = new SerialConfig();
			}
		}
		catch
		{
		}
		finally
		{
			fileStream?.Close();
		}
		return result;
	}

	private void radioFile_ValueChanged(object sender, EventArgs e)
	{
		switch ((SerialConfig.FileOptions)GetSelectedRBValue(radioFile))
		{
		case SerialConfig.FileOptions.AppendFile:
			txtAppendFileName.Enabled = true;
			btnAppendFile.Enabled = true;
			txtLocation.Enabled = false;
			btnFileLocation.Enabled = false;
			break;
		case SerialConfig.FileOptions.NewFile:
			txtAppendFileName.Enabled = false;
			btnAppendFile.Enabled = false;
			txtLocation.Enabled = true;
			btnFileLocation.Enabled = true;
			break;
		}
	}

	private void btnAppendFile_Click(object sender, EventArgs e)
	{
		openFile.Filter = "Excel File (*.xls)|*.xls";
		if (openFile.ShowDialog() == DialogResult.OK)
		{
			txtAppendFileName.Text = openFile.FileName;
		}
	}

	private void btnFileLocation_Click(object sender, EventArgs e)
	{
		if (folderBrowser.ShowDialog() == DialogResult.OK)
		{
			txtLocation.Text = folderBrowser.SelectedPath;
		}
	}

	private void btnExcelTemplate_Click(object sender, EventArgs e)
	{
		openFile.Filter = "Excel Template (*.xlt)|*.xlt";
		if (openFile.ShowDialog() == DialogResult.OK)
		{
			txtExcelTemplateName.Text = openFile.FileName;
		}
	}

	private void btnExcelFileName_Click(object sender, EventArgs e)
	{
		openFile.Filter = "Excel File (*.xls)|*.xls";
		if (openFile.ShowDialog() == DialogResult.OK)
		{
			txtExcelFileName.Text = openFile.FileName;
		}
	}

	private void ConfigurationUI_Closing(object sender, CancelEventArgs e)
	{
		if (base.DialogResult == DialogResult.OK && !SerialConfig.ValidateGroupName(txtGroupName.Text))
		{
			e.Cancel = true;
		}
	}

	private void btnOk_Click(object sender, EventArgs e)
	{
		try
		{
			CurrentConfig.ExcelFileName = txtAppendFileName.Text;
			CurrentConfig.ExcelTemplate = txtExcelTemplateName.Text;
			if (txtLocation.Text.Trim() == "")
			{
				txtLocation.Text = "TestLog";
			}
			else
			{
				CurrentConfig.FileLocation = txtLocation.Text;
			}
			CurrentConfig.GroupName = txtGroupName.Text;
			CurrentConfig.OutputFile = txtExcelFileName.Text;
			CurrentConfig.FileOption = (SerialConfig.FileOptions)GetSelectedRBValue(radioFile);
			CurrentConfig.ViewType = (SerialConfig.ViewTypes)GetSelectedRBValue(radioFormatType);
			CurrentConfig.PromptInvalidGroupName = chkBoxPromptInvalidMap.Checked;
			CurrentConfig.ShowCharValue = chkBoxShowCharValue.Checked;
			CurrentConfig.EnableGrid = chkEnableGrid.Checked;
			CurrentConfig.EnableExcelCellColoring = chkColorExcelCells.Checked;
			CurrentConfig.OpenExcelAfterTestRun = chkOpenExcelAfterRun.Checked;
			CurrentConfig.MaxVisibleArraySize = int.Parse(numUpDownMaxArraySize.Value.ToString());
			CurrentConfig.AutoScrollGrid = chkAutoScrollGrid.Checked;
			CurrentConfig.ShowTestsWithoutParameters = chkShowTestsWithoutParameters.Checked;
			CurrentConfig.EnableVisibleArraySize = chkEnableVisibleArraySize.Checked;
			CurrentConfig.AllUnitsFormatOption = (SerialConfig.AllUnitsFormatOptions)GetSelectedRBValue(radioAllUnitsType);
			CurrentConfig.ShowLinkedTreeNameColumn = chkShowLinkedTreeNameColumn.Checked;
			CurrentConfig.LinesToKeep = comboBoxLinesToKeep.Text.Trim();
			CurrentConfig.EnableCSVLog = chkAutoLogCsv.Checked;
			TestResultsLite.DataLoggingConfig = CurrentConfig;
		}
		catch (Exception ex)
		{
			MessageBox.Show("Error Saving " + ex.Message);
		}
	}

	public static void WriteToFile(SerialConfig CurrentConfig)
	{
		TextWriter textWriter = null;
		try
		{
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(SerialConfig));
			string cONFIG_FILE = CONFIG_FILE;
			textWriter = new StreamWriter(cONFIG_FILE);
			xmlSerializer.Serialize(textWriter, CurrentConfig);
			if (textWriter != null)
			{
				textWriter.Close();
				textWriter = null;
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show("Error while Saving XML " + ex.Message);
		}
		finally
		{
			textWriter?.Close();
		}
	}

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

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

	private void radioAllUnitsType_ValueChanged(object sender, EventArgs e)
	{
		switch ((SerialConfig.AllUnitsFormatOptions)GetSelectedRBValue(radioAllUnitsType))
		{
		case SerialConfig.AllUnitsFormatOptions.WideFormat:
			pictureBox.Image = imageList.Images[1];
			break;
		case SerialConfig.AllUnitsFormatOptions.LongFormat:
			pictureBox.Image = imageList.Images[2];
			break;
		}
	}

	private void chkEnableGrid_CheckedChanged(object sender, EventArgs e)
	{
		if (chkEnableGrid.Checked)
		{
			chkAutoScrollGrid.Enabled = true;
			chkEnableVisibleArraySize.Enabled = true;
			chkShowTestsWithoutParameters.Enabled = true;
			chkShowLinkedTreeNameColumn.Enabled = true;
		}
		else
		{
			chkAutoScrollGrid.Enabled = false;
			chkEnableVisibleArraySize.Enabled = false;
			chkShowTestsWithoutParameters.Enabled = false;
			chkShowLinkedTreeNameColumn.Enabled = false;
		}
	}

	private void chkEnableVisibleArraySize_CheckedChanged(object sender, EventArgs e)
	{
		try
		{
			if (chkEnableVisibleArraySize.Checked)
			{
				numUpDownMaxArraySize.Enabled = true;
			}
			else
			{
				numUpDownMaxArraySize.Enabled = false;
			}
		}
		catch
		{
		}
	}

	private void chkEnableVisibleArraySize_EnabledChanged(object sender, EventArgs e)
	{
		try
		{
			if (chkEnableVisibleArraySize.Checked && chkEnableVisibleArraySize.Enabled)
			{
				lblMaxVisibleArraySize.Enabled = true;
				numUpDownMaxArraySize.Enabled = true;
			}
			else
			{
				lblMaxVisibleArraySize.Enabled = false;
				numUpDownMaxArraySize.Enabled = false;
			}
		}
		catch
		{
		}
	}
}
