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

    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 or filled.

    • C#
    • VB.NET
    public class Brush
    Public Class Brush
    Inheritance:
    System.Object
    Brush
    Derived
    GradientFillBrush
    PatternFillBrush
    PictureFillBrush
    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 currently supports only SolidColorBrush. All other brush types are supported only through preservation.

    Properties

    IsEmpty

    Gets a value indicating whether the parent element is filled.

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

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

    Methods

    SetDefault()

    Sets a default fill on the parent element (element will be filled based on the default settings).

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

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

    SetEmpty()

    Sets an empty fill on the parent element (element won't be filled).

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

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

    SetGradient(GradientFillType)

    Sets a gradient fill on the parent element.

    • C#
    • VB.NET
    public GradientFillBrush SetGradient(GradientFillType type)
    Public Function SetGradient(type As GradientFillType) As GradientFillBrush
    Parameters
    type
    GradientFillType

    The gradient fill type to apply to the fill.

    Returns
    GradientFillBrush

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

    SetPattern(PatternFillType, Color, Color)

    Sets a pattern fill on the parent element.

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

    The type of the pattern.

    foregroundColor
    Color

    The foreground color to apply to fill.

    backgroundColor
    Color

    The backgroundColor color to apply to fill.

    Returns
    PatternFillBrush

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

    SetPicture(Content)

    Sets the fill to the picture fill.

    This method is not applicable on Fill property.

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

    Content of the picture data.

    Returns
    PictureFillBrush

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

    Remarks

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

    Exceptions
    System.ArgumentNullException

    content is null.

    SetPicture(Stream)

    Sets the fill to the picture fill.

    This method is not applicable on Fill property.

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

    Stream containing the picture data.

    Returns
    PictureFillBrush

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

    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 the fill to the picture fill.

    This method is not applicable on Fill property.

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

    Stream containing the picture data.

    contentType
    PictureContentType

    Content type of the picture data.

    Returns
    PictureFillBrush

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

    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 the fill to the picture fill.

    This method is not applicable on Fill property.

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

    Stream containing the picture data.

    contentType
    System.String

    Content type (MIME type) of the picture data.

    Returns
    PictureFillBrush

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

    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 the fill to the picture fill.

    This method is not applicable on Fill property.

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

    Path to a picture data.

    contentType
    PictureContentType

    Content type of the picture data.

    Returns
    PictureFillBrush

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

    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 the fill to the picture fill.

    This method is not applicable on Fill property.

    • C#
    • VB.NET
    public PictureFillBrush SetPicture(string picturePath, bool isLink = false)
    Public Function SetPicture(picturePath As String, isLink As Boolean = False) As PictureFillBrush
    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
    PictureFillBrush

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

    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 the fill to the picture fill.

    This method is not applicable on Fill property.

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

    Path to a picture data.

    contentType
    System.String

    Content type (MIME type) of the picture data.

    Returns
    PictureFillBrush

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

    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 fill 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 fill.

    Returns
    SolidColorBrush

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

    SetSolid(Color, Byte)

    Sets a solid color fill 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 fill.

    opacity
    System.Byte

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

    Returns
    SolidColorBrush

    A brush which specifies a solid color fill 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.