private void AddValidation(CompositeDisposable disposables) { this.BindStrictValidation( this.ViewModel, vm => vm.Channel, v => v.ChannelErrorTextBlock.Text, magicallyWorks: false) .DisposeWith(disposables); var allPeriodsValid = this.ViewModel !.Periods .ToObservableChangeSet() .AutoRefreshOnObservable(period => period.Valid) .ToCollection() .Select(periods => periods.All(period => !period.HasErrors)); this.ViewModel.PeriodsNonOverlapping .CombineLatest(allPeriodsValid, (a, b) => !a && b) .ObserveOn(RxApp.MainThreadScheduler) .BindTo(this, v => v.PeriodsOverlapTextBlock.IsVisible) .DisposeWith(disposables); }
private void BindCommands(CompositeDisposable disposables) { this.BindCommand(this.ViewModel !, vm => vm.GoToSeries, v => v.GoToSeriesButton) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.GoToSeries, v => v.GoToSeriesIconButton) .DisposeWith(disposables); this.ViewModel !.GoToSeries.CanExecute .BindTo(this, v => v.GoToSeriesIconButton.IsVisible) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.Cancel, v => v.CancelButton) .DisposeWith(disposables); this.ViewModel !.Cancel.CanExecute .BindTo(this, v => v.CancelButton.IsVisible) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.Close, v => v.CloseButton) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.GoToNext, v => v.GoToNextButton) .DisposeWith(disposables); this.ViewModel !.GoToNext.CanExecute .BindTo(this, v => v.GoToNextButton.IsVisible) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.GoToPrevious, v => v.GoToPreviousButton) .DisposeWith(disposables); this.ViewModel !.GoToPrevious.CanExecute .BindTo(this, v => v.GoToPreviousButton.IsVisible) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.Close, v => v.CloseButton) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.Delete, v => v.DeleteButton) .DisposeWith(disposables); this.ViewModel !.Delete.CanExecute .BindTo(this, v => v.DeleteButton.IsVisible) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.SwitchToNextPoster, v => v.SwitchToNextPosterButton) .DisposeWith(disposables); this.ViewModel !.SwitchToNextPoster.CanExecute .BindTo(this, v => v.SwitchToNextPosterButton.IsVisible) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.SwitchToPreviousPoster, v => v.SwitchToPreviousPosterButton) .DisposeWith(disposables); this.ViewModel !.SwitchToPreviousPoster.CanExecute .BindTo(this, v => v.SwitchToPreviousPosterButton.IsVisible) .DisposeWith(disposables); this.ViewModel !.Periods.ToObservableChangeSet() .Count() .Select(count => count > 1) .ObserveOn(RxApp.MainThreadScheduler) .BindTo(this, v => v.SwitchPosterPanel.IsVisible) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.AddTitle, v => v.AddTitleButton) .DisposeWith(disposables); this.ViewModel !.AddTitle.CanExecute .BindTo(this, v => v.AddTitleButton.IsVisible) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.AddOriginalTitle, v => v.AddOriginalTitleButton) .DisposeWith(disposables); this.ViewModel !.AddOriginalTitle.CanExecute .BindTo(this, v => v.AddOriginalTitleButton.IsVisible) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.AddPeriod, v => v.AddPeriodButton) .DisposeWith(disposables); this.ViewModel !.AddPeriod.CanExecute .BindTo(this, v => v.AddPeriodButton.IsVisible) .DisposeWith(disposables); }
private void BindCommands(CompositeDisposable disposables) { const BooleanToVisibilityHint useHidden = BooleanToVisibilityHint.UseHidden; this.BindCommand(this.ViewModel !, vm => vm.GoToSeries, v => v.GoToSeriesButton) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.GoToSeries, v => v.GoToSeriesIconButton) .DisposeWith(disposables); this.ViewModel !.GoToSeries.CanExecute .BindTo(this, v => v.GoToSeriesIconButton.Visibility, useHidden) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.Cancel, v => v.CancelButton) .DisposeWith(disposables); this.ViewModel !.Cancel.CanExecute .BindTo(this, v => v.CancelButton.Visibility) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.Close, v => v.CloseButton) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.GoToNext, v => v.GoToNextButton) .DisposeWith(disposables); this.ViewModel !.GoToNext.CanExecute .BindTo(this, v => v.GoToNextButton.Visibility, useHidden) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.GoToPrevious, v => v.GoToPreviousButton) .DisposeWith(disposables); this.ViewModel !.GoToPrevious.CanExecute .BindTo(this, v => v.GoToPreviousButton.Visibility, useHidden) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.Close, v => v.CloseButton) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.Delete, v => v.DeleteButton) .DisposeWith(disposables); this.ViewModel !.Delete.CanExecute .BindTo(this, v => v.DeleteButton.Visibility) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.SwitchToNextPoster, v => v.SwitchToNextPosterButton) .DisposeWith(disposables); this.ViewModel !.SwitchToNextPoster.CanExecute .BindTo(this, v => v.SwitchToNextPosterButton.Visibility) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.SwitchToPreviousPoster, v => v.SwitchToPreviousPosterButton) .DisposeWith(disposables); this.ViewModel !.SwitchToPreviousPoster.CanExecute .BindTo(this, v => v.SwitchToPreviousPosterButton.Visibility) .DisposeWith(disposables); this.ViewModel !.Periods.ToObservableChangeSet() .Count() .Select(count => count > 1) .ObserveOnDispatcher() .BindTo(this, v => v.SwitchPosterPanel.Visibility) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.AddTitle, v => v.AddTitleButton) .DisposeWith(disposables); this.ViewModel !.AddTitle.CanExecute .BindTo(this, v => v.AddTitleButton.Visibility) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.AddOriginalTitle, v => v.AddOriginalTitleButton) .DisposeWith(disposables); this.ViewModel !.AddOriginalTitle.CanExecute .BindTo(this, v => v.AddOriginalTitleButton.Visibility) .DisposeWith(disposables); this.BindCommand(this.ViewModel !, vm => vm.AddPeriod, v => v.AddPeriodButton) .DisposeWith(disposables); this.ViewModel !.AddPeriod.CanExecute .BindTo(this, v => v.AddPeriodButton.Visibility) .DisposeWith(disposables); }