public Icon GetStaticIcon(StaticIconType type, IconSize size) { ShellIcon.IconSize iconSize; switch (size) { case IconSize.Large: iconSize = ShellIcon.IconSize.Large; break; case IconSize.Small: iconSize = ShellIcon.IconSize.Small; break; default: throw new NotSupportedException(); } ShellIcon.FolderType folderType; switch (type) { case StaticIconType.OpenDirectory: folderType = ShellIcon.FolderType.Open; break; case StaticIconType.CloseDirectory: folderType = ShellIcon.FolderType.Closed; break; default: throw new NotSupportedException(); } SD.Icon icon = ShellIcon.GetFolderIcon(iconSize, folderType); return new Icon(new IconHandler(icon)); }
public DropDownToolbarItem(IDropDownAction action, IconSize iconSize) { _action = action; _actionEnabledChangedHandler = new EventHandler(OnActionEnabledChanged); _actionVisibleChangedHandler = new EventHandler(OnActionVisibleChanged); _actionAvailableChangedHandler = new EventHandler(OnActionAvailableChanged); _actionLabelChangedHandler = new EventHandler(OnActionLabelChanged); _actionTooltipChangedHandler = new EventHandler(OnActionTooltipChanged); _actionIconSetChangedHandler = new EventHandler(OnActionIconSetChanged); _action.EnabledChanged += _actionEnabledChangedHandler; _action.VisibleChanged += _actionVisibleChangedHandler; _action.AvailableChanged += _actionAvailableChangedHandler; _action.LabelChanged += _actionLabelChangedHandler; _action.TooltipChanged += _actionTooltipChangedHandler; _action.IconSetChanged += _actionIconSetChangedHandler; _iconSize = iconSize; this.Text = _action.Label; this.Enabled = _action.Enabled; this.Visible = _action.Visible; this.ToolTipText = _action.Tooltip; UpdateVisibility(); UpdateEnablement(); UpdateIcon(); this.ShowDropDownArrow = true; this.DropDown = new ContextMenuStrip(); this.DropDown.ImageScalingSize = StandardIconSizes.Small; this.DropDownOpening += new EventHandler(OnDropDownOpening); }
/// <summary> /// Obtains system folder icon</summary> /// <param name="size">Specifies large or small icons</param> /// <param name="folderType">Specifies open or closed FolderType</param> /// <returns>System folder icon</returns> public static Icon GetFolderIcon(IconSize size, FolderType folderType) { // Need to add size check, although errors generated at present! uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; if (FolderType.Open == folderType) { flags += Shell32.SHGFI_OPENICON; } if (IconSize.Small == size) { flags += Shell32.SHGFI_SMALLICON; } else { flags += Shell32.SHGFI_LARGEICON; } // Get the folder icon Shell32.SHFILEINFO shfi = new Shell32.SHFILEINFO(); Shell32.SHGetFileInfo(null, Shell32.FILE_ATTRIBUTE_DIRECTORY, ref shfi, (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi), flags); Icon.FromHandle(shfi.hIcon); // Load the icon from an HICON handle // Now clone the icon, so that it can be successfully stored in an ImageList Icon icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone(); User32.DestroyIcon(shfi.hIcon); // Cleanup return icon; }
/// <summary> /// Returns an icon for a given file - indicated by the Name parameter. /// </summary> /// <param Name="Name">Pathname for file.</param> /// <param Name="size">Large or small</param> /// <param Name="linkOverlay">Whether to include the link icon</param> /// <returns>System.Drawing.Icon</returns> public static Icon GetFileIcon(string name, IconSize size, bool linkOverlay) { Shell32.SHFILEINFO shfi = new Shell32.SHFILEINFO(); uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; if (linkOverlay) flags += Shell32.SHGFI_LINKOVERLAY; /* Check the size specified for return. */ if (IconSize.Small == size) { flags += Shell32.SHGFI_SMALLICON; } else { flags += Shell32.SHGFI_LARGEICON; } Shell32.SHGetFileInfo(name, Shell32.FILE_ATTRIBUTE_NORMAL, ref shfi, (uint)Marshal.SizeOf(shfi), flags); Icon.FromHandle(shfi.hIcon); // Load the icon from an HICON handle // Now clone the icon, so that it can be successfully stored in an ImageList Icon icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone(); return icon; }
/// <summary> /// Resolves icon of the file. /// </summary> /// <param name="fileExtensionName">The file extension name.</param> /// <param name="iconSize">The icon size.</param> /// <returns></returns> public Stream ResolveIcon(string fileExtensionName, IconSize iconSize) { string iconManifestPath = string.Empty; switch (iconSize) { case IconSize.Pixel16x16: iconManifestPath = string.Format(SmallIconManifestPathTemplate, fileExtensionName.ToLower()); break; case IconSize.Pixel50x50: iconManifestPath = string.Format(LargeIconManifestPathTemplate, fileExtensionName.ToLower()); break; } Stream stream = typeof(FileIconApi).Assembly.GetManifestResourceStream(iconManifestPath); if (stream == null || stream.Length == 0) { switch (iconSize) { case IconSize.Pixel16x16: stream = typeof(FileIconApi).Assembly.GetManifestResourceStream(SmallMiscellaneousIconManifestPath); break; case IconSize.Pixel50x50: stream = typeof(FileIconApi).Assembly.GetManifestResourceStream(LargeMiscellaneousIconManifestPath); break; } } return stream; }
public thumbnailInfo(WriteableBitmap b, string path, IconSize size, int rol) { bitmap = b; fullPath = path; iconsize = size; roll = rol; }
/// <summary> /// Get system icon for specified folder/file /// </summary> /// <param name="path"> Full path to a folder or file </param> /// <param name="type"> Type: folder or file </param> /// <param name="size"> Icon size: small or large</param> /// <param name="isOpen"> Is open icon (applicable for folders only) </param> /// <returns></returns> public static Icon GetIcon(string path, ItemType type, IconSize size, bool isOpen) { var flags = SHGFI_ICON | SHGFI_USEFILEATTRIBUTES; var attribute = (type == ItemType.Folder) ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_FILE; if (isOpen) flags += SHGFI_OPENICON; if (size == IconSize.Small) flags += SHGFI_SMALLICON; else flags += SHGFI_LARGEICON; var shfi = new SHFileInfo(); var res = SHGetFileInfo(path, attribute, out shfi, (uint)Marshal.SizeOf(shfi), flags); if (Equals(res, IntPtr.Zero)) throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()); try { Icon.FromHandle(shfi.hIcon); return (Icon)Icon.FromHandle(shfi.hIcon).Clone(); } finally { DestroyIcon(shfi.hIcon); } }
/// <summary> /// The current Windows default Folder Icon in the given Size (Large/Small) as System.Drawing.Icon. /// </summary> /// <param name="size">The Size of the Icon (Small or Large).</param> /// <param name="folderType">The folderTypeIcon (closed or Open).</param> /// <returns>The Folder Icon as System.Drawing.Icon.</returns> public static Icon GetDefaultDirectoryIcon(IconSize size, FolderType folderType) { var flags = ShgfiIcon | ShgfiUsefileattributes; if (FolderType.Open == folderType) { flags += ShgfiOpenicon; } if (IconSize.Small == size) { flags += ShgfiSmallicon; } else { flags += ShgfiLargeicon; } var shfi = new Structs.Shfileinfo(); var res = DllImports.SHGetFileInfo(@"C:\Windows", FileAttributeDirectory, out shfi, (uint) Marshal.SizeOf(shfi), flags); if (res == IntPtr.Zero) { throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()); } Icon.FromHandle(shfi.hIcon); var icon = (Icon) Icon.FromHandle(shfi.hIcon).Clone(); DllImports.DestroyIcon(shfi.hIcon); return icon; }
protected Bitmap GetFileBasedFSBitmap(string ext, IconSize size) { string lookup = tempPath; Bitmap folderBitmap = KeyToBitmap(lookup, size); if (ext != "") { ext = ext.Substring(0, 1).ToUpper() + ext.Substring(1).ToLower(); using (Graphics g = Graphics.FromImage(folderBitmap)) { g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; Font font = new Font("Comic Sans MS", folderBitmap.Width / 5, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic); float height = g.MeasureString(ext, font).Height; float rightOffset = folderBitmap.Width / 5; if (size == IconSize.small) { font = new Font("Arial", 5, System.Drawing.FontStyle.Bold); height = g.MeasureString(ext, font).Height; rightOffset = 0; } g.DrawString(ext, font, System.Drawing.Brushes.Black, new RectangleF(0, folderBitmap.Height - height, folderBitmap.Width - rightOffset, height), new StringFormat(StringFormatFlags.DirectionRightToLeft)); } } return folderBitmap; }
private Icon GetFileIcon(string fileName, IconSize size) { IntPtr iconPtr; Icon ret = null; SHFILEINFO shinfo = new SHFILEINFO(); uint flags = Win32.SHGFI_ICON; /* Check the size specified for return. */ if (size == IconSize.Small) flags += Win32.SHGFI_SMALLICON; else flags += Win32.SHGFI_LARGEICON; iconPtr = Win32.SHGetFileInfo(fileName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), flags); if (iconPtr != IntPtr.Zero) { // Copy (clone) the returned icon to a new object, thus allowing us to clean-up properly ret = (System.Drawing.Icon)System.Drawing.Icon.FromHandle(shinfo.hIcon).Clone(); // Cleanup Win32.DestroyIcon(shinfo.hIcon); } return ret; }
public static Icon GetIcon(string path, ItemType type, IconSize size, ItemState state) { var flags = (uint)(Interop.SHGFI_ICON | Interop.SHGFI_USEFILEATTRIBUTES); var attribute = (uint)(object.Equals(type, ItemType.Folder) ? Interop.FILE_ATTRIBUTE_DIRECTORY : Interop.FILE_ATTRIBUTE_FILE); if (object.Equals(type, ItemType.Folder) && object.Equals(state, ItemState.Open)) { flags += Interop.SHGFI_OPENICON; } if (object.Equals(size, IconSize.Small)) { flags += Interop.SHGFI_SMALLICON; } else { flags += Interop.SHGFI_LARGEICON; } var shfi = new SHFileInfo(); var res = Interop.SHGetFileInfo(path, attribute, out shfi, (uint)Marshal.SizeOf(shfi), flags); if (object.Equals(res, IntPtr.Zero)) throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()); try { Icon.FromHandle(shfi.hIcon); return (Icon)Icon.FromHandle(shfi.hIcon).Clone(); } catch { throw; } finally { Interop.DestroyIcon(shfi.hIcon); } }
public Bitmap GetImage(IconSize imageSize) { if (!File.Exists(_imagePath)) return null; if (PathEx.HasExtension(_imagePath, FileExtensions.Executable) || PathEx.HasExtension(_imagePath, FileExtensions.Shortcut) || PathEx.HasExtension(_imagePath, FileExtensions.Icon)) { return GetIcon(imageSize); } try { return new Bitmap(_imagePath); } catch (ArgumentException ex) { // Unable to convert to an image, assume it's an exe/ico/lnk file even though the extension is wrong. if (Log.IsDebugEnabled) Log.DebugFormat("Failed to convert {0} to a image, trying to convert to an icon instead: {1}", _imagePath, ex); return GetIcon(imageSize); } catch (IOException ex) { // Unable to convert to an image, assume it's an exe/ico/lnk file even though the extension is wrong. if (Log.IsDebugEnabled) Log.DebugFormat("Failed to convert {0} to a image, trying to convert to an icon instead: {1}", _imagePath, ex); return GetIcon(imageSize); } }
/// <summary> /// Returns an icon for a given file - indicated by the name parameter</summary> /// <param name="name">Pathname for file</param> /// <param name="size">Large or small icon</param> /// <param name="linkOverlay">Whether to include the link icon</param> /// <returns>Icon</returns> public static Icon GetFileIcon(string name, IconSize size, bool linkOverlay) { Shell32.SHFILEINFO shfi = new Shell32.SHFILEINFO(); uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; if (linkOverlay) flags += Shell32.SHGFI_LINKOVERLAY; // Check the size specified for return. if (IconSize.Small == size) { flags += Shell32.SHGFI_SMALLICON; } else { flags += Shell32.SHGFI_LARGEICON; } Shell32.SHGetFileInfo(name, Shell32.FILE_ATTRIBUTE_NORMAL, ref shfi, (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi), flags); // Copy (clone) the returned icon to a new object, thus allowing us to clean-up properly Icon icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone(); User32.DestroyIcon(shfi.hIcon); // Cleanup return icon; }
public TextBoxToolbarItem(ITextBoxAction action, IconSize iconSize) { _action = action; _actionEnabledChangedHandler = new EventHandler(OnActionEnabledChanged); _actionVisibleChangedHandler = new EventHandler(OnActionVisibleChanged); _actionAvailableChangedHandler = new EventHandler(OnActionAvailableChanged); _actionLabelChangedHandler = new EventHandler(OnActionLabelChanged); _actionTooltipChangedHandler = new EventHandler(OnActionTooltipChanged); _actionIconSetChangedHandler = new EventHandler(OnActionIconSetChanged); _actionTextBoxValueChangedHandler = new EventHandler(OnActionTextBoxValueChanged); _actionCueTextChangedHandler = new EventHandler(OnActionCueTextChanged); _action.EnabledChanged += _actionEnabledChangedHandler; _action.VisibleChanged += _actionVisibleChangedHandler; _action.AvailableChanged += _actionAvailableChangedHandler; _action.LabelChanged += _actionLabelChangedHandler; _action.TooltipChanged += _actionTooltipChangedHandler; _action.IconSetChanged += _actionIconSetChangedHandler; _action.TextValueChanged += _actionTextBoxValueChangedHandler; _action.CueTextChanged += _actionCueTextChangedHandler; _iconSize = iconSize; this.Text = _action.TextValue; this.Enabled = _action.Enabled; SetTooltipText(); UpdateCueBanner(); UpdateVisibility(); UpdateEnablement(); UpdateIcon(); }
public static Bitmap GetIconData(string iconId, IconSize iconSize) { var hash = StockIconCodon.ComputeHashCode(iconId, iconSize); if (IconData.ContainsKey(hash)) return IconData[hash]; if (!IconStock.ContainsKey(hash)) throw new Exception("Icon "+iconId+" not available!"); var iconCodon = IconStock[hash]; if (!string.IsNullOrEmpty (iconCodon.Resource) || !string.IsNullOrEmpty (iconCodon.File)) { Bitmap bitmap; Stream stream; if (iconCodon.Resource != null) stream = iconCodon.Addin.GetResource (iconCodon.Resource); else stream = File.OpenRead (iconCodon.Addin.GetFilePath (iconCodon.File)); using (stream) { if (stream == null || stream.Length < 0) { throw new Exception(string.Format("Did not find resource '{0}' in addin '{1}' for icon '{2}'", iconCodon.Resource, iconCodon.Addin.Id, iconCodon.StockId)); } bitmap = (Bitmap) Image.FromStream(stream); } IconData[hash] = bitmap; } return IconData[hash]; }
public static System.Drawing.Icon GetFolderIcon(string name, IconSize size, FolderType folderType) { Shell32.SHFILEINFO shfi = new Shell32.SHFILEINFO(); uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; if (FolderType.Open == folderType) { flags += Shell32.SHGFI_OPENICON; } //if (true == linkOverlay) flags += Shell32.SHGFI_LINKOVERLAY; /* Check the size specified for return. */ if (IconSize.Small == size) { flags += Shell32.SHGFI_SMALLICON; } else { flags += Shell32.SHGFI_LARGEICON; } Shell32.SHGetFileInfo(name, Shell32.FILE_ATTRIBUTE_DIRECTORY, ref shfi, (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi), flags); // Copy (clone) the returned icon to a new object, thus allowing us to clean-up properly System.Drawing.Icon icon = (System.Drawing.Icon)System.Drawing.Icon.FromHandle(shfi.hIcon).Clone(); User32.DestroyIcon(shfi.hIcon); // Cleanup return icon; }
public thumbnailInfo(WriteableBitmap b, string k, IconSize size, int rol) { bitmap = b; key = k; iconsize = size; roll = rol; }
public static ImageSource GetDirectoryIcon(string path, int iconIndex, IconSize size = IconSize.Small) { ImageSource imageSource = null; if (IconsDictionary.TryGetValue(iconIndex, out imageSource)) { return imageSource; } Int32Rect sizeRect; WinAPI.SHGFI flags; if (IconSize.Small == size) { flags = commonFlags | WinAPI.SHGFI.SHGFI_SMALLICON; sizeRect = new Int32Rect(0, 0, 16, 16); } else { flags = commonFlags | WinAPI.SHGFI.SHGFI_LARGEICON; sizeRect = new Int32Rect(0, 0, 32, 32); } WinAPI.SHFILEINFO shfileinfo = new WinAPI.SHFILEINFO(); WinAPI.SHGetFileInfo(path, 256, out shfileinfo, (uint) Marshal.SizeOf(shfileinfo), flags); if (shfileinfo.hIcon == IntPtr.Zero) { return GetIcon(path); } imageSource = Imaging.CreateBitmapSourceFromHIcon(shfileinfo.hIcon, sizeRect, BitmapSizeOptions.FromEmptyOptions()); IconsDictionary.Add(iconIndex, imageSource); WinAPI.DestroyIcon(shfileinfo.hIcon); shfileinfo.hIcon = IntPtr.Zero; return imageSource; }
/// <summary> /// Get Windows-Icon for the Extension of a file /// </summary> /// <param name="Extension">ext of tile</param> /// <param name="Size">IconSize</param> /// <returns>Icon for this extension</returns> public static Icon IconFromExtension(string Extension, IconSize Size) { Icon icon = null; try { //add '.' if necessary if (Extension[0] != '.') Extension = '.' + Extension; //search registry for the file extension RegistryKey Root = Registry.ClassesRoot; RegistryKey ExtensionKey = Root.OpenSubKey(Extension); ExtensionKey.GetValueNames(); RegistryKey appKey = Root.OpenSubKey(ExtensionKey.GetValue("").ToString()); //gets the name of the file that has the icon. string IconLocation = appKey.OpenSubKey("DefaultIcon").GetValue("").ToString(); string[] IconPath = IconLocation.Split(','); if (IconPath[1] == null) IconPath[1] = "0"; IntPtr[] Large = new IntPtr[1]; IntPtr[] Small = new IntPtr[1]; //extracts the icon from the file. ExtractIconEx(IconPath[0], Convert.ToInt16(IconPath[1]), Large, Small, 1); icon = Size == IconSize.Large ? Icon.FromHandle(Large[0]) : Icon.FromHandle(Small[0]); } catch (Exception e) { Util.Debug("Icon konnte nicht extrahiert werden!", e); } return icon; }
/// <summary> /// Returns an icon for a given file - indicated by the name parameter. /// </summary> /// <param name="name">Pathname for file.</param> /// <param name="size">Large or small</param> /// <param name="linkOverlay">Whether to include the link icon</param> /// <returns>Icon</returns> public static Icon GetFileIcon(string name, IconSize size, bool linkOverlay) { var shfi = new Shell32.SHFILEINFO(); var flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; if (linkOverlay) flags += Shell32.SHGFI_LINKOVERLAY; /* Check the size specified for return. */ if (IconSize.Small == size) { flags += Shell32.SHGFI_SMALLICON; } else { flags += Shell32.SHGFI_LARGEICON; } //Shell32.SHGetFileInfo(name, // Shell32.FILE_ATTRIBUTE_NORMAL, // ref shfi, // (uint)Marshal.SizeOf(shfi), // flags); //// Copy (clone) the returned icon to a new object, thus allowing us to clean-up properly //var icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone(); //User32.DestroyIcon(shfi.hIcon); // Cleanup //return icon; return GetIcon(flags, name, Shell32.FILE_ATTRIBUTE_NORMAL); }
public static Size GetSize(IconSize iconSize) { if (iconSize == IconSize.Small) return Small; if (iconSize == IconSize.Medium) return Medium; return Large; }
public thumbnailInfo(WriteableBitmap b, string k, IconSize size, System.Drawing.Size outSize, int rol) { bitmap = b; key = k; iconsize = size; outputSize = outSize; roll = rol; }
/* To get the above int values, pass the four char code thru this: public static int C (string code) { return ((int)code[0]) << 24 | ((int)code[1]) << 16 | ((int)code[2]) << 8 | ((int)code[3]); } */ public static SizeF ToIconSize(IconSize size) { switch (size) { case IconSize.Small: return new SizeF (16f, 16f); case IconSize.Large: return new SizeF (64f, 64f); } return new SizeF (32f, 32f); }
public VolumeButton(double min, double max, double step, IconSize size) : base() { this.size = size; BuildButton(); BuildPopup(min, max, step); }
/// <summary> /// Obtiene la imagen de un icono para un messagebox /// a partir de su tipo y tama�o /// </summary> /// <param name="_MessageBoxIcon">Tipo del MessageBoxIcon</param> /// <param name="pIconSize">Tama�o del icono</param> /// <returns>Imagen resultante.</returns> public static Image GetMessageBoxIcon(Fwk.UI.Common.MessageBoxIcon _MessageBoxIcon, IconSize pIconSize) { Image imgIcon = null; switch (_MessageBoxIcon) { case Fwk.UI.Common.MessageBoxIcon.Exclamation: { imgIcon = (Image) Epiron.Front.Bases.Properties.Resources.ResourceManager.GetObject( string.Concat("exclamation_", (int)pIconSize)); break; } case Fwk.UI.Common.MessageBoxIcon.Warning: { imgIcon = (Image) Epiron.Front.Bases.Properties.Resources.ResourceManager.GetObject( string.Concat("warning_", (int)pIconSize)); break; } case Fwk.UI.Common.MessageBoxIcon.Question: { imgIcon = (Image) Epiron.Front.Bases.Properties.Resources.ResourceManager.GetObject( string.Concat("question_", (int)pIconSize)); break; } case Fwk.UI.Common.MessageBoxIcon.Error: { imgIcon = (Image) Epiron.Front.Bases.Properties.Resources.ResourceManager.GetObject( string.Concat("error_", (int)pIconSize)); break; } case Fwk.UI.Common.MessageBoxIcon.Information: { imgIcon = (Image) Epiron.Front.Bases.Properties.Resources.ResourceManager.GetObject( string.Concat("information_", (int)pIconSize)); break; } } return imgIcon; }
public static int GetIconSize(IconSize icon_size) { int width, height; if (Icon.SizeLookup (icon_size, out width, out height)) { return width; } return DEFAULT_MENU_ICON_SIZE; }
public override object LoadFromIcon(string id, IconSize size) { NSImage img; if (!stockIcons.TryGetValue (id + size, out img)) { img = LoadStockIcon (id, size); stockIcons [id + size] = img; } return img; }
private Hashtable GetLookupTable(IconSize size) { Hashtable htIcons = (Hashtable)htSizes[size]; if (htIcons == null) { htIcons = new Hashtable(); htSizes[size] = htIcons; } return htIcons; }
public static ImageSource GetFileIcon(string path, int iconIndex, IconSize size = IconSize.Small) { ImageSource imageSource = null; if(iconIndex == 0) { return GetIcon(path); } return GetDirectoryIcon(path, iconIndex, size); }
Dictionary<object, Icon> GetLookupTable(IconSize size) { Dictionary<object, Icon> htIcons; if (!htSizes.TryGetValue(size, out htIcons)) { htIcons = new Dictionary<object, Icon>(); htSizes.Add(size, htIcons); } return htIcons; }
protected IconBlockItem(IconSize size, IconColor color, IconShape shape) { Size = size; Color = color; Shape = shape; }
public static System.Drawing.Icon GetUnkownFileTypeIcon(IconSize _iconSize) { String iconLocation = String.Empty; System.Drawing.Icon icon = null; //opens the registry for the wanted key. RegistryKey registryKeyRoot = Registry.ClassesRoot; RegistryKey registryKeyUnknown = registryKeyRoot.OpenSubKey("Unknown"); RegistryKey registryKeyDefaultIcon = registryKeyUnknown.OpenSubKey("DefaultIcon"); if (registryKeyDefaultIcon != null) { //Get the file contains the icon and the index of the icon in that file. Object value = registryKeyDefaultIcon.GetValue(""); if (value != null) { // Clear all unnecessary " sign in the string to avoid error. iconLocation = value.ToString().Replace("\"", ""); } registryKeyDefaultIcon.Close(); } registryKeyUnknown.Close(); registryKeyRoot.Close(); String[] iconPath = iconLocation.Split(','); IntPtr[] large = null; IntPtr[] small = null; int iIconPathNumber = 0; if (iconPath.Length > 1) { iIconPathNumber = 1; } else { iIconPathNumber = 0; } if (iconPath[iIconPathNumber] == null) { iconPath[iIconPathNumber] = "0"; } large = new IntPtr[1]; small = new IntPtr[1]; //extracts the icon from the file. if (iIconPathNumber > 0) { API.ExtractIconEx(iconPath[0], Convert.ToInt16(iconPath[iIconPathNumber]), large, small, 1); } else { API.ExtractIconEx(iconPath[0], Convert.ToInt16(0), large, small, 1); } try { switch (_iconSize) { case IconSize.Small: icon = System.Drawing.Icon.FromHandle(small[0]); break; case IconSize.Large: icon = System.Drawing.Icon.FromHandle(large[0]); break; } } catch (Exception) { return(null); } return(icon); return(icon); }
public int GetIcon_Assembly(IconSize size) => Assembly.GetExecutingAssembly().GetIcon(size).Width;
public thumbnailInfo(WriteableBitmap b, string path, IconSize size) { bitmap = b; fullPath = path; iconsize = size; }
public int GetIcon_FileInfo(string path, IconSize size) => new System.IO.FileInfo(path).GetIcon(size).Width;
static Xwt.Drawing.Image GetIcon(string id, IconSize size) { return(ImageService.GetIcon(id, size)); }
/// <summary> /// Converts the specified value. /// </summary> /// <param name="values">The value.</param> /// <param name="targetType">Type of the target.</param> /// <param name="parameter">The parameter.</param> /// <param name="culture">The culture.</param> /// <returns></returns> public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values == null) { return(Binding.DoNothing); } if (values.Length < 1) { return(Binding.DoNothing); } string path = values[0] as string; string secPath = null; string iconResourceId = null; if (values.Length == 2) { iconResourceId = values[1] as string; } else { if (values.Length >= 3) { secPath = values[1] as string; iconResourceId = values[2] as string; } } if (string.IsNullOrEmpty(path) == true) // Try secondary path if available { path = secPath; } if (path == null) { return(Binding.DoNothing); } IconSize iconSize = AssociatedIconConverter.DefaultIconSize; if (parameter is IconSize) { iconSize = (IconSize)parameter; } if (string.IsNullOrEmpty(path) == false) { try { // The resource for loading this item's icon is known // So, we attempt to extract and display it if (iconResourceId != null) { string[] resourceId = iconResourceId.Split(','); int iconIndex = int.Parse(resourceId[1]); if (resourceId != null && resourceId.Length == 2) { if (string.IsNullOrEmpty(resourceId[0]) == false) { if (IsReferenceToUnknownIcon(resourceId[0], iconIndex) == false) { return(Extract(resourceId[0], iconIndex, iconSize)); } } else { Debug.WriteLine(string.Format("---> 0 Failed to get icon from '{0}' with '{1}'", path, iconResourceId)); } } } } catch (Exception exception) { Debug.WriteLine(string.Format("---> 1 Failed to get icon from {0}: {1}{2}", path, Environment.NewLine, exception.ToString())); } try { // The resource for loading this item's icon is unknown // So, we attempt to determine the associated icon and load it return(GetIconFromPath(path, iconSize)); } catch (Exception exception) { Debug.WriteLine(string.Format("---> 2 Failed to get icon from {0}: {1}{2}", path, Environment.NewLine, exception.ToString())); } } return(null); }
public abstract Icon GetIcon(SystemIcons icons, IconSize iconSize);
/// <summary> /// Return a normal folder icon /// </summary> public static Icon GetFolderIcon(IconSize size, FolderType folderType) { return(GetFolderIcon(null, size, folderType)); }
extern static void gtk_icon_size_lookup(IconSize size, out int width, out int height);
public MapIconBlockItem(IconSize size, IconColor iconColor, IconShape iconShape) : base(size, iconColor, iconShape) { }
/// <summary> Query icon dimensions </summary> /// <remarks> Queries dimensions for icons of the specified size. </remarks> public void LookupIconSize(IconSize size, out int width, out int height) { gtk_icon_size_lookup(size, out width, out height); }
Bitmap GetIcon(IconSize imageSize) { // Attempt to extract the icon from the file if (imageSize == IconSize.Medium) { return(Icon.ExtractAssociatedIcon(_imagePath).ToBitmap()); } MultiIcon multicon = new MultiIcon(); try { multicon.Load(_imagePath); } catch (InvalidFileException ex) { if (Log.IsDebugEnabled) { Log.DebugFormat("Failed to get icons from {0}, using default application icon, got exception\n{1}", _imagePath, ex); } return(Icon.ExtractAssociatedIcon(_imagePath).ToBitmap()); } IconImage largeImage = null; IconImage smallImage = null; if (multicon.Count > 0) { SingleIcon icon = multicon[0]; foreach (IconImage iconImage in icon) { // Ignore low quality icons (they look ugly), really big icons (don't need them that big, saves memory) // or really small ones. if (!IsLowQuality(iconImage) && iconImage.Size.Height <= Huge && iconImage.Size.Height >= Small) { if (largeImage == null) { largeImage = iconImage; } if (smallImage == null) { smallImage = iconImage; } if (iconImage.Size.Height > largeImage.Size.Height) { largeImage = iconImage; } if (iconImage.Size.Height < smallImage.Size.Height) { smallImage = iconImage; } } } } if (imageSize == IconSize.Small && smallImage != null) { return(smallImage.Transparent); } if (imageSize == IconSize.Large && largeImage != null) { return(largeImage.Transparent); } return(Icon.ExtractAssociatedIcon(_imagePath).ToBitmap()); }
public HoverImageButton(IconSize size, string icon_name) : this(size, new string [] { icon_name }) { }
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, IconSize componentIconSize, IconColor componentIconColor, IconShape componentIconShape) { if (ComponentExists(componentType, componentName)) { return(Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType)); } var component = new IconThemeComponent(componentType, componentName, componentIconSize, componentIconColor, componentIconShape); Items.Add(component); return(component); }
public HoverImageButton(IconSize size, params string [] icon_names) : this() { this.icon_size = size; this.icon_names = icon_names; }
/// <summary> /// Constructor. /// </summary> /// <param name="action">The associated <see cref="IAction"/>.</param> /// <param name="iconSize">The initial icon size.</param> public ActionViewContext(IAction action, IconSize iconSize) { Platform.CheckForNullReference(action, "action"); _action = action; _iconSize = iconSize; }
public override Icon GetIcon(IconSize iconSize) { return(SystemIcons.GetFileIcon(Name, iconSize)); }
public int GetIcon_StockIcon(StockIcons id, IconSize size) => id.GetIcon(size).Width;
public string MapResource(Icon icon, Color color, IconSize iconSize = IconSize.Medium) { var builder = new StringBuilder(); builder.Append("ic_"); switch (icon) { case Icon.Add: builder.Append("add"); break; case Icon.AddBox: builder.Append("add_box"); break; case Icon.AddCircle: builder.Append("add_circle"); break; case Icon.Alarm: builder.Append("alarm_on"); break; case Icon.Account: builder.Append("account_circle"); break; case Icon.Calendar: builder.Append("perm_contact_calendar"); break; case Icon.Clock: builder.Append("access_time"); break; case Icon.Email: builder.Append("email"); break; case Icon.Refresh: builder.Append("autorenew"); break; case Icon.International: builder.Append("language"); break; case Icon.Flight: case Icon.Airport: builder.Append("flight"); break; case Icon.Hospital: builder.Append("local_hospital"); break; case Icon.Settings: builder.Append("settings"); break; case Icon.School: builder.Append("school"); break; case Icon.Restaurant: builder.Append("local_dining"); break; case Icon.Hotel: builder.Append("local_hotel"); break; case Icon.Phone: builder.Append("phone"); break; case Icon.Train: builder.Append("directions_subway"); break; case Icon.Bed: builder.Append("local_hotel"); break; case Icon.Home: case Icon.House: builder.Append("home"); break; case Icon.Broadband: case Icon.Wifi: builder.Append("wifi"); break; case Icon.Taxi: case Icon.Police: builder.Append("local_taxi"); break; case Icon.Money: case Icon.Currency: builder.Append("attach_money"); break; default: builder.Append("home"); break; } if (color == Color.White) { builder.Append("_white"); } if (iconSize == IconSize.Medium) { builder.Append("_2x"); } if (iconSize == IconSize.Large) { builder.Append("_3x"); } builder.Append(".png"); return(builder.ToString()); }
public int GetIcon_IInformation(string path, IconSize size) => new Cube.FileSystem.AfsIO().Get(path).GetIcon(size).Width;
/// <summary> /// Returns the display icon to use for a given file. /// </summary> /// <param name="fileName">The full path of the file to get the icon for</param> /// <param name="size">The size of the icon to get</param> /// <param name="shortcut">If true draw the short cut arrow</param> /// <returns>The icon for the given file</returns> public static Icon GetFileIcon(string fileName, IconSize size, bool shortcut) { return(GetIcon(fileName, FILE_ATTRIBUTE_NORMAL, size, (shortcut) ? SHGFI_LINKOVERLAY : 0)); }
/// <summary> /// Generates the ImageSource which is used for folders /// </summary> /// <param name="_iconSize">The size of the icon</param> /// <param name="_folderType">The type of the folder icon</param> /// <returns>Retunrs the ImageSource of the folder icon</returns> private static ImageSource GetFolderImageSource(IconSize _iconSize, FolderType _folderType) { System.Drawing.Icon icon = IconManager.GetFolderIcon(_iconSize, _folderType); return(ShellIcon.toImageSource(icon)); }
/// <summary> /// Return the display icon to use for a given folder /// </summary> /// <param name="folderName">The full path of the folder</param> /// <param name="size">The size of icon to get</param> /// <param name="open">Is the folder open or closed</param> /// <returns>The icon to use</returns> public static Icon GetFolderIcon(string folderName, IconSize size, bool open) { return(GetIcon(folderName, FILE_ATTRIBUTE_DIRECTORY, size, (open) ? SHGFI_OPENICON : 0)); }
public static System.Drawing.Icon GetFileIconFromExtension(String _extension, IconSize _size) { String iconLocation = String.Empty; // Add the '.' to the extension if needed if (_extension[0] != '.') { _extension = String.Format(".{0}", _extension); } //opens the registry for the wanted key. RegistryKey registryKeyRoot = Registry.ClassesRoot; RegistryKey registryKeyFileType = registryKeyRoot.OpenSubKey(_extension); if (registryKeyFileType == null) { return(IconManager.GetUnkownFileTypeIcon(_size)); } //Gets the default value of this key that contains the information of file type. Object defaultValue = registryKeyFileType.GetValue(""); if (defaultValue == null) { return(IconManager.GetUnkownFileTypeIcon(_size)); } //Go to the key that specifies the default icon associates with this file type. String defaultIcon = String.Format("{0}\\DefaultIcon", defaultValue.ToString()); RegistryKey registryKeyFileIcon = registryKeyRoot.OpenSubKey(defaultIcon); if (registryKeyFileIcon != null) { //Get the file contains the icon and the index of the icon in that file. Object value = registryKeyFileIcon.GetValue(""); if (value != null) { // Clear all unnecessary " sign in the string to avoid error. iconLocation = value.ToString().Replace("\"", ""); } registryKeyFileIcon.Close(); } else { return(IconManager.GetUnkownFileTypeIcon(_size)); } registryKeyFileType.Close(); registryKeyRoot.Close(); String[] iconPath = iconLocation.Split(','); IntPtr[] large = null; IntPtr[] small = null; int iIconPathNumber = 0; if (iconPath.Length > 1) { iIconPathNumber = 1; } else { iIconPathNumber = 0; } if (iconPath[iIconPathNumber] == null) { iconPath[iIconPathNumber] = "0"; } large = new IntPtr[1]; small = new IntPtr[1]; //extracts the icon from the file. if (iIconPathNumber > 0) { API.ExtractIconEx(iconPath[0], Convert.ToInt16(iconPath[iIconPathNumber]), large, small, 1); } else { API.ExtractIconEx(iconPath[0], Convert.ToInt16(0), large, small, 1); } System.Drawing.Icon icon = null; try { switch (_size) { case IconSize.Small: icon = System.Drawing.Icon.FromHandle(small[0]); break; case IconSize.Large: icon = System.Drawing.Icon.FromHandle(large[0]); break; } } catch (Exception) { return(IconManager.GetUnkownFileTypeIcon(_size)); } return(icon); }
/// <summary> /// Return the display icon to use for a given drive /// </summary> /// <param name="driveName">The full path of the drive</param> /// <param name="size">The size of icon to get</param> /// <returns>The icon to use</returns> public static Icon GetDriveIcon(string driveName, IconSize size) { return(GetIcon(driveName, FILE_ATTRIBUTE_DEVICE, size, 0)); }
public static ImageSource GetFileImageSourceFromExtension(String _extension, IconSize _size) { System.Drawing.Icon icon = IconManager.GetFileIconFromExtension(_extension, _size); return(ShellIcon.toImageSource(icon)); }
public override string GetIconKey(IconSize iconSize, IResourceResolver resourceResolver) { return(base.GetIconKey(iconSize, resourceResolver) + "_ConvertedToGrayscale"); }
public MaterialCardCurrent(IconSize s, IconTheme t) { InitializeComponent(); icons = new Icons(s, t); }
public bool Equals([AllowNull] Symbol other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return((Icon == other.Icon && Icon != null && other.Icon != null && Icon.Equals(other.Icon)) && (IconSize == other.IconSize && IconSize != null && other.IconSize != null && IconSize.Equals(other.IconSize)) && (Text == other.Text && Text != null && other.Text != null && Text.Equals(other.Text)) && (Placement == other.Placement && Placement != null && other.Placement != null && Placement.Equals(other.Placement)) && (TextFont == other.TextFont && TextFont != null && other.TextFont != null && TextFont.Equals(other.TextFont)) && (TextPosition == other.TextPosition && TextPosition != null && other.TextPosition != null && TextPosition.Equals(other.TextPosition))); }