/// <summary> /// Convert a <see cref="IItem"/> into an image representation. /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var item = value as IItem; if (item == null) { return(Binding.DoNothing); } System.Windows.Media.ImageSource displayIcon = null; try { // a folder can be represented with a seperate icon for its expanded state if (item.ItemType == FSItemType.Folder) { displayIcon = IconExtractor.GetFolderIcon(item.ItemPath, item.IsExpanded).ToImageSource(); } else { displayIcon = IconExtractor.GetFileIcon(item.ItemPath).ToImageSource(); } } catch { } return(displayIcon); }
/// <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); } }
private void ApplyFileIcon(string filePath) { if (_contentPersister != null && _contentPersister.GetType() != typeof(DefaultContentPersister)) { return; } System.Drawing.Icon icon = null; icon = IconExtractor.GetFileIcon(filePath, IconSize.Small); if (icon == null) { icon = Properties.Resources.TextEditor; } this.Icon = icon; }
/// <summary> /// Automaticly updates the document icon /// </summary> private void UpdateDocumentIcon(String file) { if (this.useCustomIcon) { return; } if (!this.IsBrowsable) { this.Icon = IconExtractor.GetFileIcon(file, true); } else { Image image = Globals.MainForm.FindImage("480"); this.Icon = ImageKonverter.ImageToIcon(image); this.useCustomIcon = true; } }
/// <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); } }
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 = ScaleHelper.Scale(icon.ToBitmap()); image = (Bitmap)PluginBase.MainForm.ImageSetAdjust(image); 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); } }
private void ShowItems(string[] items) { filesListView.SuspendLayout(); foreach (string each in items) { // Prevent includes of multiple items if (!ItemsToProcess.Contains(each)) { ListViewItem item = new ListViewItem(each.Substring(each.LastIndexOf('\\') + 1)); item.Name = each; SHFILEINFO fInfo = new SHFILEINFO(); uint dwFileAttributes = FILE_ATTRIBUTE.FILE_ATTRIBUTE_NORMAL; uint uFlags = (uint)(SHGFI.SHGFI_TYPENAME | SHGFI.SHGFI_USEFILEATTRIBUTES); SHGetFileInfo(each, dwFileAttributes, ref fInfo, (uint)Marshal.SizeOf(fInfo), uFlags); FileInfo info = new FileInfo(each); item.SubItems.Add(info.LastWriteTime.ToString()); item.SubItems.Add(fInfo.szTypeName); item.SubItems.Add(FormatFileSize(info.Length)); item.ImageKey = each; imageList.Images.Add(each, IconExtractor.GetFileIcon(each, IconExtractor.IconSize.Small)); filesListView.Items.Add(item); ItemsToProcess.Add(each); } } filesListView.ResumeLayout(); }