/// <summary> /// Extracts the icon of an existing file or folder on the system and adds the icon to an imagelist. /// </summary> /// <param name="fileName">A file or folder path to extract the icon from.</param> /// <param name="IconSizeZ">The size to extract.</param> /// <param name="selectedState">A flag to add the selected state of the icon.</param> /// <param name="openState">A flag to add the open state of the icon.</param> /// <param name="linkOverlay">A flag to add a shortcut overlay to the icon.</param> /// <param name="destinationImagelist">An existing imagelist to add the extracted icon to.</param> /// <example>.AddIconOfFile( "C:\\folder\file.exe", Narbware.IconSizeZ.Small, false, false, false, toolbarImageList );</example> public static void AddIconOfFile(string fileName, IconSizeZ IconSizeZ, bool selectedState, bool openState, bool linkOverlay, ImageList destinationImagelist) { uint uFlags = ((IconSizeZ == IconSizeZ.Large) ? SHGFI_LARGEICON : 0) | ((IconSizeZ == IconSizeZ.Small) ? SHGFI_SMALLICON : 0) | ((IconSizeZ == IconSizeZ.Shell) ? SHGFI_SHELLICONSIZE : 0) | ((selectedState) ? SHGFI_SELECTED : 0) | ((openState) ? SHGFI_OPENICON : 0) | ((linkOverlay) ? SHGFI_LINKOVERLAY : 0); Add(fileName, destinationImagelist, uFlags); }
/// <summary> /// Extracts a file extension icon from the system and adds the icon to an imagelist. /// </summary> /// <param name="fileExtension">A file extension to extract the icon from.</param> /// <param name="IconSizeZ">The size to extract.</param> /// <param name="selectedState">A flag to add the selected state of the icon.</param> /// <param name="openState">A flag to add the open state of the icon.</param> /// <param name="linkOverlay">A flag to add a shortcut overlay to the icon.</param> /// <param name="destinationImagelist">An existing imagelist to add the extracted icon to.</param> /// <example>.AddIconOfFileExt( ".jpg", Narbware.IconSizeZ.Large, false, false, false, toolbarImagelist );</example> public static void AddIconOfFileExt(string fileExtension, IconSizeZ IconSizeZ, bool selectedState, bool openState, bool linkOverlay, ImageList destinationImagelist) { uint uFlags = SHGFI_USEFILEATTRIBUTES | ((IconSizeZ == IconSizeZ.Large) ? SHGFI_LARGEICON : 0) | ((IconSizeZ == IconSizeZ.Small) ? SHGFI_SMALLICON : 0) | ((IconSizeZ == IconSizeZ.Shell) ? SHGFI_SHELLICONSIZE : 0) | ((selectedState) ? SHGFI_SELECTED : 0) | ((openState) ? SHGFI_OPENICON : 0) | ((linkOverlay) ? SHGFI_LINKOVERLAY : 0); Add(fileExtension.Insert(0, "."), destinationImagelist, uFlags); }
/// <summary> /// Extracts a file extension icon from the system and adds the icon to an imagelist. /// </summary> /// <param name="fileExtension">A file extension to extract the icon from.</param> /// <param name="IconSizeZ">The size to extract.</param> /// <param name="selectedState">A flag to add the selected state of the icon.</param> /// <param name="openState">A flag to add the open state of the icon.</param> /// <param name="linkOverlay">A flag to add a shortcut overlay to the icon.</param> /// <param name="destinationImagelist">An existing imagelist to add the extracted icon to.</param> /// <example>.AddIconOfFileExt( ".jpg", Narbware.IconSizeZ.Large, false, false, false, toolbarImagelist );</example> public static void AddIconOfFileExt(string fileExtension, IconSizeZ IconSizeZ, bool selectedState, bool openState, bool linkOverlay, ImageList destinationImagelist) { uint uFlags = SHGFI_USEFILEATTRIBUTES | ((IconSizeZ == IconSizeZ.Large) ? SHGFI_LARGEICON : 0) | ((IconSizeZ == IconSizeZ.Small) ? SHGFI_SMALLICON : 0) | ((IconSizeZ == IconSizeZ.Shell) ? SHGFI_SHELLICONSIZE : 0) | ((selectedState) ? SHGFI_SELECTED : 0) | ((openState) ? SHGFI_OPENICON : 0) | ((linkOverlay) ? SHGFI_LINKOVERLAY : 0); Add(fileExtension.Insert(0, "."), destinationImagelist, uFlags); }
/// <summary> /// Extracts the icon of an existing file or folder on the system and adds the icon to an imagelist. /// </summary> /// <param name="fileName">A file or folder path to extract the icon from.</param> /// <param name="IconSizeZ">The size to extract.</param> /// <param name="selectedState">A flag to add the selected state of the icon.</param> /// <param name="openState">A flag to add the open state of the icon.</param> /// <param name="linkOverlay">A flag to add a shortcut overlay to the icon.</param> /// <param name="destinationImagelist">An existing imagelist to add the extracted icon to.</param> /// <example>.AddIconOfFile( "C:\\folder\file.exe", Narbware.IconSizeZ.Small, false, false, false, toolbarImageList );</example> public static void AddIconOfFile(string fileName, IconSizeZ IconSizeZ, bool selectedState, bool openState, bool linkOverlay, ImageList destinationImagelist) { uint uFlags = ((IconSizeZ == IconSizeZ.Large) ? SHGFI_LARGEICON : 0) | ((IconSizeZ == IconSizeZ.Small) ? SHGFI_SMALLICON : 0) | ((IconSizeZ == IconSizeZ.Shell) ? SHGFI_SHELLICONSIZE : 0) | ((selectedState) ? SHGFI_SELECTED : 0) | ((openState) ? SHGFI_OPENICON : 0) | ((linkOverlay) ? SHGFI_LINKOVERLAY : 0); Add(fileName, destinationImagelist, uFlags); }