Summary description for SysImageList.
Наследование: IDisposable
Пример #1
0
        public int IconIndex(string fileName, bool forceLoadFromDisk, ShellIconStateConstants iconState)
        {
            SysImageList.SHGetFileInfoConstants sHGetFileInfoConstants = SysImageList.SHGetFileInfoConstants.SHGFI_SYSICONINDEX;
            if (this.size == SysImageListSize.smallIcons)
            {
                sHGetFileInfoConstants |= SysImageList.SHGetFileInfoConstants.SHGFI_SMALLICON;
            }
            int dwFileAttributes;

            if (!forceLoadFromDisk)
            {
                sHGetFileInfoConstants |= SysImageList.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES;
                dwFileAttributes        = 128;
            }
            else
            {
                dwFileAttributes = 0;
            }
            SysImageList.SHFILEINFO sHFILEINFO = default(SysImageList.SHFILEINFO);
            uint   cbFileInfo = (uint)Marshal.SizeOf(sHFILEINFO.GetType());
            IntPtr intPtr     = SysImageList.SHGetFileInfo(fileName, dwFileAttributes, ref sHFILEINFO, cbFileInfo, (uint)(sHGetFileInfoConstants | (SysImageList.SHGetFileInfoConstants)iconState));
            int    result;

            if (intPtr.Equals(IntPtr.Zero))
            {
                Debug.Assert(!intPtr.Equals(IntPtr.Zero), "Failed to get icon index");
                result = 0;
            }
            else
            {
                result = sHFILEINFO.iIcon;
            }
            return(result);
        }
Пример #2
0
 public void DrawImage(IntPtr hdc, int index, int x, int y, ImageListDrawItemConstants flags, int cx, int cy, Color foreColor, ImageListDrawStateConstants stateFlags, Color saturateColorOrAlpha, Color glowOrShadowColor)
 {
     SysImageList.IMAGELISTDRAWPARAMS iMAGELISTDRAWPARAMS = default(SysImageList.IMAGELISTDRAWPARAMS);
     iMAGELISTDRAWPARAMS.hdcDst = hdc;
     iMAGELISTDRAWPARAMS.cbSize = Marshal.SizeOf(iMAGELISTDRAWPARAMS.GetType());
     iMAGELISTDRAWPARAMS.i      = index;
     iMAGELISTDRAWPARAMS.x      = x;
     iMAGELISTDRAWPARAMS.y      = y;
     iMAGELISTDRAWPARAMS.cx     = cx;
     iMAGELISTDRAWPARAMS.cy     = cy;
     iMAGELISTDRAWPARAMS.rgbFg  = Color.FromArgb(0, (int)foreColor.R, (int)foreColor.G, (int)foreColor.B).ToArgb();
     Console.WriteLine("{0}", iMAGELISTDRAWPARAMS.rgbFg);
     iMAGELISTDRAWPARAMS.fStyle = (int)flags;
     iMAGELISTDRAWPARAMS.fState = (int)stateFlags;
     if ((stateFlags & ImageListDrawStateConstants.ILS_ALPHA) == ImageListDrawStateConstants.ILS_ALPHA)
     {
         iMAGELISTDRAWPARAMS.Frame = (int)saturateColorOrAlpha.A;
     }
     else if ((stateFlags & ImageListDrawStateConstants.ILS_SATURATE) == ImageListDrawStateConstants.ILS_SATURATE)
     {
         saturateColorOrAlpha      = Color.FromArgb(0, (int)saturateColorOrAlpha.R, (int)saturateColorOrAlpha.G, (int)saturateColorOrAlpha.B);
         iMAGELISTDRAWPARAMS.Frame = saturateColorOrAlpha.ToArgb();
     }
     glowOrShadowColor            = Color.FromArgb(0, (int)glowOrShadowColor.R, (int)glowOrShadowColor.G, (int)glowOrShadowColor.B);
     iMAGELISTDRAWPARAMS.crEffect = glowOrShadowColor.ToArgb();
     if (this.iImageList == null)
     {
         iMAGELISTDRAWPARAMS.himl = this.hIml;
         int num = SysImageList.ImageList_DrawIndirect(ref iMAGELISTDRAWPARAMS);
     }
     else
     {
         this.iImageList.Draw(ref iMAGELISTDRAWPARAMS);
     }
 }
Пример #3
0
        public static void SetTreeViewImageList(TreeView treeView, SysImageList sysImageList, bool forStateImages)
        {
            IntPtr wParam = (IntPtr)0;

            if (forStateImages)
            {
                wParam = (IntPtr)2;
            }
            SysImageListHelper.SendMessage(treeView.Handle, 4361, wParam, sysImageList.Handle);
        }
Пример #4
0
        public static void SetListViewImageList(ListView listView, SysImageList sysImageList, bool forStateImages)
        {
            IntPtr wParam = (IntPtr)0;

            if (sysImageList.ImageListSize == SysImageListSize.smallIcons)
            {
                wParam = (IntPtr)1;
            }
            if (forStateImages)
            {
                wParam = (IntPtr)2;
            }
            SysImageListHelper.SendMessage(listView.Handle, 4099, wParam, sysImageList.Handle);
        }
Пример #5
0
        /// <summary>
        /// Associates a SysImageList with a TreeView control
        /// </summary>
        /// <param Name="treeView">TreeView control to associated ImageList with</param>
        /// <param Name="sysImageList">System Image List to associate</param>
        /// <param Name="forStateImages">Whether to add ImageList as StateImageList</param>
        public static void SetTreeViewImageList(
            TreeView treeView,
            SysImageList sysImageList,
            bool forStateImages
            )
        {
            IntPtr wParam = (IntPtr)TVSIL_NORMAL;

            if (forStateImages)
            {
                wParam = (IntPtr)TVSIL_STATE;
            }
            SendMessage(
                treeView.Handle,
                TVM_SETIMAGELIST,
                wParam,
                sysImageList.Handle);
        }
Пример #6
0
 public void DrawImage(IntPtr hdc, int index, int x, int y, ImageListDrawItemConstants flags)
 {
     if (this.iImageList == null)
     {
         int num = SysImageList.ImageList_Draw(this.hIml, index, hdc, x, y, (int)flags);
     }
     else
     {
         SysImageList.IMAGELISTDRAWPARAMS iMAGELISTDRAWPARAMS = default(SysImageList.IMAGELISTDRAWPARAMS);
         iMAGELISTDRAWPARAMS.hdcDst = hdc;
         iMAGELISTDRAWPARAMS.cbSize = Marshal.SizeOf(iMAGELISTDRAWPARAMS.GetType());
         iMAGELISTDRAWPARAMS.i      = index;
         iMAGELISTDRAWPARAMS.x      = x;
         iMAGELISTDRAWPARAMS.y      = y;
         iMAGELISTDRAWPARAMS.rgbFg  = -1;
         iMAGELISTDRAWPARAMS.fStyle = (int)flags;
         this.iImageList.Draw(ref iMAGELISTDRAWPARAMS);
     }
 }
Пример #7
0
        public Icon Icon(int index)
        {
            Icon   result = null;
            IntPtr intPtr = IntPtr.Zero;

            if (this.iImageList == null)
            {
                intPtr = SysImageList.ImageList_GetIcon(this.hIml, index, 1);
            }
            else
            {
                this.iImageList.GetIcon(index, 1, ref intPtr);
            }
            if (intPtr != IntPtr.Zero)
            {
                result = System.Drawing.Icon.FromHandle(intPtr);
            }
            return(result);
        }
Пример #8
0
 public void DrawImage(IntPtr hdc, int index, int x, int y, ImageListDrawItemConstants flags, int cx, int cy)
 {
     SysImageList.IMAGELISTDRAWPARAMS iMAGELISTDRAWPARAMS = default(SysImageList.IMAGELISTDRAWPARAMS);
     iMAGELISTDRAWPARAMS.hdcDst = hdc;
     iMAGELISTDRAWPARAMS.cbSize = Marshal.SizeOf(iMAGELISTDRAWPARAMS.GetType());
     iMAGELISTDRAWPARAMS.i      = index;
     iMAGELISTDRAWPARAMS.x      = x;
     iMAGELISTDRAWPARAMS.y      = y;
     iMAGELISTDRAWPARAMS.cx     = cx;
     iMAGELISTDRAWPARAMS.cy     = cy;
     iMAGELISTDRAWPARAMS.fStyle = (int)flags;
     if (this.iImageList == null)
     {
         iMAGELISTDRAWPARAMS.himl = this.hIml;
         int num = SysImageList.ImageList_DrawIndirect(ref iMAGELISTDRAWPARAMS);
     }
     else
     {
         this.iImageList.Draw(ref iMAGELISTDRAWPARAMS);
     }
 }
Пример #9
0
        /// <summary>
        /// Associates a SysImageList with a ListView control
        /// </summary>
        /// <param Name="listView">ListView control to associate ImageList with</param>
        /// <param Name="sysImageList">System Image List to associate</param>
        /// <param Name="forStateImages">Whether to add ImageList as StateImageList</param>
        public static void SetListViewImageList(
            ListView listView,
            SysImageList sysImageList,
            bool forStateImages
            )
        {
            IntPtr wParam = (IntPtr)LVSIL_NORMAL;

            if (sysImageList.ImageListSize == SysImageListSize.smallIcons)
            {
                wParam = (IntPtr)LVSIL_SMALL;
            }
            if (forStateImages)
            {
                wParam = (IntPtr)LVSIL_STATE;
            }
            SendMessage(
                listView.Handle,
                LVM_SETIMAGELIST,
                wParam,
                sysImageList.Handle);
        }
Пример #10
0
 private void create()
 {
     this.hIml = IntPtr.Zero;
     if (this.isXpOrAbove())
     {
         Guid guid = new Guid("46EB5926-582E-4017-9FDF-E8998DAA0950");
         int  num  = SysImageList.SHGetImageList((int)this.size, ref guid, ref this.iImageList);
         SysImageList.SHGetImageListHandle((int)this.size, ref guid, ref this.hIml);
     }
     else
     {
         SysImageList.SHGetFileInfoConstants sHGetFileInfoConstants = SysImageList.SHGetFileInfoConstants.SHGFI_SYSICONINDEX | SysImageList.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES;
         if (this.size == SysImageListSize.smallIcons)
         {
             sHGetFileInfoConstants |= SysImageList.SHGetFileInfoConstants.SHGFI_SMALLICON;
         }
         SysImageList.SHFILEINFO sHFILEINFO = default(SysImageList.SHFILEINFO);
         uint cbFileInfo = (uint)Marshal.SizeOf(sHFILEINFO.GetType());
         this.hIml = SysImageList.SHGetFileInfo(".txt", 128, ref sHFILEINFO, cbFileInfo, (uint)sHGetFileInfoConstants);
         Debug.Assert(this.hIml != IntPtr.Zero, "Failed to create Image List");
     }
 }
Пример #11
0
 /// <summary>
 /// Associates a SysImageList with a TreeView control
 /// </summary>
 /// <param name="treeView">TreeView control to associated ImageList with</param>
 /// <param name="sysImageList">System Image List to associate</param>
 /// <param name="forStateImages">Whether to add ImageList as StateImageList</param>
 public static void SetTreeViewImageList(
     TreeView treeView,
     SysImageList sysImageList,
     bool forStateImages
     )
 {
     IntPtr wParam = (IntPtr) TVSIL_NORMAL;
     if (forStateImages)
     {
         wParam = (IntPtr) TVSIL_STATE;
     }
     SendMessage(
         treeView.Handle,
         TVM_SETIMAGELIST,
         wParam,
         sysImageList.Handle);
 }
Пример #12
0
 /// <summary>
 /// Associates a SysImageList with a ListView control
 /// </summary>
 /// <param name="listView">ListView control to associate ImageList with</param>
 /// <param name="sysImageList">System Image List to associate</param>
 /// <param name="forStateImages">Whether to add ImageList as StateImageList</param>
 public static void SetListViewImageList(
     ListView listView,
     SysImageList sysImageList,
     bool forStateImages
     )
 {
     IntPtr wParam = (IntPtr) LVSIL_NORMAL;
     if (sysImageList.ImageListSize == SysImageListSize.smallIcons)
     {
         wParam = (IntPtr) LVSIL_SMALL;
     }
     if (forStateImages)
     {
         wParam = (IntPtr) LVSIL_STATE;
     }
     SendMessage(
         listView.Handle,
         LVM_SETIMAGELIST,
         wParam,
         sysImageList.Handle);
 }