示例#1
0
        public override bool OnMenuItemSelected(int featureId, IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.ScanAction:
                item.SetTitle(_scanner.IsScanning ? Resource.String.StartScan : Resource.String.StopScan);
                if (_scanner.IsScanning)
                {
                    _scanner.StopScan();
                    break;
                }
                _scanner.StartScan();
                break;

            case Resource.Id.OpenServerAction:
                item.SetTitle(_bluetoothServer.IsOpened ?  Resource.String.OpenServer : Resource.String.CloseServer);
                if (_bluetoothServer.IsOpened)
                {
                    _bluetoothServer.Close();
                }
                else
                {
                    _bluetoothServer.Open();
                }
                break;
            }
            return(true);
        }
示例#2
0
 public void StartScan(Action <BLE_Device_Info> execute)
 {
     if ((Status != BLE_Status.BT_NotAwailable) &&
         (Status != BLE_Status.BT_IsSwitchOff) &&
         (Status != BLE_Status.BLE_NotAwailable))
     {
         onDeviceFound = execute;
         DeviceList.Clear();    //Очистка списка устройств
         _scanner?.StartScan(); //Запуск поиска
     }
 }