private void BrowsePath(object obj) { FolderBrowserWindow window = new FolderBrowserWindow(); if (this.viewModel == null) { this.viewModel = new FolderBrowserViewModel(this.AdapterBase) { Message = this.Adapter.Configuration.IsOriginator ? "Select the source folder" : "Select the destination folder" }; if (!string.IsNullOrWhiteSpace(this.DestinationPath)) { // TODO: Fix //this.viewModel.SelectedPath = this.DestinationPath; } } if (!this.viewModel.RootFolders.Any()) { this.viewModel.LoadRootFolders(); } window.DataContext = this.viewModel; if (!string.IsNullOrEmpty(this.DestinationPath)) { ThreadingHelper.StartBackgroundTask( (s, t) => { foreach (FolderViewModel root in this.viewModel.RootFolders) { FolderViewModel folder = this.GetFolderByPath(root, this.DestinationPath.Split('\\').ToList()); if (folder != null) { folder.IsExpanded = true; folder.IsSelected = true; break; } } }); } bool?dialogResult = window.ShowDialog(); if (dialogResult == true) { this.DestinationPath = this.viewModel.SelectedFolder.GetPath(); //this.DestinationPath = this.viewModel.SelectedPath; //this.SetDestinationPath(this.viewModel.SelectedPath); } }
private void BrowsePath(object obj) { FolderBrowserWindow window = new FolderBrowserWindow(); if (this.viewModel == null) { this.viewModel = new FolderBrowserViewModel(this.AdapterBase) { Message = "Select the destination folder" }; if (!string.IsNullOrWhiteSpace(this.DestinationPath)) { //this.viewModel.SelectedPath = this.DestinationPath; } } if (!this.viewModel.RootFolders.Any()) { this.viewModel.LoadRootFolders(); } window.DataContext = this.viewModel; if (!string.IsNullOrWhiteSpace(this.DestinationPath)) { ThreadingHelper.StartBackgroundTask( (s, t) => { foreach (FolderViewModel root in this.viewModel.RootFolders) { FolderViewModel folder = this.GetFolderByPath(root, this.DestinationPath.Split(new[] { this.AdapterBase.PathSeparator }, StringSplitOptions.None).ToList()); if (folder != null) { folder.IsExpanded = true; folder.IsSelected = true; break; } } }); } bool?dialogResult = window.ShowDialog(); if (dialogResult == true && this.viewModel.SelectedFolder != null) { this.DestinationPath = this.viewModel.SelectedFolder.GetPath(); } }