コード例 #1
0
ファイル: Extensions.cs プロジェクト: shinyorg/shiny
        public static async Task <bool> Toggle(this IManagedScan scan)
        {
            if (scan.IsScanning)
            {
                scan.Stop();
            }
            else
            {
                await scan.Start().ConfigureAwait(false);
            }

            return(scan.IsScanning);
        }
コード例 #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()
                                                         );
        }
コード例 #3
0
ファイル: ManagedScanViewModel.cs プロジェクト: moljac/shiny
        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));
            });
        }