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

namespace QC.SmartMatchApp;

public class StartTrialRunDialog : Form
{
	private List<string> selectedBandClasses = new List<string>();

	public bool segmentedRun = true;

	public bool antennaSegmentedRun = true;

	private IContainer components;

	private Button button1;

	private Button button2;

	private RadioButton rbCombinedMode;

	private RadioButton rbSegmentedMode;

	private GroupBox groupBox1;

	private Button btnUp;

	private Button btnDown;

	private CheckedListBox checkedListBoxBands;

	private CheckedListBox checkedListBoxAntenna;

	public List<string> SelectedBandClasses => selectedBandClasses;

	public bool SegmentedRun => segmentedRun;

	public StartTrialRunDialog(List<string> bandClassesToDisplay)
	{
		InitializeComponent();
		checkedListBoxAntenna.SetItemChecked(0, value: true);
		foreach (string item in bandClassesToDisplay)
		{
			checkedListBoxBands.Items.Add("PA_" + item, isChecked: true);
		}
	}

	private void btnUp_Click(object sender, EventArgs e)
	{
		if (checkedListBoxBands.SelectedItems.Count > 0)
		{
			object obj = checkedListBoxBands.SelectedItems[0];
			int num = checkedListBoxBands.SelectedIndices[0];
			bool value = checkedListBoxBands.CheckedIndices.Contains(num);
			if (num > 0)
			{
				checkedListBoxBands.Items.Remove(obj);
				checkedListBoxBands.Items.Insert(num - 1, obj);
				checkedListBoxBands.SetItemChecked(num - 1, value);
				checkedListBoxBands.SetSelected(num - 1, value: true);
			}
		}
	}

	private void btnDown_Click(object sender, EventArgs e)
	{
		if (checkedListBoxBands.SelectedItems.Count > 0)
		{
			object obj = checkedListBoxBands.SelectedItems[0];
			int num = checkedListBoxBands.SelectedIndices[0];
			bool value = checkedListBoxBands.CheckedIndices.Contains(num);
			if (num < checkedListBoxBands.Items.Count - 1)
			{
				checkedListBoxBands.Items.Remove(obj);
				checkedListBoxBands.Items.Insert(num + 1, obj);
				checkedListBoxBands.SetItemChecked(num + 1, value);
				checkedListBoxBands.SetSelected(num + 1, value: true);
			}
		}
	}

	private void rbSegmentedMode_CheckedChanged(object sender, EventArgs e)
	{
		segmentedRun = rbSegmentedMode.Checked;
		checkedListBoxAntenna.Enabled = segmentedRun;
	}

	private void checkedListBoxBands_ItemCheck(object sender, ItemCheckEventArgs e)
	{
		string text = checkedListBoxBands.Items[e.Index].ToString();
		text = text.Substring(text.IndexOf('_') + 1);
		if (e.NewValue == CheckState.Checked)
		{
			selectedBandClasses.Add(text);
		}
		else if (e.NewValue == CheckState.Unchecked)
		{
			selectedBandClasses.Remove(text);
		}
	}

	private void checkedListBoxAntenna_ItemCheck(object sender, ItemCheckEventArgs e)
	{
		if (e.NewValue == CheckState.Checked)
		{
			antennaSegmentedRun = true;
		}
		else if (e.NewValue == CheckState.Unchecked)
		{
			antennaSegmentedRun = false;
		}
	}

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

	private void InitializeComponent()
	{
		this.button1 = new System.Windows.Forms.Button();
		this.button2 = new System.Windows.Forms.Button();
		this.rbCombinedMode = new System.Windows.Forms.RadioButton();
		this.rbSegmentedMode = new System.Windows.Forms.RadioButton();
		this.groupBox1 = new System.Windows.Forms.GroupBox();
		this.btnUp = new System.Windows.Forms.Button();
		this.btnDown = new System.Windows.Forms.Button();
		this.checkedListBoxBands = new System.Windows.Forms.CheckedListBox();
		this.checkedListBoxAntenna = new System.Windows.Forms.CheckedListBox();
		this.groupBox1.SuspendLayout();
		base.SuspendLayout();
		this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
		this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.button1.Location = new System.Drawing.Point(37, 233);
		this.button1.Name = "button1";
		this.button1.Size = new System.Drawing.Size(80, 29);
		this.button1.TabIndex = 0;
		this.button1.Text = "&Start";
		this.button1.UseVisualStyleBackColor = true;
		this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
		this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.button2.Location = new System.Drawing.Point(123, 233);
		this.button2.Name = "button2";
		this.button2.Size = new System.Drawing.Size(80, 29);
		this.button2.TabIndex = 1;
		this.button2.Text = "&Cancel";
		this.button2.UseVisualStyleBackColor = true;
		this.rbCombinedMode.AutoSize = true;
		this.rbCombinedMode.Enabled = false;
		this.rbCombinedMode.Location = new System.Drawing.Point(6, 19);
		this.rbCombinedMode.Name = "rbCombinedMode";
		this.rbCombinedMode.Size = new System.Drawing.Size(72, 17);
		this.rbCombinedMode.TabIndex = 2;
		this.rbCombinedMode.Text = "Combined";
		this.rbCombinedMode.UseVisualStyleBackColor = true;
		this.rbCombinedMode.Visible = false;
		this.rbCombinedMode.CheckedChanged += new System.EventHandler(rbSegmentedMode_CheckedChanged);
		this.rbSegmentedMode.AutoSize = true;
		this.rbSegmentedMode.Checked = true;
		this.rbSegmentedMode.Location = new System.Drawing.Point(6, 42);
		this.rbSegmentedMode.Name = "rbSegmentedMode";
		this.rbSegmentedMode.Size = new System.Drawing.Size(79, 17);
		this.rbSegmentedMode.TabIndex = 3;
		this.rbSegmentedMode.TabStop = true;
		this.rbSegmentedMode.Text = "Segmented";
		this.rbSegmentedMode.UseVisualStyleBackColor = true;
		this.rbSegmentedMode.CheckedChanged += new System.EventHandler(rbSegmentedMode_CheckedChanged);
		this.groupBox1.Controls.Add(this.rbCombinedMode);
		this.groupBox1.Controls.Add(this.rbSegmentedMode);
		this.groupBox1.Location = new System.Drawing.Point(12, 12);
		this.groupBox1.Name = "groupBox1";
		this.groupBox1.Size = new System.Drawing.Size(191, 77);
		this.groupBox1.TabIndex = 4;
		this.groupBox1.TabStop = false;
		this.groupBox1.Text = "Execution Mode";
		this.btnUp.Location = new System.Drawing.Point(171, 95);
		this.btnUp.Name = "btnUp";
		this.btnUp.Size = new System.Drawing.Size(32, 32);
		this.btnUp.TabIndex = 6;
		this.btnUp.Text = "/\\";
		this.btnUp.UseVisualStyleBackColor = true;
		this.btnUp.Click += new System.EventHandler(btnUp_Click);
		this.btnDown.Location = new System.Drawing.Point(171, 180);
		this.btnDown.Name = "btnDown";
		this.btnDown.Size = new System.Drawing.Size(32, 32);
		this.btnDown.TabIndex = 7;
		this.btnDown.Text = "\\/";
		this.btnDown.UseVisualStyleBackColor = true;
		this.btnDown.Click += new System.EventHandler(btnDown_Click);
		this.checkedListBoxBands.FormattingEnabled = true;
		this.checkedListBoxBands.Location = new System.Drawing.Point(12, 118);
		this.checkedListBoxBands.Name = "checkedListBoxBands";
		this.checkedListBoxBands.Size = new System.Drawing.Size(153, 94);
		this.checkedListBoxBands.TabIndex = 5;
		this.checkedListBoxBands.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(checkedListBoxBands_ItemCheck);
		this.checkedListBoxAntenna.FormattingEnabled = true;
		this.checkedListBoxAntenna.Items.AddRange(new object[1] { "Antenna" });
		this.checkedListBoxAntenna.Location = new System.Drawing.Point(12, 96);
		this.checkedListBoxAntenna.Name = "checkedListBoxAntenna";
		this.checkedListBoxAntenna.Size = new System.Drawing.Size(153, 19);
		this.checkedListBoxAntenna.TabIndex = 4;
		this.checkedListBoxAntenna.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(checkedListBoxAntenna_ItemCheck);
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(211, 267);
		base.ControlBox = false;
		base.Controls.Add(this.checkedListBoxAntenna);
		base.Controls.Add(this.checkedListBoxBands);
		base.Controls.Add(this.btnDown);
		base.Controls.Add(this.btnUp);
		base.Controls.Add(this.groupBox1);
		base.Controls.Add(this.button2);
		base.Controls.Add(this.button1);
		this.MaximumSize = new System.Drawing.Size(227, 306);
		this.MinimumSize = new System.Drawing.Size(227, 306);
		base.Name = "StartTrialRunDialog";
		base.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
		this.Text = "Topologies to Match";
		this.groupBox1.ResumeLayout(false);
		this.groupBox1.PerformLayout();
		base.ResumeLayout(false);
	}
}
