WinForms

Upgrade Guide User Guide Demos Support Forums Download
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class DrawingUtils - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class DrawingUtils

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

    Constructors

    DrawingUtils()

    Declaration
    public DrawingUtils()

    Methods

    AdjustForeColorBrightnessForBackColor(ref Color, Color, Single)

    Adjusts the specified forecolor's brightness based on the specified backcolor and preferred contrast.

    Declaration
    public static void AdjustForeColorBrightnessForBackColor(ref Color foreColor, Color backColor, float prefContrastLevel)
    Parameters
    Type Name Description
    System.Drawing.Color foreColor

    The forecolor to adjust.

    System.Drawing.Color backColor

    The backcolor for reference.

    System.Single prefContrastLevel

    Preferred contrast level.

    Remarks

    This method checks if the current contrast in brightness between the 2 colors is less than the specified contrast level. If so, it brightens or darkens the forecolor appropriately.

    ConvertHSBToRGB(Single, Single, Single, out Single, out Single, out Single)

    Converts the HSB value to RGB.

    Declaration
    public static void ConvertHSBToRGB(float h, float s, float v, out float r, out float g, out float b)
    Parameters
    Type Name Description
    System.Single h

    Hue.

    System.Single s

    Saturation.

    System.Single v

    Brightness.

    System.Single r

    Red.

    System.Single g

    Green.

    System.Single b

    Blue.

    Remarks

    This does not seem to yield accurate results, but very close.

    DrawDesignTimeBorder(Graphics, Control)

    Declaration
    public static void DrawDesignTimeBorder(Graphics g, Control control)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Windows.Forms.Control control

    DrawGrayedImage(Graphics, Image, Rectangle, RectangleF)

    Declaration
    public static void DrawGrayedImage(Graphics g, Image image, Rectangle destRect, RectangleF srcRect)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Image image
    System.Drawing.Rectangle destRect
    System.Drawing.RectangleF srcRect

    DrawGrayedImage(Graphics, Image, Rectangle, RectangleF, Single)

    Declaration
    public static void DrawGrayedImage(Graphics g, Image image, Rectangle destRect, RectangleF srcRect, float transparency)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Image image
    System.Drawing.Rectangle destRect
    System.Drawing.RectangleF srcRect
    System.Single transparency

    DrawGrayedImage(Graphics, Image, Int32, Int32)

    Declaration
    public static void DrawGrayedImage(Graphics g, Image image, int left, int top)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Image image
    System.Int32 left
    System.Int32 top

    DrawGrayedImage(Graphics, Image, Int32, Int32, Single)

    Declaration
    public static void DrawGrayedImage(Graphics g, Image image, int left, int top, float transparency)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Image image
    System.Int32 left
    System.Int32 top
    System.Single transparency

    DrawImage(Graphics, Image, Single, Single, Single, Single)

    Draws specified image to graphics context. If image size is less than maxWidth, maxHeight parameters, it will be drawn without any changes, otherwise - it will be scaled proportionally to those values.

    Declaration
    public static void DrawImage(Graphics g, Image image, float x, float y, float maxWidth, float maxHeight)
    Parameters
    Type Name Description
    System.Drawing.Graphics g

    Graphics context.

    System.Drawing.Image image

    Image object which must be drawing.

    System.Single x

    X coordinate of the destination location.

    System.Single y

    Y coordinate of the destination location.

    System.Single maxWidth

    Maximum width of the image.

    System.Single maxHeight

    Maximum height of the image.

    DrawImageViaImageList(Graphics, ImageList, Int32, Rectangle)

    Draws an image using the ImageList, taking into account the Graphics.ClipBounds.

    Declaration
    public static void DrawImageViaImageList(Graphics g, ImageList il, int index, Rectangle rect)
    Parameters
    Type Name Description
    System.Drawing.Graphics g

    The Graphics object into which to draw.

    System.Windows.Forms.ImageList il

    The ImageList containing the image.

    System.Int32 index

    The index of the image.

    System.Drawing.Rectangle rect

    The rectangle into which to draw.

    Remarks

    This method will use ImageList_DrawEx to draw the image (to use the transparency info in the embedded images). We use the PInvoke rather than ImageList.Draw because, the Draw method uses the PaintEventArgs.ClipRectangle rather than g.ClipBounds (both can be different) and here we force the ClipBounds on the DC.

    Also, you do not have to use this method if your images will never be drawn clipped (in that case just use ImageList.Draw).

    DrawShadow(Graphics, Image, Int32, Int32)

    Declaration
    public static void DrawShadow(Graphics g, Image iconImage, int left, int top)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Image iconImage
    System.Int32 left
    System.Int32 top

    DrawTransparentImage(Graphics, Rectangle, Image, Single)

    Declaration
    protected void DrawTransparentImage(Graphics g, Rectangle rect, Image image, float transparency)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Rectangle rect
    System.Drawing.Image image
    System.Single transparency

    GetRoundedRectangle(Rectangle, Int32)

    Declaration
    public static GraphicsPath GetRoundedRectangle(Rectangle rect, int radius)
    Parameters
    Type Name Description
    System.Drawing.Rectangle rect
    System.Int32 radius
    Returns
    Type Description
    System.Drawing.Drawing2D.GraphicsPath

    NCPaintHelper(Control, INonClientPaintingSupport, ref Message)

    Call this method to help you prepare for non client painting. This method will in turn call your INonClientPaintingSupport.NonClientPaint implementation.

    Declaration
    public static IntPtr NCPaintHelper(Control control, INonClientPaintingSupport ncPaintDelegate, ref Message m)
    Parameters
    Type Name Description
    System.Windows.Forms.Control control

    The control in which we will be drawing.

    INonClientPaintingSupport ncPaintDelegate

    The INonClientPaintingSupport implementation to which we will delegate the final non client drawing.

    System.Windows.Forms.Message m

    The WM_NCPAINT message.

    Returns
    Type Description
    System.IntPtr

    PaintButtonGradient(Graphics, Rectangle, Color, Color, Color, Color, Color, Color)

    Paints a rectangular area with the given colors in Office2007 style.

    Declaration
    public static void PaintButtonGradient(Graphics g, Rectangle rect, Color clrBorder, Color topFirst, Color topLast, Color bottomFirst, Color bottomLast, Color bottomLine)
    Parameters
    Type Name Description
    System.Drawing.Graphics g

    A System.Drawing.Graphics object.

    System.Drawing.Rectangle rect

    A System.Drawing.Rectangle object that represents the drawing area.

    System.Drawing.Color clrBorder

    The border color.

    System.Drawing.Color topFirst

    The top gradient start color.

    System.Drawing.Color topLast

    The top gradient end color.

    System.Drawing.Color bottomFirst

    The bottom gradient start color.

    System.Drawing.Color bottomLast

    The bottom gradient end color.

    System.Drawing.Color bottomLine

    The bottom line color.

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