public DirectoryViewModel(IScreen hostScreen, IDirectoryTools directoryTools) { this.directoryTools = directoryTools; HostScreen = hostScreen; var sourceDirectory = Preferences.Get("sourceDirectory", string.Empty); subDirectories.DisposeWith(Disposables); SelectedDirectory = new DirectoryContent(Path.GetFileName(sourceDirectory), sourceDirectory); this.WhenAnyValue(vm => vm.SelectedDirectory) .Where(x => x != null) .Subscribe(directoryContent => SetDirectoryContent(directoryContent.FullPath)) .DisposeWith(Disposables); subDirectoriesHelper = subDirectories.ToProperty(this, vm => vm.SubDirectories); subDirectoriesHelper.DisposeWith(Disposables); CmdSetSoureDirectory = ReactiveCommand.CreateFromTask(_ => { Preferences.Set("sourceDirectory", SelectedDirectory.FullPath); HostScreen.Router.Navigate.Execute(new ScannedChatsViewModel(hostScreen, directoryTools)) .Subscribe() .DisposeWith(Disposables); return(Task.FromResult(Unit.Default)); }) .SetupErrorHandling(Disposables); SetDirectoryContent(sourceDirectory); }
public ScannedChatsViewModel(IScreen hostScreen, IDirectoryTools directoryTools) { HostScreen = hostScreen; this.directoryTools = directoryTools; sourceDirectory = Preferences.Get("sourceDirectory", string.Empty); FillContent(); }