private void ReplaceArchiveWithExtractedContents(FileSystemTreeElement archiveFileSystemTreeElement, DirectoryInfo archiveExtractionDirectory) { if (archiveFileSystemTreeElement.ParentFileSystemTreeElement.IsDirectory) { FileSystemTreeElement parent = archiveFileSystemTreeElement.ParentFileSystemTreeElement; ObservableCollection <FileSystemTreeElement> parentContainigFileSystemElementCollection = parent.ChildFileSystemTreeElements; int archiveFileIndex = parentContainigFileSystemElementCollection.IndexOf(archiveFileSystemTreeElement); var archiveRepresentationNode = new FileSystemTreeElement( parent.RootFileSystemTreeElement, parent, archiveExtractionDirectory) { IsArchive = true, AlternativeIElementName = archiveFileSystemTreeElement.ElementInfo.Name.Equals(archiveExtractionDirectory.Name, StringComparison.OrdinalIgnoreCase) ? "" : archiveExtractionDirectory.Name }; List <FileSystemTreeElement> lazySubdirectories = archiveRepresentationNode.InitializeWithLazyTreeStructure(); archiveRepresentationNode.SortChildren(); FilterFileSystemTree(archiveRepresentationNode); Application.Current.Dispatcher.Invoke( () => { parentContainigFileSystemElementCollection.Insert(archiveFileIndex, archiveRepresentationNode); parentContainigFileSystemElementCollection.Remove(archiveFileSystemTreeElement); archiveFileSystemTreeElement.ParentFileSystemTreeElement.ChildFileSystemTreeElements = parentContainigFileSystemElementCollection; if (archiveRepresentationNode.IsLazyLoading) { ObserveVirtualDirectories(lazySubdirectories); } archiveRepresentationNode.IsExpanded = true; }, DispatcherPriority.Send); } }
private void LazyLoadChildren(FileSystemTreeElement directoryNode) { if (!directoryNode.HasLazyChildren) { return; } directoryNode.HasLazyChildren = false; Task.Run( () => { List <FileSystemTreeElement> lazyFileSystemElements = directoryNode.InitializeWithLazyTreeStructure(); directoryNode.SortChildren(); FilterFileSystemTree(directoryNode); if (directoryNode.IsLazyLoading) { ObserveVirtualDirectories(lazyFileSystemElements); } }).ConfigureAwait(true); }