public ModlistSettingsEditorVM(CompilationModlistSettings settings) { this._settings = settings; ImagePath = new FilePickerVM() { ExistCheckOption = FilePickerVM.CheckOptions.IfPathNotEmpty, PathType = FilePickerVM.PathTypeOptions.File, }; ImagePath.Filters.Add(new CommonFileDialogFilter("Banner image", "*.png")); ReadmeFilePath = new FilePickerVM() { PathType = FilePickerVM.PathTypeOptions.File, ExistCheckOption = FilePickerVM.CheckOptions.IfPathNotEmpty, }; ReadmeFilePath.Filters.Add(new CommonFileDialogFilter("Text", "*.txt")); ReadmeFilePath.Filters.Add(new CommonFileDialogFilter("HTML File", "*.html")); InError = Observable.CombineLatest( this.WhenAny(x => x.ImagePath.ErrorState).Select(err => err.Failed), this.WhenAny(x => x.ReadmeFilePath.ErrorState).Select(err => err.Failed), this.WhenAny(x => x.ReadmeIsWebsite), resultSelector: (img, readme, isWebsite) => img || (readme && !isWebsite)) .Publish() .RefCount(); SwapToTextReadmeCommand = ReactiveCommand.Create(() => ReadmeIsWebsite = false); SwapToWebsiteReadmeCommand = ReactiveCommand.Create(() => ReadmeIsWebsite = true); }
public ModlistSettingsEditorVM(CompilationModlistSettings settings) { _settings = settings; ImagePath = new FilePickerVM { ExistCheckOption = FilePickerVM.CheckOptions.IfPathNotEmpty, PathType = FilePickerVM.PathTypeOptions.File, }; ImagePath.Filters.Add(new CommonFileDialogFilter("Banner image", "*.png")); _version = this.WhenAny(x => x.VersionText) .Select(x => { if (string.IsNullOrWhiteSpace(x)) { return(new Version(0, 0)); } return(!Version.TryParse(x, out var version) ? new Version(0, 0) : version); }).ObserveOnGuiThread() .ToProperty(this, x => x.Version); InError = this.WhenAny(x => x.ImagePath.ErrorState) .Select(err => err.Failed) .CombineLatest( this.WhenAny(x => x.VersionText) .Select(x => Version.TryParse(x, out _)), (image, version) => !image && !version) .Publish() .RefCount(); }