Exemplo n.º 1
0
 /// <summary>
 /// Draws an image using the specified flags
 /// </summary>
 /// <param name="hdc">Device context to draw to</param>
 /// <param name="index">Index of image to draw</param>
 /// <param name="x">X Position to draw at</param>
 /// <param name="y">Y Position to draw at</param>
 /// <param name="flags">Drawing flags</param>
 public void DrawImage(IntPtr hdc, int index, int x, int y, ImageListDrawItemConstants flags)
 {
     if (this.imageList == null)
     {
         int ret = ImageList_Draw(
             this.himl,
             index,
             hdc,
             x,
             y,
             (int)flags);
     }
     else
     {
         IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
         pimldp.HdcDst        = hdc;
         pimldp.Size          = Marshal.SizeOf(pimldp.GetType());
         pimldp.Index         = index;
         pimldp.X             = x;
         pimldp.Y             = y;
         pimldp.ForegroundRgb = -1;
         pimldp.Style         = (int)flags;
         this.imageList.Draw(ref pimldp);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Draws an image using the specified flags and state on XP systems.
        /// </summary>
        /// <param Name="hdc">Device context to draw to</param>
        /// <param Name="index">Index of image to draw</param>
        /// <param Name="x">X Position to draw at</param>
        /// <param Name="y">Y Position to draw at</param>
        /// <param Name="flags">Drawing flags</param>
        /// <param Name="cx">Width to draw</param>
        /// <param Name="cy">Height to draw</param>
        /// <param Name="foreColor">Fore colour to blend with when using the
        /// ILD_SELECTED or ILD_BLEND25 flags</param>
        /// <param Name="stateFlags">State flags</param>
        /// <param Name="glowOrShadowColor">If stateFlags include ILS_GLOW, then
        /// the colour to use for the glow effect.  Otherwise if stateFlags includes
        /// ILS_SHADOW, then the colour to use for the shadow.</param>
        /// <param Name="saturateColorOrAlpha">If stateFlags includes ILS_ALPHA,
        /// then the alpha component is applied to the icon. Otherwise if
        /// ILS_SATURATE is included, then the (R,G,B) components are used
        /// to saturate the image.</param>
        public void DrawImage(
            IntPtr hdc,
            int index,
            int x,
            int y,
            ImageListDrawItemConstants flags,
            int cx,
            int cy,
            System.Drawing.Color foreColor,
            ImageListDrawStateConstants stateFlags,
            System.Drawing.Color saturateColorOrAlpha,
            System.Drawing.Color glowOrShadowColor
            )
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();

            pimldp.hdcDst = hdc;
            pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
            pimldp.i      = index;
            pimldp.x      = x;
            pimldp.y      = y;
            pimldp.cx     = cx;
            pimldp.cy     = cy;
            pimldp.rgbFg  = Color.FromArgb(0,
                                           foreColor.R, foreColor.G, foreColor.B).ToArgb();
            Debug.WriteLine(pimldp.rgbFg.ToString());
            pimldp.fStyle = (int)flags;
            pimldp.fState = (int)stateFlags;
            if ((stateFlags & ImageListDrawStateConstants.ILS_ALPHA) ==
                ImageListDrawStateConstants.ILS_ALPHA)
            {
                // Set the alpha:
                pimldp.Frame = (int)saturateColorOrAlpha.A;
            }
            else if ((stateFlags & ImageListDrawStateConstants.ILS_SATURATE) ==
                     ImageListDrawStateConstants.ILS_SATURATE)
            {
                // discard alpha channel:
                saturateColorOrAlpha = Color.FromArgb(0,
                                                      saturateColorOrAlpha.R,
                                                      saturateColorOrAlpha.G,
                                                      saturateColorOrAlpha.B);
                // set the saturate color
                pimldp.Frame = saturateColorOrAlpha.ToArgb();
            }
            glowOrShadowColor = Color.FromArgb(0,
                                               glowOrShadowColor.R,
                                               glowOrShadowColor.G,
                                               glowOrShadowColor.B);
            pimldp.crEffect = glowOrShadowColor.ToArgb();
            if (iImageList == null)
            {
                pimldp.himl = hIml;
                int ret = ImageList_DrawIndirect(ref pimldp);
            }
            else
            {
                iImageList.Draw(ref pimldp);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Draws an image using the specified flags
 /// </summary>
 /// <param Name="hdc">Device context to draw to</param>
 /// <param Name="index">Index of image to draw</param>
 /// <param Name="x">X Position to draw at</param>
 /// <param Name="y">Y Position to draw at</param>
 /// <param Name="flags">Drawing flags</param>
 public void DrawImage(
     IntPtr hdc,
     int index,
     int x,
     int y,
     ImageListDrawItemConstants flags
     )
 {
     if (iImageList == null)
     {
         int ret = ImageList_Draw(
             hIml,
             index,
             hdc,
             x,
             y,
             (int)flags);
     }
     else
     {
         IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
         pimldp.hdcDst = hdc;
         pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
         pimldp.i      = index;
         pimldp.x      = x;
         pimldp.y      = y;
         pimldp.rgbFg  = -1;
         pimldp.fStyle = (int)flags;
         iImageList.Draw(ref pimldp);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Draws an image using the specified flags and specifies
        /// the size to clip to (or to stretch to if ILD_SCALE
        /// is provided).
        /// </summary>
        /// <param Name="hdc">Device context to draw to</param>
        /// <param Name="index">Index of image to draw</param>
        /// <param Name="x">X Position to draw at</param>
        /// <param Name="y">Y Position to draw at</param>
        /// <param Name="flags">Drawing flags</param>
        /// <param Name="cx">Width to draw</param>
        /// <param Name="cy">Height to draw</param>
        public void DrawImage(
            IntPtr hdc,
            int index,
            int x,
            int y,
            ImageListDrawItemConstants flags,
            int cx,
            int cy
            )
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();

            pimldp.hdcDst = hdc;
            pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
            pimldp.i      = index;
            pimldp.x      = x;
            pimldp.y      = y;
            pimldp.cx     = cx;
            pimldp.cy     = cy;
            pimldp.fStyle = (int)flags;
            if (iImageList == null)
            {
                pimldp.himl = hIml;
                int ret = ImageList_DrawIndirect(ref pimldp);
            }
            else
            {
                iImageList.Draw(ref pimldp);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Draws an image using the specified flags and state on XP systems.
        /// </summary>
        /// <param name="hdc">Device context to draw to</param>
        /// <param name="index">Index of image to draw</param>
        /// <param name="x">X Position to draw at</param>
        /// <param name="y">Y Position to draw at</param>
        /// <param name="flags">Drawing flags</param>
        /// <param name="cx">Width to draw</param>
        /// <param name="cy">Height to draw</param>
        /// <param name="foreColor">Fore colour to blend with when using the ILD_SELECTED or ILD_BLEND25 flags</param>
        /// <param name="stateFlags">State flags</param>
        /// <param name="saturateColorOrAlpha">If stateFlags includes ILS_ALPHA, then the alpha component is applied to the icon. Otherwise if
        /// ILS_SATURATE is included, then the (R,G,B) components are used to saturate the image.</param>
        /// <param name="glowOrShadowColor">If stateFlags include ILS_GLOW, then the colour to use for the glow effect.  Otherwise if stateFlags includes
        /// ILS_SHADOW, then the colour to use for the shadow.</param>
        public void DrawImage(
            IntPtr hdc,
            int index,
            int x,
            int y,
            ImageListDrawItemConstants flags,
            int cx,
            int cy,
            System.Drawing.Color foreColor,
            ImageListDrawStateConstants stateFlags,
            System.Drawing.Color saturateColorOrAlpha,
            System.Drawing.Color glowOrShadowColor)
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();

            pimldp.HdcDst        = hdc;
            pimldp.Size          = Marshal.SizeOf(pimldp.GetType());
            pimldp.Index         = index;
            pimldp.X             = x;
            pimldp.Y             = y;
            pimldp.CX            = cx;
            pimldp.CY            = cy;
            pimldp.ForegroundRgb = Color.FromArgb(0, foreColor.R, foreColor.G, foreColor.B).ToArgb();
            pimldp.Style         = (int)flags;
            pimldp.State         = (int)stateFlags;
            if ((stateFlags & ImageListDrawStateConstants.ILS_ALPHA) == ImageListDrawStateConstants.ILS_ALPHA)
            {
                // Set the alpha
                pimldp.Frame = saturateColorOrAlpha.A;
            }
            else if ((stateFlags & ImageListDrawStateConstants.ILS_SATURATE) == ImageListDrawStateConstants.ILS_SATURATE)
            {
                // discard alpha channel:
                saturateColorOrAlpha = Color.FromArgb(0, saturateColorOrAlpha.R, saturateColorOrAlpha.G, saturateColorOrAlpha.B);

                // set the saturate color
                pimldp.Frame = saturateColorOrAlpha.ToArgb();
            }

            glowOrShadowColor = Color.FromArgb(0, glowOrShadowColor.R, glowOrShadowColor.G, glowOrShadowColor.B);

            pimldp.Effect = glowOrShadowColor.ToArgb();

            if (this.imageList == null)
            {
                pimldp.Himl = this.himl;

                int ret = ImageList_DrawIndirect(ref pimldp);
            }
            else
            {
                this.imageList.Draw(ref pimldp);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Draws an image to the specified context.
        /// </summary>
        /// <param name="hdc"></param>
        /// <param name="index"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="flags"></param>
        static void DrawImage(IImageList iImageList, IntPtr hdc, int index, int x, int y, ImageListDrawItemConstants flags)
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();

            pimldp.hdcDst = hdc;
            pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
            pimldp.i      = index;
            pimldp.x      = x;
            pimldp.y      = y;
            pimldp.rgbFg  = -1;
            pimldp.fStyle = (int)flags;
            iImageList.Draw(ref pimldp);
        }
Exemplo n.º 7
0
        //static int CLR_NONE    = (int)0xffffffff;
        //static int CLR_INVALID = CLR_NONE;
        //static int CLR_DEFAULT = (int)0xff000000;


        private Bitmap getBitmap(int index, ImageListDrawItemConstants flags)
        {
            Size   bitmapSize = GetImageListIconSize();
            Bitmap bitmap     = new Bitmap(bitmapSize.Width, bitmapSize.Height);

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                try
                {
                    g.FillRectangle(Brushes.White, new Rectangle(0, 0, bitmapSize.Width, bitmapSize.Height));

                    IntPtr hdc = g.GetHdc();

                    IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
                    pimldp.hdcDst = hdc;
                    pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
                    pimldp.i      = index;
                    pimldp.x      = 0;
                    pimldp.y      = 0;
                    pimldp.cx     = bitmapSize.Width;
                    pimldp.cy     = bitmapSize.Height;
                    //pimldp.rgbBk = Color.Silver.ToArgb();
                    //pimldp.rgbFg = Color.Silver.ToArgb();
                    //pimldp.crEffect = Color.White.ToArgb();
                    //pimldp.Frame = 255;
                    //pimldp.fState = 0x00000008;
                    //pimldp.dwRop = (int)(dwRop.BLACKNESS);
                    pimldp.fStyle = (int)flags;

                    if (_iImageList == null || Thread.CurrentThread.GetApartmentState() == ApartmentState.MTA)
                    {
                        int ret = ImageList_DrawIndirect(ref pimldp);
                    }
                    else
                    {
                        _iImageList.Draw(ref pimldp);
                    }
                }
                finally
                {
                    g.ReleaseHdc();
                }
            }

            bitmap.MakeTransparent();
            return(bitmap);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Draws an image using the specified flags and state on XP systems.
        /// </summary>
        /// <param name="il">The image list from which an item will be drawn</param>
        /// <param name="hdc">Device context to draw to</param>
        /// <param name="index">Index of image to draw</param>
        /// <param name="x">X Position to draw at</param>
        /// <param name="y">Y Position to draw at</param>
        /// <param name="flags">Drawing flags</param>
        /// <param name="cx">Width to draw</param>
        /// <param name="cy">Height to draw</param>
        /// <param name="stateFlags">State flags</param>
        public static bool DrawImage(ImageList il, IntPtr hdc, int index, int x, int y, ImageListDrawItemConstants flags, int cx, int cy, ImageListDrawStateConstants stateFlags)
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();

            pimldp.hdcDst = hdc;
            pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
            pimldp.i      = index;
            pimldp.x      = x;
            pimldp.y      = y;
            pimldp.cx     = cx;
            pimldp.cy     = cy;
            pimldp.rgbFg  = CLR_DEFAULT;
            pimldp.fStyle = (uint)flags;
            pimldp.fState = (uint)stateFlags;
            pimldp.himl   = il.Handle;
            return(ImageList_DrawIndirect(ref pimldp));
        }
Exemplo n.º 9
0
 /// <summary>Draws the image indicated by the given index on the specified <see cref="Graphics"/> at the specified location.</summary>
 /// <param name="imageList">The image list.</param>
 /// <param name="g">The <see cref="Graphics"/> to draw on.</param>
 /// <param name="bounds">The bounds in which to draw the image. Set width and height to 0 to draw image at full size.</param>
 /// <param name="index">The index of the image in the ImageList to draw.</param>
 /// <param name="bgColor">
 /// The background color of the image. This parameter can be a <see cref="Color"/> value or <see cref="COLORREF.None"/> so the image is drawn
 /// transparently or <see cref="COLORREF.Default"/> so the image is drawn using the background color of the image list.
 /// </param>
 /// <param name="fgColor">
 /// The foreground color of the image. This parameter can be a <see cref="Color"/> value or <see cref="COLORREF.None"/> so the image is blended
 /// with the color of the destination device context or <see cref="COLORREF.Default"/> so the image is drawn using the system highlight color
 /// as the foreground color.
 /// </param>
 /// <param name="style">The drawing style.</param>
 /// <param name="overlayImageIndex">Optional index of an overlay image.</param>
 /// <exception cref="System.ComponentModel.Win32Exception">Unable to draw the image with defined parameters.</exception>
 public static void Draw(this ImageList imageList, Graphics g, Rectangle bounds, int index, COLORREF bgColor, COLORREF fgColor, IMAGELISTDRAWFLAGS style = IMAGELISTDRAWFLAGS.ILD_NORMAL, int overlayImageIndex = 0)
 {
     if (index < 0 || index >= imageList.Images.Count)
     {
         throw new ArgumentOutOfRangeException(nameof(index));
     }
     if (overlayImageIndex < 0 || overlayImageIndex > imageList.GetOverlayCount())
     {
         throw new ArgumentOutOfRangeException(nameof(overlayImageIndex));
     }
     using (var hg = new SafeHDC(g))
     {
         var p = new IMAGELISTDRAWPARAMS(hg, bounds, index, bgColor, style | (IMAGELISTDRAWFLAGS)INDEXTOOVERLAYMASK(overlayImageIndex))
         {
             rgbFg = fgColor
         };
         imageList.GetIImageList().Draw(p);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Draws an image using the specified flags and specifies
        /// the size to clip to (or to stretch to if ILD_SCALE
        /// is provided).
        /// </summary>
        /// <param name="hdc">Device context to draw to</param>
        /// <param name="index">Index of image to draw</param>
        /// <param name="x">X Position to draw at</param>
        /// <param name="y">Y Position to draw at</param>
        /// <param name="flags">Drawing flags</param>
        /// <param name="cx">Width to draw</param>
        /// <param name="cy">Height to draw</param>
        public void DrawImage(IntPtr hdc, int index, int x, int y, ImageListDrawItemConstants flags, int cx, int cy)
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();

            pimldp.HdcDst = hdc;
            pimldp.Size   = Marshal.SizeOf(pimldp.GetType());
            pimldp.Index  = index;
            pimldp.X      = x;
            pimldp.Y      = y;
            pimldp.CX     = cx;
            pimldp.CY     = cy;
            pimldp.Style  = (int)flags;

            if (this.imageList == null)
            {
                pimldp.Himl = this.himl;

                int ret = ImageList_DrawIndirect(ref pimldp);
            }
            else
            {
                this.imageList.Draw(ref pimldp);
            }
        }
Exemplo n.º 11
0
 private static extern bool ImageList_DrawIndirect(ref IMAGELISTDRAWPARAMS parms);
Exemplo n.º 12
0
 private extern static int ImageList_DrawIndirect(
     ref IMAGELISTDRAWPARAMS pimldp);
Exemplo n.º 13
0
        /// <summary>
        /// Draws an image using the specified flags and state on XP systems.
        /// </summary>
        /// <param name="hdc">Device context to draw to</param>
        /// <param name="index">Index of image to draw</param>
        /// <param name="x">X Position to draw at</param>
        /// <param name="y">Y Position to draw at</param>
        /// <param name="flags">Drawing flags</param>
        /// <param name="cx">Width to draw</param>
        /// <param name="cy">Height to draw</param>
        /// <param name="foreColor">Fore colour to blend with when using the ILD_SELECTED or ILD_BLEND25 flags</param>
        /// <param name="stateFlags">State flags</param>
        /// <param name="saturateColorOrAlpha">If stateFlags includes ILS_ALPHA, then the alpha component is applied to the icon. Otherwise if 
        /// ILS_SATURATE is included, then the (R,G,B) components are used to saturate the image.</param>
        /// <param name="glowOrShadowColor">If stateFlags include ILS_GLOW, then the colour to use for the glow effect.  Otherwise if stateFlags includes 
        /// ILS_SHADOW, then the colour to use for the shadow.</param>
        public void DrawImage(
            IntPtr hdc,
            int index,
            int x,
            int y,
            ImageListDrawItemConstants flags,
            int cx,
            int cy,
            System.Drawing.Color foreColor,
            ImageListDrawStateConstants stateFlags,
            System.Drawing.Color saturateColorOrAlpha,
            System.Drawing.Color glowOrShadowColor)
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
            pimldp.HdcDst = hdc;
            pimldp.Size = Marshal.SizeOf(pimldp.GetType());
            pimldp.Index = index;
            pimldp.X = x;
            pimldp.Y = y;
            pimldp.CX = cx;
            pimldp.CY = cy;
            pimldp.ForegroundRgb = Color.FromArgb(0, foreColor.R, foreColor.G, foreColor.B).ToArgb();
            pimldp.Style = (int)flags;
            pimldp.State = (int)stateFlags;
            if ((stateFlags & ImageListDrawStateConstants.ILS_ALPHA) == ImageListDrawStateConstants.ILS_ALPHA)
            {
                // Set the alpha
                pimldp.Frame = (int)saturateColorOrAlpha.A;
            }
            else if ((stateFlags & ImageListDrawStateConstants.ILS_SATURATE) == ImageListDrawStateConstants.ILS_SATURATE)
            {
                // discard alpha channel:
                saturateColorOrAlpha = Color.FromArgb(0, saturateColorOrAlpha.R, saturateColorOrAlpha.G, saturateColorOrAlpha.B);

                // set the saturate color
                pimldp.Frame = saturateColorOrAlpha.ToArgb();
            }

            glowOrShadowColor = Color.FromArgb(0, glowOrShadowColor.R, glowOrShadowColor.G, glowOrShadowColor.B);

            pimldp.Effect = glowOrShadowColor.ToArgb();

            if (this.imageList == null)
            {
                pimldp.Himl = this.himl;

                int ret = ImageList_DrawIndirect(ref pimldp);
            }
            else
            {
                this.imageList.Draw(ref pimldp);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Draws an image using the specified flags and specifies
        /// the size to clip to (or to stretch to if ILD_SCALE
        /// is provided).
        /// </summary>
        /// <param name="hdc">Device context to draw to</param>
        /// <param name="index">Index of image to draw</param>
        /// <param name="x">X Position to draw at</param>
        /// <param name="y">Y Position to draw at</param>
        /// <param name="flags">Drawing flags</param>
        /// <param name="cx">Width to draw</param>
        /// <param name="cy">Height to draw</param>
        public void DrawImage(IntPtr hdc, int index, int x, int y, ImageListDrawItemConstants flags, int cx, int cy)
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
            pimldp.HdcDst = hdc;
            pimldp.Size = Marshal.SizeOf(pimldp.GetType());
            pimldp.Index = index;
            pimldp.X = x;
            pimldp.Y = y;
            pimldp.CX = cx;
            pimldp.CY = cy;
            pimldp.Style = (int)flags;

            if (this.imageList == null)
            {
                pimldp.Himl = this.himl;

                int ret = ImageList_DrawIndirect(ref pimldp);
            }
            else
            {
                this.imageList.Draw(ref pimldp);
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// Draws an image using the specified flags and state on XP systems.
 /// </summary>
 /// <param name="il">The image list from which an item will be drawn</param>
 /// <param name="hdc">Device context to draw to</param>
 /// <param name="index">Index of image to draw</param>
 /// <param name="x">X Position to draw at</param>
 /// <param name="y">Y Position to draw at</param>
 /// <param name="flags">Drawing flags</param>
 /// <param name="cx">Width to draw</param>
 /// <param name="cy">Height to draw</param>
 /// <param name="stateFlags">State flags</param>
 public static bool DrawImage(ImageList il, IntPtr hdc, int index, int x, int y, ImageListDrawItemConstants flags, int cx, int cy, ImageListDrawStateConstants stateFlags) {
     IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
     pimldp.hdcDst = hdc;
     pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
     pimldp.i = index;
     pimldp.x = x;
     pimldp.y = y;
     pimldp.cx = cx;
     pimldp.cy = cy;
     pimldp.rgbFg = CLR_DEFAULT;
     pimldp.fStyle = (uint) flags;
     pimldp.fState = (uint) stateFlags;
     pimldp.himl = il.Handle;
     return ImageList_DrawIndirect(ref pimldp);
 }
        /// <summary>
        /// Draws an image using the specified flags and specifies
        /// the size to clip to (or to stretch to if ILD_SCALE
        /// is provided).
        /// </summary>
        /// <param name="hdc">Device context to draw to</param>
        /// <param name="index">Index of image to draw</param>
        /// <param name="x">X Position to draw at</param>
        /// <param name="y">Y Position to draw at</param>
        /// <param name="flags">Drawing flags</param>
        /// <param name="cx">Width to draw</param>
        /// <param name="cy">Height to draw</param>
        public void DrawImage(
            IntPtr hdc,
            int index,
            int x,
            int y,
            ImageListDrawItemConstants flags,
            int cx,
            int cy
            )
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
            pimldp.hdcDst = hdc;
            pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
            pimldp.i = index;
            pimldp.x = x;
            pimldp.y = y;
            pimldp.cx = cx;
            pimldp.cy = cy;
            pimldp.fStyle = (int)flags;
            if (iImageList == null)
            {
                pimldp.himl = hIml;
                int ret = ImageList_DrawIndirect(ref pimldp);
            }
            else
            {

                iImageList.Draw(ref pimldp);
            }
        }
 private extern static int ImageList_DrawIndirect(
     ref IMAGELISTDRAWPARAMS pimldp);
Exemplo n.º 18
0
 public static extern bool ImageList_DrawIndirect(ref IMAGELISTDRAWPARAMS pimldp);
 public static extern bool ImageList_DrawIndirect(ref IMAGELISTDRAWPARAMS pimldp);
        /// <summary>
        /// Draws an image using the specified flags
        /// </summary>
        /// <param name="hdc">Device context to draw to</param>
        /// <param name="index">Index of image to draw</param>
        /// <param name="x">X Position to draw at</param>
        /// <param name="y">Y Position to draw at</param>
        /// <param name="flags">Drawing flags</param>
        public void DrawImage(
            IntPtr hdc,
            int index,
            int x,
            int y,
            ImageListDrawItemConstants flags
            )
        {
            if (iImageList == null)
            {
                int ret = ImageList_Draw(
                    hIml,
                    index,
                    hdc,
                    x,
                    y,
                    (int)flags);
            }
            else
            {
                IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
                pimldp.hdcDst = hdc;
                pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
                pimldp.i = index;
                pimldp.x = x;
                pimldp.y = y;
                pimldp.rgbFg = -1;
                pimldp.fStyle = (int)flags;
                iImageList.Draw(ref pimldp);
            }

        }
Exemplo n.º 21
0
 /// <summary>
 /// Draws an image using the specified flags
 /// </summary>
 /// <param name="hdc">Device context to draw to</param>
 /// <param name="index">Index of image to draw</param>
 /// <param name="x">X Position to draw at</param>
 /// <param name="y">Y Position to draw at</param>
 /// <param name="flags">Drawing flags</param>
 public void DrawImage(IntPtr hdc, int index, int x, int y, ImageListDrawItemConstants flags)
 {
     if (this.imageList == null)
     {
         int ret = ImageList_Draw(
             this.himl,
             index,
             hdc,
             x,
             y,
             (int)flags);
     }
     else
     {
         IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
         pimldp.HdcDst = hdc;
         pimldp.Size = Marshal.SizeOf(pimldp.GetType());
         pimldp.Index = index;
         pimldp.X = x;
         pimldp.Y = y;
         pimldp.ForegroundRgb = -1;
         pimldp.Style = (int)flags;
         this.imageList.Draw(ref pimldp);
     }
 }
        /// <summary>
        /// Draws an image using the specified flags and state on XP systems.
        /// </summary>
        /// <param name="hdc">Device context to draw to</param>
        /// <param name="index">Index of image to draw</param>
        /// <param name="x">X Position to draw at</param>
        /// <param name="y">Y Position to draw at</param>
        /// <param name="flags">Drawing flags</param>
        /// <param name="cx">Width to draw</param>
        /// <param name="cy">Height to draw</param>
        /// <param name="foreColor">Fore colour to blend with when using the 
        /// ILD_SELECTED or ILD_BLEND25 flags</param>
        /// <param name="stateFlags">State flags</param>
        /// <param name="glowOrShadowColor">If stateFlags include ILS_GLOW, then
        /// the colour to use for the glow effect.  Otherwise if stateFlags includes 
        /// ILS_SHADOW, then the colour to use for the shadow.</param>
        /// <param name="saturateColorOrAlpha">If stateFlags includes ILS_ALPHA,
        /// then the alpha component is applied to the icon. Otherwise if 
        /// ILS_SATURATE is included, then the (R,G,B) components are used
        /// to saturate the image.</param>
        public void DrawImage(
            IntPtr hdc,
            int index,
            int x,
            int y,
            ImageListDrawItemConstants flags,
            int cx,
            int cy,
            System.Drawing.Color foreColor,
            ImageListDrawStateConstants stateFlags,
            System.Drawing.Color saturateColorOrAlpha,
            System.Drawing.Color glowOrShadowColor
            )
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
            pimldp.hdcDst = hdc;
            pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
            pimldp.i = index;
            pimldp.x = x;
            pimldp.y = y;
            pimldp.cx = cx;
            pimldp.cy = cy;
            pimldp.rgbFg = Color.FromArgb(0,
                foreColor.R, foreColor.G, foreColor.B).ToArgb();
            Console.WriteLine("{0}", pimldp.rgbFg);
            pimldp.fStyle = (int)flags;
            pimldp.fState = (int)stateFlags;
            if ((stateFlags & ImageListDrawStateConstants.ILS_ALPHA) ==
                ImageListDrawStateConstants.ILS_ALPHA)
            {
                // Set the alpha:
                pimldp.Frame = (int)saturateColorOrAlpha.A;
            }
            else if ((stateFlags & ImageListDrawStateConstants.ILS_SATURATE) ==
                ImageListDrawStateConstants.ILS_SATURATE)
            {
                // discard alpha channel:
                saturateColorOrAlpha = Color.FromArgb(0,
                    saturateColorOrAlpha.R,
                    saturateColorOrAlpha.G,
                    saturateColorOrAlpha.B);
                // set the saturate color
                pimldp.Frame = saturateColorOrAlpha.ToArgb();
            }
            glowOrShadowColor = Color.FromArgb(0,
                glowOrShadowColor.R,
                glowOrShadowColor.G,
                glowOrShadowColor.B);
            pimldp.crEffect = glowOrShadowColor.ToArgb();
            if (iImageList == null)
            {
                pimldp.himl = hIml;
                int ret = ImageList_DrawIndirect(ref pimldp);
            }
            else
            {

                iImageList.Draw(ref pimldp);
            }
        }
Exemplo n.º 23
0
 private static extern bool ImageList_DrawIndirect(ref IMAGELISTDRAWPARAMS parms);