private void mItType_Click(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; this.bluetoothType = (BluetoothTypes)Enum.Parse(typeof(BluetoothTypes), item.Text); this.lblType.Text = this.bluetoothType.ToString(); this.DisconnectFromDevice(); if (this.bluetoothType == BluetoothTypes.HC06) { this.bluetooth = new BluetoothDevice(new HC06(this.portName)); } else if (this.bluetoothType == BluetoothTypes.HC05) { this.bluetooth = new BluetoothDevice(new HC05(this.portName)); } else if (this.bluetoothType == BluetoothTypes.RN21) { this.bluetooth = new BluetoothDevice(new RN21(this.portName)); } this.bluetooth.SetRecieveEvent(this.bluetooth_RecievedMessage); this.bluetooth.SetMessageEvent(this.bluetooth_SentMessage); item.Checked = this.bluetooth.IsConnected; this.SetConnectivity(); this.SetType(); }