Class BrushInfo
Holds information on how to fill the background of a window or grid cell.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Drawing
Assembly: Syncfusion.Shared.Base.dll
Syntax
public sealed class BrushInfo : IFormattable, ICloneable, ISerializable, IXmlSerializable
Remarks
BrushInfo lets you specify a solid backcolor, gradient or pattern style with both back and forecolor.
This information can be persisted with serialization.
You can also convert the information to a string and recreate it from a string.
BrushInfo is immutable (just like System.String). You cannot change its values. Instead you have to create a new BrushInfo object.
BrushInfo can also be persisted into code when used as a property in a component designer.
FillRectangle(Graphics, Rectangle, BrushInfo) shows how to fill a rectangle using BrushInfo information.
Constructors
BrushInfo()
Overloaded. Initializes a new empty instance of BrushInfo.
Declaration
public BrushInfo()
BrushInfo(BrushInfo)
Initializes a new instance of BrushInfo and copies its information from a given BrushInfo.
Declaration
public BrushInfo(BrushInfo brush)
Parameters
Type | Name | Description |
---|---|---|
BrushInfo | brush | A BrushInfo that holds information for this BrushInfo. |
BrushInfo(GradientStyle, BrushInfoColorArrayList)
Initializes a new instance of BrushInfo with a gradient style and gradient fill colors.
Declaration
public BrushInfo(GradientStyle gradientStyle, BrushInfoColorArrayList colors)
Parameters
Type | Name | Description |
---|---|---|
GradientStyle | gradientStyle | A PatternStyle. |
BrushInfoColorArrayList | colors | List of gradient fill colors. |
BrushInfo(GradientStyle, Color, Color)
Initializes a new instance of BrushInfo with a gradient style and gradient fill colors.
Declaration
public BrushInfo(GradientStyle gradientStyle, Color foreColor, Color backColor)
Parameters
Type | Name | Description |
---|---|---|
GradientStyle | gradientStyle | A PatternStyle. |
System.Drawing.Color | foreColor | A System.Drawing.Color used for the gradient fill. |
System.Drawing.Color | backColor | A System.Drawing.Color used for the gradient fill. |
BrushInfo(GradientStyle, Color[])
Initializes a new instance of BrushInfo with a hatch style and pattern colors.
Declaration
public BrushInfo(GradientStyle gradientStyle, Color[] colors)
Parameters
Type | Name | Description |
---|---|---|
GradientStyle | gradientStyle | A PatternStyle. |
System.Drawing.Color[] | colors | List of colors. |
BrushInfo(PatternStyle, BrushInfoColorArrayList)
Initializes a new instance of BrushInfo with a hatch style and pattern colors.
Declaration
public BrushInfo(PatternStyle hatchStyle, BrushInfoColorArrayList colors)
Parameters
Type | Name | Description |
---|---|---|
PatternStyle | hatchStyle | A PatternStyle. |
BrushInfoColorArrayList | colors | List of colors. |
BrushInfo(PatternStyle, Color, Color)
Initializes a new instance of BrushInfo with a hatch style and pattern colors.
Declaration
public BrushInfo(PatternStyle hatchStyle, Color foreColor, Color backColor)
Parameters
Type | Name | Description |
---|---|---|
PatternStyle | hatchStyle | A PatternStyle. |
System.Drawing.Color | foreColor | A System.Drawing.Color used for the pattern. |
System.Drawing.Color | backColor | A System.Drawing.Color used for the pattern. |
BrushInfo(PatternStyle, Color[])
Initializes a new instance of BrushInfo with a hatch style and pattern colors.
Declaration
public BrushInfo(PatternStyle hatchStyle, Color[] colors)
Parameters
Type | Name | Description |
---|---|---|
PatternStyle | hatchStyle | A PatternStyle. |
System.Drawing.Color[] | colors | List of colors. |
BrushInfo(Color)
Initializes a new instance of BrushInfo with the specified solid backcolor.
Declaration
public BrushInfo(Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | color | A System.Drawing.Color used as solid background. |
BrushInfo(Int32, BrushInfo)
Initializes a new instance of BrushInfo with a new alpha-blend value and copies other information from a given BrushInfo.
Declaration
public BrushInfo(int alpha, BrushInfo br)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | alpha | The alpha value that should be applied to the forecolor and backcolor of the new brush. |
BrushInfo | br | A BrushInfo that holds information for this BrushInfo. |
Properties
BackColor
Returns the backcolor.
Declaration
public Color BackColor { get; }
Property Value
Type |
---|
System.Drawing.Color |
Description
Returns a string description of the BrushInfo. See ToString(String).
Declaration
public string Description { get; }
Property Value
Type |
---|
System.String |
Empty
An empty BrushInfo.
Declaration
public static BrushInfo Empty { get; }
Property Value
Type |
---|
BrushInfo |
ForeColor
Returns the forecolor.
Declaration
public Color ForeColor { get; }
Property Value
Type |
---|
System.Drawing.Color |
GradientColors
Returns the gradient colors.
Declaration
public BrushInfoColorArrayList GradientColors { get; }
Property Value
Type | Description |
---|---|
BrushInfoColorArrayList | A reference to the BrushInfoColorArrayList instance. |
Remarks
This color list will be used to specify the System.Drawing.Drawing2D.LinearGradientBrush.InterpolationColors or the System.Drawing.Drawing2D.PathGradientBrush.SurroundColors depending on the GradientStyle selected.
The first entry in this list will be the same as the BackColor property and the last entry (not the 2nd) will be the same as the ForeColor property.
Note that this list is Read-only.
GradientStyle
Returns the gradient style.
Declaration
public GradientStyle GradientStyle { get; }
Property Value
Type |
---|
GradientStyle |
IsEmpty
Indicates whether this is an empty object.
Declaration
public bool IsEmpty { get; }
Property Value
Type |
---|
System.Boolean |
PatternStyle
Returns the pattern style.
Declaration
public PatternStyle PatternStyle { get; }
Property Value
Type |
---|
PatternStyle |
Style
Returns the brush style (solid, gradient or pattern).
Declaration
public BrushStyle Style { get; }
Property Value
Type |
---|
BrushStyle |
Methods
ClearColorInfo()
Declaration
public void ClearColorInfo()
Clone()
Creates a new object that is a copy of the current instance.
Declaration
public BrushInfo Clone()
Returns
Type | Description |
---|---|
BrushInfo | A new object that is a copy of this instance. |
Equals(Object)
Overridden. Compares two BrushInfo object and indicates whether they are equal.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean | True if the specified Object is equal to the current BrushInfo; false otherwise. |
Overrides
GetBrushKey()
Returns a string id that you can use to store the BrushInfo in a HashTable.
Declaration
public string GetBrushKey()
Returns
Type | Description |
---|---|
System.String | A string with compact identitiy information about the BrushInfo. |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
---|
System.Int32 |
Overrides
MakeBlackAndWhite()
Creates a new BrushInfo with the same style but with only black and white colors.
Declaration
public BrushInfo MakeBlackAndWhite()
Returns
Type | Description |
---|---|
BrushInfo | A new object with the same style and black and white colors. |
Parse(String)
Creates a new BrushInfo object and initializes it from a string.
Declaration
public static BrushInfo Parse(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | A string in the format BrushStyle;Style;ForeColor;BackColor. |
Returns
Type | Description |
---|---|
BrushInfo | A new BrushInfo object. |
ReadXml(XmlReader)
Deserializes the contents of this object from an XML stream.
Declaration
public void ReadXml(XmlReader reader)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlReader | reader | Represents the XML stream. |
ToString()
Overloaded. Returns the string representation of the brush in the format BrushStyle;Style;ForeColor;BackColor.
Declaration
public override string ToString()
Returns
Type |
---|
System.String |
Overrides
ToString(IFormatProvider)
Returns the string representation of the brush in the format BrushStyle;Style;ForeColor;BackColor.
Declaration
public string ToString(IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | provider |
Returns
Type |
---|
System.String |
ToString(String)
Returns the string representation of the brush in the format BrushStyle;Style;ForeColor;BackColor.
Declaration
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Specifies the format for string. NULL for default, "compact" for a compact string, "G" for more descriptive text. |
Returns
Type |
---|
System.String |
ToString(String, IFormatProvider)
Returns the string representation of the brush in the format BrushStyle;Style;ForeColor;BackColor.
Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Specifies the format for string. NULL for default, "compact", for a compact string or "G" for more descriptive text. |
System.IFormatProvider | formatProvider | The IFormatProvider to use to format the value. -or- A langword_csharp_NULL reference to obtain the numeric format information from the current locale setting of the operating system. |
Returns
Type |
---|
System.String |
WriteXml(XmlWriter)
Serializes the contents of this object into an XML stream.
Declaration
public void WriteXml(XmlWriter writer)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlWriter | writer | Represents the XML stream. |
Operators
Equality(BrushInfo, BrushInfo)
Declaration
public static bool operator ==(BrushInfo lhs, BrushInfo rhs)
Parameters
Type | Name | Description |
---|---|---|
BrushInfo | lhs | |
BrushInfo | rhs |
Returns
Type |
---|
System.Boolean |
Inequality(BrushInfo, BrushInfo)
Declaration
public static bool operator !=(BrushInfo lhs, BrushInfo rhs)
Parameters
Type | Name | Description |
---|---|---|
BrushInfo | lhs | |
BrushInfo | rhs |
Returns
Type |
---|
System.Boolean |
Explicit Interface Implementations
ICloneable.Clone()
Declaration
object ICloneable.Clone()
Returns
Type |
---|
System.Object |
ISerializable.GetObjectData(SerializationInfo, StreamingContext)
Declaration
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | |
System.Runtime.Serialization.StreamingContext | context |