using System;
using System.ComponentModel;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace TeslaConsole;

public class dlgOptionalStartParams : Form
{
	private IContainer components;

	private Label label1;

	private TableLayoutPanel tlpResolution;

	private Label label2;

	private CheckBox chkCustomResolution;

	private TextBox txtResX;

	private TextBox txtResY;

	private Label label3;

	private Label label4;

	private CheckBox chkLiveCamera;

	private Button cmdOK;

	private CheckBox chkGameClient;

	private CheckBox chkMissionReview;

	private Label label5;

	public Size? Resolution
	{
		get
		{
			if (chkCustomResolution.Checked && txtResX.Text != "" && txtResY.Text != "")
			{
				return new Size(int.Parse(txtResX.Text), int.Parse(txtResY.Text));
			}
			return null;
		}
		set
		{
			chkCustomResolution.Checked = value.HasValue;
			if (value.HasValue)
			{
				txtResX.Text = value.Value.Width.ToString();
				txtResY.Text = value.Value.Height.ToString();
			}
		}
	}

	public bool IsGameClient
	{
		get
		{
			return chkGameClient.Checked;
		}
		set
		{
			chkGameClient.Checked = value;
		}
	}

	public bool IsLiveCam
	{
		get
		{
			return chkLiveCamera.Checked;
		}
		set
		{
			chkLiveCamera.Checked = value;
		}
	}

	public bool IsMissionReview
	{
		get
		{
			return chkMissionReview.Checked;
		}
		set
		{
			chkMissionReview.Checked = value;
		}
	}

	public dlgOptionalStartParams()
	{
		InitializeComponent();
	}

	private void chkCustomResolution_CheckedChanged(object sender, EventArgs e)
	{
		tlpResolution.Enabled = chkCustomResolution.Checked;
	}

	private void txtRes_TextChanged(object sender, EventArgs e)
	{
		TextBox textBox = (TextBox)sender;
		int selectionStart = textBox.SelectionStart;
		int selectionLength = textBox.SelectionLength;
		textBox.Text = Regex.Replace(textBox.Text, "[^0-9]", "");
		textBox.Select(selectionStart, selectionLength);
	}

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

	private void InitializeComponent()
	{
		this.label1 = new System.Windows.Forms.Label();
		this.tlpResolution = new System.Windows.Forms.TableLayoutPanel();
		this.txtResX = new System.Windows.Forms.TextBox();
		this.label2 = new System.Windows.Forms.Label();
		this.txtResY = new System.Windows.Forms.TextBox();
		this.label3 = new System.Windows.Forms.Label();
		this.label4 = new System.Windows.Forms.Label();
		this.chkCustomResolution = new System.Windows.Forms.CheckBox();
		this.chkLiveCamera = new System.Windows.Forms.CheckBox();
		this.cmdOK = new System.Windows.Forms.Button();
		this.chkGameClient = new System.Windows.Forms.CheckBox();
		this.chkMissionReview = new System.Windows.Forms.CheckBox();
		this.label5 = new System.Windows.Forms.Label();
		this.tlpResolution.SuspendLayout();
		base.SuspendLayout();
		this.label1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.label1.Location = new System.Drawing.Point(12, 9);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(195, 32);
		this.label1.TabIndex = 0;
		this.label1.Text = "Select options you would like sent to Red Planet when it starts.";
		this.tlpResolution.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.tlpResolution.ColumnCount = 3;
		this.tlpResolution.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50f));
		this.tlpResolution.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
		this.tlpResolution.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50f));
		this.tlpResolution.Controls.Add(this.txtResX, 0, 1);
		this.tlpResolution.Controls.Add(this.label2, 0, 0);
		this.tlpResolution.Controls.Add(this.txtResY, 2, 1);
		this.tlpResolution.Controls.Add(this.label3, 1, 1);
		this.tlpResolution.Controls.Add(this.label4, 2, 0);
		this.tlpResolution.Enabled = false;
		this.tlpResolution.Location = new System.Drawing.Point(27, 67);
		this.tlpResolution.Name = "tlpResolution";
		this.tlpResolution.RowCount = 2;
		this.tlpResolution.RowStyles.Add(new System.Windows.Forms.RowStyle());
		this.tlpResolution.RowStyles.Add(new System.Windows.Forms.RowStyle());
		this.tlpResolution.Size = new System.Drawing.Size(180, 42);
		this.tlpResolution.TabIndex = 1;
		this.txtResX.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.txtResX.Location = new System.Drawing.Point(3, 17);
		this.txtResX.MaxLength = 5;
		this.txtResX.Name = "txtResX";
		this.txtResX.Size = new System.Drawing.Size(75, 20);
		this.txtResX.TabIndex = 3;
		this.txtResX.TextChanged += new System.EventHandler(txtRes_TextChanged);
		this.label2.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(3, 0);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(35, 13);
		this.label2.TabIndex = 3;
		this.label2.Text = "Width";
		this.txtResY.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.txtResY.Location = new System.Drawing.Point(102, 17);
		this.txtResY.MaxLength = 5;
		this.txtResY.Name = "txtResY";
		this.txtResY.Size = new System.Drawing.Size(75, 20);
		this.txtResY.TabIndex = 5;
		this.txtResY.TextChanged += new System.EventHandler(txtRes_TextChanged);
		this.label3.Anchor = System.Windows.Forms.AnchorStyles.None;
		this.label3.AutoSize = true;
		this.label3.Location = new System.Drawing.Point(84, 21);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(12, 13);
		this.label3.TabIndex = 6;
		this.label3.Text = "x";
		this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
		this.label4.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
		this.label4.AutoSize = true;
		this.label4.Location = new System.Drawing.Point(102, 0);
		this.label4.Name = "label4";
		this.label4.Size = new System.Drawing.Size(38, 13);
		this.label4.TabIndex = 7;
		this.label4.Text = "Height";
		this.chkCustomResolution.AutoSize = true;
		this.chkCustomResolution.Location = new System.Drawing.Point(12, 44);
		this.chkCustomResolution.Name = "chkCustomResolution";
		this.chkCustomResolution.Size = new System.Drawing.Size(114, 17);
		this.chkCustomResolution.TabIndex = 2;
		this.chkCustomResolution.Text = "Custom Resolution";
		this.chkCustomResolution.UseVisualStyleBackColor = true;
		this.chkCustomResolution.CheckedChanged += new System.EventHandler(chkCustomResolution_CheckedChanged);
		this.chkLiveCamera.AutoSize = true;
		this.chkLiveCamera.Location = new System.Drawing.Point(12, 185);
		this.chkLiveCamera.Name = "chkLiveCamera";
		this.chkLiveCamera.Size = new System.Drawing.Size(85, 17);
		this.chkLiveCamera.TabIndex = 3;
		this.chkLiveCamera.Text = "Live Camera";
		this.chkLiveCamera.UseVisualStyleBackColor = true;
		this.cmdOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
		this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK;
		this.cmdOK.Location = new System.Drawing.Point(132, 244);
		this.cmdOK.Name = "cmdOK";
		this.cmdOK.Size = new System.Drawing.Size(75, 23);
		this.cmdOK.TabIndex = 4;
		this.cmdOK.Text = "OK";
		this.cmdOK.UseVisualStyleBackColor = true;
		this.chkGameClient.AutoSize = true;
		this.chkGameClient.Location = new System.Drawing.Point(12, 162);
		this.chkGameClient.Name = "chkGameClient";
		this.chkGameClient.Size = new System.Drawing.Size(83, 17);
		this.chkGameClient.TabIndex = 5;
		this.chkGameClient.Text = "Game Client";
		this.chkGameClient.UseVisualStyleBackColor = true;
		this.chkMissionReview.AutoSize = true;
		this.chkMissionReview.Location = new System.Drawing.Point(12, 208);
		this.chkMissionReview.Name = "chkMissionReview";
		this.chkMissionReview.Size = new System.Drawing.Size(100, 17);
		this.chkMissionReview.TabIndex = 6;
		this.chkMissionReview.Text = "Mission Review";
		this.chkMissionReview.UseVisualStyleBackColor = true;
		this.label5.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.label5.Location = new System.Drawing.Point(9, 127);
		this.label5.Name = "label5";
		this.label5.Size = new System.Drawing.Size(195, 32);
		this.label5.TabIndex = 7;
		this.label5.Text = "Select which roles you would like this machine to fill.";
		base.AcceptButton = this.cmdOK;
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(219, 279);
		base.Controls.Add(this.label5);
		base.Controls.Add(this.chkMissionReview);
		base.Controls.Add(this.chkGameClient);
		base.Controls.Add(this.cmdOK);
		base.Controls.Add(this.chkLiveCamera);
		base.Controls.Add(this.label1);
		base.Controls.Add(this.chkCustomResolution);
		base.Controls.Add(this.tlpResolution);
		base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
		base.MaximizeBox = false;
		base.MinimizeBox = false;
		base.Name = "dlgOptionalStartParams";
		this.Text = "Select Optional Parameters";
		this.tlpResolution.ResumeLayout(false);
		this.tlpResolution.PerformLayout();
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
