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