private void CompleteScan(IEnumerable <Artist> artists) { IsCompleted = true; var data = GetSharedData(); data.ScannedArtists = artists; //automatically navigate to next wizard step after scan is finished ContinueCommand.Execute(null); }
private void OnViewLoadedCommand(object parameter) { var settings = CurrentUser.GetSettings(); IsStepDisabledNextTime = !settings.ImportFirstStepVisible; if (!settings.ImportFirstStepVisible) { ContinueCommand.Execute(null); } }
private void OnBeginImportCommand(object parameter) { var markedItems = GetMarkedItems(); var validationResult = Validate(markedItems); if (!validationResult.Success) { Notify(validationResult.Message, NotificationType.Error); } else { IsBusy = true; Task <bool> importTask = Task.Factory.StartNew <bool>(() => { if (markedItems.Count() == 0) { return(true); } return(dataService.BulkImportData(markedItems)); }, TaskScheduler.Default); Task finishImportTask = importTask.ContinueWith((r) => { IsBusy = false; if (r.Result) { Notify("Import has been successful", NotificationType.Success); ImportCompleted = true; eventAggregator.GetEvent <ReloadAlbumsEvent>().Publish(null); eventAggregator.GetEvent <ReloadArtistsEvent>().Publish(null); //automatically navigate to next step in wizard ContinueCommand.Execute(null); } else { Notify("Errors occured during import. Please see log for details", NotificationType.Error); } }, TaskScheduler.FromCurrentSynchronizationContext()); } }
void SelectVideo(Video video) { ContinueCommand?.Execute(video); }
public MainViewModel() { Activator = new ViewModelActivator(); IsTimerRunning = false; this.WhenActivated( disposables => { Disposable // https://stackoverflow.com/a/5838632/12207453 .Create(() => BuddyAvatarBitmap?.Dispose()) .DisposeWith(disposables); }); var canInitiateNewFetch = this.WhenAnyValue(vm => vm.Fetching, fetching => !fetching); // https://reactiveui.net/docs/handbook/commands/ // https://reactiveui.net/docs/handbook/scheduling/ // https://blog.jonstodle.com/task-toobservable-observable-fromasync-task/ // https://github.com/reactiveui/ReactiveUI/issues/1245 StalkCommand = ReactiveCommand.CreateFromObservable( () => Observable.StartAsync(Stalk), canInitiateNewFetch, RxApp.MainThreadScheduler ); ContinueCommand = ReactiveCommand.CreateFromObservable( () => Observable.StartAsync(Continue), canInitiateNewFetch, RxApp.MainThreadScheduler ); // Run the "Continue" command once in the beginning in order to fetch the first buddy. // https://reactiveui.net/docs/handbook/when-activated/#no-need ContinueCommand.Execute().Subscribe(); // https://reactiveui.net/docs/handbook/commands/canceling#canceling-via-another-observable var startTimerCommand = ReactiveCommand.CreateFromObservable( () => Observable .Return(Unit.Default) .Delay(TimeSpan.FromMilliseconds(DecisionTimeMilliseconds)) .TakeUntil( TriggeringTheTimer .Where(trigger => trigger == TimerTrigger.Stop))); startTimerCommand.Subscribe(_ => ContinueCommand.Execute().Subscribe()); this .WhenAnyObservable(vm => vm.TriggeringTheTimer) .Do(trigger => { if (trigger == TimerTrigger.Start) { startTimerCommand.Execute().Subscribe(); IsTimerRunning = true; } else { IsTimerRunning = false; } }) .Subscribe(); }