using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using nsoftware.IPWorksBLE;
using System.Diagnostics;
using System.IO;
using static System.Net.WebRequestMethods;
namespace nsoftware.Demos {
  public class bleclientDemo : Form {
    private const int FLAG_BROADCAST = 0x00000001;
    private const int FLAG_READ = 0x00000002;
    private const int FLAG_WRITE_NO_RESPONSE = 0x00000004;
    private const int FLAG_WRITE = 0x00000008;
    private const int FLAG_NOTIFY = 0x00000010;
    private const int FLAG_INDICATE = 0x00000020;
    private const int FLAG_AUTH_SIGNED_WRITE = 0x00000040;
    private const int FLAG_RELIABLE_WRITE = 0x00000080;
    private const int FLAG_WRITABLE_AUXILIARIES = 0x00000100;
    private static readonly Color CHILD_SVC_COLOR = Color.DodgerBlue;
    private static readonly Color PARENT_SVC_COLOR = Color.Firebrick;
    internal const int TYPE_SERVER = 0;
    internal const int TYPE_SERVICE = 1;
    internal const int TYPE_CHARACTERISTIC = 2;
    internal const int TYPE_DESCRIPTOR = 3;
    #region Designer Variables
    /// 
    /// Required designer variable.
    /// 
    private IContainer components = null;
    private Label lblInstructions;
    private TabControl tabCtrlMain;
    private TabPage tabScanConnect;
    private Bleclient bleclient1;
    private TabPage tabLog;
    private CheckBox cbLogAdvertisements;
    private ComboBox cbbLogLevel;
    private Label lblLogLevel;
    private Button btnClearLog;
    private TextBox tbLog;
    private ListView lvwDevices;
    private ColumnHeader colServerId;
    private ColumnHeader colName;
    private ColumnHeader colRssi;
    private ColumnHeader colTxPower;
    private ColumnHeader colServiceUuids;
    private ColumnHeader colServicesWithData;
    private ColumnHeader colSolicitedServiceUuids;
    private ColumnHeader colManufacturerCompanyId;
    private ColumnHeader colManufacturerData;
    private ColumnHeader colConnectable;
    private GroupBox gbScanCtrls;
    private Button btnScan;
    private Label lblScanFilter;
    private CheckBox cbActiveScanning;
    private GroupBox gbConnectCtrls;
    private ToolTip ToolTip1;
    private Label lblBrowseOverlay;
    private Button btnConnect;
    private TextBox tbSelectedServerId;
    private Label lblSelectedServerId;
    private Button btnDisconnect;
    private Label lblCurrentlyConnectedTo;
    private TextBox tbConnectedServerId;
    private SplitContainer splitBrowse;
    private SplitContainer splitData;
    private TreeView treeGattObjects;
    private TabControlWithoutHeader tabCtrlGattData;
    private TabPage tabGattServer;
    private TabPage tabGattService;
    private TabPage tabGattCharacteristic;
    private TabPage tabGattDescriptor;
    private TextBox tbServerName;
    private Label lblServerName;
    private Label lblServerId;
    private TextBox tbServerId;
    private TabPage tabBrowse;
    private Button btnChooseScanUuids;
    private ListBox lbScanFilter;
    private GroupBox gbSrvDiscovery;
    private Label lblSrvDiscovery;
    private Button btnSrvChooseServiceUuids;
    private Button btnSrvDiscoverServices;
    private ListBox lbSrvServiceUuids;
    private Label lblSrvServiceUuids;
    private TabPage tabSubscribed;
    private TextBox tbServiceName;
    private Label lblServiceName;
    private TextBox tbServiceId;
    private Label lblServiceId;
    private Label lblServiceUuid;
    private TextBox tbServiceUuid;
    private Label lblServiceColorsNote;
    private TabControl tabCtrlSvcDiscovery;
    private TabPage tabSvcDiscoverCharacteristics;
    private Button btnSvcChooseCharacteristics;
    private Button btnSvcDiscoverCharacteristics;
    private ListBox lbSvcCharacteristicUuids;
    private Label lblSvcCharacteristicUuids;
    private Label lblSrvDiscoverCharacteristics;
    private TabPage tabSvcDiscoverInclServices;
    private Button btnSvcChooseInclServices;
    private Button btnSvcDiscoverInclServices;
    private ListBox lbSvcInclServiceUuids;
    private Label lblSvcInclServiceUuids;
    private Label lblSvcDiscoverInclServices;
    private GroupBox gbCharaDiscoverDescriptors;
    private Label lblCharaDiscoverDescriptors;
    private Button btnCharaDiscoverDescriptors;
    private TextBox tbCharacteristicUserDescription;
    private Label lblCharacteristicUserDescription;
    private TextBox tbCharacteristicId;
    private Label lblCharacteristicId;
    private Label lblCharacteristicUuid;
    private TextBox tbCharacteristicUuid;
    private TextBox tbCharacteristicName;
    private Label lblCharacteristicName;
    private TextBox tbCharacteristicFlags;
    private Label lblCharacteristicFlags;
    private Label lblCharacteristicValueFormatExponent;
    private Label lblCharacteristicValueFormatUnit;
    private TextBox tbCharacteristicValueFormatExponent;
    private TextBox tbCharacteristicValueFormatUnit;
    private TextBox tbCharacteristicValueFormatType;
    private Label lblCharacteristicValueFormats;
    private NumericUpDown numCharacteristicValueFormatIdx;
    private GroupBox gbCharacteristicValue;
    private Label lblCharacteristicValue;
    private GroupBox gbCharaDisplayValueAs;
    private RadioButton rbCharaNumber;
    private RadioButton rbCharaBoolean;
    private Button btnCustomizeCharaFormat;
    private RadioButton rbCharaHexBytes;
    private RadioButton rbCharaUTF16;
    private RadioButton rbCharaUTF8;
    private ComboBox cboCharaNumberType;
    private RadioButton rbCharaCustom;
    private Button btnCharaReadValue;
    private TextBox tbCharacteristicValue;
    private Button btnCharaWriteValue;
    private Button btnToggleSubscribe;
    private GroupBox gbDescriptorValue;
    private Button btnDescWriteValue;
    private Button btnDescReadValue;
    private TextBox tbDescriptorValue;
    private GroupBox gbDescDisplayValueAs;
    private RadioButton rbDescUTF16;
    private RadioButton rbDescUTF8;
    private ComboBox cboDescNumberType;
    private RadioButton rbDescNumber;
    private RadioButton rbDescBoolean;
    private RadioButton rbDescHexBytes;
    private Label lblDescriptorValue;
    private TextBox tbDescriptorId;
    private Label lblDescriptorId;
    private Label lblDescriptorUuid;
    private TextBox tbDescriptorUuid;
    private TextBox tbDescriptorName;
    private Label lblDescriptorName;
    private Button btnUpdateCharacteristicUserDescription;
    private Button btnCharaPostValue;
    private SplitContainer splitSubscribed;
    private Label lblSubscribedOverlay;
    private FlowLayoutPanel flowSubscribedCharacteristics;
    private RadioButton rbDescCustom;
    private Button btnCustomizeDescFormat;
    private Button btnPrintGattObjTree;
    private ContextMenuStrip contextMenuStrip1;
    private ToolStripMenuItem toolStripMenuItemCopyValue;
    private Label lblGattObjectsTree;
    private GroupBox gbSrvDiscoverEverything;
    private Label lblSrvDiscoverAll;
    private Button btnSrvDiscoverEverything;
    #endregion
    private byte[] currValue = new byte[0];
    private bool suppressEvents = false;
    private Dictionary uuidDisplayTypes = new Dictionary();
    private SortedDictionary uuidCustomFormats = null;
    private List subscribedCharacteristics = new List();
    /// 
    /// The main entry point for the application.
    /// 
    [STAThread]
    static void Main() {
      Application.EnableVisualStyles();
      Application.Run(new bleclientDemo());
    }
    public bleclientDemo() {
            nsoftware.IPWorksBLE.Bleclient tempBleclient1 = new nsoftware.IPWorksBLE.Bleclient(this.components);
            Console.WriteLine(tempBleclient1.RuntimeLicense);
            // prints  31314E42414431535542323031393130313052413153554241414A39313634310000000000000000343858565831385A00005745544E59413533523238470000
            InitializeComponent();
      uuidCustomFormats = ValueFormatter.LoadCustomFormats();
      ResetBrowseTab();
      ResetSubscribedCharacteristicsTab();
      bleclient1.RuntimeLicense = "31314E42414431535542323031393130313052413153554241414A39313634310000000000000000343858565831385A00005745544E59413533523238470000";
      bleclient1.Config("LogLevel=" + cbbLogLevel.SelectedIndex);
      // Double buffer the ListView used for scanning since it flickers badly otherwise.
      var doubleBufferedPropInfo = lvwDevices.GetType().GetProperty("DoubleBuffered",
        System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
      doubleBufferedPropInfo.SetValue(lvwDevices, true, null);
            object sender = null;
            EventArgs e = null;
            btnScan_Click(sender, e);
    }
    /// 
    /// Clean up any resources being used.
    /// 
    /// true if managed resources should be disposed; otherwise, false.
    protected override void Dispose(bool disposing) {
      if (disposing && (components != null)) {
        components.Dispose();
      }
      base.Dispose(disposing);
    }
    #region Windows Form Designer generated code
    /// 
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// 
    private void InitializeComponent() {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(bleclientDemo));
            System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("[Server]");
            this.lblInstructions = new System.Windows.Forms.Label();
            this.tabCtrlMain = new System.Windows.Forms.TabControl();
            this.tabScanConnect = new System.Windows.Forms.TabPage();
            this.gbConnectCtrls = new System.Windows.Forms.GroupBox();
            this.btnDisconnect = new System.Windows.Forms.Button();
            this.lblCurrentlyConnectedTo = new System.Windows.Forms.Label();
            this.tbConnectedServerId = new System.Windows.Forms.TextBox();
            this.btnConnect = new System.Windows.Forms.Button();
            this.tbSelectedServerId = new System.Windows.Forms.TextBox();
            this.lblSelectedServerId = new System.Windows.Forms.Label();
            this.gbScanCtrls = new System.Windows.Forms.GroupBox();
            this.lbScanFilter = new System.Windows.Forms.ListBox();
            this.btnChooseScanUuids = new System.Windows.Forms.Button();
            this.lblScanFilter = new System.Windows.Forms.Label();
            this.cbActiveScanning = new System.Windows.Forms.CheckBox();
            this.btnScan = new System.Windows.Forms.Button();
            this.lvwDevices = new System.Windows.Forms.ListView();
            this.colServerId = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.colName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.colRssi = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.colTxPower = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.colConnectable = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.colServiceUuids = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.colServicesWithData = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.colManufacturerCompanyId = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.colManufacturerData = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.colSolicitedServiceUuids = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.tabBrowse = new System.Windows.Forms.TabPage();
            this.splitBrowse = new System.Windows.Forms.SplitContainer();
            this.splitData = new System.Windows.Forms.SplitContainer();
            this.lblGattObjectsTree = new System.Windows.Forms.Label();
            this.treeGattObjects = new System.Windows.Forms.TreeView();
            this.tabCtrlGattData = new nsoftware.Demos.bleclientDemo.TabControlWithoutHeader();
            this.tabGattServer = new System.Windows.Forms.TabPage();
            this.gbSrvDiscoverEverything = new System.Windows.Forms.GroupBox();
            this.lblSrvDiscoverAll = new System.Windows.Forms.Label();
            this.btnSrvDiscoverEverything = new System.Windows.Forms.Button();
            this.gbSrvDiscovery = new System.Windows.Forms.GroupBox();
            this.btnSrvChooseServiceUuids = new System.Windows.Forms.Button();
            this.btnSrvDiscoverServices = new System.Windows.Forms.Button();
            this.lbSrvServiceUuids = new System.Windows.Forms.ListBox();
            this.lblSrvServiceUuids = new System.Windows.Forms.Label();
            this.lblSrvDiscovery = new System.Windows.Forms.Label();
            this.lblServerId = new System.Windows.Forms.Label();
            this.tbServerId = new System.Windows.Forms.TextBox();
            this.tbServerName = new System.Windows.Forms.TextBox();
            this.lblServerName = new System.Windows.Forms.Label();
            this.tabGattService = new System.Windows.Forms.TabPage();
            this.tabCtrlSvcDiscovery = new System.Windows.Forms.TabControl();
            this.tabSvcDiscoverCharacteristics = new System.Windows.Forms.TabPage();
            this.btnSvcChooseCharacteristics = new System.Windows.Forms.Button();
            this.btnSvcDiscoverCharacteristics = new System.Windows.Forms.Button();
            this.lbSvcCharacteristicUuids = new System.Windows.Forms.ListBox();
            this.lblSvcCharacteristicUuids = new System.Windows.Forms.Label();
            this.lblSrvDiscoverCharacteristics = new System.Windows.Forms.Label();
            this.tabSvcDiscoverInclServices = new System.Windows.Forms.TabPage();
            this.btnSvcChooseInclServices = new System.Windows.Forms.Button();
            this.btnSvcDiscoverInclServices = new System.Windows.Forms.Button();
            this.lbSvcInclServiceUuids = new System.Windows.Forms.ListBox();
            this.lblSvcInclServiceUuids = new System.Windows.Forms.Label();
            this.lblSvcDiscoverInclServices = new System.Windows.Forms.Label();
            this.lblServiceColorsNote = new System.Windows.Forms.Label();
            this.tbServiceId = new System.Windows.Forms.TextBox();
            this.lblServiceId = new System.Windows.Forms.Label();
            this.lblServiceUuid = new System.Windows.Forms.Label();
            this.tbServiceUuid = new System.Windows.Forms.TextBox();
            this.tbServiceName = new System.Windows.Forms.TextBox();
            this.lblServiceName = new System.Windows.Forms.Label();
            this.tabGattCharacteristic = new System.Windows.Forms.TabPage();
            this.tbCharacteristicUserDescription = new System.Windows.Forms.TextBox();
            this.btnUpdateCharacteristicUserDescription = new System.Windows.Forms.Button();
            this.gbCharacteristicValue = new System.Windows.Forms.GroupBox();
            this.btnCharaPostValue = new System.Windows.Forms.Button();
            this.btnToggleSubscribe = new System.Windows.Forms.Button();
            this.btnCharaWriteValue = new System.Windows.Forms.Button();
            this.btnCharaReadValue = new System.Windows.Forms.Button();
            this.tbCharacteristicValue = new System.Windows.Forms.TextBox();
            this.gbCharaDisplayValueAs = new System.Windows.Forms.GroupBox();
            this.rbCharaCustom = new System.Windows.Forms.RadioButton();
            this.rbCharaUTF16 = new System.Windows.Forms.RadioButton();
            this.rbCharaUTF8 = new System.Windows.Forms.RadioButton();
            this.cboCharaNumberType = new System.Windows.Forms.ComboBox();
            this.rbCharaNumber = new System.Windows.Forms.RadioButton();
            this.rbCharaBoolean = new System.Windows.Forms.RadioButton();
            this.btnCustomizeCharaFormat = new System.Windows.Forms.Button();
            this.rbCharaHexBytes = new System.Windows.Forms.RadioButton();
            this.lblCharacteristicValue = new System.Windows.Forms.Label();
            this.lblCharacteristicValueFormatExponent = new System.Windows.Forms.Label();
            this.lblCharacteristicValueFormatUnit = new System.Windows.Forms.Label();
            this.tbCharacteristicValueFormatExponent = new System.Windows.Forms.TextBox();
            this.tbCharacteristicValueFormatUnit = new System.Windows.Forms.TextBox();
            this.tbCharacteristicValueFormatType = new System.Windows.Forms.TextBox();
            this.lblCharacteristicValueFormats = new System.Windows.Forms.Label();
            this.numCharacteristicValueFormatIdx = new System.Windows.Forms.NumericUpDown();
            this.tbCharacteristicFlags = new System.Windows.Forms.TextBox();
            this.lblCharacteristicFlags = new System.Windows.Forms.Label();
            this.gbCharaDiscoverDescriptors = new System.Windows.Forms.GroupBox();
            this.lblCharaDiscoverDescriptors = new System.Windows.Forms.Label();
            this.btnCharaDiscoverDescriptors = new System.Windows.Forms.Button();
            this.lblCharacteristicUserDescription = new System.Windows.Forms.Label();
            this.tbCharacteristicId = new System.Windows.Forms.TextBox();
            this.lblCharacteristicId = new System.Windows.Forms.Label();
            this.lblCharacteristicUuid = new System.Windows.Forms.Label();
            this.tbCharacteristicUuid = new System.Windows.Forms.TextBox();
            this.tbCharacteristicName = new System.Windows.Forms.TextBox();
            this.lblCharacteristicName = new System.Windows.Forms.Label();
            this.tabGattDescriptor = new System.Windows.Forms.TabPage();
            this.gbDescriptorValue = new System.Windows.Forms.GroupBox();
            this.btnDescWriteValue = new System.Windows.Forms.Button();
            this.btnDescReadValue = new System.Windows.Forms.Button();
            this.tbDescriptorValue = new System.Windows.Forms.TextBox();
            this.gbDescDisplayValueAs = new System.Windows.Forms.GroupBox();
            this.rbDescCustom = new System.Windows.Forms.RadioButton();
            this.btnCustomizeDescFormat = new System.Windows.Forms.Button();
            this.rbDescUTF16 = new System.Windows.Forms.RadioButton();
            this.rbDescUTF8 = new System.Windows.Forms.RadioButton();
            this.cboDescNumberType = new System.Windows.Forms.ComboBox();
            this.rbDescNumber = new System.Windows.Forms.RadioButton();
            this.rbDescBoolean = new System.Windows.Forms.RadioButton();
            this.rbDescHexBytes = new System.Windows.Forms.RadioButton();
            this.lblDescriptorValue = new System.Windows.Forms.Label();
            this.tbDescriptorId = new System.Windows.Forms.TextBox();
            this.lblDescriptorId = new System.Windows.Forms.Label();
            this.lblDescriptorUuid = new System.Windows.Forms.Label();
            this.tbDescriptorUuid = new System.Windows.Forms.TextBox();
            this.tbDescriptorName = new System.Windows.Forms.TextBox();
            this.lblDescriptorName = new System.Windows.Forms.Label();
            this.lblBrowseOverlay = new System.Windows.Forms.Label();
            this.tabSubscribed = new System.Windows.Forms.TabPage();
            this.splitSubscribed = new System.Windows.Forms.SplitContainer();
            this.flowSubscribedCharacteristics = new System.Windows.Forms.FlowLayoutPanel();
            this.lblSubscribedOverlay = new System.Windows.Forms.Label();
            this.tabLog = new System.Windows.Forms.TabPage();
            this.btnPrintGattObjTree = new System.Windows.Forms.Button();
            this.tbLog = new System.Windows.Forms.TextBox();
            this.btnClearLog = new System.Windows.Forms.Button();
            this.cbLogAdvertisements = new System.Windows.Forms.CheckBox();
            this.cbbLogLevel = new System.Windows.Forms.ComboBox();
            this.lblLogLevel = new System.Windows.Forms.Label();
            this.ToolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.bleclient1 = new nsoftware.IPWorksBLE.Bleclient(this.components);
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.toolStripMenuItemCopyValue = new System.Windows.Forms.ToolStripMenuItem();
            this.tabCtrlMain.SuspendLayout();
            this.tabScanConnect.SuspendLayout();
            this.gbConnectCtrls.SuspendLayout();
            this.gbScanCtrls.SuspendLayout();
            this.tabBrowse.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitBrowse)).BeginInit();
            this.splitBrowse.Panel1.SuspendLayout();
            this.splitBrowse.Panel2.SuspendLayout();
            this.splitBrowse.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitData)).BeginInit();
            this.splitData.Panel1.SuspendLayout();
            this.splitData.Panel2.SuspendLayout();
            this.splitData.SuspendLayout();
            this.tabCtrlGattData.SuspendLayout();
            this.tabGattServer.SuspendLayout();
            this.gbSrvDiscoverEverything.SuspendLayout();
            this.gbSrvDiscovery.SuspendLayout();
            this.tabGattService.SuspendLayout();
            this.tabCtrlSvcDiscovery.SuspendLayout();
            this.tabSvcDiscoverCharacteristics.SuspendLayout();
            this.tabSvcDiscoverInclServices.SuspendLayout();
            this.tabGattCharacteristic.SuspendLayout();
            this.gbCharacteristicValue.SuspendLayout();
            this.gbCharaDisplayValueAs.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.numCharacteristicValueFormatIdx)).BeginInit();
            this.gbCharaDiscoverDescriptors.SuspendLayout();
            this.tabGattDescriptor.SuspendLayout();
            this.gbDescriptorValue.SuspendLayout();
            this.gbDescDisplayValueAs.SuspendLayout();
            this.tabSubscribed.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitSubscribed)).BeginInit();
            this.splitSubscribed.Panel1.SuspendLayout();
            this.splitSubscribed.Panel2.SuspendLayout();
            this.splitSubscribed.SuspendLayout();
            this.tabLog.SuspendLayout();
            this.contextMenuStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // lblInstructions
            // 
            this.lblInstructions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lblInstructions.ForeColor = System.Drawing.SystemColors.Highlight;
            this.lblInstructions.Location = new System.Drawing.Point(12, 9);
            this.lblInstructions.Name = "lblInstructions";
            this.lblInstructions.Size = new System.Drawing.Size(1010, 32);
            this.lblInstructions.TabIndex = 0;
            this.lblInstructions.Text = resources.GetString("lblInstructions.Text");
            // 
            // tabCtrlMain
            // 
            this.tabCtrlMain.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tabCtrlMain.Controls.Add(this.tabScanConnect);
            this.tabCtrlMain.Controls.Add(this.tabBrowse);
            this.tabCtrlMain.Controls.Add(this.tabSubscribed);
            this.tabCtrlMain.Controls.Add(this.tabLog);
            this.tabCtrlMain.Location = new System.Drawing.Point(12, 44);
            this.tabCtrlMain.Name = "tabCtrlMain";
            this.tabCtrlMain.SelectedIndex = 0;
            this.tabCtrlMain.ShowToolTips = true;
            this.tabCtrlMain.Size = new System.Drawing.Size(1010, 480);
            this.tabCtrlMain.TabIndex = 1;
            // 
            // tabScanConnect
            // 
            this.tabScanConnect.Controls.Add(this.gbConnectCtrls);
            this.tabScanConnect.Controls.Add(this.gbScanCtrls);
            this.tabScanConnect.Controls.Add(this.lvwDevices);
            this.tabScanConnect.Location = new System.Drawing.Point(4, 22);
            this.tabScanConnect.Name = "tabScanConnect";
            this.tabScanConnect.Padding = new System.Windows.Forms.Padding(3);
            this.tabScanConnect.Size = new System.Drawing.Size(1002, 454);
            this.tabScanConnect.TabIndex = 0;
            this.tabScanConnect.Text = "Scan and Connect";
            this.tabScanConnect.ToolTipText = "The \"Scan and Connect\" tab allows you to scan for devices, view advertisement dat" +
    "a, and manage what device you\'re connected to.";
            this.tabScanConnect.UseVisualStyleBackColor = true;
            // 
            // gbConnectCtrls
            // 
            this.gbConnectCtrls.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.gbConnectCtrls.Controls.Add(this.btnDisconnect);
            this.gbConnectCtrls.Controls.Add(this.lblCurrentlyConnectedTo);
            this.gbConnectCtrls.Controls.Add(this.tbConnectedServerId);
            this.gbConnectCtrls.Controls.Add(this.btnConnect);
            this.gbConnectCtrls.Controls.Add(this.tbSelectedServerId);
            this.gbConnectCtrls.Controls.Add(this.lblSelectedServerId);
            this.gbConnectCtrls.Location = new System.Drawing.Point(685, 6);
            this.gbConnectCtrls.Name = "gbConnectCtrls";
            this.gbConnectCtrls.Size = new System.Drawing.Size(311, 91);
            this.gbConnectCtrls.TabIndex = 1;
            this.gbConnectCtrls.TabStop = false;
            this.gbConnectCtrls.Text = "Connection";
            // 
            // btnDisconnect
            // 
            this.btnDisconnect.Enabled = false;
            this.btnDisconnect.Location = new System.Drawing.Point(231, 41);
            this.btnDisconnect.Name = "btnDisconnect";
            this.btnDisconnect.Size = new System.Drawing.Size(74, 23);
            this.btnDisconnect.TabIndex = 5;
            this.btnDisconnect.Text = "&Disconnect";
            this.btnDisconnect.UseVisualStyleBackColor = true;
            this.btnDisconnect.Click += new System.EventHandler(this.btnDisconnect_Click);
            // 
            // lblCurrentlyConnectedTo
            // 
            this.lblCurrentlyConnectedTo.AutoSize = true;
            this.lblCurrentlyConnectedTo.Location = new System.Drawing.Point(6, 46);
            this.lblCurrentlyConnectedTo.Name = "lblCurrentlyConnectedTo";
            this.lblCurrentlyConnectedTo.Size = new System.Drawing.Size(122, 13);
            this.lblCurrentlyConnectedTo.TabIndex = 3;
            this.lblCurrentlyConnectedTo.Text = "Currently Connected To:";
            // 
            // tbConnectedServerId
            // 
            this.tbConnectedServerId.Location = new System.Drawing.Point(6, 65);
            this.tbConnectedServerId.Name = "tbConnectedServerId";
            this.tbConnectedServerId.ReadOnly = true;
            this.tbConnectedServerId.Size = new System.Drawing.Size(299, 20);
            this.tbConnectedServerId.TabIndex = 4;
            this.tbConnectedServerId.Text = "[Not Connected]";
            // 
            // btnConnect
            // 
            this.btnConnect.Location = new System.Drawing.Point(231, 11);
            this.btnConnect.Name = "btnConnect";
            this.btnConnect.Size = new System.Drawing.Size(74, 23);
            this.btnConnect.TabIndex = 2;
            this.btnConnect.Text = "&Connect";
            this.btnConnect.UseVisualStyleBackColor = true;
            this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
            // 
            // tbSelectedServerId
            // 
            this.tbSelectedServerId.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.tbSelectedServerId.Location = new System.Drawing.Point(67, 13);
            this.tbSelectedServerId.Name = "tbSelectedServerId";
            this.tbSelectedServerId.Size = new System.Drawing.Size(158, 20);
            this.tbSelectedServerId.TabIndex = 1;
            // 
            // lblSelectedServerId
            // 
            this.lblSelectedServerId.AutoSize = true;
            this.lblSelectedServerId.Location = new System.Drawing.Point(6, 16);
            this.lblSelectedServerId.Name = "lblSelectedServerId";
            this.lblSelectedServerId.Size = new System.Drawing.Size(55, 13);
            this.lblSelectedServerId.TabIndex = 0;
            this.lblSelectedServerId.Text = "Server &ID:";
            // 
            // gbScanCtrls
            // 
            this.gbScanCtrls.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gbScanCtrls.Controls.Add(this.lbScanFilter);
            this.gbScanCtrls.Controls.Add(this.btnChooseScanUuids);
            this.gbScanCtrls.Controls.Add(this.lblScanFilter);
            this.gbScanCtrls.Controls.Add(this.cbActiveScanning);
            this.gbScanCtrls.Controls.Add(this.btnScan);
            this.gbScanCtrls.Location = new System.Drawing.Point(6, 6);
            this.gbScanCtrls.Name = "gbScanCtrls";
            this.gbScanCtrls.Size = new System.Drawing.Size(673, 91);
            this.gbScanCtrls.TabIndex = 0;
            this.gbScanCtrls.TabStop = false;
            this.gbScanCtrls.Text = "Scanning";
            // 
            // lbScanFilter
            // 
            this.lbScanFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lbScanFilter.FormattingEnabled = true;
            this.lbScanFilter.Location = new System.Drawing.Point(99, 32);
            this.lbScanFilter.Name = "lbScanFilter";
            this.lbScanFilter.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
            this.lbScanFilter.Size = new System.Drawing.Size(568, 56);
            this.lbScanFilter.TabIndex = 3;
            this.ToolTip1.SetToolTip(this.lbScanFilter, "If not empty when scanning begins, BLEClient will filter out any devices which ar" +
        "e not advertising one or more of these services.");
            this.lbScanFilter.KeyUp += new System.Windows.Forms.KeyEventHandler(this.lbUuids_KeyUp);
            // 
            // btnChooseScanUuids
            // 
            this.btnChooseScanUuids.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnChooseScanUuids.Location = new System.Drawing.Point(570, 8);
            this.btnChooseScanUuids.Name = "btnChooseScanUuids";
            this.btnChooseScanUuids.Size = new System.Drawing.Size(97, 23);
            this.btnChooseScanUuids.TabIndex = 4;
            this.btnChooseScanUuids.Text = "C&hoose UUIDs";
            this.btnChooseScanUuids.UseVisualStyleBackColor = true;
            this.btnChooseScanUuids.Click += new System.EventHandler(this.btnChooseScanUuids_Click);
            // 
            // lblScanFilter
            // 
            this.lblScanFilter.AutoSize = true;
            this.lblScanFilter.Location = new System.Drawing.Point(99, 15);
            this.lblScanFilter.Name = "lblScanFilter";
            this.lblScanFilter.Size = new System.Drawing.Size(203, 13);
            this.lblScanFilter.TabIndex = 2;
            this.lblScanFilter.Text = "Service UUIDs to &filter advertisements by:\r\n";
            // 
            // cbActiveScanning
            // 
            this.cbActiveScanning.Checked = true;
            this.cbActiveScanning.CheckState = System.Windows.Forms.CheckState.Checked;
            this.cbActiveScanning.Location = new System.Drawing.Point(7, 49);
            this.cbActiveScanning.Name = "cbActiveScanning";
            this.cbActiveScanning.Size = new System.Drawing.Size(86, 38);
            this.cbActiveScanning.TabIndex = 1;
            this.cbActiveScanning.Text = "Use &Active Scanning";
            this.ToolTip1.SetToolTip(this.cbActiveScanning, "Active scanning will cause BLEClient to request a\r\nscan response for every advert" +
        "isement received.\r\nThis uses more battery life.");
            this.cbActiveScanning.UseVisualStyleBackColor = true;
            // 
            // btnScan
            // 
            this.btnScan.Location = new System.Drawing.Point(6, 19);
            this.btnScan.Name = "btnScan";
            this.btnScan.Size = new System.Drawing.Size(87, 23);
            this.btnScan.TabIndex = 0;
            this.btnScan.Text = "&Start Scanning";
            this.btnScan.UseVisualStyleBackColor = true;
            this.btnScan.Click += new System.EventHandler(this.btnScan_Click);
            // 
            // lvwDevices
            // 
            this.lvwDevices.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lvwDevices.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.colServerId,
            this.colName,
            this.colRssi,
            this.colTxPower,
            this.colConnectable,
            this.colServiceUuids,
            this.colServicesWithData,
            this.colManufacturerCompanyId,
            this.colManufacturerData,
            this.colSolicitedServiceUuids});
            this.lvwDevices.FullRowSelect = true;
            this.lvwDevices.GridLines = true;
            this.lvwDevices.Location = new System.Drawing.Point(3, 103);
            this.lvwDevices.MultiSelect = false;
            this.lvwDevices.Name = "lvwDevices";
            this.lvwDevices.ShowItemToolTips = true;
            this.lvwDevices.Size = new System.Drawing.Size(996, 348);
            this.lvwDevices.TabIndex = 2;
            this.lvwDevices.UseCompatibleStateImageBehavior = false;
            this.lvwDevices.View = System.Windows.Forms.View.Details;
            this.lvwDevices.SelectedIndexChanged += new System.EventHandler(this.lvwDevices_SelectedIndexChanged);
            this.lvwDevices.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lvwDevices_MouseUp);
            // 
            // colServerId
            // 
            this.colServerId.Text = "Server ID";
            this.colServerId.Width = 90;
            // 
            // colName
            // 
            this.colName.Text = "Local Name";
            this.colName.Width = 120;
            // 
            // colRssi
            // 
            this.colRssi.Text = "RSSI";
            this.colRssi.Width = 40;
            // 
            // colTxPower
            // 
            this.colTxPower.Text = "TxPwr";
            this.colTxPower.Width = 45;
            // 
            // colConnectable
            // 
            this.colConnectable.Text = "Connectable";
            this.colConnectable.Width = 72;
            // 
            // colServiceUuids
            // 
            this.colServiceUuids.Text = "Service UUIDs";
            this.colServiceUuids.Width = 300;
            // 
            // colServicesWithData
            // 
            this.colServicesWithData.Text = "Services With Data";
            this.colServicesWithData.Width = 105;
            // 
            // colManufacturerCompanyId
            // 
            this.colManufacturerCompanyId.Text = "Mfr ID";
            // 
            // colManufacturerData
            // 
            this.colManufacturerData.Text = "Manufacturer Data";
            this.colManufacturerData.Width = 300;
            // 
            // colSolicitedServiceUuids
            // 
            this.colSolicitedServiceUuids.Text = "Solicited Service UUIDs";
            this.colSolicitedServiceUuids.Width = 130;
            // 
            // tabBrowse
            // 
            this.tabBrowse.Controls.Add(this.splitBrowse);
            this.tabBrowse.Location = new System.Drawing.Point(4, 22);
            this.tabBrowse.Name = "tabBrowse";
            this.tabBrowse.Padding = new System.Windows.Forms.Padding(3);
            this.tabBrowse.Size = new System.Drawing.Size(1002, 454);
            this.tabBrowse.TabIndex = 1;
            this.tabBrowse.Text = "Browse Data";
            this.tabBrowse.ToolTipText = "The \"Browse Data\" tab allows you to discover and browse the currently connected d" +
    "evice\'s services, characteristics, and descriptors.";
            this.tabBrowse.UseVisualStyleBackColor = true;
            // 
            // splitBrowse
            // 
            this.splitBrowse.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitBrowse.IsSplitterFixed = true;
            this.splitBrowse.Location = new System.Drawing.Point(3, 3);
            this.splitBrowse.Name = "splitBrowse";
            this.splitBrowse.Orientation = System.Windows.Forms.Orientation.Horizontal;
            // 
            // splitBrowse.Panel1
            // 
            this.splitBrowse.Panel1.Controls.Add(this.splitData);
            // 
            // splitBrowse.Panel2
            // 
            this.splitBrowse.Panel2.Controls.Add(this.lblBrowseOverlay);
            this.splitBrowse.Panel2Collapsed = true;
            this.splitBrowse.Size = new System.Drawing.Size(996, 448);
            this.splitBrowse.SplitterDistance = 419;
            this.splitBrowse.TabIndex = 0;
            this.splitBrowse.TabStop = false;
            // 
            // splitData
            // 
            this.splitData.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitData.Location = new System.Drawing.Point(0, 0);
            this.splitData.Name = "splitData";
            // 
            // splitData.Panel1
            // 
            this.splitData.Panel1.Controls.Add(this.lblGattObjectsTree);
            this.splitData.Panel1.Controls.Add(this.treeGattObjects);
            // 
            // splitData.Panel2
            // 
            this.splitData.Panel2.Controls.Add(this.tabCtrlGattData);
            this.splitData.Panel2MinSize = 650;
            this.splitData.Size = new System.Drawing.Size(996, 448);
            this.splitData.SplitterDistance = 332;
            this.splitData.TabIndex = 0;
            // 
            // lblGattObjectsTree
            // 
            this.lblGattObjectsTree.AutoSize = true;
            this.lblGattObjectsTree.Dock = System.Windows.Forms.DockStyle.Top;
            this.lblGattObjectsTree.Location = new System.Drawing.Point(0, 0);
            this.lblGattObjectsTree.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
            this.lblGattObjectsTree.Name = "lblGattObjectsTree";
            this.lblGattObjectsTree.Size = new System.Drawing.Size(160, 13);
            this.lblGattObjectsTree.TabIndex = 0;
            this.lblGattObjectsTree.Text = "Discovered &GATT Objects Tree:";
            // 
            // treeGattObjects
            // 
            this.treeGattObjects.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.treeGattObjects.HideSelection = false;
            this.treeGattObjects.Location = new System.Drawing.Point(0, 19);
            this.treeGattObjects.Name = "treeGattObjects";
            treeNode1.Name = "nodeServer";
            treeNode1.Text = "[Server]";
            this.treeGattObjects.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
            treeNode1});
            this.treeGattObjects.ShowPlusMinus = false;
            this.treeGattObjects.Size = new System.Drawing.Size(332, 429);
            this.treeGattObjects.TabIndex = 1;
            this.treeGattObjects.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeGattObjects_BeforeCollapse);
            this.treeGattObjects.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeGattObjects_AfterSelect);
            // 
            // tabCtrlGattData
            // 
            this.tabCtrlGattData.Controls.Add(this.tabGattServer);
            this.tabCtrlGattData.Controls.Add(this.tabGattService);
            this.tabCtrlGattData.Controls.Add(this.tabGattCharacteristic);
            this.tabCtrlGattData.Controls.Add(this.tabGattDescriptor);
            this.tabCtrlGattData.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabCtrlGattData.Location = new System.Drawing.Point(0, 0);
            this.tabCtrlGattData.Multiline = true;
            this.tabCtrlGattData.Name = "tabCtrlGattData";
            this.tabCtrlGattData.SelectedIndex = 0;
            this.tabCtrlGattData.Size = new System.Drawing.Size(660, 448);
            this.tabCtrlGattData.TabIndex = 0;
            this.tabCtrlGattData.TabStop = false;
            // 
            // tabGattServer
            // 
            this.tabGattServer.Controls.Add(this.gbSrvDiscoverEverything);
            this.tabGattServer.Controls.Add(this.gbSrvDiscovery);
            this.tabGattServer.Controls.Add(this.lblServerId);
            this.tabGattServer.Controls.Add(this.tbServerId);
            this.tabGattServer.Controls.Add(this.tbServerName);
            this.tabGattServer.Controls.Add(this.lblServerName);
            this.tabGattServer.Location = new System.Drawing.Point(4, 22);
            this.tabGattServer.Name = "tabGattServer";
            this.tabGattServer.Padding = new System.Windows.Forms.Padding(3);
            this.tabGattServer.Size = new System.Drawing.Size(652, 422);
            this.tabGattServer.TabIndex = 0;
            this.tabGattServer.Text = "[Server Controls]";
            this.tabGattServer.UseVisualStyleBackColor = true;
            // 
            // gbSrvDiscoverEverything
            // 
            this.gbSrvDiscoverEverything.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gbSrvDiscoverEverything.Controls.Add(this.lblSrvDiscoverAll);
            this.gbSrvDiscoverEverything.Controls.Add(this.btnSrvDiscoverEverything);
            this.gbSrvDiscoverEverything.Location = new System.Drawing.Point(6, 376);
            this.gbSrvDiscoverEverything.Name = "gbSrvDiscoverEverything";
            this.gbSrvDiscoverEverything.Size = new System.Drawing.Size(640, 40);
            this.gbSrvDiscoverEverything.TabIndex = 5;
            this.gbSrvDiscoverEverything.TabStop = false;
            this.gbSrvDiscoverEverything.Text = "Discover Everything";
            // 
            // lblSrvDiscoverAll
            // 
            this.lblSrvDiscoverAll.AutoSize = true;
            this.lblSrvDiscoverAll.ForeColor = System.Drawing.SystemColors.Highlight;
            this.lblSrvDiscoverAll.Location = new System.Drawing.Point(6, 16);
            this.lblSrvDiscoverAll.Name = "lblSrvDiscoverAll";
            this.lblSrvDiscoverAll.Size = new System.Drawing.Size(421, 13);
            this.lblSrvDiscoverAll.TabIndex = 0;
            this.lblSrvDiscoverAll.Text = "If you wish to discover everything on the server at once, you can. (It might take" +
    " a while.)";
            // 
            // btnSrvDiscoverEverything
            // 
            this.btnSrvDiscoverEverything.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnSrvDiscoverEverything.Location = new System.Drawing.Point(511, 11);
            this.btnSrvDiscoverEverything.Name = "btnSrvDiscoverEverything";
            this.btnSrvDiscoverEverything.Size = new System.Drawing.Size(123, 23);
            this.btnSrvDiscoverEverything.TabIndex = 1;
            this.btnSrvDiscoverEverything.Text = "Discover &Everything";
            this.btnSrvDiscoverEverything.UseVisualStyleBackColor = true;
            this.btnSrvDiscoverEverything.Click += new System.EventHandler(this.btnSrvDiscoverEverything_Click);
            // 
            // gbSrvDiscovery
            // 
            this.gbSrvDiscovery.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gbSrvDiscovery.Controls.Add(this.btnSrvChooseServiceUuids);
            this.gbSrvDiscovery.Controls.Add(this.btnSrvDiscoverServices);
            this.gbSrvDiscovery.Controls.Add(this.lbSrvServiceUuids);
            this.gbSrvDiscovery.Controls.Add(this.lblSrvServiceUuids);
            this.gbSrvDiscovery.Controls.Add(this.lblSrvDiscovery);
            this.gbSrvDiscovery.Location = new System.Drawing.Point(6, 59);
            this.gbSrvDiscovery.Name = "gbSrvDiscovery";
            this.gbSrvDiscovery.Size = new System.Drawing.Size(640, 311);
            this.gbSrvDiscovery.TabIndex = 4;
            this.gbSrvDiscovery.TabStop = false;
            this.gbSrvDiscovery.Text = "Root Service Discovery";
            // 
            // btnSrvChooseServiceUuids
            // 
            this.btnSrvChooseServiceUuids.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.btnSrvChooseServiceUuids.Location = new System.Drawing.Point(6, 282);
            this.btnSrvChooseServiceUuids.Name = "btnSrvChooseServiceUuids";
            this.btnSrvChooseServiceUuids.Size = new System.Drawing.Size(113, 23);
            this.btnSrvChooseServiceUuids.TabIndex = 3;
            this.btnSrvChooseServiceUuids.Text = "&Choose Services";
            this.btnSrvChooseServiceUuids.UseVisualStyleBackColor = true;
            this.btnSrvChooseServiceUuids.Click += new System.EventHandler(this.btnSrvChooseServiceUuids_Click);
            // 
            // btnSrvDiscoverServices
            // 
            this.btnSrvDiscoverServices.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnSrvDiscoverServices.Location = new System.Drawing.Point(498, 282);
            this.btnSrvDiscoverServices.Name = "btnSrvDiscoverServices";
            this.btnSrvDiscoverServices.Size = new System.Drawing.Size(136, 23);
            this.btnSrvDiscoverServices.TabIndex = 4;
            this.btnSrvDiscoverServices.Text = "&Discover Root Services";
            this.btnSrvDiscoverServices.UseVisualStyleBackColor = true;
            this.btnSrvDiscoverServices.Click += new System.EventHandler(this.btnSrvDiscoverServices_Click);
            // 
            // lbSrvServiceUuids
            // 
            this.lbSrvServiceUuids.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lbSrvServiceUuids.FormattingEnabled = true;
            this.lbSrvServiceUuids.Location = new System.Drawing.Point(6, 71);
            this.lbSrvServiceUuids.Name = "lbSrvServiceUuids";
            this.lbSrvServiceUuids.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
            this.lbSrvServiceUuids.Size = new System.Drawing.Size(628, 199);
            this.lbSrvServiceUuids.TabIndex = 2;
            this.lbSrvServiceUuids.KeyUp += new System.Windows.Forms.KeyEventHandler(this.lbUuids_KeyUp);
            // 
            // lblSrvServiceUuids
            // 
            this.lblSrvServiceUuids.AutoSize = true;
            this.lblSrvServiceUuids.Location = new System.Drawing.Point(6, 55);
            this.lblSrvServiceUuids.Name = "lblSrvServiceUuids";
            this.lblSrvServiceUuids.Size = new System.Drawing.Size(147, 13);
            this.lblSrvServiceUuids.TabIndex = 1;
            this.lblSrvServiceUuids.Text = "Root Service Discovery &Filter:";
            // 
            // lblSrvDiscovery
            // 
            this.lblSrvDiscovery.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lblSrvDiscovery.ForeColor = System.Drawing.SystemColors.Highlight;
            this.lblSrvDiscovery.Location = new System.Drawing.Point(6, 16);
            this.lblSrvDiscovery.Name = "lblSrvDiscovery";
            this.lblSrvDiscovery.Size = new System.Drawing.Size(628, 31);
            this.lblSrvDiscovery.TabIndex = 0;
            this.lblSrvDiscovery.Text = resources.GetString("lblSrvDiscovery.Text");
            // 
            // lblServerId
            // 
            this.lblServerId.AutoSize = true;
            this.lblServerId.Location = new System.Drawing.Point(6, 36);
            this.lblServerId.Name = "lblServerId";
            this.lblServerId.Size = new System.Drawing.Size(55, 13);
            this.lblServerId.TabIndex = 2;
            this.lblServerId.Text = "Server ID:";
            // 
            // tbServerId
            // 
            this.tbServerId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbServerId.Location = new System.Drawing.Point(67, 33);
            this.tbServerId.Name = "tbServerId";
            this.tbServerId.ReadOnly = true;
            this.tbServerId.Size = new System.Drawing.Size(579, 20);
            this.tbServerId.TabIndex = 3;
            // 
            // tbServerName
            // 
            this.tbServerName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbServerName.Location = new System.Drawing.Point(87, 6);
            this.tbServerName.Name = "tbServerName";
            this.tbServerName.ReadOnly = true;
            this.tbServerName.Size = new System.Drawing.Size(559, 20);
            this.tbServerName.TabIndex = 1;
            // 
            // lblServerName
            // 
            this.lblServerName.AutoSize = true;
            this.lblServerName.Location = new System.Drawing.Point(6, 9);
            this.lblServerName.Name = "lblServerName";
            this.lblServerName.Size = new System.Drawing.Size(75, 13);
            this.lblServerName.TabIndex = 0;
            this.lblServerName.Text = "Server Name: ";
            // 
            // tabGattService
            // 
            this.tabGattService.Controls.Add(this.tabCtrlSvcDiscovery);
            this.tabGattService.Controls.Add(this.lblServiceColorsNote);
            this.tabGattService.Controls.Add(this.tbServiceId);
            this.tabGattService.Controls.Add(this.lblServiceId);
            this.tabGattService.Controls.Add(this.lblServiceUuid);
            this.tabGattService.Controls.Add(this.tbServiceUuid);
            this.tabGattService.Controls.Add(this.tbServiceName);
            this.tabGattService.Controls.Add(this.lblServiceName);
            this.tabGattService.Location = new System.Drawing.Point(4, 22);
            this.tabGattService.Name = "tabGattService";
            this.tabGattService.Padding = new System.Windows.Forms.Padding(3);
            this.tabGattService.Size = new System.Drawing.Size(652, 422);
            this.tabGattService.TabIndex = 1;
            this.tabGattService.Text = "[Service Controls]";
            this.tabGattService.UseVisualStyleBackColor = true;
            // 
            // tabCtrlSvcDiscovery
            // 
            this.tabCtrlSvcDiscovery.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tabCtrlSvcDiscovery.Controls.Add(this.tabSvcDiscoverCharacteristics);
            this.tabCtrlSvcDiscovery.Controls.Add(this.tabSvcDiscoverInclServices);
            this.tabCtrlSvcDiscovery.Location = new System.Drawing.Point(6, 97);
            this.tabCtrlSvcDiscovery.Name = "tabCtrlSvcDiscovery";
            this.tabCtrlSvcDiscovery.SelectedIndex = 0;
            this.tabCtrlSvcDiscovery.Size = new System.Drawing.Size(640, 319);
            this.tabCtrlSvcDiscovery.TabIndex = 7;
            // 
            // tabSvcDiscoverCharacteristics
            // 
            this.tabSvcDiscoverCharacteristics.Controls.Add(this.btnSvcChooseCharacteristics);
            this.tabSvcDiscoverCharacteristics.Controls.Add(this.btnSvcDiscoverCharacteristics);
            this.tabSvcDiscoverCharacteristics.Controls.Add(this.lbSvcCharacteristicUuids);
            this.tabSvcDiscoverCharacteristics.Controls.Add(this.lblSvcCharacteristicUuids);
            this.tabSvcDiscoverCharacteristics.Controls.Add(this.lblSrvDiscoverCharacteristics);
            this.tabSvcDiscoverCharacteristics.Location = new System.Drawing.Point(4, 22);
            this.tabSvcDiscoverCharacteristics.Name = "tabSvcDiscoverCharacteristics";
            this.tabSvcDiscoverCharacteristics.Padding = new System.Windows.Forms.Padding(3);
            this.tabSvcDiscoverCharacteristics.Size = new System.Drawing.Size(632, 293);
            this.tabSvcDiscoverCharacteristics.TabIndex = 0;
            this.tabSvcDiscoverCharacteristics.Text = "Discover Characteristics";
            this.tabSvcDiscoverCharacteristics.UseVisualStyleBackColor = true;
            // 
            // btnSvcChooseCharacteristics
            // 
            this.btnSvcChooseCharacteristics.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.btnSvcChooseCharacteristics.Location = new System.Drawing.Point(6, 264);
            this.btnSvcChooseCharacteristics.Name = "btnSvcChooseCharacteristics";
            this.btnSvcChooseCharacteristics.Size = new System.Drawing.Size(132, 23);
            this.btnSvcChooseCharacteristics.TabIndex = 3;
            this.btnSvcChooseCharacteristics.Text = "&Choose Characteristics";
            this.btnSvcChooseCharacteristics.UseVisualStyleBackColor = true;
            this.btnSvcChooseCharacteristics.Click += new System.EventHandler(this.btnSvcChooseCharacteristics_Click);
            // 
            // btnSvcDiscoverCharacteristics
            // 
            this.btnSvcDiscoverCharacteristics.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnSvcDiscoverCharacteristics.Location = new System.Drawing.Point(490, 264);
            this.btnSvcDiscoverCharacteristics.Name = "btnSvcDiscoverCharacteristics";
            this.btnSvcDiscoverCharacteristics.Size = new System.Drawing.Size(136, 23);
            this.btnSvcDiscoverCharacteristics.TabIndex = 4;
            this.btnSvcDiscoverCharacteristics.Text = "&Discover Characteristics";
            this.btnSvcDiscoverCharacteristics.UseVisualStyleBackColor = true;
            this.btnSvcDiscoverCharacteristics.Click += new System.EventHandler(this.btnSvcDiscoverCharacteristics_Click);
            // 
            // lbSvcCharacteristicUuids
            // 
            this.lbSvcCharacteristicUuids.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lbSvcCharacteristicUuids.FormattingEnabled = true;
            this.lbSvcCharacteristicUuids.Location = new System.Drawing.Point(6, 50);
            this.lbSvcCharacteristicUuids.Name = "lbSvcCharacteristicUuids";
            this.lbSvcCharacteristicUuids.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
            this.lbSvcCharacteristicUuids.Size = new System.Drawing.Size(620, 212);
            this.lbSvcCharacteristicUuids.TabIndex = 2;
            this.lbSvcCharacteristicUuids.KeyUp += new System.Windows.Forms.KeyEventHandler(this.lbUuids_KeyUp);
            // 
            // lblSvcCharacteristicUuids
            // 
            this.lblSvcCharacteristicUuids.AutoSize = true;
            this.lblSvcCharacteristicUuids.Location = new System.Drawing.Point(6, 34);
            this.lblSvcCharacteristicUuids.Name = "lblSvcCharacteristicUuids";
            this.lblSvcCharacteristicUuids.Size = new System.Drawing.Size(149, 13);
            this.lblSvcCharacteristicUuids.TabIndex = 1;
            this.lblSvcCharacteristicUuids.Text = "Characteristic Discovery &Filter:";
            // 
            // lblSrvDiscoverCharacteristics
            // 
            this.lblSrvDiscoverCharacteristics.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lblSrvDiscoverCharacteristics.ForeColor = System.Drawing.SystemColors.Highlight;
            this.lblSrvDiscoverCharacteristics.Location = new System.Drawing.Point(6, 3);
            this.lblSrvDiscoverCharacteristics.Name = "lblSrvDiscoverCharacteristics";
            this.lblSrvDiscoverCharacteristics.Size = new System.Drawing.Size(620, 31);
            this.lblSrvDiscoverCharacteristics.TabIndex = 0;
            this.lblSrvDiscoverCharacteristics.Text = resources.GetString("lblSrvDiscoverCharacteristics.Text");
            // 
            // tabSvcDiscoverInclServices
            // 
            this.tabSvcDiscoverInclServices.Controls.Add(this.btnSvcChooseInclServices);
            this.tabSvcDiscoverInclServices.Controls.Add(this.btnSvcDiscoverInclServices);
            this.tabSvcDiscoverInclServices.Controls.Add(this.lbSvcInclServiceUuids);
            this.tabSvcDiscoverInclServices.Controls.Add(this.lblSvcInclServiceUuids);
            this.tabSvcDiscoverInclServices.Controls.Add(this.lblSvcDiscoverInclServices);
            this.tabSvcDiscoverInclServices.Location = new System.Drawing.Point(4, 22);
            this.tabSvcDiscoverInclServices.Name = "tabSvcDiscoverInclServices";
            this.tabSvcDiscoverInclServices.Padding = new System.Windows.Forms.Padding(3);
            this.tabSvcDiscoverInclServices.Size = new System.Drawing.Size(632, 293);
            this.tabSvcDiscoverInclServices.TabIndex = 1;
            this.tabSvcDiscoverInclServices.Text = "Discover Included Services";
            this.tabSvcDiscoverInclServices.UseVisualStyleBackColor = true;
            // 
            // btnSvcChooseInclServices
            // 
            this.btnSvcChooseInclServices.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.btnSvcChooseInclServices.Location = new System.Drawing.Point(6, 264);
            this.btnSvcChooseInclServices.Name = "btnSvcChooseInclServices";
            this.btnSvcChooseInclServices.Size = new System.Drawing.Size(113, 23);
            this.btnSvcChooseInclServices.TabIndex = 3;
            this.btnSvcChooseInclServices.Text = "&Choose Services";
            this.btnSvcChooseInclServices.UseVisualStyleBackColor = true;
            this.btnSvcChooseInclServices.Click += new System.EventHandler(this.btnSvcChooseInclServices_Click);
            // 
            // btnSvcDiscoverInclServices
            // 
            this.btnSvcDiscoverInclServices.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnSvcDiscoverInclServices.Location = new System.Drawing.Point(468, 264);
            this.btnSvcDiscoverInclServices.Name = "btnSvcDiscoverInclServices";
            this.btnSvcDiscoverInclServices.Size = new System.Drawing.Size(158, 23);
            this.btnSvcDiscoverInclServices.TabIndex = 4;
            this.btnSvcDiscoverInclServices.Text = "&Discover Included Services";
            this.btnSvcDiscoverInclServices.UseVisualStyleBackColor = true;
            this.btnSvcDiscoverInclServices.Click += new System.EventHandler(this.btnSvcDiscoverInclServices_Click);
            // 
            // lbSvcInclServiceUuids
            // 
            this.lbSvcInclServiceUuids.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lbSvcInclServiceUuids.FormattingEnabled = true;
            this.lbSvcInclServiceUuids.Location = new System.Drawing.Point(6, 50);
            this.lbSvcInclServiceUuids.Name = "lbSvcInclServiceUuids";
            this.lbSvcInclServiceUuids.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
            this.lbSvcInclServiceUuids.Size = new System.Drawing.Size(620, 212);
            this.lbSvcInclServiceUuids.TabIndex = 2;
            this.lbSvcInclServiceUuids.KeyUp += new System.Windows.Forms.KeyEventHandler(this.lbUuids_KeyUp);
            // 
            // lblSvcInclServiceUuids
            // 
            this.lblSvcInclServiceUuids.AutoSize = true;
            this.lblSvcInclServiceUuids.Location = new System.Drawing.Point(6, 34);
            this.lblSvcInclServiceUuids.Name = "lblSvcInclServiceUuids";
            this.lblSvcInclServiceUuids.Size = new System.Drawing.Size(165, 13);
            this.lblSvcInclServiceUuids.TabIndex = 1;
            this.lblSvcInclServiceUuids.Text = "Included Service Discovery &Filter:";
            // 
            // lblSvcDiscoverInclServices
            // 
            this.lblSvcDiscoverInclServices.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lblSvcDiscoverInclServices.ForeColor = System.Drawing.SystemColors.Highlight;
            this.lblSvcDiscoverInclServices.Location = new System.Drawing.Point(6, 3);
            this.lblSvcDiscoverInclServices.Name = "lblSvcDiscoverInclServices";
            this.lblSvcDiscoverInclServices.Size = new System.Drawing.Size(620, 31);
            this.lblSvcDiscoverInclServices.TabIndex = 0;
            this.lblSvcDiscoverInclServices.Text = resources.GetString("lblSvcDiscoverInclServices.Text");
            // 
            // lblServiceColorsNote
            // 
            this.lblServiceColorsNote.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lblServiceColorsNote.ForeColor = System.Drawing.SystemColors.Highlight;
            this.lblServiceColorsNote.Location = new System.Drawing.Point(6, 55);
            this.lblServiceColorsNote.Name = "lblServiceColorsNote";
            this.lblServiceColorsNote.Size = new System.Drawing.Size(640, 28);
            this.lblServiceColorsNote.TabIndex = 6;
            this.lblServiceColorsNote.Text = resources.GetString("lblServiceColorsNote.Text");
            // 
            // tbServiceId
            // 
            this.tbServiceId.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.tbServiceId.Location = new System.Drawing.Point(511, 32);
            this.tbServiceId.Name = "tbServiceId";
            this.tbServiceId.ReadOnly = true;
            this.tbServiceId.Size = new System.Drawing.Size(135, 20);
            this.tbServiceId.TabIndex = 5;
            // 
            // lblServiceId
            // 
            this.lblServiceId.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblServiceId.AutoSize = true;
            this.lblServiceId.Location = new System.Drawing.Point(445, 35);
            this.lblServiceId.Name = "lblServiceId";
            this.lblServiceId.Size = new System.Drawing.Size(60, 13);
            this.lblServiceId.TabIndex = 4;
            this.lblServiceId.Text = "Service ID:";
            // 
            // lblServiceUuid
            // 
            this.lblServiceUuid.AutoSize = true;
            this.lblServiceUuid.Location = new System.Drawing.Point(6, 35);
            this.lblServiceUuid.Name = "lblServiceUuid";
            this.lblServiceUuid.Size = new System.Drawing.Size(76, 13);
            this.lblServiceUuid.TabIndex = 2;
            this.lblServiceUuid.Text = "Service UUID:";
            // 
            // tbServiceUuid
            // 
            this.tbServiceUuid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbServiceUuid.Location = new System.Drawing.Point(88, 32);
            this.tbServiceUuid.Name = "tbServiceUuid";
            this.tbServiceUuid.ReadOnly = true;
            this.tbServiceUuid.Size = new System.Drawing.Size(351, 20);
            this.tbServiceUuid.TabIndex = 3;
            // 
            // tbServiceName
            // 
            this.tbServiceName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbServiceName.Location = new System.Drawing.Point(89, 6);
            this.tbServiceName.Name = "tbServiceName";
            this.tbServiceName.ReadOnly = true;
            this.tbServiceName.Size = new System.Drawing.Size(557, 20);
            this.tbServiceName.TabIndex = 1;
            // 
            // lblServiceName
            // 
            this.lblServiceName.AutoSize = true;
            this.lblServiceName.Location = new System.Drawing.Point(6, 9);
            this.lblServiceName.Name = "lblServiceName";
            this.lblServiceName.Size = new System.Drawing.Size(77, 13);
            this.lblServiceName.TabIndex = 0;
            this.lblServiceName.Text = "Service Name:";
            // 
            // tabGattCharacteristic
            // 
            this.tabGattCharacteristic.Controls.Add(this.tbCharacteristicUserDescription);
            this.tabGattCharacteristic.Controls.Add(this.btnUpdateCharacteristicUserDescription);
            this.tabGattCharacteristic.Controls.Add(this.gbCharacteristicValue);
            this.tabGattCharacteristic.Controls.Add(this.lblCharacteristicValueFormatExponent);
            this.tabGattCharacteristic.Controls.Add(this.lblCharacteristicValueFormatUnit);
            this.tabGattCharacteristic.Controls.Add(this.tbCharacteristicValueFormatExponent);
            this.tabGattCharacteristic.Controls.Add(this.tbCharacteristicValueFormatUnit);
            this.tabGattCharacteristic.Controls.Add(this.tbCharacteristicValueFormatType);
            this.tabGattCharacteristic.Controls.Add(this.lblCharacteristicValueFormats);
            this.tabGattCharacteristic.Controls.Add(this.numCharacteristicValueFormatIdx);
            this.tabGattCharacteristic.Controls.Add(this.tbCharacteristicFlags);
            this.tabGattCharacteristic.Controls.Add(this.lblCharacteristicFlags);
            this.tabGattCharacteristic.Controls.Add(this.gbCharaDiscoverDescriptors);
            this.tabGattCharacteristic.Controls.Add(this.lblCharacteristicUserDescription);
            this.tabGattCharacteristic.Controls.Add(this.tbCharacteristicId);
            this.tabGattCharacteristic.Controls.Add(this.lblCharacteristicId);
            this.tabGattCharacteristic.Controls.Add(this.lblCharacteristicUuid);
            this.tabGattCharacteristic.Controls.Add(this.tbCharacteristicUuid);
            this.tabGattCharacteristic.Controls.Add(this.tbCharacteristicName);
            this.tabGattCharacteristic.Controls.Add(this.lblCharacteristicName);
            this.tabGattCharacteristic.Location = new System.Drawing.Point(4, 22);
            this.tabGattCharacteristic.Name = "tabGattCharacteristic";
            this.tabGattCharacteristic.Padding = new System.Windows.Forms.Padding(3);
            this.tabGattCharacteristic.Size = new System.Drawing.Size(652, 422);
            this.tabGattCharacteristic.TabIndex = 2;
            this.tabGattCharacteristic.Text = "[Characteristic Controls]";
            this.tabGattCharacteristic.UseVisualStyleBackColor = true;
            // 
            // tbCharacteristicUserDescription
            // 
            this.tbCharacteristicUserDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbCharacteristicUserDescription.Location = new System.Drawing.Point(100, 58);
            this.tbCharacteristicUserDescription.Name = "tbCharacteristicUserDescription";
            this.tbCharacteristicUserDescription.ReadOnly = true;
            this.tbCharacteristicUserDescription.Size = new System.Drawing.Size(462, 20);
            this.tbCharacteristicUserDescription.TabIndex = 7;
            // 
            // btnUpdateCharacteristicUserDescription
            // 
            this.btnUpdateCharacteristicUserDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnUpdateCharacteristicUserDescription.Enabled = false;
            this.btnUpdateCharacteristicUserDescription.Location = new System.Drawing.Point(571, 56);
            this.btnUpdateCharacteristicUserDescription.Name = "btnUpdateCharacteristicUserDescription";
            this.btnUpdateCharacteristicUserDescription.Size = new System.Drawing.Size(75, 23);
            this.btnUpdateCharacteristicUserDescription.TabIndex = 8;
            this.btnUpdateCharacteristicUserDescription.Text = "&Update";
            this.btnUpdateCharacteristicUserDescription.UseVisualStyleBackColor = true;
            this.btnUpdateCharacteristicUserDescription.Click += new System.EventHandler(this.btnUpdateCharacteristicUserDescription_Click);
            // 
            // gbCharacteristicValue
            // 
            this.gbCharacteristicValue.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gbCharacteristicValue.Controls.Add(this.btnCharaPostValue);
            this.gbCharacteristicValue.Controls.Add(this.btnToggleSubscribe);
            this.gbCharacteristicValue.Controls.Add(this.btnCharaWriteValue);
            this.gbCharacteristicValue.Controls.Add(this.btnCharaReadValue);
            this.gbCharacteristicValue.Controls.Add(this.tbCharacteristicValue);
            this.gbCharacteristicValue.Controls.Add(this.gbCharaDisplayValueAs);
            this.gbCharacteristicValue.Controls.Add(this.lblCharacteristicValue);
            this.gbCharacteristicValue.Location = new System.Drawing.Point(6, 136);
            this.gbCharacteristicValue.Name = "gbCharacteristicValue";
            this.gbCharacteristicValue.Size = new System.Drawing.Size(640, 234);
            this.gbCharacteristicValue.TabIndex = 18;
            this.gbCharacteristicValue.TabStop = false;
            this.gbCharacteristicValue.Text = "Characteristic Value";
            // 
            // btnCharaPostValue
            // 
            this.btnCharaPostValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.btnCharaPostValue.Enabled = false;
            this.btnCharaPostValue.Location = new System.Drawing.Point(238, 205);
            this.btnCharaPostValue.Name = "btnCharaPostValue";
            this.btnCharaPostValue.Size = new System.Drawing.Size(110, 23);
            this.btnCharaPostValue.TabIndex = 5;
            this.btnCharaPostValue.Text = "&Post Value";
            this.btnCharaPostValue.UseVisualStyleBackColor = true;
            this.btnCharaPostValue.Click += new System.EventHandler(this.btnCharaPostValue_Click);
            // 
            // btnToggleSubscribe
            // 
            this.btnToggleSubscribe.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnToggleSubscribe.Enabled = false;
            this.btnToggleSubscribe.Location = new System.Drawing.Point(524, 205);
            this.btnToggleSubscribe.Name = "btnToggleSubscribe";
            this.btnToggleSubscribe.Size = new System.Drawing.Size(110, 23);
            this.btnToggleSubscribe.TabIndex = 6;
            this.btnToggleSubscribe.Text = "&Subscribe";
            this.btnToggleSubscribe.UseVisualStyleBackColor = true;
            this.btnToggleSubscribe.Click += new System.EventHandler(this.btnToggleSubscribe_Click);
            // 
            // btnCharaWriteValue
            // 
            this.btnCharaWriteValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.btnCharaWriteValue.Enabled = false;
            this.btnCharaWriteValue.Location = new System.Drawing.Point(122, 205);
            this.btnCharaWriteValue.Name = "btnCharaWriteValue";
            this.btnCharaWriteValue.Size = new System.Drawing.Size(110, 23);
            this.btnCharaWriteValue.TabIndex = 4;
            this.btnCharaWriteValue.Text = "&Write Value";
            this.btnCharaWriteValue.UseVisualStyleBackColor = true;
            this.btnCharaWriteValue.Click += new System.EventHandler(this.btnCharaWriteValue_Click);
            // 
            // btnCharaReadValue
            // 
            this.btnCharaReadValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.btnCharaReadValue.Enabled = false;
            this.btnCharaReadValue.Location = new System.Drawing.Point(6, 205);
            this.btnCharaReadValue.Name = "btnCharaReadValue";
            this.btnCharaReadValue.Size = new System.Drawing.Size(110, 23);
            this.btnCharaReadValue.TabIndex = 3;
            this.btnCharaReadValue.Text = "&Read Value";
            this.btnCharaReadValue.UseVisualStyleBackColor = true;
            this.btnCharaReadValue.Click += new System.EventHandler(this.btnCharaReadValue_Click);
            // 
            // tbCharacteristicValue
            // 
            this.tbCharacteristicValue.AcceptsReturn = true;
            this.tbCharacteristicValue.AcceptsTab = true;
            this.tbCharacteristicValue.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbCharacteristicValue.Location = new System.Drawing.Point(6, 100);
            this.tbCharacteristicValue.Multiline = true;
            this.tbCharacteristicValue.Name = "tbCharacteristicValue";
            this.tbCharacteristicValue.ReadOnly = true;
            this.tbCharacteristicValue.Size = new System.Drawing.Size(628, 99);
            this.tbCharacteristicValue.TabIndex = 2;
            // 
            // gbCharaDisplayValueAs
            // 
            this.gbCharaDisplayValueAs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gbCharaDisplayValueAs.Controls.Add(this.rbCharaCustom);
            this.gbCharaDisplayValueAs.Controls.Add(this.rbCharaUTF16);
            this.gbCharaDisplayValueAs.Controls.Add(this.rbCharaUTF8);
            this.gbCharaDisplayValueAs.Controls.Add(this.cboCharaNumberType);
            this.gbCharaDisplayValueAs.Controls.Add(this.rbCharaNumber);
            this.gbCharaDisplayValueAs.Controls.Add(this.rbCharaBoolean);
            this.gbCharaDisplayValueAs.Controls.Add(this.btnCustomizeCharaFormat);
            this.gbCharaDisplayValueAs.Controls.Add(this.rbCharaHexBytes);
            this.gbCharaDisplayValueAs.Location = new System.Drawing.Point(6, 46);
            this.gbCharaDisplayValueAs.Name = "gbCharaDisplayValueAs";
            this.gbCharaDisplayValueAs.Size = new System.Drawing.Size(628, 48);
            this.gbCharaDisplayValueAs.TabIndex = 1;
            this.gbCharaDisplayValueAs.TabStop = false;
            this.gbCharaDisplayValueAs.Text = "Display Value As...";
            // 
            // rbCharaCustom
            // 
            this.rbCharaCustom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.rbCharaCustom.AutoSize = true;
            this.rbCharaCustom.Location = new System.Drawing.Point(446, 19);
            this.rbCharaCustom.Name = "rbCharaCustom";
            this.rbCharaCustom.Size = new System.Drawing.Size(95, 17);
            this.rbCharaCustom.TabIndex = 6;
            this.rbCharaCustom.Text = "Custom &Format";
            this.rbCharaCustom.UseVisualStyleBackColor = true;
            this.rbCharaCustom.CheckedChanged += new System.EventHandler(this.rbCharaDisplayType_CheckedChanged);
            // 
            // rbCharaUTF16
            // 
            this.rbCharaUTF16.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.rbCharaUTF16.AutoSize = true;
            this.rbCharaUTF16.Location = new System.Drawing.Point(379, 19);
            this.rbCharaUTF16.Name = "rbCharaUTF16";
            this.rbCharaUTF16.Size = new System.Drawing.Size(61, 17);
            this.rbCharaUTF16.TabIndex = 5;
            this.rbCharaUTF16.Text = "UTF-1&6";
            this.rbCharaUTF16.UseVisualStyleBackColor = true;
            this.rbCharaUTF16.CheckedChanged += new System.EventHandler(this.rbCharaDisplayType_CheckedChanged);
            // 
            // rbCharaUTF8
            // 
            this.rbCharaUTF8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.rbCharaUTF8.AutoSize = true;
            this.rbCharaUTF8.Location = new System.Drawing.Point(318, 19);
            this.rbCharaUTF8.Name = "rbCharaUTF8";
            this.rbCharaUTF8.Size = new System.Drawing.Size(55, 17);
            this.rbCharaUTF8.TabIndex = 4;
            this.rbCharaUTF8.Text = "UTF-&8";
            this.rbCharaUTF8.UseVisualStyleBackColor = true;
            this.rbCharaUTF8.CheckedChanged += new System.EventHandler(this.rbCharaDisplayType_CheckedChanged);
            // 
            // cboCharaNumberType
            // 
            this.cboCharaNumberType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.cboCharaNumberType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cboCharaNumberType.FormattingEnabled = true;
            this.cboCharaNumberType.Items.AddRange(new object[] {
            "UInt8",
            "UInt16",
            "UInt32",
            "UInt64",
            "SInt8",
            "SInt16",
            "SInt32",
            "SInt64",
            "Float32",
            "Float64"});
            this.cboCharaNumberType.Location = new System.Drawing.Point(222, 17);
            this.cboCharaNumberType.Name = "cboCharaNumberType";
            this.cboCharaNumberType.Size = new System.Drawing.Size(90, 21);
            this.cboCharaNumberType.TabIndex = 3;
            this.cboCharaNumberType.SelectionChangeCommitted += new System.EventHandler(this.cboCharaNumberType_SelectionChangeCommitted);
            // 
            // rbCharaNumber
            // 
            this.rbCharaNumber.AutoSize = true;
            this.rbCharaNumber.Location = new System.Drawing.Point(155, 19);
            this.rbCharaNumber.Name = "rbCharaNumber";
            this.rbCharaNumber.Size = new System.Drawing.Size(65, 17);
            this.rbCharaNumber.TabIndex = 2;
            this.rbCharaNumber.Text = "&Number:";
            this.rbCharaNumber.UseVisualStyleBackColor = true;
            this.rbCharaNumber.CheckedChanged += new System.EventHandler(this.rbCharaDisplayType_CheckedChanged);
            // 
            // rbCharaBoolean
            // 
            this.rbCharaBoolean.AutoSize = true;
            this.rbCharaBoolean.Location = new System.Drawing.Point(85, 19);
            this.rbCharaBoolean.Name = "rbCharaBoolean";
            this.rbCharaBoolean.Size = new System.Drawing.Size(64, 17);
            this.rbCharaBoolean.TabIndex = 1;
            this.rbCharaBoolean.Text = "&Boolean";
            this.rbCharaBoolean.UseVisualStyleBackColor = true;
            this.rbCharaBoolean.CheckedChanged += new System.EventHandler(this.rbCharaDisplayType_CheckedChanged);
            // 
            // btnCustomizeCharaFormat
            // 
            this.btnCustomizeCharaFormat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnCustomizeCharaFormat.Location = new System.Drawing.Point(547, 16);
            this.btnCustomizeCharaFormat.Name = "btnCustomizeCharaFormat";
            this.btnCustomizeCharaFormat.Size = new System.Drawing.Size(75, 23);
            this.btnCustomizeCharaFormat.TabIndex = 7;
            this.btnCustomizeCharaFormat.Text = "&Customize...";
            this.btnCustomizeCharaFormat.UseVisualStyleBackColor = true;
            this.btnCustomizeCharaFormat.Click += new System.EventHandler(this.btnCustomizeCharaFormat_Click);
            // 
            // rbCharaHexBytes
            // 
            this.rbCharaHexBytes.AutoSize = true;
            this.rbCharaHexBytes.Checked = true;
            this.rbCharaHexBytes.Location = new System.Drawing.Point(6, 19);
            this.rbCharaHexBytes.Name = "rbCharaHexBytes";
            this.rbCharaHexBytes.Size = new System.Drawing.Size(73, 17);
            this.rbCharaHexBytes.TabIndex = 0;
            this.rbCharaHexBytes.TabStop = true;
            this.rbCharaHexBytes.Text = "&Hex Bytes";
            this.rbCharaHexBytes.UseVisualStyleBackColor = true;
            this.rbCharaHexBytes.CheckedChanged += new System.EventHandler(this.rbCharaDisplayType_CheckedChanged);
            // 
            // lblCharacteristicValue
            // 
            this.lblCharacteristicValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lblCharacteristicValue.ForeColor = System.Drawing.SystemColors.Highlight;
            this.lblCharacteristicValue.Location = new System.Drawing.Point(6, 16);
            this.lblCharacteristicValue.Name = "lblCharacteristicValue";
            this.lblCharacteristicValue.Size = new System.Drawing.Size(628, 27);
            this.lblCharacteristicValue.TabIndex = 0;
            this.lblCharacteristicValue.Text = resources.GetString("lblCharacteristicValue.Text");
            // 
            // lblCharacteristicValueFormatExponent
            // 
            this.lblCharacteristicValueFormatExponent.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblCharacteristicValueFormatExponent.AutoSize = true;
            this.lblCharacteristicValueFormatExponent.Location = new System.Drawing.Point(524, 113);
            this.lblCharacteristicValueFormatExponent.Name = "lblCharacteristicValueFormatExponent";
            this.lblCharacteristicValueFormatExponent.Size = new System.Drawing.Size(55, 13);
            this.lblCharacteristicValueFormatExponent.TabIndex = 16;
            this.lblCharacteristicValueFormatExponent.Text = "Exponent:";
            // 
            // lblCharacteristicValueFormatUnit
            // 
            this.lblCharacteristicValueFormatUnit.AutoSize = true;
            this.lblCharacteristicValueFormatUnit.Location = new System.Drawing.Point(199, 113);
            this.lblCharacteristicValueFormatUnit.Name = "lblCharacteristicValueFormatUnit";
            this.lblCharacteristicValueFormatUnit.Size = new System.Drawing.Size(29, 13);
            this.lblCharacteristicValueFormatUnit.TabIndex = 14;
            this.lblCharacteristicValueFormatUnit.Text = "Unit:";
            // 
            // tbCharacteristicValueFormatExponent
            // 
            this.tbCharacteristicValueFormatExponent.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.tbCharacteristicValueFormatExponent.Location = new System.Drawing.Point(585, 110);
            this.tbCharacteristicValueFormatExponent.Name = "tbCharacteristicValueFormatExponent";
            this.tbCharacteristicValueFormatExponent.ReadOnly = true;
            this.tbCharacteristicValueFormatExponent.Size = new System.Drawing.Size(61, 20);
            this.tbCharacteristicValueFormatExponent.TabIndex = 17;
            this.ToolTip1.SetToolTip(this.tbCharacteristicValueFormatExponent, resources.GetString("tbCharacteristicValueFormatExponent.ToolTip"));
            // 
            // tbCharacteristicValueFormatUnit
            // 
            this.tbCharacteristicValueFormatUnit.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbCharacteristicValueFormatUnit.Location = new System.Drawing.Point(234, 110);
            this.tbCharacteristicValueFormatUnit.Name = "tbCharacteristicValueFormatUnit";
            this.tbCharacteristicValueFormatUnit.ReadOnly = true;
            this.tbCharacteristicValueFormatUnit.Size = new System.Drawing.Size(284, 20);
            this.tbCharacteristicValueFormatUnit.TabIndex = 15;
            this.ToolTip1.SetToolTip(this.tbCharacteristicValueFormatUnit, resources.GetString("tbCharacteristicValueFormatUnit.ToolTip"));
            // 
            // tbCharacteristicValueFormatType
            // 
            this.tbCharacteristicValueFormatType.Location = new System.Drawing.Point(128, 110);
            this.tbCharacteristicValueFormatType.Name = "tbCharacteristicValueFormatType";
            this.tbCharacteristicValueFormatType.ReadOnly = true;
            this.tbCharacteristicValueFormatType.Size = new System.Drawing.Size(65, 20);
            this.tbCharacteristicValueFormatType.TabIndex = 13;
            this.ToolTip1.SetToolTip(this.tbCharacteristicValueFormatType, resources.GetString("tbCharacteristicValueFormatType.ToolTip"));
            // 
            // lblCharacteristicValueFormats
            // 
            this.lblCharacteristicValueFormats.AutoSize = true;
            this.lblCharacteristicValueFormats.Location = new System.Drawing.Point(6, 113);
            this.lblCharacteristicValueFormats.Name = "lblCharacteristicValueFormats";
            this.lblCharacteristicValueFormats.Size = new System.Drawing.Size(77, 13);
            this.lblCharacteristicValueFormats.TabIndex = 11;
            this.lblCharacteristicValueFormats.Text = "&Value Formats:";
            this.ToolTip1.SetToolTip(this.lblCharacteristicValueFormats, resources.GetString("lblCharacteristicValueFormats.ToolTip"));
            // 
            // numCharacteristicValueFormatIdx
            // 
            this.numCharacteristicValueFormatIdx.Location = new System.Drawing.Point(89, 110);
            this.numCharacteristicValueFormatIdx.Maximum = new decimal(new int[] {
            1,
            0,
            0,
            -2147483648});
            this.numCharacteristicValueFormatIdx.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            -2147483648});
            this.numCharacteristicValueFormatIdx.Name = "numCharacteristicValueFormatIdx";
            this.numCharacteristicValueFormatIdx.ReadOnly = true;
            this.numCharacteristicValueFormatIdx.Size = new System.Drawing.Size(33, 20);
            this.numCharacteristicValueFormatIdx.TabIndex = 12;
            this.ToolTip1.SetToolTip(this.numCharacteristicValueFormatIdx, resources.GetString("numCharacteristicValueFormatIdx.ToolTip"));
            this.numCharacteristicValueFormatIdx.Value = new decimal(new int[] {
            1,
            0,
            0,
            -2147483648});
            this.numCharacteristicValueFormatIdx.ValueChanged += new System.EventHandler(this.numCharacteristicValueFormatIdx_ValueChanged);
            // 
            // tbCharacteristicFlags
            // 
            this.tbCharacteristicFlags.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbCharacteristicFlags.Location = new System.Drawing.Point(47, 84);
            this.tbCharacteristicFlags.Name = "tbCharacteristicFlags";
            this.tbCharacteristicFlags.ReadOnly = true;
            this.tbCharacteristicFlags.Size = new System.Drawing.Size(599, 20);
            this.tbCharacteristicFlags.TabIndex = 10;
            // 
            // lblCharacteristicFlags
            // 
            this.lblCharacteristicFlags.AutoSize = true;
            this.lblCharacteristicFlags.Location = new System.Drawing.Point(6, 87);
            this.lblCharacteristicFlags.Name = "lblCharacteristicFlags";
            this.lblCharacteristicFlags.Size = new System.Drawing.Size(35, 13);
            this.lblCharacteristicFlags.TabIndex = 9;
            this.lblCharacteristicFlags.Text = "Flags:";
            // 
            // gbCharaDiscoverDescriptors
            // 
            this.gbCharaDiscoverDescriptors.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gbCharaDiscoverDescriptors.Controls.Add(this.lblCharaDiscoverDescriptors);
            this.gbCharaDiscoverDescriptors.Controls.Add(this.btnCharaDiscoverDescriptors);
            this.gbCharaDiscoverDescriptors.Location = new System.Drawing.Point(6, 376);
            this.gbCharaDiscoverDescriptors.Name = "gbCharaDiscoverDescriptors";
            this.gbCharaDiscoverDescriptors.Size = new System.Drawing.Size(640, 40);
            this.gbCharaDiscoverDescriptors.TabIndex = 19;
            this.gbCharaDiscoverDescriptors.TabStop = false;
            this.gbCharaDiscoverDescriptors.Text = "Discover Descriptors";
            // 
            // lblCharaDiscoverDescriptors
            // 
            this.lblCharaDiscoverDescriptors.AutoSize = true;
            this.lblCharaDiscoverDescriptors.ForeColor = System.Drawing.SystemColors.Highlight;
            this.lblCharaDiscoverDescriptors.Location = new System.Drawing.Point(6, 16);
            this.lblCharaDiscoverDescriptors.Name = "lblCharaDiscoverDescriptors";
            this.lblCharaDiscoverDescriptors.Size = new System.Drawing.Size(454, 13);
            this.lblCharaDiscoverDescriptors.TabIndex = 0;
            this.lblCharaDiscoverDescriptors.Text = "BLEClient allows you to discover all of a characteristic\'s descriptors. Press the" +
    " button the do so.";
            // 
            // btnCharaDiscoverDescriptors
            // 
            this.btnCharaDiscoverDescriptors.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnCharaDiscoverDescriptors.Location = new System.Drawing.Point(511, 11);
            this.btnCharaDiscoverDescriptors.Name = "btnCharaDiscoverDescriptors";
            this.btnCharaDiscoverDescriptors.Size = new System.Drawing.Size(123, 23);
            this.btnCharaDiscoverDescriptors.TabIndex = 1;
            this.btnCharaDiscoverDescriptors.Text = "&Discover Descriptors";
            this.btnCharaDiscoverDescriptors.UseVisualStyleBackColor = true;
            this.btnCharaDiscoverDescriptors.Click += new System.EventHandler(this.btnCharaDiscoverDescriptors_Click);
            // 
            // lblCharacteristicUserDescription
            // 
            this.lblCharacteristicUserDescription.AutoSize = true;
            this.lblCharacteristicUserDescription.Location = new System.Drawing.Point(6, 61);
            this.lblCharacteristicUserDescription.Name = "lblCharacteristicUserDescription";
            this.lblCharacteristicUserDescription.Size = new System.Drawing.Size(88, 13);
            this.lblCharacteristicUserDescription.TabIndex = 6;
            this.lblCharacteristicUserDescription.Text = "User D&escription:";
            // 
            // tbCharacteristicId
            // 
            this.tbCharacteristicId.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.tbCharacteristicId.Location = new System.Drawing.Point(518, 32);
            this.tbCharacteristicId.Name = "tbCharacteristicId";
            this.tbCharacteristicId.ReadOnly = true;
            this.tbCharacteristicId.Size = new System.Drawing.Size(128, 20);
            this.tbCharacteristicId.TabIndex = 5;
            // 
            // lblCharacteristicId
            // 
            this.lblCharacteristicId.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblCharacteristicId.AutoSize = true;
            this.lblCharacteristicId.Location = new System.Drawing.Point(424, 35);
            this.lblCharacteristicId.Name = "lblCharacteristicId";
            this.lblCharacteristicId.Size = new System.Drawing.Size(88, 13);
            this.lblCharacteristicId.TabIndex = 4;
            this.lblCharacteristicId.Text = "Characteristic ID:";
            // 
            // lblCharacteristicUuid
            // 
            this.lblCharacteristicUuid.AutoSize = true;
            this.lblCharacteristicUuid.Location = new System.Drawing.Point(6, 35);
            this.lblCharacteristicUuid.Name = "lblCharacteristicUuid";
            this.lblCharacteristicUuid.Size = new System.Drawing.Size(104, 13);
            this.lblCharacteristicUuid.TabIndex = 2;
            this.lblCharacteristicUuid.Text = "Characteristic UUID:";
            // 
            // tbCharacteristicUuid
            // 
            this.tbCharacteristicUuid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbCharacteristicUuid.Location = new System.Drawing.Point(116, 32);
            this.tbCharacteristicUuid.Name = "tbCharacteristicUuid";
            this.tbCharacteristicUuid.ReadOnly = true;
            this.tbCharacteristicUuid.Size = new System.Drawing.Size(302, 20);
            this.tbCharacteristicUuid.TabIndex = 3;
            // 
            // tbCharacteristicName
            // 
            this.tbCharacteristicName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbCharacteristicName.Location = new System.Drawing.Point(117, 6);
            this.tbCharacteristicName.Name = "tbCharacteristicName";
            this.tbCharacteristicName.ReadOnly = true;
            this.tbCharacteristicName.Size = new System.Drawing.Size(529, 20);
            this.tbCharacteristicName.TabIndex = 1;
            // 
            // lblCharacteristicName
            // 
            this.lblCharacteristicName.AutoSize = true;
            this.lblCharacteristicName.Location = new System.Drawing.Point(6, 9);
            this.lblCharacteristicName.Name = "lblCharacteristicName";
            this.lblCharacteristicName.Size = new System.Drawing.Size(105, 13);
            this.lblCharacteristicName.TabIndex = 0;
            this.lblCharacteristicName.Text = "Characteristic Name:";
            // 
            // tabGattDescriptor
            // 
            this.tabGattDescriptor.Controls.Add(this.gbDescriptorValue);
            this.tabGattDescriptor.Controls.Add(this.tbDescriptorId);
            this.tabGattDescriptor.Controls.Add(this.lblDescriptorId);
            this.tabGattDescriptor.Controls.Add(this.lblDescriptorUuid);
            this.tabGattDescriptor.Controls.Add(this.tbDescriptorUuid);
            this.tabGattDescriptor.Controls.Add(this.tbDescriptorName);
            this.tabGattDescriptor.Controls.Add(this.lblDescriptorName);
            this.tabGattDescriptor.Location = new System.Drawing.Point(4, 22);
            this.tabGattDescriptor.Name = "tabGattDescriptor";
            this.tabGattDescriptor.Padding = new System.Windows.Forms.Padding(3);
            this.tabGattDescriptor.Size = new System.Drawing.Size(652, 422);
            this.tabGattDescriptor.TabIndex = 3;
            this.tabGattDescriptor.Text = "[Descriptor Controls]";
            this.tabGattDescriptor.UseVisualStyleBackColor = true;
            // 
            // gbDescriptorValue
            // 
            this.gbDescriptorValue.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gbDescriptorValue.Controls.Add(this.btnDescWriteValue);
            this.gbDescriptorValue.Controls.Add(this.btnDescReadValue);
            this.gbDescriptorValue.Controls.Add(this.tbDescriptorValue);
            this.gbDescriptorValue.Controls.Add(this.gbDescDisplayValueAs);
            this.gbDescriptorValue.Controls.Add(this.lblDescriptorValue);
            this.gbDescriptorValue.Location = new System.Drawing.Point(6, 58);
            this.gbDescriptorValue.Name = "gbDescriptorValue";
            this.gbDescriptorValue.Size = new System.Drawing.Size(640, 358);
            this.gbDescriptorValue.TabIndex = 6;
            this.gbDescriptorValue.TabStop = false;
            this.gbDescriptorValue.Text = "Descriptor Value";
            // 
            // btnDescWriteValue
            // 
            this.btnDescWriteValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.btnDescWriteValue.Location = new System.Drawing.Point(122, 329);
            this.btnDescWriteValue.Name = "btnDescWriteValue";
            this.btnDescWriteValue.Size = new System.Drawing.Size(110, 23);
            this.btnDescWriteValue.TabIndex = 4;
            this.btnDescWriteValue.Text = "&Write Value";
            this.btnDescWriteValue.UseVisualStyleBackColor = true;
            this.btnDescWriteValue.Click += new System.EventHandler(this.btnDescWriteValue_Click);
            // 
            // btnDescReadValue
            // 
            this.btnDescReadValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.btnDescReadValue.Location = new System.Drawing.Point(6, 329);
            this.btnDescReadValue.Name = "btnDescReadValue";
            this.btnDescReadValue.Size = new System.Drawing.Size(110, 23);
            this.btnDescReadValue.TabIndex = 3;
            this.btnDescReadValue.Text = "&Read Value";
            this.btnDescReadValue.UseVisualStyleBackColor = true;
            this.btnDescReadValue.Click += new System.EventHandler(this.btnDescReadValue_Click);
            // 
            // tbDescriptorValue
            // 
            this.tbDescriptorValue.AcceptsReturn = true;
            this.tbDescriptorValue.AcceptsTab = true;
            this.tbDescriptorValue.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbDescriptorValue.Location = new System.Drawing.Point(6, 87);
            this.tbDescriptorValue.Multiline = true;
            this.tbDescriptorValue.Name = "tbDescriptorValue";
            this.tbDescriptorValue.Size = new System.Drawing.Size(628, 236);
            this.tbDescriptorValue.TabIndex = 2;
            // 
            // gbDescDisplayValueAs
            // 
            this.gbDescDisplayValueAs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.gbDescDisplayValueAs.Controls.Add(this.rbDescCustom);
            this.gbDescDisplayValueAs.Controls.Add(this.btnCustomizeDescFormat);
            this.gbDescDisplayValueAs.Controls.Add(this.rbDescUTF16);
            this.gbDescDisplayValueAs.Controls.Add(this.rbDescUTF8);
            this.gbDescDisplayValueAs.Controls.Add(this.cboDescNumberType);
            this.gbDescDisplayValueAs.Controls.Add(this.rbDescNumber);
            this.gbDescDisplayValueAs.Controls.Add(this.rbDescBoolean);
            this.gbDescDisplayValueAs.Controls.Add(this.rbDescHexBytes);
            this.gbDescDisplayValueAs.Location = new System.Drawing.Point(6, 33);
            this.gbDescDisplayValueAs.Name = "gbDescDisplayValueAs";
            this.gbDescDisplayValueAs.Size = new System.Drawing.Size(628, 48);
            this.gbDescDisplayValueAs.TabIndex = 1;
            this.gbDescDisplayValueAs.TabStop = false;
            this.gbDescDisplayValueAs.Text = "Display Value As...";
            // 
            // rbDescCustom
            // 
            this.rbDescCustom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.rbDescCustom.AutoSize = true;
            this.rbDescCustom.Location = new System.Drawing.Point(446, 19);
            this.rbDescCustom.Name = "rbDescCustom";
            this.rbDescCustom.Size = new System.Drawing.Size(95, 17);
            this.rbDescCustom.TabIndex = 6;
            this.rbDescCustom.Text = "Custom &Format";
            this.rbDescCustom.UseVisualStyleBackColor = true;
            this.rbDescCustom.CheckedChanged += new System.EventHandler(this.rbDescDisplayType_CheckedChanged);
            // 
            // btnCustomizeDescFormat
            // 
            this.btnCustomizeDescFormat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnCustomizeDescFormat.Location = new System.Drawing.Point(547, 16);
            this.btnCustomizeDescFormat.Name = "btnCustomizeDescFormat";
            this.btnCustomizeDescFormat.Size = new System.Drawing.Size(75, 23);
            this.btnCustomizeDescFormat.TabIndex = 7;
            this.btnCustomizeDescFormat.Text = "&Customize...";
            this.btnCustomizeDescFormat.UseVisualStyleBackColor = true;
            this.btnCustomizeDescFormat.Click += new System.EventHandler(this.btnCustomizeDescFormat_Click);
            // 
            // rbDescUTF16
            // 
            this.rbDescUTF16.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.rbDescUTF16.AutoSize = true;
            this.rbDescUTF16.Location = new System.Drawing.Point(379, 19);
            this.rbDescUTF16.Name = "rbDescUTF16";
            this.rbDescUTF16.Size = new System.Drawing.Size(61, 17);
            this.rbDescUTF16.TabIndex = 5;
            this.rbDescUTF16.Text = "UTF-1&6";
            this.rbDescUTF16.UseVisualStyleBackColor = true;
            this.rbDescUTF16.CheckedChanged += new System.EventHandler(this.rbDescDisplayType_CheckedChanged);
            // 
            // rbDescUTF8
            // 
            this.rbDescUTF8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.rbDescUTF8.AutoSize = true;
            this.rbDescUTF8.Location = new System.Drawing.Point(318, 19);
            this.rbDescUTF8.Name = "rbDescUTF8";
            this.rbDescUTF8.Size = new System.Drawing.Size(55, 17);
            this.rbDescUTF8.TabIndex = 4;
            this.rbDescUTF8.Text = "UTF-&8";
            this.rbDescUTF8.UseVisualStyleBackColor = true;
            this.rbDescUTF8.CheckedChanged += new System.EventHandler(this.rbDescDisplayType_CheckedChanged);
            // 
            // cboDescNumberType
            // 
            this.cboDescNumberType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.cboDescNumberType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cboDescNumberType.FormattingEnabled = true;
            this.cboDescNumberType.Items.AddRange(new object[] {
            "UInt8",
            "UInt16",
            "UInt32",
            "UInt64",
            "SInt8",
            "SInt16",
            "SInt32",
            "SInt64",
            "Float32",
            "Float64"});
            this.cboDescNumberType.Location = new System.Drawing.Point(222, 17);
            this.cboDescNumberType.Name = "cboDescNumberType";
            this.cboDescNumberType.Size = new System.Drawing.Size(90, 21);
            this.cboDescNumberType.TabIndex = 3;
            this.cboDescNumberType.SelectionChangeCommitted += new System.EventHandler(this.cboDescNumberType_SelectionChangeCommitted);
            // 
            // rbDescNumber
            // 
            this.rbDescNumber.AutoSize = true;
            this.rbDescNumber.Location = new System.Drawing.Point(155, 19);
            this.rbDescNumber.Name = "rbDescNumber";
            this.rbDescNumber.Size = new System.Drawing.Size(65, 17);
            this.rbDescNumber.TabIndex = 2;
            this.rbDescNumber.Text = "&Number:";
            this.rbDescNumber.UseVisualStyleBackColor = true;
            this.rbDescNumber.CheckedChanged += new System.EventHandler(this.rbDescDisplayType_CheckedChanged);
            // 
            // rbDescBoolean
            // 
            this.rbDescBoolean.AutoSize = true;
            this.rbDescBoolean.Location = new System.Drawing.Point(85, 19);
            this.rbDescBoolean.Name = "rbDescBoolean";
            this.rbDescBoolean.Size = new System.Drawing.Size(64, 17);
            this.rbDescBoolean.TabIndex = 1;
            this.rbDescBoolean.Text = "&Boolean";
            this.rbDescBoolean.UseVisualStyleBackColor = true;
            this.rbDescBoolean.CheckedChanged += new System.EventHandler(this.rbDescDisplayType_CheckedChanged);
            // 
            // rbDescHexBytes
            // 
            this.rbDescHexBytes.AutoSize = true;
            this.rbDescHexBytes.Checked = true;
            this.rbDescHexBytes.Location = new System.Drawing.Point(6, 19);
            this.rbDescHexBytes.Name = "rbDescHexBytes";
            this.rbDescHexBytes.Size = new System.Drawing.Size(73, 17);
            this.rbDescHexBytes.TabIndex = 0;
            this.rbDescHexBytes.TabStop = true;
            this.rbDescHexBytes.Tag = "";
            this.rbDescHexBytes.Text = "&Hex Bytes";
            this.rbDescHexBytes.UseVisualStyleBackColor = true;
            this.rbDescHexBytes.CheckedChanged += new System.EventHandler(this.rbDescDisplayType_CheckedChanged);
            // 
            // lblDescriptorValue
            // 
            this.lblDescriptorValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lblDescriptorValue.ForeColor = System.Drawing.SystemColors.Highlight;
            this.lblDescriptorValue.Location = new System.Drawing.Point(6, 16);
            this.lblDescriptorValue.Name = "lblDescriptorValue";
            this.lblDescriptorValue.Size = new System.Drawing.Size(628, 14);
            this.lblDescriptorValue.TabIndex = 0;
            this.lblDescriptorValue.Text = "These controls allow you to read and display a descriptor\'s value in a variety of" +
    " ways. You can also write the value.";
            // 
            // tbDescriptorId
            // 
            this.tbDescriptorId.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.tbDescriptorId.Location = new System.Drawing.Point(523, 32);
            this.tbDescriptorId.Name = "tbDescriptorId";
            this.tbDescriptorId.ReadOnly = true;
            this.tbDescriptorId.Size = new System.Drawing.Size(123, 20);
            this.tbDescriptorId.TabIndex = 5;
            // 
            // lblDescriptorId
            // 
            this.lblDescriptorId.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblDescriptorId.AutoSize = true;
            this.lblDescriptorId.Location = new System.Drawing.Point(445, 35);
            this.lblDescriptorId.Name = "lblDescriptorId";
            this.lblDescriptorId.Size = new System.Drawing.Size(72, 13);
            this.lblDescriptorId.TabIndex = 4;
            this.lblDescriptorId.Text = "Descriptor ID:";
            // 
            // lblDescriptorUuid
            // 
            this.lblDescriptorUuid.AutoSize = true;
            this.lblDescriptorUuid.Location = new System.Drawing.Point(6, 35);
            this.lblDescriptorUuid.Name = "lblDescriptorUuid";
            this.lblDescriptorUuid.Size = new System.Drawing.Size(88, 13);
            this.lblDescriptorUuid.TabIndex = 2;
            this.lblDescriptorUuid.Text = "Descriptor UUID:";
            // 
            // tbDescriptorUuid
            // 
            this.tbDescriptorUuid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbDescriptorUuid.Location = new System.Drawing.Point(100, 32);
            this.tbDescriptorUuid.Name = "tbDescriptorUuid";
            this.tbDescriptorUuid.ReadOnly = true;
            this.tbDescriptorUuid.Size = new System.Drawing.Size(339, 20);
            this.tbDescriptorUuid.TabIndex = 3;
            // 
            // tbDescriptorName
            // 
            this.tbDescriptorName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbDescriptorName.Location = new System.Drawing.Point(101, 6);
            this.tbDescriptorName.Name = "tbDescriptorName";
            this.tbDescriptorName.ReadOnly = true;
            this.tbDescriptorName.Size = new System.Drawing.Size(545, 20);
            this.tbDescriptorName.TabIndex = 1;
            // 
            // lblDescriptorName
            // 
            this.lblDescriptorName.AutoSize = true;
            this.lblDescriptorName.Location = new System.Drawing.Point(6, 9);
            this.lblDescriptorName.Name = "lblDescriptorName";
            this.lblDescriptorName.Size = new System.Drawing.Size(89, 13);
            this.lblDescriptorName.TabIndex = 0;
            this.lblDescriptorName.Text = "Descriptor Name:";
            // 
            // lblBrowseOverlay
            // 
            this.lblBrowseOverlay.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lblBrowseOverlay.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblBrowseOverlay.Location = new System.Drawing.Point(0, 0);
            this.lblBrowseOverlay.Name = "lblBrowseOverlay";
            this.lblBrowseOverlay.Size = new System.Drawing.Size(150, 46);
            this.lblBrowseOverlay.TabIndex = 0;
            this.lblBrowseOverlay.Text = "You must connect to a device before you can browse its data";
            this.lblBrowseOverlay.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // tabSubscribed
            // 
            this.tabSubscribed.Controls.Add(this.splitSubscribed);
            this.tabSubscribed.Location = new System.Drawing.Point(4, 22);
            this.tabSubscribed.Name = "tabSubscribed";
            this.tabSubscribed.Size = new System.Drawing.Size(1002, 454);
            this.tabSubscribed.TabIndex = 3;
            this.tabSubscribed.Text = "Subscribed Characteristics";
            this.tabSubscribed.ToolTipText = "The \"Subscribed Characteristics\" tab shows real-time updates of the values of all" +
    " characteristics subscribed to in the \"Browse Data\" tab.";
            this.tabSubscribed.UseVisualStyleBackColor = true;
            // 
            // splitSubscribed
            // 
            this.splitSubscribed.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitSubscribed.IsSplitterFixed = true;
            this.splitSubscribed.Location = new System.Drawing.Point(0, 0);
            this.splitSubscribed.Name = "splitSubscribed";
            this.splitSubscribed.Orientation = System.Windows.Forms.Orientation.Horizontal;
            // 
            // splitSubscribed.Panel1
            // 
            this.splitSubscribed.Panel1.AutoScroll = true;
            this.splitSubscribed.Panel1.Controls.Add(this.flowSubscribedCharacteristics);
            this.splitSubscribed.Panel1Collapsed = true;
            // 
            // splitSubscribed.Panel2
            // 
            this.splitSubscribed.Panel2.Controls.Add(this.lblSubscribedOverlay);
            this.splitSubscribed.Size = new System.Drawing.Size(1002, 454);
            this.splitSubscribed.SplitterDistance = 334;
            this.splitSubscribed.TabIndex = 0;
            this.splitSubscribed.TabStop = false;
            // 
            // flowSubscribedCharacteristics
            // 
            this.flowSubscribedCharacteristics.AutoSize = true;
            this.flowSubscribedCharacteristics.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            this.flowSubscribedCharacteristics.Dock = System.Windows.Forms.DockStyle.Top;
            this.flowSubscribedCharacteristics.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
            this.flowSubscribedCharacteristics.Location = new System.Drawing.Point(0, 0);
            this.flowSubscribedCharacteristics.Name = "flowSubscribedCharacteristics";
            this.flowSubscribedCharacteristics.Size = new System.Drawing.Size(150, 0);
            this.flowSubscribedCharacteristics.TabIndex = 0;
            this.flowSubscribedCharacteristics.WrapContents = false;
            this.flowSubscribedCharacteristics.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.flowSubscribedCharacteristics_ControlsChanged);
            this.flowSubscribedCharacteristics.ControlRemoved += new System.Windows.Forms.ControlEventHandler(this.flowSubscribedCharacteristics_ControlsChanged);
            // 
            // lblSubscribedOverlay
            // 
            this.lblSubscribedOverlay.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lblSubscribedOverlay.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblSubscribedOverlay.Location = new System.Drawing.Point(0, 0);
            this.lblSubscribedOverlay.Name = "lblSubscribedOverlay";
            this.lblSubscribedOverlay.Size = new System.Drawing.Size(1002, 454);
            this.lblSubscribedOverlay.TabIndex = 0;
            this.lblSubscribedOverlay.Text = "Any characteristics you subscribe to in the \"Browse Data\" tab\r\nwill show up here," +
    " and their values will update in real time\r\n";
            this.lblSubscribedOverlay.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // tabLog
            // 
            this.tabLog.Controls.Add(this.btnPrintGattObjTree);
            this.tabLog.Controls.Add(this.tbLog);
            this.tabLog.Controls.Add(this.btnClearLog);
            this.tabLog.Controls.Add(this.cbLogAdvertisements);
            this.tabLog.Controls.Add(this.cbbLogLevel);
            this.tabLog.Controls.Add(this.lblLogLevel);
            this.tabLog.Location = new System.Drawing.Point(4, 22);
            this.tabLog.Name = "tabLog";
            this.tabLog.Size = new System.Drawing.Size(1002, 454);
            this.tabLog.TabIndex = 2;
            this.tabLog.Text = "Log";
            this.tabLog.ToolTipText = "The \"Log\" tab keeps a running log of all component operations.";
            this.tabLog.UseVisualStyleBackColor = true;
            // 
            // btnPrintGattObjTree
            // 
            this.btnPrintGattObjTree.Location = new System.Drawing.Point(756, 3);
            this.btnPrintGattObjTree.Name = "btnPrintGattObjTree";
            this.btnPrintGattObjTree.Size = new System.Drawing.Size(162, 23);
            this.btnPrintGattObjTree.TabIndex = 3;
            this.btnPrintGattObjTree.Text = "&Print GATT Object Tree Info";
            this.btnPrintGattObjTree.UseVisualStyleBackColor = true;
            this.btnPrintGattObjTree.Click += new System.EventHandler(this.btnPrintGattObjTree_Click);
            // 
            // tbLog
            // 
            this.tbLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tbLog.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.tbLog.Location = new System.Drawing.Point(0, 32);
            this.tbLog.MaxLength = 0;
            this.tbLog.Multiline = true;
            this.tbLog.Name = "tbLog";
            this.tbLog.ReadOnly = true;
            this.tbLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            this.tbLog.Size = new System.Drawing.Size(1002, 422);
            this.tbLog.TabIndex = 4;
            this.tbLog.VisibleChanged += new System.EventHandler(this.tbLog_VisibleChanged);
            // 
            // btnClearLog
            // 
            this.btnClearLog.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnClearLog.AutoSize = true;
            this.btnClearLog.Location = new System.Drawing.Point(924, 3);
            this.btnClearLog.Name = "btnClearLog";
            this.btnClearLog.Size = new System.Drawing.Size(75, 23);
            this.btnClearLog.TabIndex = 5;
            this.btnClearLog.Text = "&Clear Log";
            this.btnClearLog.UseVisualStyleBackColor = true;
            this.btnClearLog.Click += new System.EventHandler(this.btnClearLog_Click);
            // 
            // cbLogAdvertisements
            // 
            this.cbLogAdvertisements.AutoSize = true;
            this.cbLogAdvertisements.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.cbLogAdvertisements.Location = new System.Drawing.Point(192, 5);
            this.cbLogAdvertisements.Name = "cbLogAdvertisements";
            this.cbLogAdvertisements.Size = new System.Drawing.Size(122, 17);
            this.cbLogAdvertisements.TabIndex = 2;
            this.cbLogAdvertisements.Text = "Log &Advertisements:";
            this.cbLogAdvertisements.UseVisualStyleBackColor = true;
            // 
            // cbbLogLevel
            // 
            this.cbbLogLevel.FormattingEnabled = true;
            this.cbbLogLevel.Items.AddRange(new object[] {
            "None",
            "Info",
            "Verbose",
            "Debug"});
            this.cbbLogLevel.Location = new System.Drawing.Point(65, 3);
            this.cbbLogLevel.Name = "cbbLogLevel";
            this.cbbLogLevel.Size = new System.Drawing.Size(121, 21);
            this.cbbLogLevel.TabIndex = 1;
            this.cbbLogLevel.Text = "Debug";
            this.cbbLogLevel.SelectedIndexChanged += new System.EventHandler(this.cbbLogLevel_SelectedIndexChanged);
            // 
            // lblLogLevel
            // 
            this.lblLogLevel.AutoSize = true;
            this.lblLogLevel.Location = new System.Drawing.Point(2, 6);
            this.lblLogLevel.Name = "lblLogLevel";
            this.lblLogLevel.Size = new System.Drawing.Size(57, 13);
            this.lblLogLevel.TabIndex = 0;
            this.lblLogLevel.Text = "Log &Level:";
            // 
            // bleclient1
            // 
            this.bleclient1.About = "IP*Works! BLE 2016 [Build 6800]";
            this.bleclient1.InvokeThrough = this;
            this.bleclient1.OnAdvertisement += new nsoftware.IPWorksBLE.Bleclient.OnAdvertisementHandler(this.bleclient1_OnAdvertisement);
            this.bleclient1.OnConnected += new nsoftware.IPWorksBLE.Bleclient.OnConnectedHandler(this.bleclient1_OnConnected);
            this.bleclient1.OnDisconnected += new nsoftware.IPWorksBLE.Bleclient.OnDisconnectedHandler(this.bleclient1_OnDisconnected);
            this.bleclient1.OnDiscovered += new nsoftware.IPWorksBLE.Bleclient.OnDiscoveredHandler(this.bleclient1_OnDiscovered);
            this.bleclient1.OnError += new nsoftware.IPWorksBLE.Bleclient.OnErrorHandler(this.bleclient1_OnError);
            this.bleclient1.OnLog += new nsoftware.IPWorksBLE.Bleclient.OnLogHandler(this.bleclient1_OnLog);
            this.bleclient1.OnServerUpdate += new nsoftware.IPWorksBLE.Bleclient.OnServerUpdateHandler(this.bleclient1_OnServerUpdate);
            this.bleclient1.OnStartScan += new nsoftware.IPWorksBLE.Bleclient.OnStartScanHandler(this.bleclient1_OnStartScan);
            this.bleclient1.OnStopScan += new nsoftware.IPWorksBLE.Bleclient.OnStopScanHandler(this.bleclient1_OnStopScan);
            this.bleclient1.OnSubscribed += new nsoftware.IPWorksBLE.Bleclient.OnSubscribedHandler(this.bleclient1_OnSubscribed);
            this.bleclient1.OnUnsubscribed += new nsoftware.IPWorksBLE.Bleclient.OnUnsubscribedHandler(this.bleclient1_OnUnsubscribed);
            this.bleclient1.OnValue += new nsoftware.IPWorksBLE.Bleclient.OnValueHandler(this.bleclient1_OnValue);
            this.bleclient1.OnWriteResponse += new nsoftware.IPWorksBLE.Bleclient.OnWriteResponseHandler(this.bleclient1_OnWriteResponse);
            // 
            // contextMenuStrip1
            // 
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripMenuItemCopyValue});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
            this.contextMenuStrip1.ShowImageMargin = false;
            this.contextMenuStrip1.Size = new System.Drawing.Size(109, 26);
            // 
            // toolStripMenuItemCopyValue
            // 
            this.toolStripMenuItemCopyValue.Name = "toolStripMenuItemCopyValue";
            this.toolStripMenuItemCopyValue.Size = new System.Drawing.Size(108, 22);
            this.toolStripMenuItemCopyValue.Text = "&Copy Value";
            this.toolStripMenuItemCopyValue.Click += new System.EventHandler(this.toolStripMenuItemCopyValue_Click);
            // 
            // bleclientDemo
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(1034, 536);
            this.Controls.Add(this.tabCtrlMain);
            this.Controls.Add(this.lblInstructions);
            this.MinimumSize = new System.Drawing.Size(1050, 575);
            this.Name = "bleclientDemo";
            this.Text = "BLEClient Demo";
            this.tabCtrlMain.ResumeLayout(false);
            this.tabScanConnect.ResumeLayout(false);
            this.gbConnectCtrls.ResumeLayout(false);
            this.gbConnectCtrls.PerformLayout();
            this.gbScanCtrls.ResumeLayout(false);
            this.gbScanCtrls.PerformLayout();
            this.tabBrowse.ResumeLayout(false);
            this.splitBrowse.Panel1.ResumeLayout(false);
            this.splitBrowse.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitBrowse)).EndInit();
            this.splitBrowse.ResumeLayout(false);
            this.splitData.Panel1.ResumeLayout(false);
            this.splitData.Panel1.PerformLayout();
            this.splitData.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitData)).EndInit();
            this.splitData.ResumeLayout(false);
            this.tabCtrlGattData.ResumeLayout(false);
            this.tabGattServer.ResumeLayout(false);
            this.tabGattServer.PerformLayout();
            this.gbSrvDiscoverEverything.ResumeLayout(false);
            this.gbSrvDiscoverEverything.PerformLayout();
            this.gbSrvDiscovery.ResumeLayout(false);
            this.gbSrvDiscovery.PerformLayout();
            this.tabGattService.ResumeLayout(false);
            this.tabGattService.PerformLayout();
            this.tabCtrlSvcDiscovery.ResumeLayout(false);
            this.tabSvcDiscoverCharacteristics.ResumeLayout(false);
            this.tabSvcDiscoverCharacteristics.PerformLayout();
            this.tabSvcDiscoverInclServices.ResumeLayout(false);
            this.tabSvcDiscoverInclServices.PerformLayout();
            this.tabGattCharacteristic.ResumeLayout(false);
            this.tabGattCharacteristic.PerformLayout();
            this.gbCharacteristicValue.ResumeLayout(false);
            this.gbCharacteristicValue.PerformLayout();
            this.gbCharaDisplayValueAs.ResumeLayout(false);
            this.gbCharaDisplayValueAs.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.numCharacteristicValueFormatIdx)).EndInit();
            this.gbCharaDiscoverDescriptors.ResumeLayout(false);
            this.gbCharaDiscoverDescriptors.PerformLayout();
            this.tabGattDescriptor.ResumeLayout(false);
            this.tabGattDescriptor.PerformLayout();
            this.gbDescriptorValue.ResumeLayout(false);
            this.gbDescriptorValue.PerformLayout();
            this.gbDescDisplayValueAs.ResumeLayout(false);
            this.gbDescDisplayValueAs.PerformLayout();
            this.tabSubscribed.ResumeLayout(false);
            this.splitSubscribed.Panel1.ResumeLayout(false);
            this.splitSubscribed.Panel1.PerformLayout();
            this.splitSubscribed.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitSubscribed)).EndInit();
            this.splitSubscribed.ResumeLayout(false);
            this.tabLog.ResumeLayout(false);
            this.tabLog.PerformLayout();
            this.contextMenuStrip1.ResumeLayout(false);
            this.ResumeLayout(false);
    }
    #endregion
    #region BLEClient Event Handlers
    private void bleclient1_OnAdvertisement(object sender, BleclientAdvertisementEventArgs e) {
      LogAdvertisement(e);
      HandleAdvertisement(e);
    }
    private void bleclient1_OnConnected(object sender, BleclientConnectedEventArgs e) {
      if (e.StatusCode == 0) {
        Log("Successfully connected to server");
        SetUpBrowseTab();
      } else {
        Log(string.Format("Failed to connect to server: [{0}] {1}", e.StatusCode, e.Description));
        MessageBox.Show(string.Format("Error Connecting: [{0}] {1}", e.StatusCode, e.Description));
      }
      tbSelectedServerId.Enabled = true;
      lvwDevices.Enabled = true;
      tbConnectedServerId.Text = !string.IsNullOrEmpty(bleclient1.ServerId) ? bleclient1.ServerId : "[Not Connected]";
      btnDisconnect.Enabled = !string.IsNullOrEmpty(bleclient1.ServerId);
      btnConnect.Enabled = true;
    }
    private void bleclient1_OnDisconnected(object sender, BleclientDisconnectedEventArgs e) {
      Log(string.Format("Disconnected from server: [{0}] {1}", e.StatusCode, e.Description));
      ResetBrowseTab();
      ResetSubscribedCharacteristicsTab();
      btnDisconnect.Enabled = false;
      tbConnectedServerId.Text = "[Not Connected]";
      tbSelectedServerId.Enabled = true;
      btnConnect.Enabled = true;
    }
    private void bleclient1_OnDiscovered(object sender, BleclientDiscoveredEventArgs e) {
      HandleGattObjDiscovered(e);
    }
    private void bleclient1_OnError(object sender, BleclientErrorEventArgs e) {
      LogAndShowMessage(string.Format("Error: [{0}] {1}", e.ErrorCode, e.Description));
    }
    private void bleclient1_OnLog(object sender, BleclientLogEventArgs e) {
      Log(string.Format("Log [{0}]: {1} - {2}", TranslateLogLevel(e.LogLevel), e.LogType, e.Message));
    }
    private void bleclient1_OnServerUpdate(object sender, BleclientServerUpdateEventArgs e) {
      Log("Server Update: Name=" + e.Name);
      UpdateServerName();
    }
    private void bleclient1_OnStartScan(object sender, BleclientStartScanEventArgs e) {
      Log("Start Scan: " + (string.IsNullOrEmpty(e.ServiceUuids) ? "[No Filter]" : e.ServiceUuids));
      btnScan.Text = "&Stop Scanning";
      btnScan.Enabled = true;
    }
    private void bleclient1_OnStopScan(object sender, BleclientStopScanEventArgs e) {
      Log(e.ErrorCode != 0 ? string.Format("StopScan: [{0}] {1}", e.ErrorCode, e.ErrorDescription) : "StopScan fired");
      btnScan.Text = "&Start Scanning";
      SetScanCtrlsEnabled(true);
      btnScan.Enabled = true;
    }
    private void bleclient1_OnSubscribed(object sender, BleclientSubscribedEventArgs e) {
      Log(string.Format("Subscribed to characteristic {0} ({1})", e.Uuid, e.CharacteristicId));
      CreateSubCharaRow(GetCharacteristic(e.ServiceId, e.CharacteristicId));
    }
    private void bleclient1_OnUnsubscribed(object sender, BleclientUnsubscribedEventArgs e) {
      Log(string.Format("Unsubscribed from characteristic {0} ({1})", e.Uuid, e.CharacteristicId));
      RemoveSubCharaRow(e.CharacteristicId);
    }
    private void bleclient1_OnValue(object sender, BleclientValueEventArgs e) {
      
      // We only handle characteristic values here. Descriptors values are handled without events.
      if (string.IsNullOrEmpty(e.DescriptorId)) {
        RefreshDisplayedValueForCharacteristic(e.CharacteristicId, e.Uuid, e.ValueB);
        //  Can we write this to disk here???  Seems to be working, SEpt 25 2018 PRAA
        //string pathString = @"c:\WiiGraphData\DataChannel2";
        // Channel 2 = RED, Channel1 = BLUE
        string pathString = @"c:\WiiGraphData\DataChannel1";
        //byte[] data = new byte[] { 0x41, 0x42, 0x43, 0x44 };
        byte[] data = e.ValueB;
        int index;
        int limit = data.Length;
        Stopwatch stopwatch = new Stopwatch();
                // Begin timing.
        stopwatch.Start();
        Boolean done = false;
                int howMany = 0;
                while (!done)
                {
                    try
                    {
                        using (System.IO.FileStream fs = System.IO.File.Create(pathString))
                        {
                            /*for (index = 0; index < limit; index++)
                            {
                                fs.WriteByte(data[index]);
                                        fs.
                            }*/
                            fs.Write(data, 0, limit);
                            fs.Close();
                            done = true;
                        }
                    }
                    catch (Exception)
                    {
                        // delay 7 milliseconds and try again
                        System.Threading.Thread.Sleep(7);
                        howMany += 1;
                        if (howMany > 10) done = true;
                        //throw;
                        if (howMany == 2) {
                            // PUt in test here to see if the directory is missing - if so, create it.
                            string dataDirectory = @"c:\WiiGraphData";
                            if (!Directory.Exists(dataDirectory))
                                Directory.CreateDirectory(dataDirectory);
                        } 
                    }
                }
                // Stop timing.
        stopwatch.Stop();
        // Write result.
        Console.WriteLine("Time elapsed RED: {0}", stopwatch.Elapsed);
       }
    }
    private void bleclient1_OnWriteResponse(object sender, BleclientWriteResponseEventArgs e) {
      if (string.IsNullOrEmpty(e.DescriptorId)) Log(string.Format("Characteristic Write Response: {0} ({1})", e.Uuid, e.CharacteristicId));
      else Log(string.Format("Descriptor Write Response: {0} ({1})", e.Uuid, e.DescriptorId));
    }
    #endregion
    #region Scan and Connect Tab
    private void SetScanCtrlsEnabled(bool enabled) {
      cbActiveScanning.Enabled = btnChooseScanUuids.Enabled = lbScanFilter.Enabled = enabled;
    }
    private void btnChooseScanUuids_Click(object sender, EventArgs e) {
      OpenUuidPickerForListbox(TYPE_SERVICE, lbScanFilter);
    }
    private void btnScan_Click(object sender, EventArgs e) {
      btnScan.Enabled = false;
      SetScanCtrlsEnabled(false);
      if (btnScan.Text == "&Start Scanning" && !bleclient1.Scanning) {
        lvwDevices.Items.Clear();
        try {
          bleclient1.ActiveScanning = cbActiveScanning.Checked;
          bleclient1.StartScanning(GetUuidListStrFromListbox(lbScanFilter));
        } catch (IPWorksBLEException ex) {
          HandleEx(ex);
          SetScanCtrlsEnabled(true);
          btnScan.Enabled = true;
        }
      } else if (btnScan.Text == "&Stop Scanning" && bleclient1.Scanning)
        bleclient1.StopScanning();
      // StartScan and StopScan events take care of the rest.
    }
    private void HandleAdvertisement(BleclientAdvertisementEventArgs e) {
      ListViewItem advertItem = lvwDevices.Items[e.ServerId];
      if (advertItem == null) {
                // Need to make a new item.
        advertItem = new ListViewItem(new string[] { e.ServerId, e.Name, e.RSSI.ToString(), e.TxPower == int.MinValue ? "" : e.TxPower.ToString(),
          e.IsConnectable.ToString(), GattUuidUtils.GetNiceNames(e.ServiceUuids), GattUuidUtils.GetNiceNames(e.ServicesWithData),
          e.ManufacturerCompanyId.ToString(), BitConverter.ToString(e.ManufacturerDataB), GattUuidUtils.GetNiceNames(e.SolicitedServiceUuids) });
        advertItem.Name = e.ServerId;
                if (advertItem.SubItems[5].Text.Equals("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"))
                {
                    Console.WriteLine("they are equal");
                    advertItem.SubItems[1].Text = " goal !! ";
                }
                //ifadvertItem.Name = "just because";
                lvwDevices.Items.Add(advertItem);
      } else {
        // Need to update an existing item.
        // Don't overwrite our name with empty.
        string temp = advertItem.SubItems[1].Text;
        if (string.IsNullOrEmpty(temp) || (!string.IsNullOrEmpty(e.Name) && !temp.Equals(e.Name))) advertItem.SubItems[1].Text = e.Name;
                //advertItem.SubItems[1].Text = "why isn't this here?";   // testing MArch 2019 PRAA
                //advertItem.SubItems[1].Text = "testing 1 2 3 ";
                advertItem.SubItems[2].Text = e.RSSI.ToString();
        advertItem.SubItems[3].Text = e.TxPower == int.MinValue ? "" : e.TxPower.ToString();
        // We want to keep our "IsConnectable" column true if we ever got a "true"...that way scan response can't make it false again.
        temp = advertItem.SubItems[4].Text;
        advertItem.SubItems[4].Text = !string.IsNullOrEmpty(temp) ? (bool.Parse(temp) || e.IsConnectable).ToString() : e.IsConnectable.ToString();
        // Don't overwrite our serviceUuids with empty.
        temp = advertItem.SubItems[5].Text;
        if (string.IsNullOrEmpty(temp)) advertItem.SubItems[5].Text = GattUuidUtils.GetNiceNames(e.ServiceUuids);
        else advertItem.SubItems[5].Text = !string.IsNullOrEmpty(e.ServiceUuids) ? GattUuidUtils.GetNiceNames(e.ServiceUuids) : temp;
                /* TEsting, PRAA MArch 2019 */
                int test = advertItem.SubItems[1].Text.IndexOf("luefruit52Oct12");
                if (test==1)
                {
                    test = advertItem.SubItems[1].Text.Length;
                    char RedOrBlue = advertItem.SubItems[1].Text[test - 1];
                    Console.WriteLine("the letter is {0}", RedOrBlue);
                    if ((RedOrBlue == '1') || (RedOrBlue == '3') || (RedOrBlue == '5') || (RedOrBlue == '7') || (RedOrBlue == '9'))
                    {
                        Console.WriteLine("It seems odd");
                        advertItem.SubItems[6].Text = "WeTooMove - Blue";
                    }
                    else
                    {
                        Console.WriteLine("It's not odd, it's even");
                        advertItem.SubItems[6].Text = "WeTooMove - Red";
                    }
                }
                /*if (advertItem.SubItems[5].Text.Equals("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"))
                        {
                            Console.WriteLine("they are equal, trying to Connect");
                            advertItem.SubItems[1].Text = " goal  ";
                            try
                            {
                                bleclient1.Connect(advertItem.SubItems[0].Text);
                                Console.WriteLine(" enter something . . . .  I'll wait for you");
                                string hemp = Console.ReadLine();
                                Console.WriteLine(hemp);
                                hemp = bleclient1.ServerName;
                                Console.WriteLine(hemp);
                            }
                           catch (IPWorksBLEException ex)
                            {
                                HandleEx(ex);
                                Console.WriteLine("an error occurred");
                            }
                            bleclient1.Disconnect();
                        }
                */
                // Don't overwrite our servicesWithData with empty.
                temp = advertItem.SubItems[6].Text;
        if (string.IsNullOrEmpty(temp)) advertItem.SubItems[6].Text = GattUuidUtils.GetNiceNames(e.ServicesWithData);
        else advertItem.SubItems[6].Text = !string.IsNullOrEmpty(e.ServicesWithData) ? GattUuidUtils.GetNiceNames(e.ServicesWithData) : temp;
        // Don't overwrite our manufacturer data details.
        temp = advertItem.SubItems[7].Text;
        if (string.IsNullOrEmpty(temp) || e.ManufacturerCompanyId != -1) {
          advertItem.SubItems[7].Text = e.ManufacturerCompanyId.ToString();
          advertItem.SubItems[8].Text = BitConverter.ToString(e.ManufacturerDataB);
        }
        // Don't overwrite our solicitiedServiceUuids with empty.
        temp = advertItem.SubItems[9].Text;
        if (string.IsNullOrEmpty(temp)) advertItem.SubItems[9].Text = GattUuidUtils.GetNiceNames(e.SolicitedServiceUuids);
        else advertItem.SubItems[9].Text = !string.IsNullOrEmpty(e.SolicitedServiceUuids) ? GattUuidUtils.GetNiceNames(e.SolicitedServiceUuids) : temp;
      }
    }
    private void btnConnect_Click(object sender, EventArgs e) {
      if (string.IsNullOrWhiteSpace(tbSelectedServerId.Text) || tbSelectedServerId.Text.Trim().Equals(bleclient1.ServerId, StringComparison.OrdinalIgnoreCase))
        return;
      btnConnect.Enabled = false;
      btnDisconnect.Enabled = false;
      lvwDevices.Enabled = false;
      tbSelectedServerId.Enabled = false;
      try {
        bleclient1.Connect(tbSelectedServerId.Text);
      } catch (IPWorksBLEException ex) {
        HandleEx(ex);
        tbSelectedServerId.Enabled = true;
        lvwDevices.Enabled = true;
        btnDisconnect.Enabled = !string.IsNullOrEmpty(bleclient1.ServerId);
        btnConnect.Enabled = true;
      }
      // Connected event (and possibly Disconnected and StopScan events too) will take care of the rest.
    }
    private void btnDisconnect_Click(object sender, EventArgs e) {
      btnDisconnect.Enabled = false;
      if (string.IsNullOrEmpty(bleclient1.ServerId)) {
        // Already disconnected!
        tbConnectedServerId.Text = "[Not Connected]";
        return;
      }
      btnConnect.Enabled = false;
      tbSelectedServerId.Enabled = false;
      bleclient1.Disconnect();
      // Disconnected event will take care of the rest.
    }
    private void lvwDevices_SelectedIndexChanged(object sender, EventArgs e) {
      if (lvwDevices.SelectedItems.Count == 0) return;
      tbSelectedServerId.Text = lvwDevices.SelectedItems[0].Name;
    }
    private void lvwDevices_MouseUp(object sender, MouseEventArgs e) {
      if (e.Button == MouseButtons.Right) {
        ListViewHitTestInfo htInfo = lvwDevices.HitTest(e.Location);
        if (htInfo.Item != null && htInfo.SubItem != null) {
          toolStripMenuItemCopyValue.Tag = htInfo.SubItem.Text;
          contextMenuStrip1.Show(lvwDevices, e.Location);
        }
      }
    }
    private void toolStripMenuItemCopyValue_Click(object sender, EventArgs e) {
      if (toolStripMenuItemCopyValue.Tag != null)
        Clipboard.SetText((string) toolStripMenuItemCopyValue.Tag);
    }
    #endregion
    #region Browse Data Tab 
    private void SetUpBrowseTab() {
      UpdateServerName();
      if (treeGattObjects.SelectedNode == GetServerNode()) {
        // Workaround for AfterSelect not firing when already-selected node is selected.
        UpdateServerDataTab();
        tabCtrlGattData.SelectedIndex = TYPE_SERVER;
      } else treeGattObjects.SelectedNode = GetServerNode();
      splitBrowse.Panel1Collapsed = false;
      splitBrowse.Panel2Collapsed = true;
            // try to automate - March 27 PRAA
            object sender = null;
            EventArgs e = null;
            btnSrvDiscoverEverything_Click(sender, e);
    }
    private void ResetBrowseTab() {
      GetServerNode().Nodes.Clear();
      UpdateServerName();
      // We need a default number selection for these.
      cboCharaNumberType.SelectedItem = "SInt32";
      cboDescNumberType.SelectedItem = "SInt32";
      splitBrowse.Panel1Collapsed = true;
      splitBrowse.Panel2Collapsed = false;
    }
    #region Discovery and TreeView Handling
    private void HandleGattObjDiscovered(BleclientDiscoveredEventArgs e) {
          int index = 0; // used to find the stuff we want to subscribe to
          // In the case of services, we'll need to check to see if we've discovered that an _already discovered_ service
          TreeNode node = GetNodeById(e.ServiceId, e.CharacteristicId, e.DescriptorId);
          TreeNode parentNode = null;
          if (node == null && !string.IsNullOrEmpty(e.DescriptorId)) {
            // Create a descriptor TreeNode.
            Descriptor d = GetDescriptor(e.ServiceId, e.CharacteristicId, e.DescriptorId);
            if (node == null) {
              // Make sure that we have a display type and custom format ready for this UUID.
              if (!uuidDisplayTypes.ContainsKey(d.Uuid)) uuidDisplayTypes[d.Uuid] = DisplayType.HexBytes;
              if (!uuidCustomFormats.ContainsKey(d.Uuid)) uuidCustomFormats[d.Uuid] = new CustomFormat();
            }
            node = new TreeNode() { Name = e.DescriptorId, Text = GattUuidUtils.GetNiceName(d.Uuid) };
            parentNode = GetNodeById(e.ServiceId, e.CharacteristicId, null);
          } else if (node == null && !string.IsNullOrEmpty(e.CharacteristicId)) {
            // Create a characteristic TreeNode.
            Characteristic c = GetCharacteristic(e.ServiceId, e.CharacteristicId);
            if (node == null) {
              // Make sure that we have a display type and custom format ready for this UUID.
              if (!uuidDisplayTypes.ContainsKey(c.Uuid)) uuidDisplayTypes[c.Uuid] = DisplayType.HexBytes;
              if (!uuidCustomFormats.ContainsKey(c.Uuid)) uuidCustomFormats[c.Uuid] = new CustomFormat();
            }
            node = new TreeNode() { Name = e.CharacteristicId, Text = GattUuidUtils.GetNiceName(c.Uuid) };
            parentNode = GetNodeById(e.ServiceId, null, null);
          } else if (!string.IsNullOrEmpty(e.ServiceId)) {
            if (node == null) {
              // Create a service TreeNode.
              Service s = GetService(e.ServiceId);
              node = new TreeNode() { Name = e.ServiceId, Text = GattUuidUtils.GetNiceName(s.Uuid) };
              parentNode = GetServerNode();
            }
            ColorServiceNode(node);
          }
          if (node != null) {   // test to see if it's one of our units . . . . could also check the color at this point . . . 
                    Console.WriteLine("Node follows this");
                    Console.WriteLine(node);
                    Console.WriteLine("trying to compare");
                    string magic_string = "6E400003-B5A3-F393-E0A9-E50E24DCCA9E";
                    //string magic_string = "6E40000";
                    Console.WriteLine("mAgic   = {0}", magic_string);
                    string buffer = "{0}";
                    buffer = string.Format( buffer, node);
                    Console.WriteLine(buffer);
                    // Note that Buffer contains leading text along the lines of "Tree ID:  . . . . 
                    index = buffer.IndexOf(magic_string, StringComparison.OrdinalIgnoreCase);
                    Console.WriteLine("Using the index function                                  {0}", index);
                    // If it's a match, try to connect . . . . but only after adding the node
          }
          // Add the new node to its parent, and make sure the parent is expanded.
          if (parentNode != null) {
            parentNode.Nodes.Add(node);
            if (!parentNode.IsExpanded) parentNode.Expand();
          }
          // now that it's added, if it is the one we are looking for, try to subscribe to it
          if (index > 1)
          {   //this is the btnToggleSubscribe  . . . 
                SetMainTabsEnabled(false);
                try
                {
                    // TreeNode node = treeGattObjects.SelectedNode;
                    bleclient1.Subscribe(node.Parent.Name, node.Name);
                }
                catch (IPWorksBLEException ex)
                {
                    HandleEx(ex);
                }
                finally
                {
                    SetMainTabsEnabled(true);
                }
          }
    }
    private void treeGattObjects_AfterSelect(object sender, TreeViewEventArgs e) {
      treeGattObjects.Enabled = false;
      
      // Determine what type of TreeNode this is based on its level.
      switch (e.Node.Level) {
        case TYPE_SERVER:
          UpdateServerDataTab();
          break;
        case TYPE_SERVICE:
          UpdateServiceDataTab(e.Node);
          break;
        case TYPE_CHARACTERISTIC:
          UpdateCharacteristicDataTab(e.Node);
          break;
        case TYPE_DESCRIPTOR:
          UpdateDescriptorDataTab(e.Node);
          break;
      }
      // Select the tab containing the appropriate controls.
      tabCtrlGattData.SelectedIndex = e.Node.Level;
      treeGattObjects.Enabled = true;
    }
    private void treeGattObjects_BeforeCollapse(object sender, TreeViewCancelEventArgs e) {
      // Don't allow user to collapse nodes.
      e.Cancel = true;
    }
    private TreeNode GetServerNode() {
      // The server node is always present, and is always the only root node.
      return treeGattObjects.Nodes[0];
    }
    private TreeNode GetNodeById(string serviceId, string characteristicId, string descriptorId) {
      TreeNode node = null;
      // Get service node.
      if (!GetServerNode().Nodes.ContainsKey(serviceId)) return null;
      node = GetServerNode().Nodes[serviceId];
      if (string.IsNullOrEmpty(characteristicId)) return node;
      // Get characteristic node.
      if (!node.Nodes.ContainsKey(characteristicId)) return null;
      node = node.Nodes[characteristicId];
      if (string.IsNullOrEmpty(descriptorId)) return node;
      // Get Descriptor node.
      if (!node.Nodes.ContainsKey(descriptorId)) return null;
      return node.Nodes[descriptorId];
    }
    private void UpdateServerName() {
      if (string.IsNullOrEmpty(bleclient1.ServerId)) {
        GetServerNode().Text = "[Server]";
      } else {
        GetServerNode().Text = string.IsNullOrEmpty(bleclient1.ServerName) ? ("[" + bleclient1.ServerId + "]") : bleclient1.ServerName;
      }
      tbServerName.Text = bleclient1.ServerName;
    }
    private void ColorServiceNode(TreeNode svcNodeToColor) {
      Color newColor = treeGattObjects.ForeColor;
      if (treeGattObjects.SelectedNode.Level == TYPE_SERVICE) {
        Service currService = GetService(treeGattObjects.SelectedNode.Name);
        if (currService.IncludedSvcIds.Contains(svcNodeToColor.Name)) newColor = CHILD_SVC_COLOR;
        else if (currService.ParentSvcIds.Contains(svcNodeToColor.Name)) newColor = PARENT_SVC_COLOR;
      }
      svcNodeToColor.ForeColor = newColor;
    }
    private void ColorAllServiceNodes() {
      foreach (TreeNode svcNode in GetServerNode().Nodes)
        ColorServiceNode(svcNode);
    }
    #endregion
    #region Server Data
    private void UpdateServerDataTab() {
      tbServerName.Text = bleclient1.ServerName;
      tbServerId.Text = bleclient1.ServerId;
      ColorAllServiceNodes();
    }
    private void btnSrvChooseServiceUuids_Click(object sender, EventArgs e) {
      OpenUuidPickerForListbox(TYPE_SERVICE, lbSrvServiceUuids);
    }
    private void btnSrvDiscoverServices_Click(object sender, EventArgs e) {
      SetMainTabsEnabled(false);
      bleclient1.DiscoverServices(GetUuidListStrFromListbox(lbSrvServiceUuids), "");
      SetMainTabsEnabled(true);
    }
    private void btnSrvDiscoverEverything_Click(object sender, EventArgs e) {
      SetMainTabsEnabled(false);
      bleclient1.Discover("", "", true, "");
      SetMainTabsEnabled(true);
    }
    #endregion
    #region Service Data
    private void UpdateServiceDataTab(TreeNode node) {
      Service currService = GetService(node.Name);
      tbServiceName.Text = GattUuidUtils.GetNiceName(currService.Uuid);
      tbServiceUuid.Text = currService.Uuid;
      tbServiceId.Text = currService.Id;
      ColorAllServiceNodes();
    }
    private void btnSvcChooseCharacteristics_Click(object sender, EventArgs e) {
      OpenUuidPickerForListbox(TYPE_CHARACTERISTIC, lbSvcCharacteristicUuids);
    }
    private void btnSvcDiscoverCharacteristics_Click(object sender, EventArgs e) {
      SetMainTabsEnabled(false);
      bleclient1.DiscoverCharacteristics(tbServiceId.Text, GetUuidListStrFromListbox(lbSvcCharacteristicUuids));
      SetMainTabsEnabled(true);
    }
    private void btnSvcChooseInclServices_Click(object sender, EventArgs e) {
      OpenUuidPickerForListbox(TYPE_SERVICE, lbSvcInclServiceUuids);
    }
    private void btnSvcDiscoverInclServices_Click(object sender, EventArgs e) {
      SetMainTabsEnabled(false);
      bleclient1.DiscoverServices(GetUuidListStrFromListbox(lbSvcInclServiceUuids), tbServiceId.Text);
      SetMainTabsEnabled(true);
    }
    #endregion
    #region Characteristic Data
    private void UpdateCharacteristicDataTab(TreeNode node) {
      Characteristic currCharacteristic = GetCharacteristic(node.Parent.Name, node.Name);
      string uuid = currCharacteristic.Uuid;
      int flags = currCharacteristic.Flags;
      tbCharacteristicName.Text = GattUuidUtils.GetNiceName(uuid);
      tbCharacteristicUserDescription.Text = currCharacteristic.UserDescription;
      btnUpdateCharacteristicUserDescription.Enabled = HasFlag(FLAG_WRITABLE_AUXILIARIES, flags);
      tbCharacteristicUserDescription.ReadOnly = !btnUpdateCharacteristicUserDescription.Enabled;
      tbCharacteristicUuid.Text = currCharacteristic.Uuid;
      tbCharacteristicId.Text = currCharacteristic.Id;
      tbCharacteristicFlags.Text = TranslateFlags(flags);
      if (currCharacteristic.ValueFormatCount > 0) {
        numCharacteristicValueFormatIdx.Minimum = 0;
        numCharacteristicValueFormatIdx.Maximum = currCharacteristic.ValueFormatCount - 1;
      } else {
        numCharacteristicValueFormatIdx.Minimum = -1;
        numCharacteristicValueFormatIdx.Maximum = -1;
      }
      btnCharaReadValue.Enabled = HasFlag(FLAG_READ, flags);
      btnCharaWriteValue.Enabled = HasFlag(FLAG_WRITE, flags);
      btnCharaPostValue.Enabled = HasFlag(FLAG_WRITE_NO_RESPONSE, flags);
      tbCharacteristicValue.ReadOnly = !(btnCharaWriteValue.Enabled || btnCharaPostValue.Enabled);
      btnToggleSubscribe.Enabled = HasFlag(FLAG_NOTIFY, flags) || HasFlag(FLAG_INDICATE, flags);
      btnToggleSubscribe.Text = (btnToggleSubscribe.Enabled && currCharacteristic.Subscribed) ? "Unsubscribe" : "Subscribe";
      currValue = btnCharaReadValue.Enabled ? currCharacteristic.CachedValueB : new byte[] {};
      RestoreSelectedCharacteristicDisplayType(currCharacteristic.Uuid);
      tbCharacteristicValue.Text = ValueFormatter.BytesToFormattedValue(currValue, uuidDisplayTypes[uuid], uuidCustomFormats[uuid]);
      ColorAllServiceNodes();
      if (btnToggleSubscribe.Text.Equals("Unsubscribe")) CreateSubCharaRow(currCharacteristic);
    }
    /// 
    /// Selects the correct radio button (and number type, if applicable) based on the DisplayType currently
    /// associated with the current characteristic's UUID.
    /// 
    private void RestoreSelectedCharacteristicDisplayType(string charaUuid) {
      suppressEvents = true;
      DisplayType dt = uuidDisplayTypes[charaUuid];
      string dtStr = ValueFormatter.DisplayTypeToString(dt);
      if (cboCharaNumberType.Items.Contains(dtStr)) {
        cboCharaNumberType.SelectedItem = dtStr;
        rbCharaNumber.Checked = true;
      } else {
        gbCharaDisplayValueAs.Controls.OfType().FirstOrDefault(r => r.Text.Replace("&", "").Contains(dtStr)).Checked = true;
      }
      suppressEvents = false;
    }
    /// 
    /// Refreshes the currently displayed value for the characteristic with the given ID and UUID. This will affect
    /// the browse tab if the currently shown item is the specified characteristic, and the subscribed characteristics
    /// tab if we're subscribed to the specified characteristic.
    /// 
    /// Characteristic ID
    /// Characteristic UUID
    /// If not null, the new value to set before updating the displayed value
    private void RefreshDisplayedValueForCharacteristic(string charaId, string charaUuid, byte[] newValue) {
      // Get latest display type and custom format.
      DisplayType dt = uuidDisplayTypes[charaUuid];
      CustomFormat customFormat = dt == DisplayType.Custom ? uuidCustomFormats[charaUuid] : null;
      // If we're currently showing this characteristic in the Browse tab, refresh there.
      TreeNode currNode = treeGattObjects.SelectedNode;
      if (currNode.Level == TYPE_CHARACTERISTIC && currNode.Name.Equals(charaId)) {
        if (newValue != null) currValue = newValue;
        tbCharacteristicValue.Text = ValueFormatter.BytesToFormattedValue(currValue, dt, customFormat);
      }
      // If we're subscribed to this characteristic in the Subscribed Characteristics tab, refresh there.
      SubscribedCharacteristic subbedChara = GetSubCharaForId(charaId);
      if (subbedChara != null) subbedChara.RefreshDisplayedValue(dt, customFormat, newValue);
    }
    /// 
    /// Updates the samed display type for a characteristic, takes case of ensuring that both the browse and subscribed
    /// characteristics tabs are in sync if need be, and refreshes the displayed value to reflect the change.
    /// 
    /// New DisplayType for the characteristic
    /// Characteristic ID
    /// Characteristic UUID
    /// If true, called from the Subscribed Characteristics tab; if false, called from the Browse tab
    private void UpdateDisplayTypeForCharacteristic(DisplayType newDt, string charaId, string charaUuid, bool fromSubChara) {
      uuidDisplayTypes[charaUuid] = newDt;
      // Make sure that all places using this are in sync.
      if (fromSubChara) RestoreSelectedCharacteristicDisplayType(charaUuid);
      else {
        SubscribedCharacteristic subbedChara = GetSubCharaForId(charaId);
        if (subbedChara != null) subbedChara.RestoreSelectedDisplayType();
      }
      // Refresh the displayed value for this characteristic everywhere.
      RefreshDisplayedValueForCharacteristic(charaId, charaUuid, null);
    }
    private void numCharacteristicValueFormatIdx_ValueChanged(object sender, EventArgs e) {
      numCharacteristicValueFormatIdx.Enabled = false;
      Characteristic currCharacteristic = GetCharacteristic(treeGattObjects.SelectedNode.Parent.Name, treeGattObjects.SelectedNode.Name);
      currCharacteristic.ValueFormatIndex = (int) numCharacteristicValueFormatIdx.Value;
      tbCharacteristicValueFormatType.Text = currCharacteristic.ValueFormat.ToString().Replace("vf", "");
      tbCharacteristicValueFormatUnit.Text = GattUuidUtils.GetNiceName(currCharacteristic.ValueUnit);
      tbCharacteristicValueFormatExponent.Text = currCharacteristic.ValueExponent.ToString();
      numCharacteristicValueFormatIdx.Enabled = currCharacteristic.ValueFormatCount > 0;
    }
    private void btnUpdateCharacteristicUserDescription_Click(object sender, EventArgs e) {
      TreeNode node = treeGattObjects.SelectedNode;
      Characteristic c = GetCharacteristic(node.Parent.Name, node.Name);
      try {
        SetMainTabsEnabled(false);
        c.UserDescription = tbCharacteristicUserDescription.Text;
      } catch (IPWorksBLEException ex) {
        HandleEx(ex);
      } finally {
        tbCharacteristicUserDescription.Text = c.UserDescription;
        SetMainTabsEnabled(true);
      }
    }
    private void rbCharaDisplayType_CheckedChanged(object sender, EventArgs e) {
      if (suppressEvents) return;
      if (((RadioButton) sender).Checked) {
        RadioButton rb = (RadioButton) sender;
        DisplayType newDt = ValueFormatter.ParseDisplayType(rb != rbCharaNumber ? rb.Text.Replace("&", "") : (string) cboCharaNumberType.SelectedItem);
        UpdateDisplayTypeForCharacteristic(newDt, tbCharacteristicId.Text, tbCharacteristicUuid.Text, false);
      }
    }
    private void cboCharaNumberType_SelectionChangeCommitted(object sender, EventArgs e) {
      if (suppressEvents) return;
      if (rbCharaNumber.Checked) {
        DisplayType newDt = ValueFormatter.ParseDisplayType((string) cboCharaNumberType.SelectedItem);
        UpdateDisplayTypeForCharacteristic(newDt, tbCharacteristicId.Text, tbCharacteristicUuid.Text, false);
      }
    }
    private void btnCustomizeCharaFormat_Click(object sender, EventArgs e) {
      using (CustomFormatBuilder frmCustomFormatBuilder = new CustomFormatBuilder()) {
        CustomFormat customFormat = uuidCustomFormats[tbCharacteristicUuid.Text];
        DialogResult result = frmCustomFormatBuilder.ShowForCustomFormat(customFormat);
        if (result == DialogResult.OK) {
          customFormat = frmCustomFormatBuilder.GetCustomFormat();
          uuidCustomFormats[tbCharacteristicUuid.Text] = customFormat;
          ValueFormatter.SaveCustomFormats(uuidCustomFormats);
          if (rbCharaCustom.Checked) RefreshDisplayedValueForCharacteristic(tbCharacteristicId.Text, tbCharacteristicUuid.Text, null);
        }
      }
    }
    private void btnCharaReadValue_Click(object sender, EventArgs e) {
      try {
        SetMainTabsEnabled(false);
        TreeNode node = treeGattObjects.SelectedNode;
        bleclient1.ReadValue(node.Parent.Name, node.Name, "");
        // Everything else is taken care of by the Value event.
      } catch (IPWorksBLEException ex) {
        HandleEx(ex);
      } finally {
        SetMainTabsEnabled(true);
      }
    }
    private void btnCharaWriteValue_Click(object sender, EventArgs e) {
      try {
        SetMainTabsEnabled(false);
        CustomFormat customFormat = uuidCustomFormats[tbCharacteristicUuid.Text];
        byte[] newValue = ValueFormatter.FormattedValueToBytes(tbCharacteristicValue.Text, uuidDisplayTypes[tbCharacteristicUuid.Text], customFormat);
        TreeNode node = treeGattObjects.SelectedNode;
        bleclient1.WriteValue(node.Parent.Name, node.Name, "", newValue);
        currValue = newValue;
      } catch (Exception ex) {
        HandleEx(ex);
      } finally {
        SetMainTabsEnabled(true);
      }
    }
    private void btnCharaPostValue_Click(object sender, EventArgs e) {
      try {
        SetMainTabsEnabled(false);
        CustomFormat customFormat = uuidCustomFormats[tbCharacteristicUuid.Text];
        byte[] newValue = ValueFormatter.FormattedValueToBytes(tbCharacteristicValue.Text, uuidDisplayTypes[tbCharacteristicUuid.Text], customFormat);
        TreeNode node = treeGattObjects.SelectedNode;
        bleclient1.PostValue(node.Parent.Name, node.Name, newValue);
        currValue = newValue;
      } catch (Exception ex) {
        HandleEx(ex);
      } finally {
        SetMainTabsEnabled(true);
      }
    }
    private void btnToggleSubscribe_Click(object sender, EventArgs e) {
      SetMainTabsEnabled(false);
      try {
        TreeNode node = treeGattObjects.SelectedNode;
        if (btnToggleSubscribe.Text.Equals("Subscribe")) {
          bleclient1.Subscribe(node.Parent.Name, node.Name);
          btnToggleSubscribe.Text = "Unsubscribe";
        } else {
          bleclient1.Unsubscribe(node.Parent.Name, node.Name);
          btnToggleSubscribe.Text = "Subscribe";
        }
      } catch (IPWorksBLEException ex) {
        HandleEx(ex);
      } finally {
        SetMainTabsEnabled(true);
      }
    }
    private void btnCharaDiscoverDescriptors_Click(object sender, EventArgs e) {
      treeGattObjects.Enabled = btnCharaDiscoverDescriptors.Enabled = false;
      bleclient1.DiscoverDescriptors(treeGattObjects.SelectedNode.Parent.Name, tbCharacteristicId.Text);
      treeGattObjects.Enabled = btnCharaDiscoverDescriptors.Enabled = true;
    }
    #endregion
    #region Descriptor Data
    private void UpdateDescriptorDataTab(TreeNode node) {
      Descriptor currDescriptor = GetDescriptor(node.Parent.Parent.Name, node.Parent.Name, node.Name);
      tbDescriptorName.Text = GattUuidUtils.GetNiceName(currDescriptor.Uuid);
      tbDescriptorUuid.Text = currDescriptor.Uuid;
      tbDescriptorId.Text = currDescriptor.Id;
      currValue = currDescriptor.CachedValueB;
      RestoreSelectedDescriptorDisplayType(currDescriptor.Uuid);
      RefreshDisplayedDescriptorValue();
      ColorAllServiceNodes();
    }
    private void RestoreSelectedDescriptorDisplayType(string descUuid) {
      suppressEvents = true;
      DisplayType dt = uuidDisplayTypes[descUuid];
      string dtStr = ValueFormatter.DisplayTypeToString(dt);
      if (cboDescNumberType.Items.Contains(dtStr)) {
        cboDescNumberType.SelectedItem = dtStr;
        rbDescNumber.Checked = true;
      } else {
        gbDescDisplayValueAs.Controls.OfType().FirstOrDefault(r => r.Text.Replace("&", "").Contains(dtStr)).Checked = true;
      }
      suppressEvents = false;
    }
    private void RefreshDisplayedDescriptorValue() {
      RadioButton rb = gbDescDisplayValueAs.Controls.OfType().FirstOrDefault(r => r.Checked);
      DisplayType newDt = ValueFormatter.ParseDisplayType(rb != rbDescNumber ? rb.Text.Replace("&", "") : (string) cboDescNumberType.SelectedItem);
      uuidDisplayTypes[tbDescriptorUuid.Text] = newDt;
      CustomFormat customFormat = newDt == DisplayType.Custom ? uuidCustomFormats[tbDescriptorUuid.Text] : null;
      tbDescriptorValue.Text = ValueFormatter.BytesToFormattedValue(currValue, newDt, customFormat);
    }
    private void rbDescDisplayType_CheckedChanged(object sender, EventArgs e) {
      if (suppressEvents) return;
      if (((RadioButton) sender).Checked) RefreshDisplayedDescriptorValue();
    }
    private void cboDescNumberType_SelectionChangeCommitted(object sender, EventArgs e) {
      if (suppressEvents) return;
      if (rbDescNumber.Checked) RefreshDisplayedDescriptorValue();
    }
    private void btnCustomizeDescFormat_Click(object sender, EventArgs e) {
      using (CustomFormatBuilder frmCustomFormatBuilder = new CustomFormatBuilder()) {
        CustomFormat customFormat = uuidCustomFormats[tbDescriptorUuid.Text];
        DialogResult result = frmCustomFormatBuilder.ShowForCustomFormat(customFormat);
        if (result == DialogResult.OK) {
          customFormat = frmCustomFormatBuilder.GetCustomFormat();
          uuidCustomFormats[tbDescriptorUuid.Text] = customFormat;
          ValueFormatter.SaveCustomFormats(uuidCustomFormats);
          if (rbCharaCustom.Checked) RefreshDisplayedDescriptorValue();
        }
      }
    }
    private void btnDescReadValue_Click(object sender, EventArgs e) {
      try {
        SetMainTabsEnabled(false);
        TreeNode node = treeGattObjects.SelectedNode;
        currValue = bleclient1.ReadValue(node.Parent.Parent.Name, node.Parent.Name, node.Name);
        RefreshDisplayedDescriptorValue();
      } catch (IPWorksBLEException ex) {
        HandleEx(ex);
      } finally {
        SetMainTabsEnabled(true);
      }
    }
    private void btnDescWriteValue_Click(object sender, EventArgs e) {
      try {
        SetMainTabsEnabled(false);
        CustomFormat customFormat = uuidCustomFormats[tbDescriptorUuid.Text];
        byte[] newValue = ValueFormatter.FormattedValueToBytes(tbDescriptorValue.Text, uuidDisplayTypes[tbDescriptorUuid.Text], customFormat);
        TreeNode node = treeGattObjects.SelectedNode;
        bleclient1.WriteValue(node.Parent.Parent.Name, node.Parent.Name, node.Name, newValue);
        currValue = newValue;
      } catch (Exception ex) {
        HandleEx(ex);
      } finally {
        SetMainTabsEnabled(true);
      }
    }
    #endregion
    #endregion Browse Data Tab
    #region Subscribed Characteristics Tab
    private void flowSubscribedCharacteristics_ControlsChanged(object sender, ControlEventArgs e) {
      // Automatically expand/collapse the panels in the SplitContainer as the Subscribed Characteristics FlowLayoutPanel
      // has the first control added to it or the last control removed from it.
      splitSubscribed.Panel1Collapsed = !(splitSubscribed.Panel2Collapsed = flowSubscribedCharacteristics.Controls.Count > 0);
    }
    private void ResetSubscribedCharacteristicsTab() {
      for (int i = subscribedCharacteristics.Count - 1; i >= 0; i--)
        subscribedCharacteristics[i].RemoveAndDispose();
    }
    private void CreateSubCharaRow(Characteristic chara) {
      if (GetSubCharaForId(chara.Id) == null) SubscribedCharacteristic.CreateAndAdd(this, chara);
    }
    private void RemoveSubCharaRow(string charaId) {
      SubscribedCharacteristic subbedChara = GetSubCharaForId(charaId);
      if (subbedChara != null) subbedChara.RemoveAndDispose();
    }
    private SubscribedCharacteristic GetSubCharaForId(string charaId) {
      foreach (SubscribedCharacteristic sc in subscribedCharacteristics) {
        if (sc.CharaId.Equals(charaId)) return sc;
      }
      return null;
    }
    /// 
    /// Convenience class that handles all of the logic for each row of controls associated with a subscribed characteristic.
    /// 
    private class SubscribedCharacteristic {
      private Panel pnlSubChara;
      private TextBox tbSubCharaName;
      private Label lblSubCharaName;
      private TextBox tbSubCharaValue;
      private GroupBox gbSubCharaDisplayValueAs;
      private RadioButton rbSubCharaCustom;
      private RadioButton rbSubCharaUTF16;
      private RadioButton rbSubCharaUTF8;
      private ComboBox cboSubCharaNumberType;
      private RadioButton rbSubCharaNumber;
      private RadioButton rbSubCharaBoolean;
      private Button btnSubCharaCustomize;
      private RadioButton rbSubCharaHexBytes;
      private Button btnShowSubCharaInBrowseTab;
      private TextBox tbSubCharaUuid;
      private Label lblSubCharaUuid;
      private readonly bleclientDemo owner;
      private string uuid;
      private byte[] currValue;
      private bool suppressEvents = false;
      public string CharaId { get; private set; }
      public static void CreateAndAdd(bleclientDemo owner, Characteristic characteristic) {
        new SubscribedCharacteristic(owner, characteristic);
      }
      private SubscribedCharacteristic(bleclientDemo owner, Characteristic characteristic) {
        this.owner = owner;
        CharaId = characteristic.Id;
        currValue = owner.HasFlag(FLAG_READ, characteristic.Flags) ? characteristic.CachedValueB : new byte[] {};
        uuid = characteristic.Uuid;
        owner.subscribedCharacteristics.Add(this);
        #region Control Creation and Setup
        pnlSubChara = new Panel();
        tbSubCharaValue = new TextBox();
        gbSubCharaDisplayValueAs = new GroupBox();
        rbSubCharaCustom = new RadioButton();
        rbSubCharaUTF16 = new RadioButton();
        rbSubCharaUTF8 = new RadioButton();
        cboSubCharaNumberType = new ComboBox();
        rbSubCharaNumber = new RadioButton();
        rbSubCharaBoolean = new RadioButton();
        btnSubCharaCustomize = new Button();
        rbSubCharaHexBytes = new RadioButton();
        lblSubCharaName = new Label();
        tbSubCharaName = new TextBox();
        lblSubCharaUuid = new Label();
        tbSubCharaUuid = new TextBox();
        btnShowSubCharaInBrowseTab = new Button();
        // Start Layout
        owner.flowSubscribedCharacteristics.SuspendLayout();
        pnlSubChara.SuspendLayout();
        gbSubCharaDisplayValueAs.SuspendLayout();
        // pnlSubChara
        pnlSubChara.AutoSize = true;
        pnlSubChara.AutoSizeMode = AutoSizeMode.GrowAndShrink;
        pnlSubChara.BorderStyle = BorderStyle.FixedSingle;
        pnlSubChara.Controls.Add(btnShowSubCharaInBrowseTab);
        pnlSubChara.Controls.Add(tbSubCharaUuid);
        pnlSubChara.Controls.Add(lblSubCharaUuid);
        pnlSubChara.Controls.Add(tbSubCharaName);
        pnlSubChara.Controls.Add(lblSubCharaName);
        pnlSubChara.Controls.Add(tbSubCharaValue);
        pnlSubChara.Controls.Add(gbSubCharaDisplayValueAs);
        pnlSubChara.Dock = DockStyle.Fill;
        pnlSubChara.Location = new Point(3, 3);
        pnlSubChara.Padding = new Padding(3);
        pnlSubChara.Size = new Size(996, 115);
        pnlSubChara.TabIndex = 0;
        // tbSubCharaValue
        tbSubCharaValue.AcceptsReturn = true;
        tbSubCharaValue.AcceptsTab = true;
        tbSubCharaValue.Anchor = ((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right);
        tbSubCharaValue.Location = new Point(6, 35);
        tbSubCharaValue.Multiline = true;
        tbSubCharaValue.ReadOnly = true;
        tbSubCharaValue.Size = new Size(656, 72);
        tbSubCharaValue.TabIndex = 5;
        // gbSubCharaDisplayAs
        gbSubCharaDisplayValueAs.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
        gbSubCharaDisplayValueAs.Controls.Add(rbSubCharaCustom);
        gbSubCharaDisplayValueAs.Controls.Add(rbSubCharaUTF16);
        gbSubCharaDisplayValueAs.Controls.Add(rbSubCharaUTF8);
        gbSubCharaDisplayValueAs.Controls.Add(cboSubCharaNumberType);
        gbSubCharaDisplayValueAs.Controls.Add(rbSubCharaNumber);
        gbSubCharaDisplayValueAs.Controls.Add(rbSubCharaBoolean);
        gbSubCharaDisplayValueAs.Controls.Add(btnSubCharaCustomize);
        gbSubCharaDisplayValueAs.Controls.Add(rbSubCharaHexBytes);
        gbSubCharaDisplayValueAs.Location = new Point(668, 35);
        gbSubCharaDisplayValueAs.Size = new Size(320, 72);
        gbSubCharaDisplayValueAs.TabIndex = 6;
        gbSubCharaDisplayValueAs.TabStop = false;
        gbSubCharaDisplayValueAs.Text = "Display Value As...";
        // rbSubCharaCustom
        rbSubCharaCustom.AutoSize = true;
        rbSubCharaCustom.Location = new Point(134, 47);
        rbSubCharaCustom.Size = new Size(95, 17);
        rbSubCharaCustom.TabIndex = 6;
        rbSubCharaCustom.Text = "Custom Format";
        rbSubCharaCustom.UseVisualStyleBackColor = true;
        rbSubCharaCustom.CheckedChanged += rbSubCharaDisplayType_CheckedChanged;
        // rbSubCharaUTF16
        rbSubCharaUTF16.AutoSize = true;
        rbSubCharaUTF16.Location = new Point(67, 47);
        rbSubCharaUTF16.Size = new Size(61, 17);
        rbSubCharaUTF16.TabIndex = 5;
        rbSubCharaUTF16.Text = "UTF-16";
        rbSubCharaUTF16.UseVisualStyleBackColor = true;
        rbSubCharaUTF16.CheckedChanged += rbSubCharaDisplayType_CheckedChanged;
        // rbSubCharaUTF8
        rbSubCharaUTF8.AutoSize = true;
        rbSubCharaUTF8.Location = new Point(6, 47);
        rbSubCharaUTF8.Size = new Size(55, 17);
        rbSubCharaUTF8.TabIndex = 4;
        rbSubCharaUTF8.Text = "UTF-8";
        rbSubCharaUTF8.UseVisualStyleBackColor = true;
        rbSubCharaUTF8.CheckedChanged += rbSubCharaDisplayType_CheckedChanged;
        // cboSubCharaNumberType
        cboSubCharaNumberType.DropDownStyle = ComboBoxStyle.DropDownList;
        cboSubCharaNumberType.FormattingEnabled = true;
        cboSubCharaNumberType.Items.AddRange(new object[] {
            "UInt8",
            "UInt16",
            "UInt32",
            "UInt64",
            "SInt8",
            "SInt16",
            "SInt32",
            "SInt64",
            "Float32",
            "Float64"});
        cboSubCharaNumberType.SelectedItem = "SInt32";
        cboSubCharaNumberType.Location = new Point(222, 17);
        cboSubCharaNumberType.Size = new Size(92, 21);
        cboSubCharaNumberType.TabIndex = 3;
        cboSubCharaNumberType.SelectionChangeCommitted += cboSubCharaNumberType_SelectionChangeCommitted;
        // rbSubCharaNumber
        rbSubCharaNumber.AutoSize = true;
        rbSubCharaNumber.Location = new Point(155, 19);
        rbSubCharaNumber.Size = new Size(65, 17);
        rbSubCharaNumber.TabIndex = 2;
        rbSubCharaNumber.Text = "Number:";
        rbSubCharaNumber.UseVisualStyleBackColor = true;
        rbSubCharaNumber.CheckedChanged += rbSubCharaDisplayType_CheckedChanged;
        // rbSubCharaBoolean
        rbSubCharaBoolean.AutoSize = true;
        rbSubCharaBoolean.Location = new Point(85, 19);
        rbSubCharaBoolean.Size = new Size(64, 17);
        rbSubCharaBoolean.TabIndex = 1;
        rbSubCharaBoolean.Text = "Boolean";
        rbSubCharaBoolean.UseVisualStyleBackColor = true;
        rbSubCharaBoolean.CheckedChanged += rbSubCharaDisplayType_CheckedChanged;
        // btnSubCharaCustomize
        btnSubCharaCustomize.Location = new Point(235, 44);
        btnSubCharaCustomize.Size = new Size(79, 23);
        btnSubCharaCustomize.TabIndex = 7;
        btnSubCharaCustomize.Text = "Customize...";
        btnSubCharaCustomize.UseVisualStyleBackColor = true;
        btnSubCharaCustomize.Click += btnSubCharaCustomize_Click;
        // rbSubCharaHexBytes
        rbSubCharaHexBytes.AutoSize = true;
        rbSubCharaHexBytes.Checked = true;
        rbSubCharaHexBytes.Location = new Point(6, 19);
        rbSubCharaHexBytes.Size = new Size(73, 17);
        rbSubCharaHexBytes.TabIndex = 0;
        rbSubCharaHexBytes.TabStop = true;
        rbSubCharaHexBytes.Text = "Hex Bytes";
        rbSubCharaHexBytes.UseVisualStyleBackColor = true;
        rbSubCharaHexBytes.CheckedChanged += rbSubCharaDisplayType_CheckedChanged;
        // lblSubCharaName
        lblSubCharaName.AutoSize = true;
        lblSubCharaName.Location = new Point(6, 11);
        lblSubCharaName.Size = new Size(38, 13);
        lblSubCharaName.TabIndex = 0;
        lblSubCharaName.Text = "Name:";
        // tbSubCharaName
        tbSubCharaName.Anchor = ((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right);
        tbSubCharaName.Location = new Point(50, 8);
        tbSubCharaName.ReadOnly = true;
        tbSubCharaName.Size = new Size(421, 20);
        tbSubCharaName.TabIndex = 1;
        // lblSubCharaUuid
        lblSubCharaUuid.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
        lblSubCharaUuid.AutoSize = true;
        lblSubCharaUuid.Location = new Point(477, 11);
        lblSubCharaUuid.Size = new Size(37, 13);
        lblSubCharaUuid.TabIndex = 2;
        lblSubCharaUuid.Text = "UUID:";
        // tbSubCharaUuid
        tbSubCharaUuid.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
        tbSubCharaUuid.Location = new Point(520, 8);
        tbSubCharaUuid.ReadOnly = true;
        tbSubCharaUuid.Size = new Size(332, 20);
        tbSubCharaUuid.TabIndex = 3;
        // btnShowSubCharaInBrowseTab
        btnShowSubCharaInBrowseTab.Location = new Point(858, 6);
        btnShowSubCharaInBrowseTab.Size = new Size(130, 23);
        btnShowSubCharaInBrowseTab.TabIndex = 4;
        btnShowSubCharaInBrowseTab.Text = "Show In Browse Tab";
        btnShowSubCharaInBrowseTab.UseVisualStyleBackColor = true;
        btnShowSubCharaInBrowseTab.Click += btnShowSubCharaInBrowseTab_Click;
        #endregion
        owner.flowSubscribedCharacteristics.Controls.Add(pnlSubChara);
        #region Do Control Layout
        // Finish control setup.
        owner.flowSubscribedCharacteristics.ResumeLayout(false);
        owner.flowSubscribedCharacteristics.PerformLayout();
        pnlSubChara.ResumeLayout(false);
        pnlSubChara.PerformLayout();
        gbSubCharaDisplayValueAs.ResumeLayout(false);
        gbSubCharaDisplayValueAs.PerformLayout();
        #endregion
        tbSubCharaName.Text = GattUuidUtils.GetNiceName(uuid);
        tbSubCharaUuid.Text = uuid;
        RestoreSelectedDisplayType();
        tbSubCharaValue.Text = ValueFormatter.BytesToFormattedValue(currValue, owner.uuidDisplayTypes[uuid], owner.uuidCustomFormats[uuid]);
      }
      public void RestoreSelectedDisplayType() {
        suppressEvents = true;
        DisplayType dt = owner.uuidDisplayTypes[uuid];
        string dtStr = ValueFormatter.DisplayTypeToString(dt);
        if (cboSubCharaNumberType.Items.Contains(dtStr)) {
          cboSubCharaNumberType.SelectedItem = dtStr;
          rbSubCharaNumber.Checked = true;
        } else {
          gbSubCharaDisplayValueAs.Controls.OfType().FirstOrDefault(r => r.Text.Contains(dtStr)).Checked = true;
        }
        suppressEvents = false;
      }
      public void RefreshDisplayedValue(DisplayType dt, CustomFormat customFormat, byte[] newValue) {
        if (newValue != null) currValue = newValue;
        tbSubCharaValue.Text = ValueFormatter.BytesToFormattedValue(currValue, dt, customFormat);
      }
      public void RemoveAndDispose() {
        owner.flowSubscribedCharacteristics.Controls.Remove(pnlSubChara);
        pnlSubChara.Dispose();
        owner.subscribedCharacteristics.Remove(this);
      }
      private void btnShowSubCharaInBrowseTab_Click(object sender, EventArgs e) {
        owner.tabCtrlMain.SelectedTab = owner.tabBrowse;
        // We can make this characteristic's service ID by taking the first 4 characters and replacing the last 8 with 0s.
        string svcId = CharaId.Substring(0, 4) + "00000000";
        owner.treeGattObjects.SelectedNode = owner.GetNodeById(svcId, CharaId, null);
      }
      private void rbSubCharaDisplayType_CheckedChanged(object sender, EventArgs e) {
        if (suppressEvents) return;
        if (((RadioButton) sender).Checked) {
          RadioButton rb = (RadioButton) sender;
          DisplayType newDt = ValueFormatter.ParseDisplayType(rb != rbSubCharaNumber ? rb.Text : (string) cboSubCharaNumberType.SelectedItem);
          owner.UpdateDisplayTypeForCharacteristic(newDt, CharaId, uuid, true);
        }
      }
      private void cboSubCharaNumberType_SelectionChangeCommitted(object sender, EventArgs e) {
        if (suppressEvents) return;
        if (rbSubCharaNumber.Checked) {
          DisplayType newDt = ValueFormatter.ParseDisplayType((string) cboSubCharaNumberType.SelectedItem);
          owner.UpdateDisplayTypeForCharacteristic(newDt, CharaId, uuid, true);
        }
      }
      private void btnSubCharaCustomize_Click(object sender, EventArgs e) {
        using (CustomFormatBuilder frmCustomFormatBuilder = new CustomFormatBuilder()) {
          CustomFormat customFormat = owner.uuidCustomFormats[uuid];
          DialogResult result = frmCustomFormatBuilder.ShowForCustomFormat(customFormat);
          if (result == DialogResult.OK) {
            customFormat = frmCustomFormatBuilder.GetCustomFormat();
            owner.uuidCustomFormats[tbSubCharaUuid.Text] = customFormat;
            ValueFormatter.SaveCustomFormats(owner.uuidCustomFormats);
            if (rbSubCharaCustom.Checked) owner.RefreshDisplayedValueForCharacteristic(CharaId, uuid, null);
          }
        }
      }
    }
    #endregion
    #region Log Tab
    private string TranslateLogLevel(int logLevel) {
      switch (logLevel) {
        case 3:
          return "DEBUG";
        case 2:
          return "VERBOSE";
        case 1:
          return "INFO";
      }
      return "";
    }
    private void Log(string s) {
      if (tbLog.Disposing || tbLog.IsDisposed) return;
      tbLog.AppendText(s + "\r\n");
    }
    private void LogAndShowMessage(string s) {
      Log(s);
      MessageBox.Show(s);
    }
    private void LogAdvertisement(BleclientAdvertisementEventArgs e) {
      if (!cbLogAdvertisements.Checked) return;
      Log(string.Format("Advertisement:\r\n" +
                        "\tServerId: {0}\r\n" +
                        "\tName: {1}\r\n" +
                        "\tRSSI: {2}\r\n" +
                        "\tTxPower: {3}\r\n" +
                        "\tServiceUuids: {4}\r\n" +
                        "\tServicesWithData: {5}\r\n" +
                        "\tSolicitedServiceUuids: {6}\r\n" +
                        "\tManufacturerCompanyId: {7}\r\n" +
                        "\tManufacturerCompanyData: {8}\r\n" +
                        "\tIsConnectable: {9}\r\n" +
                        "\tIsScanResponse: {10}\r\n",
                        e.ServerId, e.Name, e.RSSI, e.TxPower, e.ServiceUuids, e.ServicesWithData, e.SolicitedServiceUuids,
                        e.ManufacturerCompanyId, BitConverter.ToString(e.ManufacturerDataB), e.IsConnectable, e.IsScanResponse));
    }
    private void HandleEx(Exception ex) {
      if (ex is IPWorksBLEException)
        LogAndShowMessage(string.Format("Exception: [{0}] {1}", ((IPWorksBLEException) ex).Code, ex.Message));
      else
        LogAndShowMessage("Exception: " + ex.Message);
    }
    private void btnPrintGattObjTree_Click(object sender, EventArgs e) {
      Log(bleclient1.Config("GattObjTreeInfo"));
    }
    private void btnClearLog_Click(object sender, EventArgs e) {
      tbLog.Clear();
    }
    private void tbLog_VisibleChanged(object sender, EventArgs e) {
      if (tbLog.Visible) {
        tbLog.SelectionStart = tbLog.TextLength;
        tbLog.ScrollToCaret();
      }
    }
    private void cbbLogLevel_SelectedIndexChanged(object sender, EventArgs e) {
      bleclient1.Config("LogLevel=" + cbbLogLevel.SelectedIndex);
    }
    #endregion
    #region Convenience & Utility
    /// 
    /// When we do BLE operations, we typically don't want to let the user do other things, so we use this to
    /// disable all tab content for the main tabs (other than the log tab). Note that doing it this way still
    /// allows the user to switch between tabs, which is fine.
    /// 
    private void SetMainTabsEnabled(bool enabled) {
      tabScanConnect.Enabled = tabBrowse.Enabled = tabSubscribed.Enabled = enabled;
    }
    private Service GetService(string serviceId) {
      foreach (Service service in bleclient1.Services)
        if (service.Id.Equals(serviceId)) return service;
      return null;
    }
    private Characteristic GetCharacteristic(string serviceId, string characteristicId) {
      bleclient1.Select(serviceId, "");
      foreach (Characteristic characteristic in bleclient1.Characteristics)
        if (characteristic.Id.Equals(characteristicId)) return characteristic;
      return null;
    }
    private Descriptor GetDescriptor(string serviceId, string characteristicId, string descriptorId) {
      bleclient1.Select(serviceId, characteristicId);
      foreach (Descriptor descriptor in bleclient1.Descriptors)
        if (descriptor.Id.Equals(descriptorId)) return descriptor;
      return null;
    }
    private string TranslateFlags(int flags) {
      List flagsList = new List();
      if (HasFlag(FLAG_BROADCAST, flags)) flagsList.Add("Broadcast");
      if (HasFlag(FLAG_READ, flags)) flagsList.Add("Read");
      if (HasFlag(FLAG_WRITE_NO_RESPONSE, flags)) flagsList.Add("Write_No_Response");
      if (HasFlag(FLAG_WRITE, flags)) flagsList.Add("Write");
      if (HasFlag(FLAG_NOTIFY, flags)) flagsList.Add("Notify");
      if (HasFlag(FLAG_INDICATE, flags)) flagsList.Add("Indicate");
      if (HasFlag(FLAG_AUTH_SIGNED_WRITE, flags)) flagsList.Add("Auth_Signed_Write");
      if (HasFlag(FLAG_RELIABLE_WRITE, flags)) flagsList.Add("Reliable_Write");
      if (HasFlag(FLAG_WRITABLE_AUXILIARIES, flags)) flagsList.Add("Writable_Auxiliaries");
      return string.Join(", ", flagsList);
    }
    private bool HasFlag(int flag, int flags) {
      return (flags & flag) == flag;
    }
    /// 
    /// Convenience method to open the UUID Picker dialog for a given UUID type, with the initial state and resulting state
    /// tied to a given ListBox.
    /// 
    /// The UUID type.
    /// The ListBox to get the initial UUIDs from, and to put the resulting UUIDs into.
    private void OpenUuidPickerForListbox(int uuidType, ListBox lb) {
      using (UuidPicker frmUuidPicker = new UuidPicker()) {
        DialogResult result = frmUuidPicker.ShowForUuidType(uuidType, lb.Items.Cast().ToList());
        if (result == DialogResult.OK) {
          lb.Items.Clear();
          lb.Items.AddRange(frmUuidPicker.GetSelectedUuids().ToArray());
        }
      }
    }
    private string GetUuidListStrFromListbox(ListBox lb) {
      if (lb.Items.Count == 0) return "";
      return string.Join(",", lb.Items.Cast().Select(g => g.Uuid).ToArray());
    }
    private void lbUuids_KeyUp(object sender, KeyEventArgs e) {
      ListBox lb = (ListBox) sender;
      // Remove selected items.
      if (e.KeyCode == Keys.Delete) {
        for (int i = lb.SelectedIndices.Count - 1; i >= 0; i--)
          lb.Items.RemoveAt(lb.SelectedIndices[i]);
      }
    }
    /// 
    /// For ease of design-time manipulation, we use a TabControl to hold the sets of controls for different GATT objects
    /// in the Browse tab. But at runtime, we don't want to show the tabs since we don't want the user to be able to switch
    /// between them at will. 
    /// Hiding the tabs alone technically doesn't require subclassing TabControl, but if we want to hide the tabs _and_ keep
    /// the TabControl from drawing a thick, ugly border around the tab pages then we have to do it this way.
    /// See https://stackoverflow.com/a/6954785
    /// 
    public partial class TabControlWithoutHeader : TabControl {
      private const int TCM_ADJUSTRECT = 0x1328;
      public TabControlWithoutHeader() {
        if (!this.DesignMode) this.Multiline = true;
      }
      protected override void OnKeyDown(KeyEventArgs ke) {
        // Prevent the user from switching tabs using Ctrl+Tab and Shift+Ctrl+Tab. TabControl is weird and we can't
        // just use the events for this.
        if (!(ke.Control && (ke.KeyCode == Keys.Tab || ke.KeyCode == Keys.Next || ke.KeyCode == Keys.Prior)))
          base.OnKeyDown(ke);
      }
      protected override void WndProc(ref Message m) {
        if (m.Msg == TCM_ADJUSTRECT && !this.DesignMode) m.Result = new IntPtr(1);
        else base.WndProc(ref m);
      }
    }
    #endregion
  }
}