GemBox.Document
  • Overview
  • Examples
  • Free version
  • Support
  • Pricing

    Show / Hide Table of Contents

    Brush Class

    Namespace:
    GemBox.Document.Drawing
    Assembly:
    GemBox.Document.dll

    Represents a type which describes how the area is painted.

    • C#
    • VB.NET
    public class Brush
    Public Class Brush
    Inheritance:
    System.Object
    Brush
    Derived
    GradientBrush
    PatternBrush
    PictureBrush
    SolidColorBrush
    Remarks

    Different brushes have different types of output. Some brushes paint an area with a solid color, others with a gradient, pattern or image.

    GemBox.Document supports SolidColorBrush, GradientBrush, PictureBrush, and PatternBrush.

    Properties

    IsEmpty

    Gets a value indicating whether the parent element is painted.

    • C#
    • VB.NET
    public bool IsEmpty { get; }
    Public ReadOnly Property IsEmpty As Boolean
    Property Value
    System.Boolean

    true if the parent element is not painted; otherwise, false.

    Methods

    SetDefault()

    Sets a default brush on the parent element (element will be painted based on the default settings).

    • C#
    • VB.NET
    public Brush SetDefault()
    Public Function SetDefault As Brush
    Returns
    Brush

    A brush which specifies that default brush will be applied to the parent element.

    SetEmpty()

    Sets an empty brush on the parent element (element won't be painted).

    • C#
    • VB.NET
    public Brush SetEmpty()
    Public Function SetEmpty As Brush
    Returns
    Brush

    A brush which specifies that no paint will be applied to the parent element.

    SetGradient(GradientBrushType)

    Sets a gradient brush on the parent element.

    • C#
    • VB.NET
    public GradientBrush SetGradient(GradientBrushType type)
    Public Function SetGradient(type As GradientBrushType) As GradientBrush
    Parameters
    type
    GradientBrushType

    The gradient brush type to apply to the brush.

    Returns
    GradientBrush

    A brush which specifies a gradient brush which will be applied to the parent element.

    SetPattern(PatternBrushType, Color, Color)

    Sets a pattern brush on the parent element.

    • C#
    • VB.NET
    public PatternBrush SetPattern(PatternBrushType type, Color foregroundColor, Color backgroundColor)
    Public Function SetPattern(type As PatternBrushType, foregroundColor As Color, backgroundColor As Color) As PatternBrush
    Parameters
    type
    PatternBrushType

    The type of the pattern.

    foregroundColor
    Color

    The foreground color to apply to brush.

    backgroundColor
    Color

    The backgroundColor color to apply to brush.

    Returns
    PatternBrush

    A brush which specifies a pattern brush which will be applied to the parent element.

    SetPicture(Content)

    Sets a picture brush on the parent element.

    This method is not applicable on Fill property.

    • C#
    • VB.NET
    public PictureBrush SetPicture(Content content)
    Public Function SetPicture(content As Content) As PictureBrush
    Parameters
    content
    Content

    Content of the picture data.

    Returns
    PictureBrush

    An instance of a PictureBrush type that was set and can be used to set tiling or stretch options of the picture brush.

    Remarks

    Use this overload if multiple PictureBrushs should share the same picture data.

    Exceptions
    System.ArgumentNullException

    content is null.

    SetPicture(Stream)

    Sets a picture brush on the parent element.

    This method is not applicable on Fill property.

    • C#
    • VB.NET
    public PictureBrush SetPicture(Stream stream)
    Public Function SetPicture(stream As Stream) As PictureBrush
    Parameters
    stream
    System.IO.Stream

    Stream containing the picture data.

    Returns
    PictureBrush

    An instance of a PictureBrush type that was set and can be used to set tiling or stretch options of the picture brush.

    Remarks

    Use this overload to automatically detect the picture content type from the decoded picture stream.

    Exceptions
    System.ArgumentNullException

    stream is null.

    System.ArgumentException

    Picture stream encoding format is not supported.

    SetPicture(Stream, PictureContentType)

    Sets a picture brush on the parent element.

    This method is not applicable on Fill property.

    • C#
    • VB.NET
    public PictureBrush SetPicture(Stream stream, PictureContentType contentType)
    Public Function SetPicture(stream As Stream, contentType As PictureContentType) As PictureBrush
    Parameters
    stream
    System.IO.Stream

    Stream containing the picture data.

    contentType
    PictureContentType

    Content type of the picture data.

    Returns
    PictureBrush

    An instance of a PictureBrush type that was set and can be used to set tiling or stretch options of the picture brush.

    Remarks

    Use this overload to explicitly specify picture content type so that the picture stream doesn't have to be decoded to detect the picture content type.

    Exceptions
    System.ArgumentNullException

    stream is null.

    SetPicture(Stream, String)

    Sets a picture brush on the parent element.

    This method is not applicable on Fill property.

    • C#
    • VB.NET
    public PictureBrush SetPicture(Stream stream, string contentType)
    Public Function SetPicture(stream As Stream, contentType As String) As PictureBrush
    Parameters
    stream
    System.IO.Stream

    Stream containing the picture data.

    contentType
    System.String

    Content type (MIME type) of the picture data.

    Returns
    PictureBrush

    An instance of a PictureBrush type that was set and can be used to set tiling or stretch options of the picture brush.

    Remarks

    Use this overload to explicitly specify picture content type that is not supported by the PictureContentType.

    Exceptions
    System.ArgumentNullException

    stream is null.

    System.ArgumentException

    contentType is null or System.String.Empty.

    SetPicture(String, PictureContentType)

    Sets a picture brush on the parent element.

    This method is not applicable on Fill property.

    • C#
    • VB.NET
    public PictureBrush SetPicture(string picturePath, PictureContentType contentType)
    Public Function SetPicture(picturePath As String, contentType As PictureContentType) As PictureBrush
    Parameters
    picturePath
    System.String

    Path to a picture data.

    contentType
    PictureContentType

    Content type of the picture data.

    Returns
    PictureBrush

    An instance of a PictureBrush type that was set and can be used to set tiling or stretch options of the picture brush.

    Remarks

    Use this overload to explicitly specify picture content type (for example, if picturePath doesn't specify a file extension).

    Exceptions
    System.ArgumentException

    picturePath is null or System.String.Empty.

    SetPicture(String, Boolean)

    Sets a picture brush on the parent element.

    This method is not applicable on Fill property.

    • C#
    • VB.NET
    public PictureBrush SetPicture(string picturePath, bool isLink = false)
    Public Function SetPicture(picturePath As String, isLink As Boolean = False) As PictureBrush
    Parameters
    picturePath
    System.String

    Path or link to a picture data.

    isLink
    System.Boolean

    true if the picture is linked to the file in which DocumentModel instance is saved; otherwise, false.

    Returns
    PictureBrush

    An instance of a PictureBrush type that was set and can be used to set tiling or stretch options of the picture brush.

    Remarks

    Use this overload to automatically detect the picture content type from the picturePath extension.

    Parameter picturePath must contain supported extension (for example, ".png") if isLink is false, otherwise exception is thrown.

    Exceptions
    System.ArgumentException

    picturePath is null or System.String.Empty or picturePath doesn't contain extension or extension is not supported.

    SetPicture(String, String)

    Sets a picture brush on the parent element.

    This method is not applicable on Fill property.

    • C#
    • VB.NET
    public PictureBrush SetPicture(string picturePath, string contentType)
    Public Function SetPicture(picturePath As String, contentType As String) As PictureBrush
    Parameters
    picturePath
    System.String

    Path to a picture data.

    contentType
    System.String

    Content type (MIME type) of the picture data.

    Returns
    PictureBrush

    An instance of a PictureBrush type that was set and can be used to set tiling or stretch options of the picture brush.

    Remarks

    Use this overload to explicitly specify picture content type that is not supported by the PictureContentType.

    Exceptions
    System.ArgumentException

    picturePath or contentType is null or System.String.Empty.

    SetSolid(Color)

    Sets a solid color brush on the parent element.

    • C#
    • VB.NET
    public SolidColorBrush SetSolid(Color color)
    Public Function SetSolid(color As Color) As SolidColorBrush
    Parameters
    color
    Color

    The color to apply to the brush.

    Returns
    SolidColorBrush

    A brush which specifies a solid color brush which will be applied to the parent element.

    SetSolid(Color, Byte)

    Sets a solid color brush on the parent element.

    • C#
    • VB.NET
    public SolidColorBrush SetSolid(Color color, byte opacity)
    Public Function SetSolid(color As Color, opacity As Byte) As SolidColorBrush
    Parameters
    color
    Color

    The color to apply to the brush.

    opacity
    System.Byte

    The color opacity (0 = fully transparent, 255 = fully opaque).

    Returns
    SolidColorBrush

    A brush which specifies a solid color brush which will be applied to the parent element.

    ToString()

    Returns a System.String that represents this Brush instance.

    • C#
    • VB.NET
    public sealed override string ToString()
    Public NotOverridable Overrides Function ToString As String
    Returns
    System.String

    A System.String that represents this Brush instance.

    Overrides
    System.Object.ToString()
    Remarks

    This method should be used primarily for debugging purposes and should be considered volatile (format of its return value might change in future versions).

    Examples

    Shapes example
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.