CustomLineCap Class

CustomLineCap Class


Encapsulates a custom user-defined line cap.

Namespace:   System.Drawing.Drawing2D
Assembly:  System.Drawing (in System.Drawing.dll)


Public Class CustomLineCap
	Inherits MarshalByRefObject
	Implements ICloneable, IDisposable

System_CAPS_pubmethodCustomLineCap(GraphicsPath, GraphicsPath)

Initializes a new instance of the CustomLineCap class with the specified outline and fill.

System_CAPS_pubmethodCustomLineCap(GraphicsPath, GraphicsPath, LineCap)

Initializes a new instance of the CustomLineCap class from the specified existing LineCap enumeration with the specified outline and fill.

System_CAPS_pubmethodCustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single)

Initializes a new instance of the CustomLineCap class from the specified existing LineCap enumeration with the specified outline, fill, and inset.


Gets or sets the LineCap enumeration on which this CustomLineCap is based.


Gets or sets the distance between the cap and the line.


Gets or sets the LineJoin enumeration that determines how lines that compose this CustomLineCap object are joined.


Gets or sets the amount by which to scale this CustomLineCap Class object with respect to the width of the Pen object.


Creates an exact copy of this CustomLineCap.


Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)


Releases all resources used by this CustomLineCap object.


Releases the unmanaged resources used by the CustomLineCap and optionally releases the managed resources.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an CustomLineCap to attempt to free resources and perform other cleanup operations before the CustomLineCap is reclaimed by garbage collection.(Overrides Object.Finalize().)


Serves as the default hash function. (Inherited from Object.)


Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetStrokeCaps(LineCap, LineCap)

Gets the caps used to start and end lines that make up this custom cap.


Gets the Type of the current instance.(Inherited from Object.)


Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodSetStrokeCaps(LineCap, LineCap)

Sets the caps used to start and end lines that make up this custom cap.


Returns a string that represents the current object.(Inherited from Object.)

Line caps are used at the beginnings and ends of lines or curves drawn by GDI+ Pen objects. GDI+ supports several predefined cap styles, and also allows users to define their own cap styles. This class is used to create custom cap styles.

The following example demonstrates how to use the CustomLineCap class. To run this example paste, the code into a Windows Form. Handle the form's Paint event and call DrawCaps from the form's Paint event-handling method, passing e as PaintEventArgs.

Protected Sub DrawCaps(ByVal e As PaintEventArgs)
    Dim hPath As New GraphicsPath()

    ' Create the outline for our custom end cap.
    hPath.AddLine(New Point(0, 0), New Point(0, 5))
    hPath.AddLine(New Point(0, 5), New Point(5, 1))
    hPath.AddLine(New Point(5, 1), New Point(3, 1))

    ' Construct the hook-shaped end cap.
    Dim HookCap As New CustomLineCap(Nothing, hPath)

    ' Set the start cap and end cap of the HookCap to be rounded.
    HookCap.SetStrokeCaps(LineCap.Round, LineCap.Round)

    ' Create a pen and set end custom start and end
    ' caps to the hook cap.
    Dim customCapPen As New Pen(Color.Black, 5)
    customCapPen.CustomStartCap = HookCap
    customCapPen.CustomEndCap = HookCap

    ' Create a second pen using the start and end caps from
    ' the hook cap.
    Dim capPen As New Pen(Color.Red, 10)
    Dim startCap As LineCap
    Dim endCap As LineCap
    HookCap.GetStrokeCaps(startCap, endCap)
    capPen.StartCap = startCap
    capPen.EndCap = endCap

    ' Create a line to draw.
    Dim points As Point() = {New Point(100, 100), New Point(200, 50), _
        New Point(250, 300)}

    ' Draw the lines.
    e.Graphics.DrawLines(capPen, points)
    e.Graphics.DrawLines(customCapPen, points)

End Sub

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2016 Microsoft