In This Article

MultiColorLinearGradient Class

Represents a multi-color linear gradient.

public class MultiColorLinearGradient : LinearGradient, ICloneable
Inheritance:
object BackgroundFill Gradient LinearGradient object
Implements:
ICloneable

Constructors

MultiColorLinearGradient()

Initializes an instance of the class.

public MultiColorLinearGradient()

Remarks

The default constructor initializes all fields to their default values.

MultiColorLinearGradient(MultiColorLinearGradient)

Initializes an instance of the class.

protected MultiColorLinearGradient(MultiColorLinearGradient copyFrom)
Parameter Type Description
copyFrom MultiColorLinearGradient

An instance of MultiColorLinearGradient which will be copied to initialize the new instance.

Remarks

This constructor used in support of Clone() for base classes to initialize their fields.

MultiColorLinearGradient(Color, LinearGradientColorPosition[], Color, float, BackgroundFillRotationType)

Initializes an instance of the class.

public MultiColorLinearGradient(Color startColor, LinearGradientColorPosition[] intermediateColors, Color endColor, float angle, BackgroundFillRotationType rotationType)
Parameter Type Description
startColor Color

The start color of the gradient.

intermediateColors LinearGradientColorPosition[]

The intermediate colors of the gradient.

endColor Color

The end color of the gradient.

angle float

The angle, measured in degrees clockwise from the x-axis, that defines the orientation of the gradient.

rotationType BackgroundFillRotationType

The type of rotation to perform when drawing the background fill for a side.

MultiColorLinearGradient(Color, Color, Color, float)

Initializes an instance of the class.

public MultiColorLinearGradient(Color startColor, Color middleColor, Color endColor, float angle)
Parameter Type Description
startColor Color

The start color of the gradient.

middleColor Color

The middle color of the gradient.

endColor Color

The end color of the gradient.

angle float

The angle, measured in degrees clockwise from the x-axis, that defines the orientation of the gradient.

MultiColorLinearGradient(Color, Color, Color, float, BackgroundFillRotationType)

Initializes an instance of the class.

public MultiColorLinearGradient(Color startColor, Color middleColor, Color endColor, float angle, BackgroundFillRotationType rotationType)
Parameter Type Description
startColor Color

The start color of the gradient.

middleColor Color

The middle color of the gradient.

endColor Color

The end color of the gradient.

angle float

The angle, measured in degrees clockwise from the x-axis, that defines the orientation of the gradient.

rotationType BackgroundFillRotationType

The type of rotation to perform when drawing the background fill for a side.

Properties

IntermediateColors

The intermediate colors of the gradient.

[TypeConverter(typeof(LinearGradientColorPositionArrayConverter))]
public LinearGradientColorPosition[]? IntermediateColors { get; set; }

Property Value

LinearGradientColorPosition[]:

An array of LinearGradientColorPosition objects containing the intermediate colors.

Methods

Clone()

Creates an exact duplicate of the BackgroundFill object.

public override BackgroundFill Clone()

Returns

BackgroundFill

Draw(Graphics, Rectangle, Rectangle, Color, LinearGradientColorPosition[]?, Color, float)

Fills an area with the gradient.

public static void Draw(Graphics g, Rectangle bounds, Rectangle gradientBounds, Color startColor, LinearGradientColorPosition[]? intermediateColors, Color endColor, float angle)
Parameter Type Description
g Graphics

The Graphics object used to paint.

bounds Rectangle

The bounds of the area to paint.

gradientBounds Rectangle

The bounds of the gradient effect.

startColor Color

The start color of the gradient.

intermediateColors LinearGradientColorPosition[]

The intermediate colors of the gradient.

endColor Color

The end color of the gradient.

angle float

The angle, measured in degrees clockwise from the x-axis, that defines the orientation of the gradient.

Draw(Graphics, Rectangle, Rectangle, Color, Color, Color, float)

Fills an area with the gradient.

public static void Draw(Graphics g, Rectangle bounds, Rectangle gradientBounds, Color startColor, Color middleColor, Color endColor, float angle)
Parameter Type Description
g Graphics

The Graphics object used to paint.

bounds Rectangle

The bounds of the area to paint.

gradientBounds Rectangle

The bounds of the gradient effect.

startColor Color

The start color of the gradient.

middleColor Color

The middle color of the gradient.

endColor Color

The end color of the gradient.

angle float

The angle, measured in degrees clockwise from the x-axis, that defines the orientation of the gradient.

DrawScaled(Graphics, Rectangle, Rectangle, Sides, SizeF)

Fills an area with the background fill.

public override void DrawScaled(Graphics g, Rectangle bounds, Rectangle gradientBounds, Sides side, SizeF scaleFactor)
Parameter Type Description
g Graphics

The Graphics object used to paint.

bounds Rectangle

The bounds of the area to paint.

gradientBounds Rectangle

The Graphics object used to paint.

side Sides

The side with which the background fill should be oriented.

scaleFactor SizeF

The factor of the scale transform to be applied where Width is applied to the x-axis, and Height is applied to the y-axis.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)
Parameter Type Description
obj object

The object to compare with the current object.

Returns

bool:

true if the specified object is equal to the current object; otherwise, false.

GetBrush(Rectangle, Sides)

Returns a Brush that represents the background fill.

public override Brush GetBrush(Rectangle bounds, Sides side)
Parameter Type Description
bounds Rectangle

The bounds of the area to paint.

side Sides

The side with which the background fill should be oriented.

Returns

Brush

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int:

A hash code for the current object.

ResetIntermediateColors()

Resets the IntermediateColors property to its default value.

public virtual void ResetIntermediateColors()

ShouldSerializeIntermediateColors()

Indicates whether the IntermediateColors property should be persisted.

public virtual bool ShouldSerializeIntermediateColors()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Inherited Members

Extension Methods