/// <summary> /// Ask the shell to feed us the appropriate icon for the given file, but /// first try looking in our cache to see if we've already loaded it. /// </summary> private int ExtractIconIfNecessary(String path) { Icon icon; Size size = GetSmallIconSize(); String ext = Path.GetExtension(path); if (String.IsNullOrEmpty(ext)) { ext = "folder"; } if (this.imageList.Images[ext] != null) { return(this.imageList.Images.IndexOfKey(ext)); } else { if (File.Exists(path)) { icon = IconExtractor.GetFileIcon(path, false, true); } else { icon = IconExtractor.GetFolderIcon(path, false, true); } Image image = ImageKonverter.ImageResize(icon.ToBitmap(), size.Width, size.Height); this.imageList.Images.Add(ext, image); icon.Dispose(); image.Dispose(); return(this.imageList.Images.Count - 1); } }
/// <summary> /// Resizes the image based on the display scale. Uses high quality settings. /// </summary> public static Bitmap Scale(Bitmap image) { if (GetScale() == 1) { return(image); } int width = Scale(image.Width); int height = Scale(image.Height); return((Bitmap)ImageKonverter.ImageResize(image, width, height)); }
/// <summary> /// Ask the shell to feed us the appropriate icon for the given file, but /// first try looking in our cache to see if we've already loaded it. /// </summary> private int ExtractIconIfNecessary(String path) { Icon icon; Size size = GetSmallIconSize(); if (File.Exists(path)) { icon = IconExtractor.GetFileIcon(path, false, true); } else { icon = IconExtractor.GetFolderIcon(path, false, true); } Image image = ImageKonverter.ImageResize(icon.ToBitmap(), size.Width, size.Height); this.imageList.Images.Add(image); icon.Dispose(); image.Dispose(); return(this.imageList.Images.Count - 1); }
public static FDImage ExtractIconIfNecessary(string file) { string extension = Path.GetExtension(file); if (extensionIcons.ContainsKey(extension)) { return(extensionIcons[extension]); } else { Icon icon = IconExtractor.GetFileIcon(file, true); Image image = ImageKonverter.ImageResize(icon.ToBitmap(), 16, 16); icon.Dispose(); imageList.Images.Add(image); int index = imageList.Images.Count - 1; // of the icon we just added FDImage fdImage = new FDImage(image, index); extensionIcons.Add(extension, fdImage); return(fdImage); } }