Exemplo n.º 1
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            setButtonEnabled = new setButtonEnabledHandler(setButtonEnabledMethod);
            setRcvText       = new setTextHandler(setRcvTextMethod);
            setLabelStatus   = new setLabelStatusHandler(setLabelStatusMethod);
            BluetoothRadio br = BluetoothRadio.PrimaryRadio;

            if (br == null)
            {
                MessageBox.Show("No supported Bluetooth radio/stack found.");
                btnListen.Enabled = false;
            }
            else if (br.Mode != InTheHand.Net.Bluetooth.RadioMode.Discoverable)
            {
                DialogResult rslt = MessageBox.Show("Make BluetoothRadio Discoverable?", "Bluetooth Remote Listener", MessageBoxButtons.YesNo);
                if (rslt == DialogResult.Yes)
                {
                    br.Mode = RadioMode.Discoverable;
                }
                else
                {
                    btnListen.Enabled = false;
                }
            }
            bl = new BluetoothListener(service);
        }
Exemplo n.º 2
0
 private void setButtonEnabled(Button obj, bool flag)
 {
     if (obj.InvokeRequired == true)
     {
         setButtonEnabledHandler set = new setButtonEnabledHandler(setButtonEnabled); //委托的方法参数应和SetCalResult一致
         obj.Invoke(set, new object[] { obj, flag });                                 //此方法第二参数用于传入方法,代替形参result
     }
     else
     {
         obj.Enabled = flag;
     }
 }
		private void Form1_Load(object sender, System.EventArgs e)
		{
            setButtonEnabled = new setButtonEnabledHandler(setButtonEnabledMethod);
            setRcvText = new setTextHandler(setRcvTextMethod);
            setSendText = new setTextHandler(setSendTextMethod);
            setLabelStatus = new setLabelStatusHandler(setLabelStatusMethod);
            BluetoothRadio br = BluetoothRadio.PrimaryRadio;
            if (br == null) {
                MessageBox.Show("No supported Bluetooth radio/stack found.");
                btnListen.Enabled = false;
            } else if (br.Mode != InTheHand.Net.Bluetooth.RadioMode.Discoverable) {
                DialogResult rslt = MessageBox.Show("Make BluetoothRadio Discoverable?", "Bluetooth Remote Listener", MessageBoxButtons.YesNo);
                if (rslt == DialogResult.Yes) {
                    br.Mode = RadioMode.Discoverable;
                }
                else btnListen.Enabled = false;
            }
            bl = new BluetoothListener(PANUService);
        }