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

namespace QDART_MFG_CfgEditor;

public class OffsetForm : Form
{
	public const int KEY_ENTER = 13;

	private IContainer components;

	private Label labelOffset1;

	private Label labelOffset2;

	private TextBox textBoxOffset;

	private Label labelOffsetUnit;

	private Button btnApply;

	private Button btnReset;

	private Button btnCancel;

	public string OffSet
	{
		get
		{
			return textBoxOffset.Text;
		}
		set
		{
			textBoxOffset.Text = value;
		}
	}

	public OffsetForm()
	{
		InitializeComponent();
		textBoxOffset.Focus();
	}

	private void btnApply_Click(object sender, EventArgs e)
	{
		if (OffSet != null)
		{
			double result;
			if (OffSet == "")
			{
				MessageBox.Show("Offset cannot be empty. Please enter valid offset!");
				textBoxOffset.Focus();
			}
			else if (!double.TryParse(textBoxOffset.Text.ToString(), out result))
			{
				MessageBox.Show("Invalid input. Please enter valid offset!");
				textBoxOffset.Text = "";
				textBoxOffset.Focus();
			}
			else
			{
				Close();
			}
		}
	}

	private void btnReset_Click(object sender, EventArgs e)
	{
		textBoxOffset.Text = "";
		textBoxOffset.Focus();
	}

	private void btnCancel_Click(object sender, EventArgs e)
	{
		textBoxOffset.Text = "";
		Close();
	}

	private void textBoxOffset_KeyPress(object sender, KeyPressEventArgs e)
	{
		if (e.KeyChar == '\r')
		{
			btnApply_Click(null, null);
		}
	}

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

	private void InitializeComponent()
	{
		System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QDART_MFG_CfgEditor.OffsetForm));
		this.labelOffset1 = new System.Windows.Forms.Label();
		this.labelOffset2 = new System.Windows.Forms.Label();
		this.textBoxOffset = new System.Windows.Forms.TextBox();
		this.labelOffsetUnit = new System.Windows.Forms.Label();
		this.btnApply = new System.Windows.Forms.Button();
		this.btnReset = new System.Windows.Forms.Button();
		this.btnCancel = new System.Windows.Forms.Button();
		base.SuspendLayout();
		this.labelOffset1.AutoSize = true;
		this.labelOffset1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.labelOffset1.Location = new System.Drawing.Point(26, 14);
		this.labelOffset1.Name = "labelOffset1";
		this.labelOffset1.Size = new System.Drawing.Size(199, 15);
		this.labelOffset1.TabIndex = 0;
		this.labelOffset1.Text = "Are you going to add offset to Loss?";
		this.labelOffset2.AutoSize = true;
		this.labelOffset2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.labelOffset2.Location = new System.Drawing.Point(26, 46);
		this.labelOffset2.Name = "labelOffset2";
		this.labelOffset2.Size = new System.Drawing.Size(232, 45);
		this.labelOffset2.TabIndex = 1;
		this.labelOffset2.Text = "Please enter the loss offset that you need,\r\nnumbers only please, \r\ne.g. 0.031, -1.106\r\n";
		this.textBoxOffset.AcceptsReturn = true;
		this.textBoxOffset.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.textBoxOffset.Location = new System.Drawing.Point(172, 91);
		this.textBoxOffset.Multiline = true;
		this.textBoxOffset.Name = "textBoxOffset";
		this.textBoxOffset.Size = new System.Drawing.Size(100, 24);
		this.textBoxOffset.TabIndex = 2;
		this.textBoxOffset.KeyPress += new System.Windows.Forms.KeyPressEventHandler(textBoxOffset_KeyPress);
		this.labelOffsetUnit.AutoSize = true;
		this.labelOffsetUnit.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.labelOffsetUnit.Location = new System.Drawing.Point(276, 93);
		this.labelOffsetUnit.Name = "labelOffsetUnit";
		this.labelOffsetUnit.Size = new System.Drawing.Size(33, 16);
		this.labelOffsetUnit.TabIndex = 3;
		this.labelOffsetUnit.Text = "(dB)";
		this.btnApply.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnApply.Location = new System.Drawing.Point(30, 141);
		this.btnApply.Name = "btnApply";
		this.btnApply.Size = new System.Drawing.Size(75, 23);
		this.btnApply.TabIndex = 4;
		this.btnApply.Text = "Apply";
		this.btnApply.UseVisualStyleBackColor = true;
		this.btnApply.Click += new System.EventHandler(btnApply_Click);
		this.btnReset.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnReset.Location = new System.Drawing.Point(139, 141);
		this.btnReset.Name = "btnReset";
		this.btnReset.Size = new System.Drawing.Size(75, 23);
		this.btnReset.TabIndex = 5;
		this.btnReset.Text = "Reset";
		this.btnReset.UseVisualStyleBackColor = true;
		this.btnReset.Click += new System.EventHandler(btnReset_Click);
		this.btnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.btnCancel.Location = new System.Drawing.Point(240, 141);
		this.btnCancel.Name = "btnCancel";
		this.btnCancel.Size = new System.Drawing.Size(75, 23);
		this.btnCancel.TabIndex = 6;
		this.btnCancel.Text = "Cancel";
		this.btnCancel.UseVisualStyleBackColor = true;
		this.btnCancel.Click += new System.EventHandler(btnCancel_Click);
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(343, 183);
		base.Controls.Add(this.btnCancel);
		base.Controls.Add(this.btnReset);
		base.Controls.Add(this.btnApply);
		base.Controls.Add(this.labelOffsetUnit);
		base.Controls.Add(this.textBoxOffset);
		base.Controls.Add(this.labelOffset2);
		base.Controls.Add(this.labelOffset1);
		base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
		base.MaximizeBox = false;
		this.MaximumSize = new System.Drawing.Size(359, 221);
		base.MinimizeBox = false;
		this.MinimumSize = new System.Drawing.Size(359, 221);
		base.Name = "OffsetForm";
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
		this.Text = "OffSet";
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
