using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace QCRPG.TSL.BT;

public class LERemoteDeviceOptions : Form
{
	private string bdAddress = "";

	private bool positiveReply = true;

	private bool negativeReply;

	private string leLongTermKey;

	private string leRandomNumber;

	private string leEncryptedDiversifier;

	private List<string> leLongTermKeys;

	private List<string> leRandomNumbers;

	private uint leConnUpdateIntervalMin;

	private uint leConnUpdateIntervalMax;

	private uint leConnUpdateTimeoutmsec;

	private uint leConnUpdateLatency;

	private uint leConnUpdateCELengthMin;

	private uint leConnUpdateCELengthMax;

	private bool leConnRequestPositiveAutoReply = true;

	private bool leConnRequestNegativeAutoReply;

	private uint leConnRequestRejectReason;

	private IContainer components;

	private SplitContainer splitContainer1;

	private TabControl tabControlLERemoteDeviceOptions;

	private TabPage tabPageLERemoteDeviceAttributes;

	private TabPage tabPageEncryption;

	private TabPage tabPageUpdateConnection;

	private SplitContainer splitContainer2;

	private Button buttonOK;

	private Button buttonCancel;

	private TextBox textBoxBDAddress;

	private Label labelBDAddress;

	private GroupBox groupBoxAutoReply;

	private RadioButton radioButtonNegative;

	private RadioButton radioButtonPositive;

	private GroupBox groupBoxEncryptionParameters;

	private TextBox textBoxEncryptedDiversifier;

	private ComboBox comboBoxRandomNumber;

	private ComboBox comboBoxLongTermKey;

	private Label labelEncyptedDivsiefer;

	private Label labelRandomNumber;

	private Label labelLongTermKey;

	private GroupBox groupBoxLeConnEventTiming;

	private GroupBox groupBoxLEConnectionTiming;

	private TextBox tbLEUpdateConnInternalLatency;

	private TextBox tbLEUpdateConnInternalTimeout;

	private Label label4;

	private Label label2;

	private TextBox tbLEUpdateConnInternalMaxLength;

	private TextBox tbLEUpdateConnInternalMinLength;

	private Label label5;

	private Label label6;

	private TextBox tbLEUpdateConnInternalMax;

	private TextBox tbLEUpdateConnInternalMin;

	private Label label3;

	private Label label1;

	private Button buttonReverseRandomNumber;

	private Button buttonReverseLongTermKey;

	private GroupBox groupBoxLeConnAutoReply;

	private RadioButton positiveParamRequestRadioButton;

	private RadioButton negativeParamRequestRadioButton;

	private TextBox tbParamRejectReason;

	private Label labelParamRejectReason;

	public string BDAddress
	{
		get
		{
			return bdAddress;
		}
		set
		{
			bdAddress = value;
			tabControlLERemoteDeviceOptions.Controls.Remove(tabPageLERemoteDeviceAttributes);
		}
	}

	public bool PositiveReply
	{
		get
		{
			return positiveReply;
		}
		set
		{
			positiveReply = value;
		}
	}

	public bool NegativeReply
	{
		get
		{
			return negativeReply;
		}
		set
		{
			negativeReply = value;
		}
	}

	public string LeLongTermKey
	{
		get
		{
			return leLongTermKey;
		}
		set
		{
			leLongTermKey = value;
		}
	}

	public string LeRandomNumber
	{
		get
		{
			return leRandomNumber;
		}
		set
		{
			leRandomNumber = value;
		}
	}

	public string LeEncryptedDiversifier
	{
		get
		{
			return leEncryptedDiversifier;
		}
		set
		{
			leEncryptedDiversifier = value;
		}
	}

	public List<string> LeLongTermKeys
	{
		set
		{
			leLongTermKeys = value;
		}
	}

	public List<string> LeRandomNumbers
	{
		set
		{
			leRandomNumbers = value;
		}
	}

	public uint LEConnUpdateIntervalMin
	{
		get
		{
			return leConnUpdateIntervalMin;
		}
		set
		{
			leConnUpdateIntervalMin = value;
		}
	}

	public uint LEConnUpdateIntervalMax
	{
		get
		{
			return leConnUpdateIntervalMax;
		}
		set
		{
			leConnUpdateIntervalMax = value;
		}
	}

	public uint LEConnUpdateTimeoutmsec
	{
		get
		{
			return leConnUpdateTimeoutmsec;
		}
		set
		{
			leConnUpdateTimeoutmsec = value;
		}
	}

	public uint LEConnUpdateLatency
	{
		get
		{
			return leConnUpdateLatency;
		}
		set
		{
			leConnUpdateLatency = value;
		}
	}

	public uint LEConnUpdateCELengthMin
	{
		get
		{
			return leConnUpdateCELengthMin;
		}
		set
		{
			leConnUpdateCELengthMin = value;
		}
	}

	public uint LEConnUpdateCELengthMax
	{
		get
		{
			return leConnUpdateCELengthMax;
		}
		set
		{
			leConnUpdateCELengthMax = value;
		}
	}

	public bool LEConnRequestPositiveAutoReply
	{
		get
		{
			return leConnRequestPositiveAutoReply;
		}
		set
		{
			leConnRequestPositiveAutoReply = value;
		}
	}

	public bool LEConnRequestNegativeAutoReply
	{
		get
		{
			return leConnRequestNegativeAutoReply;
		}
		set
		{
			leConnRequestNegativeAutoReply = value;
		}
	}

	public uint LEConnRequestRejectReason
	{
		get
		{
			return leConnRequestRejectReason;
		}
		set
		{
			leConnRequestRejectReason = value;
		}
	}

	public LERemoteDeviceOptions()
	{
		InitializeComponent();
	}

	private void LERemoteDeviceOptions_Load(object sender, EventArgs e)
	{
		textBoxBDAddress.Text = bdAddress;
		comboBoxLongTermKey.Text = leLongTermKey;
		comboBoxLongTermKey.Items.AddRange(leLongTermKeys.ToArray());
		comboBoxRandomNumber.Text = leRandomNumber;
		comboBoxRandomNumber.Items.AddRange(leRandomNumbers.ToArray());
		textBoxEncryptedDiversifier.Text = leEncryptedDiversifier;
		tbLEUpdateConnInternalMin.Text = leConnUpdateIntervalMin.ToString();
		tbLEUpdateConnInternalMax.Text = leConnUpdateIntervalMax.ToString();
		tbLEUpdateConnInternalTimeout.Text = leConnUpdateTimeoutmsec.ToString();
		tbLEUpdateConnInternalLatency.Text = leConnUpdateLatency.ToString();
		tbLEUpdateConnInternalMinLength.Text = leConnUpdateCELengthMin.ToString();
		tbLEUpdateConnInternalMaxLength.Text = leConnUpdateCELengthMax.ToString();
		positiveParamRequestRadioButton.Checked = leConnRequestPositiveAutoReply;
		negativeParamRequestRadioButton.Checked = leConnRequestNegativeAutoReply;
	}

	private void buttonOK_Click(object sender, EventArgs e)
	{
		bdAddress = textBoxBDAddress.Text;
		positiveReply = radioButtonPositive.Checked;
		negativeReply = radioButtonNegative.Checked;
		leLongTermKey = comboBoxLongTermKey.Text.ToUpper().PadLeft(32, '0');
		int num = leLongTermKeys.IndexOf(leLongTermKey);
		leLongTermKeys.Insert(0, leLongTermKey);
		if (num != -1)
		{
			leLongTermKeys.RemoveAt(num + 1);
		}
		leRandomNumber = comboBoxRandomNumber.Text.ToUpper().PadLeft(16, '0');
		int num2 = leRandomNumbers.IndexOf(leRandomNumber);
		leRandomNumbers.Insert(0, leRandomNumber);
		if (num2 != -1)
		{
			leRandomNumbers.RemoveAt(num2 + 1);
		}
		leEncryptedDiversifier = textBoxEncryptedDiversifier.Text.ToUpper().PadLeft(4, '0');
		uint.TryParse(tbLEUpdateConnInternalMin.Text.ToString(), out leConnUpdateIntervalMin);
		uint.TryParse(tbLEUpdateConnInternalMax.Text.ToString(), out leConnUpdateIntervalMax);
		uint.TryParse(tbLEUpdateConnInternalTimeout.Text.ToString(), out leConnUpdateTimeoutmsec);
		uint.TryParse(tbLEUpdateConnInternalLatency.Text.ToString(), out leConnUpdateLatency);
		uint.TryParse(tbLEUpdateConnInternalMinLength.Text.ToString(), out leConnUpdateCELengthMin);
		uint.TryParse(tbLEUpdateConnInternalMaxLength.Text.ToString(), out leConnUpdateCELengthMax);
		leConnRequestNegativeAutoReply = negativeParamRequestRadioButton.Checked;
		leConnRequestPositiveAutoReply = positiveParamRequestRadioButton.Checked;
		if (leConnRequestNegativeAutoReply)
		{
			uint.TryParse(tbParamRejectReason.Text.ToString(), out leConnRequestRejectReason);
		}
	}

	private void textBoxBDAddress_TextChanged(object sender, EventArgs e)
	{
		if (!string.IsNullOrEmpty(textBoxBDAddress.Text) && !ConfirmHex(textBoxBDAddress.Text.ToString()))
		{
			MessageBox.Show("Value is not HEX");
		}
	}

	private void comboBoxLongTermKey_TextChanged(object sender, EventArgs e)
	{
		if (!string.IsNullOrEmpty(comboBoxLongTermKey.Text) && !ConfirmHex(comboBoxLongTermKey.Text.ToString()))
		{
			MessageBox.Show("Value is not HEX");
		}
	}

	private void buttonReverseLongTermKey_Click(object sender, EventArgs e)
	{
		string key = comboBoxLongTermKey.Text.PadLeft(32, '0');
		IEnumerable<string> source = from i in Enumerable.Range(0, 16)
			select key.Substring(2 * i, 2);
		comboBoxLongTermKey.Text = string.Join(string.Empty, source.Reverse());
	}

	private bool ConfirmHex(string hexString)
	{
		Regex regex = new Regex("^[0-9A-F]+$", RegexOptions.IgnoreCase);
		return regex.IsMatch(hexString);
	}

	private void comboBoxRandomNumber_TextChanged(object sender, EventArgs e)
	{
		if (!string.IsNullOrEmpty(comboBoxRandomNumber.Text) && !ConfirmHex(comboBoxRandomNumber.Text.ToString()))
		{
			MessageBox.Show("Value is not HEX");
		}
	}

	private void buttonReverseRandomNumber_Click(object sender, EventArgs e)
	{
		string rn = comboBoxRandomNumber.Text.PadLeft(16, '0');
		IEnumerable<string> source = from i in Enumerable.Range(0, 8)
			select rn.Substring(2 * i, 2);
		comboBoxRandomNumber.Text = string.Join(string.Empty, source.Reverse());
	}

	private void textBoxEncryptedDiversifier_TextChanged(object sender, EventArgs e)
	{
		if (!string.IsNullOrEmpty(textBoxEncryptedDiversifier.Text) && !ConfirmHex(textBoxEncryptedDiversifier.Text.ToString()))
		{
			MessageBox.Show("Value is not HEX");
		}
	}

	private void tbLEUpdateConnInternalMax_TextChanged(object sender, EventArgs e)
	{
		int minValue = 0;
		int maxValue = 65535;
		string text = tbLEUpdateConnInternalMax.Text.ToString();
		VerifyInputValue(minValue, maxValue, text);
	}

	private static void VerifyInputValue(int minValue, int maxValue, string text)
	{
		int result = 0;
		if (!int.TryParse(text, out result) || result < minValue || result > maxValue)
		{
			MessageBox.Show($"Value should be between {minValue} to {maxValue}");
		}
	}

	private void tbLEUpdateConnInternalMin_TextChanged(object sender, EventArgs e)
	{
		int minValue = 0;
		int maxValue = 65535;
		string text = tbLEUpdateConnInternalMin.Text.ToString();
		VerifyInputValue(minValue, maxValue, text);
	}

	private void tbLEUpdateConnInternalTimeout_TextChanged(object sender, EventArgs e)
	{
		int minValue = 0;
		int maxValue = 32000;
		string text = tbLEUpdateConnInternalTimeout.Text.ToString();
		VerifyInputValue(minValue, maxValue, text);
	}

	private void tbLEUpdateConnInternalLatency_TextChanged(object sender, EventArgs e)
	{
		int minValue = 0;
		int maxValue = 499;
		string text = tbLEUpdateConnInternalLatency.Text.ToString();
		VerifyInputValue(minValue, maxValue, text);
	}

	private void tbLEUpdateConnInternalMinLength_TextChanged(object sender, EventArgs e)
	{
		int minValue = 0;
		int maxValue = 65535;
		string text = tbLEUpdateConnInternalMinLength.Text.ToString();
		VerifyInputValue(minValue, maxValue, text);
	}

	private void tbLEUpdateConnInternalMaxLength_TextAlignChanged(object sender, EventArgs e)
	{
		int minValue = 0;
		int maxValue = 65535;
		string text = tbLEUpdateConnInternalMaxLength.Text.ToString();
		VerifyInputValue(minValue, maxValue, text);
	}

	private void negativeParamRequestRadioButton_CheckedChanged(object sender, EventArgs e)
	{
		if (negativeParamRequestRadioButton.Checked)
		{
			labelParamRejectReason.Visible = true;
			tbParamRejectReason.Visible = true;
		}
	}

	private void positiveParamRequestRadioButton_CheckedChanged(object sender, EventArgs e)
	{
		if (positiveParamRequestRadioButton.Checked)
		{
			labelParamRejectReason.Visible = false;
			tbParamRejectReason.Visible = false;
			tbParamRejectReason.Text = "0";
		}
	}

	private void tbParamRejectReason_TextChanged(object sender, EventArgs e)
	{
		if (!string.IsNullOrEmpty(tbParamRejectReason.Text))
		{
			if (!ConfirmHex(tbParamRejectReason.Text.ToString()))
			{
				MessageBox.Show("Value is not HEX");
			}
			if (tbParamRejectReason.Text.ToString().Length > 2)
			{
				MessageBox.Show("Invalid value");
			}
		}
	}

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

	private void InitializeComponent()
	{
		this.splitContainer1 = new System.Windows.Forms.SplitContainer();
		this.tabControlLERemoteDeviceOptions = new System.Windows.Forms.TabControl();
		this.tabPageLERemoteDeviceAttributes = new System.Windows.Forms.TabPage();
		this.textBoxBDAddress = new System.Windows.Forms.TextBox();
		this.labelBDAddress = new System.Windows.Forms.Label();
		this.tabPageEncryption = new System.Windows.Forms.TabPage();
		this.groupBoxAutoReply = new System.Windows.Forms.GroupBox();
		this.radioButtonNegative = new System.Windows.Forms.RadioButton();
		this.radioButtonPositive = new System.Windows.Forms.RadioButton();
		this.groupBoxEncryptionParameters = new System.Windows.Forms.GroupBox();
		this.textBoxEncryptedDiversifier = new System.Windows.Forms.TextBox();
		this.comboBoxRandomNumber = new System.Windows.Forms.ComboBox();
		this.comboBoxLongTermKey = new System.Windows.Forms.ComboBox();
		this.labelEncyptedDivsiefer = new System.Windows.Forms.Label();
		this.labelRandomNumber = new System.Windows.Forms.Label();
		this.labelLongTermKey = new System.Windows.Forms.Label();
		this.tabPageUpdateConnection = new System.Windows.Forms.TabPage();
		this.groupBoxLeConnAutoReply = new System.Windows.Forms.GroupBox();
		this.tbParamRejectReason = new System.Windows.Forms.TextBox();
		this.labelParamRejectReason = new System.Windows.Forms.Label();
		this.negativeParamRequestRadioButton = new System.Windows.Forms.RadioButton();
		this.positiveParamRequestRadioButton = new System.Windows.Forms.RadioButton();
		this.groupBoxLeConnEventTiming = new System.Windows.Forms.GroupBox();
		this.tbLEUpdateConnInternalMaxLength = new System.Windows.Forms.TextBox();
		this.tbLEUpdateConnInternalMinLength = new System.Windows.Forms.TextBox();
		this.label5 = new System.Windows.Forms.Label();
		this.label6 = new System.Windows.Forms.Label();
		this.groupBoxLEConnectionTiming = new System.Windows.Forms.GroupBox();
		this.tbLEUpdateConnInternalLatency = new System.Windows.Forms.TextBox();
		this.tbLEUpdateConnInternalMax = new System.Windows.Forms.TextBox();
		this.tbLEUpdateConnInternalTimeout = new System.Windows.Forms.TextBox();
		this.tbLEUpdateConnInternalMin = new System.Windows.Forms.TextBox();
		this.label4 = new System.Windows.Forms.Label();
		this.label3 = new System.Windows.Forms.Label();
		this.label2 = new System.Windows.Forms.Label();
		this.label1 = new System.Windows.Forms.Label();
		this.splitContainer2 = new System.Windows.Forms.SplitContainer();
		this.buttonOK = new System.Windows.Forms.Button();
		this.buttonCancel = new System.Windows.Forms.Button();
		this.buttonReverseLongTermKey = new System.Windows.Forms.Button();
		this.buttonReverseRandomNumber = new System.Windows.Forms.Button();
		((System.ComponentModel.ISupportInitialize)this.splitContainer1).BeginInit();
		this.splitContainer1.Panel1.SuspendLayout();
		this.splitContainer1.Panel2.SuspendLayout();
		this.splitContainer1.SuspendLayout();
		this.tabControlLERemoteDeviceOptions.SuspendLayout();
		this.tabPageLERemoteDeviceAttributes.SuspendLayout();
		this.tabPageEncryption.SuspendLayout();
		this.groupBoxAutoReply.SuspendLayout();
		this.groupBoxEncryptionParameters.SuspendLayout();
		this.tabPageUpdateConnection.SuspendLayout();
		this.groupBoxLeConnAutoReply.SuspendLayout();
		this.groupBoxLeConnEventTiming.SuspendLayout();
		this.groupBoxLEConnectionTiming.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.splitContainer2).BeginInit();
		this.splitContainer2.Panel1.SuspendLayout();
		this.splitContainer2.Panel2.SuspendLayout();
		this.splitContainer2.SuspendLayout();
		base.SuspendLayout();
		this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.splitContainer1.IsSplitterFixed = true;
		this.splitContainer1.Location = new System.Drawing.Point(0, 0);
		this.splitContainer1.Name = "splitContainer1";
		this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
		this.splitContainer1.Panel1.Controls.Add(this.tabControlLERemoteDeviceOptions);
		this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
		this.splitContainer1.Size = new System.Drawing.Size(473, 497);
		this.splitContainer1.SplitterDistance = 427;
		this.splitContainer1.TabIndex = 0;
		this.tabControlLERemoteDeviceOptions.Controls.Add(this.tabPageLERemoteDeviceAttributes);
		this.tabControlLERemoteDeviceOptions.Controls.Add(this.tabPageEncryption);
		this.tabControlLERemoteDeviceOptions.Controls.Add(this.tabPageUpdateConnection);
		this.tabControlLERemoteDeviceOptions.Dock = System.Windows.Forms.DockStyle.Fill;
		this.tabControlLERemoteDeviceOptions.Location = new System.Drawing.Point(0, 0);
		this.tabControlLERemoteDeviceOptions.Name = "tabControlLERemoteDeviceOptions";
		this.tabControlLERemoteDeviceOptions.SelectedIndex = 0;
		this.tabControlLERemoteDeviceOptions.Size = new System.Drawing.Size(473, 427);
		this.tabControlLERemoteDeviceOptions.TabIndex = 0;
		this.tabPageLERemoteDeviceAttributes.Controls.Add(this.textBoxBDAddress);
		this.tabPageLERemoteDeviceAttributes.Controls.Add(this.labelBDAddress);
		this.tabPageLERemoteDeviceAttributes.Location = new System.Drawing.Point(4, 22);
		this.tabPageLERemoteDeviceAttributes.Name = "tabPageLERemoteDeviceAttributes";
		this.tabPageLERemoteDeviceAttributes.Padding = new System.Windows.Forms.Padding(3);
		this.tabPageLERemoteDeviceAttributes.Size = new System.Drawing.Size(465, 401);
		this.tabPageLERemoteDeviceAttributes.TabIndex = 0;
		this.tabPageLERemoteDeviceAttributes.Text = "LE Remote Device Attributes";
		this.tabPageLERemoteDeviceAttributes.UseVisualStyleBackColor = true;
		this.textBoxBDAddress.Location = new System.Drawing.Point(141, 62);
		this.textBoxBDAddress.MaxLength = 12;
		this.textBoxBDAddress.Name = "textBoxBDAddress";
		this.textBoxBDAddress.Size = new System.Drawing.Size(142, 20);
		this.textBoxBDAddress.TabIndex = 1;
		this.textBoxBDAddress.TextChanged += new System.EventHandler(textBoxBDAddress_TextChanged);
		this.labelBDAddress.AutoSize = true;
		this.labelBDAddress.Font = new System.Drawing.Font("Microsoft Sans Serif", 14f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.labelBDAddress.Location = new System.Drawing.Point(8, 62);
		this.labelBDAddress.Name = "labelBDAddress";
		this.labelBDAddress.Size = new System.Drawing.Size(110, 24);
		this.labelBDAddress.TabIndex = 0;
		this.labelBDAddress.Text = "BD Address";
		this.tabPageEncryption.Controls.Add(this.groupBoxAutoReply);
		this.tabPageEncryption.Controls.Add(this.groupBoxEncryptionParameters);
		this.tabPageEncryption.Location = new System.Drawing.Point(4, 22);
		this.tabPageEncryption.Name = "tabPageEncryption";
		this.tabPageEncryption.Padding = new System.Windows.Forms.Padding(3);
		this.tabPageEncryption.Size = new System.Drawing.Size(465, 401);
		this.tabPageEncryption.TabIndex = 1;
		this.tabPageEncryption.Text = "Encryption";
		this.tabPageEncryption.UseVisualStyleBackColor = true;
		this.groupBoxAutoReply.Controls.Add(this.radioButtonNegative);
		this.groupBoxAutoReply.Controls.Add(this.radioButtonPositive);
		this.groupBoxAutoReply.Location = new System.Drawing.Point(12, 207);
		this.groupBoxAutoReply.Name = "groupBoxAutoReply";
		this.groupBoxAutoReply.Size = new System.Drawing.Size(440, 69);
		this.groupBoxAutoReply.TabIndex = 2;
		this.groupBoxAutoReply.TabStop = false;
		this.groupBoxAutoReply.Text = "Auto Reply";
		this.radioButtonNegative.AutoSize = true;
		this.radioButtonNegative.Location = new System.Drawing.Point(137, 31);
		this.radioButtonNegative.Name = "radioButtonNegative";
		this.radioButtonNegative.Size = new System.Drawing.Size(68, 17);
		this.radioButtonNegative.TabIndex = 1;
		this.radioButtonNegative.Text = "Negative";
		this.radioButtonNegative.UseVisualStyleBackColor = true;
		this.radioButtonPositive.AutoSize = true;
		this.radioButtonPositive.Checked = true;
		this.radioButtonPositive.Location = new System.Drawing.Point(23, 31);
		this.radioButtonPositive.Name = "radioButtonPositive";
		this.radioButtonPositive.Size = new System.Drawing.Size(62, 17);
		this.radioButtonPositive.TabIndex = 0;
		this.radioButtonPositive.TabStop = true;
		this.radioButtonPositive.Text = "Positive";
		this.radioButtonPositive.UseVisualStyleBackColor = true;
		this.groupBoxEncryptionParameters.Controls.Add(this.buttonReverseRandomNumber);
		this.groupBoxEncryptionParameters.Controls.Add(this.buttonReverseLongTermKey);
		this.groupBoxEncryptionParameters.Controls.Add(this.textBoxEncryptedDiversifier);
		this.groupBoxEncryptionParameters.Controls.Add(this.comboBoxRandomNumber);
		this.groupBoxEncryptionParameters.Controls.Add(this.comboBoxLongTermKey);
		this.groupBoxEncryptionParameters.Controls.Add(this.labelEncyptedDivsiefer);
		this.groupBoxEncryptionParameters.Controls.Add(this.labelRandomNumber);
		this.groupBoxEncryptionParameters.Controls.Add(this.labelLongTermKey);
		this.groupBoxEncryptionParameters.Location = new System.Drawing.Point(12, 45);
		this.groupBoxEncryptionParameters.Name = "groupBoxEncryptionParameters";
		this.groupBoxEncryptionParameters.Size = new System.Drawing.Size(440, 130);
		this.groupBoxEncryptionParameters.TabIndex = 0;
		this.groupBoxEncryptionParameters.TabStop = false;
		this.groupBoxEncryptionParameters.Text = "Encryption Parameters";
		this.textBoxEncryptedDiversifier.Location = new System.Drawing.Point(117, 92);
		this.textBoxEncryptedDiversifier.MaxLength = 4;
		this.textBoxEncryptedDiversifier.Name = "textBoxEncryptedDiversifier";
		this.textBoxEncryptedDiversifier.Size = new System.Drawing.Size(231, 20);
		this.textBoxEncryptedDiversifier.TabIndex = 5;
		this.textBoxEncryptedDiversifier.Text = "0000";
		this.textBoxEncryptedDiversifier.TextChanged += new System.EventHandler(textBoxEncryptedDiversifier_TextChanged);
		this.comboBoxRandomNumber.FormattingEnabled = true;
		this.comboBoxRandomNumber.Location = new System.Drawing.Point(117, 61);
		this.comboBoxRandomNumber.MaxLength = 16;
		this.comboBoxRandomNumber.Name = "comboBoxRandomNumber";
		this.comboBoxRandomNumber.Size = new System.Drawing.Size(231, 21);
		this.comboBoxRandomNumber.TabIndex = 4;
		this.comboBoxRandomNumber.Text = "0102030405060708";
		this.comboBoxRandomNumber.TextChanged += new System.EventHandler(comboBoxRandomNumber_TextChanged);
		this.comboBoxLongTermKey.FormattingEnabled = true;
		this.comboBoxLongTermKey.Location = new System.Drawing.Point(117, 34);
		this.comboBoxLongTermKey.MaxLength = 32;
		this.comboBoxLongTermKey.Name = "comboBoxLongTermKey";
		this.comboBoxLongTermKey.Size = new System.Drawing.Size(231, 21);
		this.comboBoxLongTermKey.TabIndex = 30;
		this.comboBoxLongTermKey.Text = "0102030405060708090A0B0C0D0E0F10";
		this.comboBoxLongTermKey.TextChanged += new System.EventHandler(comboBoxLongTermKey_TextChanged);
		this.labelEncyptedDivsiefer.AutoSize = true;
		this.labelEncyptedDivsiefer.Location = new System.Drawing.Point(7, 95);
		this.labelEncyptedDivsiefer.Name = "labelEncyptedDivsiefer";
		this.labelEncyptedDivsiefer.Size = new System.Drawing.Size(104, 13);
		this.labelEncyptedDivsiefer.TabIndex = 2;
		this.labelEncyptedDivsiefer.Text = "Encrypted Diversifier";
		this.labelRandomNumber.AutoSize = true;
		this.labelRandomNumber.Location = new System.Drawing.Point(7, 64);
		this.labelRandomNumber.Name = "labelRandomNumber";
		this.labelRandomNumber.Size = new System.Drawing.Size(87, 13);
		this.labelRandomNumber.TabIndex = 1;
		this.labelRandomNumber.Text = "Random Number";
		this.labelLongTermKey.AutoSize = true;
		this.labelLongTermKey.Location = new System.Drawing.Point(7, 37);
		this.labelLongTermKey.Name = "labelLongTermKey";
		this.labelLongTermKey.Size = new System.Drawing.Size(79, 13);
		this.labelLongTermKey.TabIndex = 0;
		this.labelLongTermKey.Text = "Long Term Key";
		this.tabPageUpdateConnection.Controls.Add(this.groupBoxLeConnAutoReply);
		this.tabPageUpdateConnection.Controls.Add(this.groupBoxLeConnEventTiming);
		this.tabPageUpdateConnection.Controls.Add(this.groupBoxLEConnectionTiming);
		this.tabPageUpdateConnection.Location = new System.Drawing.Point(4, 22);
		this.tabPageUpdateConnection.Name = "tabPageUpdateConnection";
		this.tabPageUpdateConnection.Size = new System.Drawing.Size(465, 401);
		this.tabPageUpdateConnection.TabIndex = 3;
		this.tabPageUpdateConnection.Text = "Update Connection";
		this.tabPageUpdateConnection.UseVisualStyleBackColor = true;
		this.groupBoxLeConnAutoReply.Controls.Add(this.tbParamRejectReason);
		this.groupBoxLeConnAutoReply.Controls.Add(this.labelParamRejectReason);
		this.groupBoxLeConnAutoReply.Controls.Add(this.negativeParamRequestRadioButton);
		this.groupBoxLeConnAutoReply.Controls.Add(this.positiveParamRequestRadioButton);
		this.groupBoxLeConnAutoReply.Location = new System.Drawing.Point(9, 271);
		this.groupBoxLeConnAutoReply.Name = "groupBoxLeConnAutoReply";
		this.groupBoxLeConnAutoReply.Size = new System.Drawing.Size(447, 64);
		this.groupBoxLeConnAutoReply.TabIndex = 2;
		this.groupBoxLeConnAutoReply.TabStop = false;
		this.groupBoxLeConnAutoReply.Text = "Parameter Request Auto Reply";
		this.tbParamRejectReason.Location = new System.Drawing.Point(341, 27);
		this.tbParamRejectReason.Name = "tbParamRejectReason";
		this.tbParamRejectReason.Size = new System.Drawing.Size(49, 20);
		this.tbParamRejectReason.TabIndex = 3;
		this.tbParamRejectReason.Text = "0";
		this.tbParamRejectReason.Visible = false;
		this.tbParamRejectReason.TextChanged += new System.EventHandler(tbParamRejectReason_TextChanged);
		this.labelParamRejectReason.AutoSize = true;
		this.labelParamRejectReason.Location = new System.Drawing.Point(228, 29);
		this.labelParamRejectReason.Name = "labelParamRejectReason";
		this.labelParamRejectReason.Size = new System.Drawing.Size(104, 13);
		this.labelParamRejectReason.TabIndex = 2;
		this.labelParamRejectReason.Text = "Reject Reason (hex)";
		this.labelParamRejectReason.Visible = false;
		this.negativeParamRequestRadioButton.AutoSize = true;
		this.negativeParamRequestRadioButton.Location = new System.Drawing.Point(136, 27);
		this.negativeParamRequestRadioButton.Name = "negativeParamRequestRadioButton";
		this.negativeParamRequestRadioButton.Size = new System.Drawing.Size(68, 17);
		this.negativeParamRequestRadioButton.TabIndex = 1;
		this.negativeParamRequestRadioButton.TabStop = true;
		this.negativeParamRequestRadioButton.Text = "Negative";
		this.negativeParamRequestRadioButton.UseVisualStyleBackColor = true;
		this.negativeParamRequestRadioButton.CheckedChanged += new System.EventHandler(negativeParamRequestRadioButton_CheckedChanged);
		this.positiveParamRequestRadioButton.AutoSize = true;
		this.positiveParamRequestRadioButton.Checked = true;
		this.positiveParamRequestRadioButton.Location = new System.Drawing.Point(21, 27);
		this.positiveParamRequestRadioButton.Name = "positiveParamRequestRadioButton";
		this.positiveParamRequestRadioButton.Size = new System.Drawing.Size(62, 17);
		this.positiveParamRequestRadioButton.TabIndex = 0;
		this.positiveParamRequestRadioButton.TabStop = true;
		this.positiveParamRequestRadioButton.Text = "Positive";
		this.positiveParamRequestRadioButton.UseVisualStyleBackColor = true;
		this.positiveParamRequestRadioButton.CheckedChanged += new System.EventHandler(positiveParamRequestRadioButton_CheckedChanged);
		this.groupBoxLeConnEventTiming.Controls.Add(this.tbLEUpdateConnInternalMaxLength);
		this.groupBoxLeConnEventTiming.Controls.Add(this.tbLEUpdateConnInternalMinLength);
		this.groupBoxLeConnEventTiming.Controls.Add(this.label5);
		this.groupBoxLeConnEventTiming.Controls.Add(this.label6);
		this.groupBoxLeConnEventTiming.Location = new System.Drawing.Point(9, 176);
		this.groupBoxLeConnEventTiming.Name = "groupBoxLeConnEventTiming";
		this.groupBoxLeConnEventTiming.Size = new System.Drawing.Size(448, 59);
		this.groupBoxLeConnEventTiming.TabIndex = 1;
		this.groupBoxLeConnEventTiming.TabStop = false;
		this.groupBoxLeConnEventTiming.Text = "Connection Event Timing";
		this.tbLEUpdateConnInternalMaxLength.Location = new System.Drawing.Point(330, 24);
		this.tbLEUpdateConnInternalMaxLength.MaxLength = 5;
		this.tbLEUpdateConnInternalMaxLength.Name = "tbLEUpdateConnInternalMaxLength";
		this.tbLEUpdateConnInternalMaxLength.Size = new System.Drawing.Size(60, 20);
		this.tbLEUpdateConnInternalMaxLength.TabIndex = 10;
		this.tbLEUpdateConnInternalMaxLength.Text = "0";
		this.tbLEUpdateConnInternalMaxLength.TextAlignChanged += new System.EventHandler(tbLEUpdateConnInternalMaxLength_TextAlignChanged);
		this.tbLEUpdateConnInternalMinLength.Location = new System.Drawing.Point(109, 24);
		this.tbLEUpdateConnInternalMinLength.MaxLength = 5;
		this.tbLEUpdateConnInternalMinLength.Name = "tbLEUpdateConnInternalMinLength";
		this.tbLEUpdateConnInternalMinLength.Size = new System.Drawing.Size(60, 20);
		this.tbLEUpdateConnInternalMinLength.TabIndex = 9;
		this.tbLEUpdateConnInternalMinLength.Text = "0";
		this.tbLEUpdateConnInternalMinLength.TextChanged += new System.EventHandler(tbLEUpdateConnInternalMinLength_TextChanged);
		this.label5.AutoSize = true;
		this.label5.Location = new System.Drawing.Point(225, 27);
		this.label5.Name = "label5";
		this.label5.Size = new System.Drawing.Size(97, 13);
		this.label5.TabIndex = 8;
		this.label5.Text = "Max Length (msec)";
		this.label6.AutoSize = true;
		this.label6.Location = new System.Drawing.Point(7, 27);
		this.label6.Name = "label6";
		this.label6.Size = new System.Drawing.Size(90, 13);
		this.label6.TabIndex = 7;
		this.label6.Text = "Min length (msec)";
		this.groupBoxLEConnectionTiming.Controls.Add(this.tbLEUpdateConnInternalLatency);
		this.groupBoxLEConnectionTiming.Controls.Add(this.tbLEUpdateConnInternalMax);
		this.groupBoxLEConnectionTiming.Controls.Add(this.tbLEUpdateConnInternalTimeout);
		this.groupBoxLEConnectionTiming.Controls.Add(this.tbLEUpdateConnInternalMin);
		this.groupBoxLEConnectionTiming.Controls.Add(this.label4);
		this.groupBoxLEConnectionTiming.Controls.Add(this.label3);
		this.groupBoxLEConnectionTiming.Controls.Add(this.label2);
		this.groupBoxLEConnectionTiming.Controls.Add(this.label1);
		this.groupBoxLEConnectionTiming.Location = new System.Drawing.Point(9, 44);
		this.groupBoxLEConnectionTiming.Name = "groupBoxLEConnectionTiming";
		this.groupBoxLEConnectionTiming.Size = new System.Drawing.Size(448, 102);
		this.groupBoxLEConnectionTiming.TabIndex = 0;
		this.groupBoxLEConnectionTiming.TabStop = false;
		this.groupBoxLEConnectionTiming.Text = "Connection Timing";
		this.tbLEUpdateConnInternalLatency.Location = new System.Drawing.Point(329, 56);
		this.tbLEUpdateConnInternalLatency.MaxLength = 5;
		this.tbLEUpdateConnInternalLatency.Name = "tbLEUpdateConnInternalLatency";
		this.tbLEUpdateConnInternalLatency.Size = new System.Drawing.Size(60, 20);
		this.tbLEUpdateConnInternalLatency.TabIndex = 7;
		this.tbLEUpdateConnInternalLatency.Text = "0";
		this.tbLEUpdateConnInternalLatency.TextChanged += new System.EventHandler(tbLEUpdateConnInternalLatency_TextChanged);
		this.tbLEUpdateConnInternalMax.Location = new System.Drawing.Point(330, 17);
		this.tbLEUpdateConnInternalMax.MaxLength = 5;
		this.tbLEUpdateConnInternalMax.Name = "tbLEUpdateConnInternalMax";
		this.tbLEUpdateConnInternalMax.Size = new System.Drawing.Size(60, 20);
		this.tbLEUpdateConnInternalMax.TabIndex = 6;
		this.tbLEUpdateConnInternalMax.Text = "40";
		this.tbLEUpdateConnInternalMax.TextChanged += new System.EventHandler(tbLEUpdateConnInternalMax_TextChanged);
		this.tbLEUpdateConnInternalTimeout.Location = new System.Drawing.Point(109, 56);
		this.tbLEUpdateConnInternalTimeout.MaxLength = 5;
		this.tbLEUpdateConnInternalTimeout.Name = "tbLEUpdateConnInternalTimeout";
		this.tbLEUpdateConnInternalTimeout.Size = new System.Drawing.Size(60, 20);
		this.tbLEUpdateConnInternalTimeout.TabIndex = 5;
		this.tbLEUpdateConnInternalTimeout.Text = "10000";
		this.tbLEUpdateConnInternalTimeout.TextChanged += new System.EventHandler(tbLEUpdateConnInternalTimeout_TextChanged);
		this.tbLEUpdateConnInternalMin.Location = new System.Drawing.Point(109, 17);
		this.tbLEUpdateConnInternalMin.MaxLength = 5;
		this.tbLEUpdateConnInternalMin.Name = "tbLEUpdateConnInternalMin";
		this.tbLEUpdateConnInternalMin.Size = new System.Drawing.Size(60, 20);
		this.tbLEUpdateConnInternalMin.TabIndex = 4;
		this.tbLEUpdateConnInternalMin.Text = "40";
		this.tbLEUpdateConnInternalMin.TextChanged += new System.EventHandler(tbLEUpdateConnInternalMin_TextChanged);
		this.label4.AutoSize = true;
		this.label4.Location = new System.Drawing.Point(228, 59);
		this.label4.Name = "label4";
		this.label4.Size = new System.Drawing.Size(45, 13);
		this.label4.TabIndex = 3;
		this.label4.Text = "Latency";
		this.label3.AutoSize = true;
		this.label3.Location = new System.Drawing.Point(225, 20);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(99, 13);
		this.label3.TabIndex = 2;
		this.label3.Text = "Interval Max (msec)";
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(6, 59);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(79, 13);
		this.label2.TabIndex = 1;
		this.label2.Text = "Timeout (msec)";
		this.label1.AutoSize = true;
		this.label1.Location = new System.Drawing.Point(7, 20);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(96, 13);
		this.label1.TabIndex = 0;
		this.label1.Text = "Interval Min (msec)";
		this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
		this.splitContainer2.Location = new System.Drawing.Point(0, 0);
		this.splitContainer2.Name = "splitContainer2";
		this.splitContainer2.Panel1.Controls.Add(this.buttonOK);
		this.splitContainer2.Panel2.Controls.Add(this.buttonCancel);
		this.splitContainer2.Size = new System.Drawing.Size(473, 66);
		this.splitContainer2.SplitterDistance = 338;
		this.splitContainer2.TabIndex = 0;
		this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
		this.buttonOK.Dock = System.Windows.Forms.DockStyle.Fill;
		this.buttonOK.Location = new System.Drawing.Point(0, 0);
		this.buttonOK.Name = "buttonOK";
		this.buttonOK.Size = new System.Drawing.Size(338, 66);
		this.buttonOK.TabIndex = 0;
		this.buttonOK.Text = "OK";
		this.buttonOK.UseVisualStyleBackColor = true;
		this.buttonOK.Click += new System.EventHandler(buttonOK_Click);
		this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
		this.buttonCancel.Dock = System.Windows.Forms.DockStyle.Fill;
		this.buttonCancel.Location = new System.Drawing.Point(0, 0);
		this.buttonCancel.Name = "buttonCancel";
		this.buttonCancel.Size = new System.Drawing.Size(131, 66);
		this.buttonCancel.TabIndex = 0;
		this.buttonCancel.Text = "Cancel";
		this.buttonCancel.UseVisualStyleBackColor = true;
		this.buttonReverseLongTermKey.Location = new System.Drawing.Point(354, 32);
		this.buttonReverseLongTermKey.Name = "buttonReverseLongTermKey";
		this.buttonReverseLongTermKey.Size = new System.Drawing.Size(75, 23);
		this.buttonReverseLongTermKey.TabIndex = 31;
		this.buttonReverseLongTermKey.Text = "Reverse";
		this.buttonReverseLongTermKey.UseVisualStyleBackColor = true;
		this.buttonReverseLongTermKey.Click += new System.EventHandler(buttonReverseLongTermKey_Click);
		this.buttonReverseRandomNumber.Location = new System.Drawing.Point(354, 59);
		this.buttonReverseRandomNumber.Name = "buttonReverseRandomNumber";
		this.buttonReverseRandomNumber.Size = new System.Drawing.Size(75, 23);
		this.buttonReverseRandomNumber.TabIndex = 31;
		this.buttonReverseRandomNumber.Text = "Reverse";
		this.buttonReverseRandomNumber.UseVisualStyleBackColor = true;
		this.buttonReverseRandomNumber.Click += new System.EventHandler(buttonReverseRandomNumber_Click);
		base.AcceptButton = this.buttonOK;
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(473, 497);
		base.Controls.Add(this.splitContainer1);
		base.MaximizeBox = false;
		base.MinimizeBox = false;
		base.Name = "LERemoteDeviceOptions";
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
		this.Text = "LERemoteDeviceOptions";
		base.Load += new System.EventHandler(LERemoteDeviceOptions_Load);
		this.splitContainer1.Panel1.ResumeLayout(false);
		this.splitContainer1.Panel2.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.splitContainer1).EndInit();
		this.splitContainer1.ResumeLayout(false);
		this.tabControlLERemoteDeviceOptions.ResumeLayout(false);
		this.tabPageLERemoteDeviceAttributes.ResumeLayout(false);
		this.tabPageLERemoteDeviceAttributes.PerformLayout();
		this.tabPageEncryption.ResumeLayout(false);
		this.groupBoxAutoReply.ResumeLayout(false);
		this.groupBoxAutoReply.PerformLayout();
		this.groupBoxEncryptionParameters.ResumeLayout(false);
		this.groupBoxEncryptionParameters.PerformLayout();
		this.tabPageUpdateConnection.ResumeLayout(false);
		this.groupBoxLeConnAutoReply.ResumeLayout(false);
		this.groupBoxLeConnAutoReply.PerformLayout();
		this.groupBoxLeConnEventTiming.ResumeLayout(false);
		this.groupBoxLeConnEventTiming.PerformLayout();
		this.groupBoxLEConnectionTiming.ResumeLayout(false);
		this.groupBoxLEConnectionTiming.PerformLayout();
		this.splitContainer2.Panel1.ResumeLayout(false);
		this.splitContainer2.Panel2.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.splitContainer2).EndInit();
		this.splitContainer2.ResumeLayout(false);
		base.ResumeLayout(false);
	}
}
