Class Pen
Defines an object used to draw lines, curves and figures.
public class Pen : TransparencySupporter
- Inheritance
-
Pen
- Inherited Members
Constructors
Pen(Brush)
public Pen(Brush brush)
Parameters
Exceptions
- ArgumentNullException
brush
is null.
Pen(Brush, float)
public Pen(Brush brush, float width)
Parameters
Exceptions
- ArgumentNullException
brush
is null.
Pen(Color)
Initializes a new instance of the Pen class with the specified color.
public Pen(Color color)
Parameters
Pen(Color, float)
public Pen(Color color, float width)
Parameters
Properties
Alignment
Gets or sets the alignment for this Pen.
public PenAlignment Alignment { get; set; }
Property Value
- PenAlignment
A PenAlignment that represents the alignment for this Pen.
Exceptions
- ArgumentException
The Alignment property is set on an immutable Pen, such as those returned by the Pen class.
Brush
public Brush Brush { get; set; }
Property Value
Exceptions
- ArgumentException
The Brush property is set on an immutable Pen, such as those returned by the Pen class.
Color
Gets or sets the color of this Pen.
public Color Color { get; set; }
Property Value
Exceptions
- ArgumentException
The Color property is set on an immutable Pen, such as those returned by the Pen class.
CompoundArray
Gets or sets an array of values that specifies a compound pen. A compound pen draws a compound line made up of parallel lines and spaces.
public float[] CompoundArray { get; set; }
Property Value
- float[]
An array of real numbers that specifies the compound array. The elements in the array must be in increasing order, not less than 0, and not greater than 1.
Exceptions
- ArgumentException
The CompoundArray property is set on an immutable Pen, such as those returned by the Pen class.
CustomEndCap
Gets or sets a custom cap to use at the end of lines drawn with this Pen.
public CustomLineCap CustomEndCap { get; set; }
Property Value
- CustomLineCap
A CustomLineCap that represents the cap used at the end of lines drawn with this Pen.
Exceptions
- ArgumentException
The CustomEndCap property is set on an immutable Pen, such as those returned by the Pen class.
CustomStartCap
Gets or sets a custom cap to use at the beginning of lines drawn with this Pen.
public CustomLineCap CustomStartCap { get; set; }
Property Value
- CustomLineCap
A CustomLineCap that represents the cap used at the beginning of lines drawn with this Pen.
Exceptions
- ArgumentException
The CustomStartCap property is set on an immutable Pen, such as those returned by the Pen class.
DashCap
Gets or sets the cap style used at the end of the dashes that make up dashed lines drawn with this Pen.
public DashCap DashCap { get; set; }
Property Value
- DashCap
One of the DashCap values that represents the cap style used at the beginning and end of the dashes that make up dashed lines drawn with this Pen.
Exceptions
- ArgumentException
The DashCap property is set on an immutable Pen, such as those returned by the Pen class.
DashOffset
Gets or sets the distance from the start of a line to the beginning of a dash pattern.
public float DashOffset { get; set; }
Property Value
- float
The distance from the start of a line to the beginning of a dash pattern.
DashPattern
Gets or sets an array of custom dashes and spaces.
public float[] DashPattern { get; set; }
Property Value
- float[]
An array of real numbers that specifies the lengths of alternating dashes and spaces in dashed lines.
Exceptions
- ArgumentException
The DashPattern property is set on an immutable Pen, such as those returned by the Pen class.
DashStyle
Gets or sets the style used for dashed lines drawn with this Pen.
public DashStyle DashStyle { get; set; }
Property Value
Exceptions
- ArgumentException
The DashStyle property is set on an immutable Pen, such as those returned by the Pen class.
EndCap
Gets or sets the cap style used at the end of lines drawn with this Pen.
public LineCap EndCap { get; set; }
Property Value
- LineCap
One of the LineCap values that represents the cap style used at the end of lines drawn with this Pen.
Exceptions
- ArgumentException
The EndCap property is set on an immutable Pen, such as those returned by the Pen class.
LineJoin
Gets or sets the join style for the ends of two consecutive lines drawn with this Pen.
public LineJoin LineJoin { get; set; }
Property Value
- LineJoin
A LineJoin that represents the join style for the ends of two consecutive lines drawn with this Pen.
Exceptions
- ArgumentException
The LineJoin property is set on an immutable Pen, such as those returned by the Pen class.
MiterLimit
Gets or sets the limit of the thickness of the join on a mitered corner.
public float MiterLimit { get; set; }
Property Value
- float
The limit of the thickness of the join on a mitered corner.
Exceptions
- ArgumentException
The MiterLimit property is set on an immutable Pen, such as those returned by the Pen class.
PenType
Gets the style of lines drawn with this Pen.
public PenType PenType { get; }
Property Value
StartCap
Gets or sets the cap style used at the beginning of lines drawn with this Pen.
public LineCap StartCap { get; set; }
Property Value
- LineCap
One of the LineCap values that represents the cap style used at the beginning of lines drawn with this Pen.
Exceptions
- ArgumentException
The StartCap property is set on an immutable Pen, such as those returned by the Pen class.
Transform
Gets or sets a copy of the geometric transformation for this Pen.
public Matrix Transform { get; set; }
Property Value
Exceptions
- ArgumentException
The Transform property is set on an immutable Pen, such as those returned by the Pen class.
Width
Gets or sets the width of this Pen, in units of the Graphics object used for drawing.
public float Width { get; set; }
Property Value
Exceptions
- ArgumentException
The Width property is set on an immutable Pen, such as those returned by the Pen class.
Methods
Equals(Pen)
Check if objects are equal.
protected bool Equals(Pen other)
Parameters
other
PenThe other object.
Returns
- bool
The equality comparison result.
Equals(object)
Check if objects are equal.
public override bool Equals(object obj)
Parameters
obj
objectThe other object.
Returns
- bool
The equality comparison result.
GetHashCode()
Get hash code of the current object.
public override int GetHashCode()
Returns
- int
The hash code.
MultiplyTransform(Matrix)
public void MultiplyTransform(Matrix matrix)
Parameters
MultiplyTransform(Matrix, MatrixOrder)
public void MultiplyTransform(Matrix matrix, MatrixOrder order)
Parameters
matrix
MatrixThe Matrix by which to multiply the transformation matrix.
order
MatrixOrderThe order in which to perform the multiplication operation.
ResetTransform()
Resets the geometric transformation matrix for this Pen to identity.
public void ResetTransform()
RotateTransform(float)
Rotates the local geometric transformation by the specified angle. This method prepends the rotation to the transformation.
public void RotateTransform(float angle)
Parameters
angle
floatThe angle of rotation.
RotateTransform(float, MatrixOrder)
Rotates the local geometric transformation by the specified angle in the specified order.
public void RotateTransform(float angle, MatrixOrder order)
Parameters
angle
floatThe angle of rotation.
order
MatrixOrderA MatrixOrder that specifies whether to append or prepend the rotation matrix.
ScaleTransform(float, float)
Scales the local geometric transformation by the specified factors. This method prepends the scaling matrix to the transformation.
public void ScaleTransform(float sx, float sy)
Parameters
sx
floatThe factor by which to scale the transformation in the x-axis direction.
sy
floatThe factor by which to scale the transformation in the y-axis direction.
ScaleTransform(float, float, MatrixOrder)
Scales the local geometric transformation by the specified factors in the specified order.
public void ScaleTransform(float sx, float sy, MatrixOrder order)
Parameters
sx
floatThe factor by which to scale the transformation in the x-axis direction.
sy
floatThe factor by which to scale the transformation in the y-axis direction.
order
MatrixOrderA MatrixOrder that specifies whether to append or prepend the scaling matrix.
SetLineCap(LineCap, LineCap, DashCap)
Sets the values that determine the style of cap used to end lines drawn by this Pen.
public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
Parameters
startCap
LineCapA LineCap that represents the cap style to use at the beginning of lines drawn with this Pen.
endCap
LineCapA LineCap that represents the cap style to use at the end of lines drawn with this Pen.
dashCap
DashCapA LineCap that represents the cap style to use at the beginning or end of dashed lines drawn with this Pen.
TranslateTransform(float, float)
Translates the local geometric transformation by the specified dimensions. This method prepends the translation to the transformation.
public void TranslateTransform(float dx, float dy)
Parameters
TranslateTransform(float, float, MatrixOrder)
Translates the local geometric transformation by the specified dimensions in the specified order.
public void TranslateTransform(float dx, float dy, MatrixOrder order)
Parameters
dx
floatThe value of the translation in x.
dy
floatThe value of the translation in y.
order
MatrixOrderThe order (prepend or append) in which to apply the translation.