Exemple #1
0
        private void OnSelection(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem == null)
            {
                return;
            }

            ScanResults selectedScanResult = (ScanResults)e.SelectedItem;

            //DisplayAlert("Item Selected", selectedScanResult.GuiName, "Ok");
            ((ListView)sender).SelectedItem = null;
            selectedScanResult.IsRunning    = true;
            selectedScanResult.IsVisible    = true;

            System.Collections.Generic.List <Plugin.BLE.Abstractions.Contracts.IDevice> systemDevices =
                Plugin.BLE.CrossBluetoothLE.Current.Adapter.GetSystemConnectedOrPairedDevices();

            if ((selectedDevice == null) || (selectedScanResult.Name != selectedDevice.scanResult.Name))
            {
                selectedDevice = new SelectedDevice(selectedScanResult);
            }
            else if (systemDevices.Contains(selectedDevice.bledevice))
            {
                selectedDevice.SendDataToConnectedDevice();
            }
            else
            {
                selectedDevice = new SelectedDevice(selectedScanResult);
            }
        }