static ImageSource GetIconInternal(string path, ItemType itemType) { using (var icon = ShellManager.GetIcon(path, itemType)) { return(Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(16, 16))); } }
public static ImageSource GetImageSource(string filename, Size size) { try { using (var icon = ShellManager.GetIcon(Path.GetExtension(filename), ItemType.File, IconSize.Small, ItemState.Undefined)) { return(Imaging.CreateBitmapSourceFromHIcon(icon.Handle, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight((int)size.Width, (int)size.Height))); } } catch { throw; } }
public static ImageSource GetImageSource(string directory, Size size, ItemState folderType) { try { using (var icon = ShellManager.GetIcon(directory, ItemType.Folder, IconSize.Large, folderType)) { return(Imaging.CreateBitmapSourceFromHIcon(icon.Handle, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight((int)size.Width, (int)size.Height))); } } catch { throw; } }