Example #1
0
        public static async Task <bool> Toggle(this IManagedScan scan)
        {
            if (scan.IsScanning)
            {
                scan.Stop();
            }
            else
            {
                await scan.Start().ConfigureAwait(false);
            }

            return(scan.IsScanning);
        }
Example #2
0
        public ManagedScanViewModel(IBleManager bleManager)
        {
            this.scanner = bleManager
                           .CreateManagedScanner(
                RxApp.MainThreadScheduler,
                TimeSpan.FromSeconds(10)
                )
                           .DisposedBy(this.DeactivateWith);

            this.Toggle = ReactiveCommand.CreateFromTask(async() =>
                                                         this.IsBusy = await this.scanner.Toggle()
                                                         );
        }
Example #3
0
        public ManagedScanViewModel(IBleManager bleManager, INavigationService navigator)
        {
            this.scanner = bleManager
                           .CreateManagedScanner(RxApp.MainThreadScheduler, TimeSpan.FromSeconds(10))
                           .DisposedBy(this.DeactivateWith);

            this.Toggle = ReactiveCommand.CreateFromTask(async() =>
                                                         this.IsBusy = await this.scanner.Toggle()
                                                         );

            this.WhenAnyValue(x => x.SelectedPeripheral)
            .Skip(1)
            .Where(x => x != null)
            .Subscribe(async x =>
            {
                this.SelectedPeripheral = null;
                this.scanner.Stop();
                await navigator.Navigate("ManagedPeripheral", ("Peripheral", x.Peripheral));
            });
        }