public DotNetNotInstalledVM( MainVM mvm, ViewModel goBack, IObservable <Version?> dotNetVersion) { dotNetVersion .Subscribe(v => { if (v != null) { mvm.ActivePanel = goBack; } }) .DisposeWith(this); DownloadCommand = ReactiveCommand.Create( () => { Utility.NavigateToPath("https://dotnet.microsoft.com/download"); }); }
public DotNetNotInstalledVM( MainVM mvm, ViewModel goBack, IObservable <DotNetVersion> dotNetVersion) { dotNetVersion .Subscribe(v => { if (v.Acceptable) { mvm.ActivePanel = goBack; } }) .DisposeWith(this); _CustomDisplayString = dotNetVersion .Select(x => { if (x.Acceptable) { return(string.Empty); } if (x.Version.IsNullOrWhitespace()) { return("While the app can open with the DotNet Runtime, it also needs the SDK to be able to function."); } else { return($"While an SDK was found, it was not an acceptable version. You had {x.Version}, but it must be at least {DotNetCommands.MinVersion}"); } }) .ToGuiProperty(this, nameof(CustomDisplayString), string.Empty); DownloadCommand = ReactiveCommand.Create( () => { Utility.NavigateToPath("https://dotnet.microsoft.com/download"); }); }
public ConfigurationVM(MainVM mvm) { MainVM = mvm; ProfilesDisplay = Profiles.Connect().ToObservableCollection(this); PatchersDisplay = this.WhenAnyValue(x => x.SelectedProfile) .Select(p => p?.Patchers.Connect() ?? Observable.Empty <IChangeSet <PatcherVM> >()) .Switch() .ToObservableCollection(this); CompleteConfiguration = ReactiveCommand.CreateFromTask( async() => { var initializer = this.NewPatcher; if (initializer == null) { return; } AddNewPatchers(await initializer.Construct().ToListAsync()); }, canExecute: this.WhenAnyValue(x => x.NewPatcher) .Select(patcher => { if (patcher == null) { return(Observable.Return(false)); } return(patcher.WhenAnyValue(x => x.CanCompleteConfiguration) .Select(e => e.Succeeded)); }) .Switch()); CancelConfiguration = ReactiveCommand.Create( () => { NewPatcher?.Cancel(); NewPatcher = null; }); // Dispose any old patcher initializations this.WhenAnyValue(x => x.NewPatcher) .DisposePrevious() .Subscribe() .DisposeWith(this); _DisplayedObject = Observable.CombineLatest( this.WhenAnyValue(x => x.SelectedProfile !.DisplayedObject), this.WhenAnyValue(x => x.NewPatcher), (selected, newConfig) => (newConfig as object) ?? selected) .ToGuiProperty(this, nameof(DisplayedObject), default); RunPatchers = NoggogCommand.CreateFromJob( extraInput: this.WhenAnyValue(x => x.SelectedProfile), jobCreator: (profile) => { if (SelectedProfile == null) { return(default(PatchersRunVM?), Observable.Return(Unit.Default)); } var ret = new PatchersRunVM(this, SelectedProfile); var completeSignal = ret.WhenAnyValue(x => x.Running) .TurnedOff() .FirstAsync(); return(ret, completeSignal); }, createdJobs: out var createdRuns, canExecute: this.WhenAnyFallback(x => x.SelectedProfile !.BlockingError, fallback: ErrorResponse.Failure) .Select(err => err.Succeeded)) .DisposeWith(this); _CurrentRun = createdRuns .ToGuiProperty(this, nameof(CurrentRun), default); this.WhenAnyValue(x => x.CurrentRun) .NotNull() .Do(run => MainVM.ActivePanel = run) .ObserveOn(RxApp.TaskpoolScheduler) .Subscribe(r => r.Run()) .DisposeWith(this); ShowHelpToggleCommand = ReactiveCommand.Create(() => ShowHelp = !ShowHelp); }