public static ImageSource GetImageSource(string directory, ItemState folderType) { try { return(FolderManager.GetImageSource(directory, new Size(16, 16), folderType)); } catch { throw; } }
public FileSystemObjectInfo(FileSystemInfo info) { if (this is DummyFileSystemObjectInfo) { return; } this.Children = new ObservableCollection <FileSystemObjectInfo>(); this.FileSystemInfo = info; if (info is DirectoryInfo) { this.ImageSource = FolderManager.GetImageSource(info.FullName, ItemState.Close); this.AddDummy(); } else if (info is FileInfo) { this.ImageSource = FileManager.GetImageSource(info.FullName); } this.PropertyChanged += FileSystemObjectInfo_PropertyChanged; }
void FileSystemObjectInfo_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (this.FileSystemInfo is DirectoryInfo) { if (string.Equals(e.PropertyName, "IsExpanded", StringComparison.CurrentCultureIgnoreCase)) { if (this.IsExpanded) { this.ImageSource = FolderManager.GetImageSource(this.FileSystemInfo.FullName, ItemState.Open); if (this.HasDummy()) { this.RemoveDummy(); this.ExploreDirectories(); this.ExploreFiles(); } } else { this.ImageSource = FolderManager.GetImageSource(this.FileSystemInfo.FullName, ItemState.Close); } } } }