//Disconnect
        private void btnDisconnect_Click(object sender, EventArgs e)
        {
            btnDisconnect.Enabled = false;

            if (!mBtAdt.Disconnect())
            {
                btnDisconnect.Enabled = true;
            }
        }
示例#2
0
        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;
                }
            }
        }
示例#3
0
 public void SetDown()
 {
     _btAdt.Disconnect();
 }
示例#4
0
 /// <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();
 }