//Disconnect private void btnDisconnect_Click(object sender, EventArgs e) { btnDisconnect.Enabled = false; if (!mBtAdt.Disconnect()) { btnDisconnect.Enabled = true; } }
private void btnConnect_Click(object sender, EventArgs e) { if (btnConnect.Text == "Connect") { if (txtMacAddress.Text == "") { MessageBox.Show("Select Mac Address of Pen!!"); return; } btnConnect.Enabled = false; Thread thread = new Thread(unused => { // Binds a socket created by connecting with pen through Bluetooth interface according to Device Class bool result = mBtAdt.Connect(txtMacAddress.Text, delegate(uint deviceClass) { // Binding when Device Class is F110 if (deviceClass == mPenCommV1.DeviceClass) { mBtAdt.Bind(mPenCommV1); } // Binding if Device Class is not F110 else if (deviceClass == mPenCommV2.DeviceClass) { mBtAdt.Bind(mPenCommV2); } }); if (!result) { MessageBox.Show("Fail to connect"); this.BeginInvoke(new MethodInvoker(delegate() { btnConnect.Enabled = true; })); } }); thread.IsBackground = true; thread.Start(); } else { if (!mBtAdt.Disconnect()) { btnConnect.Text = "Connect"; btnConnect.Enabled = true; } } }
public void SetDown() { _btAdt.Disconnect(); }
/// <summary> /// Attempt to disconnect to a pen device. /// </summary> /// <returns>true if disconnected, otherwise false.</returns> public bool Disconnect() { return(mBtAdapter.Disconnect()); }
public void SetDown() { _callbackObj.Dispose(); _btAdt.Disconnect(); }