Brush Class
Represents a type which describes how the area is painted.
- Inheritance:
- System.ObjectBrush
- Derived
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.
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).
Returns
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).
Returns
A brush which specifies that no paint will be applied to the parent element.
SetGradient(GradientBrushType)
Sets a gradient brush on the parent element.
public GradientBrush SetGradient(GradientBrushType type)Public Function SetGradient(type As GradientBrushType) As GradientBrushParameters
The gradient brush type to apply to the brush.
Returns
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.
public PatternBrush SetPattern(PatternBrushType type, Color foregroundColor, Color backgroundColor)Public Function SetPattern(type As PatternBrushType, foregroundColor As Color, backgroundColor As Color) As PatternBrushParameters
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
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.
public PictureBrush SetPicture(Content content)Public Function SetPicture(content As Content) As PictureBrushParameters
content- Content
Content of the picture data.
Returns
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.
public PictureBrush SetPicture(Stream stream)Public Function SetPicture(stream As Stream) As PictureBrushParameters
stream- System.IO.Stream
Stream containing the picture data.
Returns
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.
public PictureBrush SetPicture(Stream stream, PictureContentType contentType)Public Function SetPicture(stream As Stream, contentType As PictureContentType) As PictureBrushParameters
stream- System.IO.Stream
Stream containing the picture data.
contentType- PictureContentType
Content type of the picture data.
Returns
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.
public PictureBrush SetPicture(Stream stream, string contentType)Public Function SetPicture(stream As Stream, contentType As String) As PictureBrushParameters
stream- System.IO.Stream
Stream containing the picture data.
contentType- System.String
Content type (MIME type) of the picture data.
Returns
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.
public PictureBrush SetPicture(string picturePath, PictureContentType contentType)Public Function SetPicture(picturePath As String, contentType As PictureContentType) As PictureBrushParameters
picturePath- System.String
Path to a picture data.
contentType- PictureContentType
Content type of the picture data.
Returns
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.
public PictureBrush SetPicture(string picturePath, bool isLink = false)Public Function SetPicture(picturePath As String, isLink As Boolean = False) As PictureBrushParameters
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
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.
public PictureBrush SetPicture(string picturePath, string contentType)Public Function SetPicture(picturePath As String, contentType As String) As PictureBrushParameters
picturePath- System.String
Path to a picture data.
contentType- System.String
Content type (MIME type) of the picture data.
Returns
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.
public SolidColorBrush SetSolid(Color color)Public Function SetSolid(color As Color) As SolidColorBrushParameters
color- Color
The color to apply to the brush.
Returns
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.
public SolidColorBrush SetSolid(Color color, byte opacity)Public Function SetSolid(color As Color, opacity As Byte) As SolidColorBrushParameters
color- Color
The color to apply to the brush.
opacity- System.Byte
The color opacity (0 = fully transparent, 255 = fully opaque).
Returns
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.
public sealed override string ToString()Public NotOverridable Overrides Function ToString As StringReturns
- System.String
A System.String that represents this Brush instance.
Overrides
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).