menu

WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class IconPaint - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class IconPaint

    IconPaint is a helper class for drawing and caching bitmaps from a resource manifest with a given forecolor.

    Inheritance
    System.Object
    IconPaint
    GridIconPaint
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Syncfusion.Drawing
    Assembly: Syncfusion.Shared.Base.dll
    Syntax
    public class IconPaint
    Remarks

    The bitmaps are loaded from the manifest and cached. The PaintIcon routine will substitute black pixels of the original bitmap and draw them with a specified forecolor.

    Constructors

    IconPaint(String, Assembly)

    Initializes a new IconPaint object with manifestPrefix and a reference to the assembly to load bitmaps from. You should save this object in a static variable.

    Declaration
    public IconPaint(string manifestPrefix, Assembly ass)
    Parameters
    Type Name Description
    System.String manifestPrefix

    The manifest to load from. The bitmaps should be saved in the Resources tree in the Visual Studio project with the build action set to "Embedded Resource".

    System.Reflection.Assembly ass

    The assembly to load from. The bitmaps should be saved in the Resources tree in Visual Studio project with the build action set to "Embedded Resource".

    Methods

    CenterInRect(Rectangle, Size)

    Calculates coordinates for a centered rectangle.

    Declaration
    public Rectangle CenterInRect(Rectangle rect, Size size)
    Parameters
    Type Name Description
    System.Drawing.Rectangle rect

    The existing bounds.

    System.Drawing.Size size

    The size of the rectangle to be centered.

    Returns
    Type Description
    System.Drawing.Rectangle

    A rectangle inside the specified bounds.

    GetBitmap(String)

    Returns bitmap from cache or loads bitmap from manifest on first use.

    Declaration
    public Bitmap GetBitmap(string bitmapName)
    Parameters
    Type Name Description
    System.String bitmapName

    The bitmap name.

    Returns
    Type Description
    System.Drawing.Bitmap

    Reference to bitmap; NULL if bitmap failed to load.

    PaintIcon(Graphics, Rectangle, Point, Bitmap, Color)

    Paints the specified bitmap substituting black pixels with a new color.

    Declaration
    public Rectangle PaintIcon(Graphics g, Rectangle bounds, Point offset, Bitmap bmp, Color foreColor)
    Parameters
    Type Name Description
    System.Drawing.Graphics g

    A Graphics object used to draw the bitmap.

    System.Drawing.Rectangle bounds

    A Rectangle which contains the boundary data of the rectangle.

    System.Drawing.Point offset

    A Point that specifies pixels to offset the bitmap from its origin point.

    System.Drawing.Bitmap bmp

    The bitmap to be drawn on the screen.

    System.Drawing.Color foreColor

    The new color used to substitute black pixels.

    Returns
    Type Description
    System.Drawing.Rectangle

    A Rectangle which contains the boundary data of the drawn bitmap.

    Remarks

    The PaintIcon routine will substitute black pixels of the original bitmap and draw them with the specified forecolor. The bitmap is centered inside the specified bounds. Use the offset if you want to display a "pressed button" state. If the button is pressed, specify offset = new Point(1, 1).

    PaintIcon(Graphics, Rectangle, Point, String, Color)

    Loads the bitmap from the manifest and paints it substituting black pixels with a new color.

    Declaration
    public void PaintIcon(Graphics g, Rectangle bounds, Point offset, string bitmapName, Color foreColor)
    Parameters
    Type Name Description
    System.Drawing.Graphics g

    A Graphics object used to draw the bitmap.

    System.Drawing.Rectangle bounds

    A Rectangle which contains the boundary data of the rectangle.

    System.Drawing.Point offset

    A Point that specifies pixel to offset the bitmap from its origin point.

    System.String bitmapName

    The name of the bitmap.

    System.Drawing.Color foreColor

    The new color used to substitute black pixels.

    Remarks

    The PaintIcon routine will substitute black pixels of the original bitmap and draw them with the specified forecolor. The bitmap is centered inside the specified bounds. Use the offset if you want to display a "pressed button" state. If the button is pressed, specify offset = new Point(1, 1).

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved