Export (0) Print
Expand All

CustomLineCap Class

Encapsulates a custom user-defined line cap.

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

public class CustomLineCap : MarshalByRefObject, 
	ICloneable, IDisposable

The CustomLineCap type exposes the following members.

  NameDescription
Public methodCustomLineCap(GraphicsPath, GraphicsPath)Initializes a new instance of the CustomLineCap class with the specified outline and fill.
Public methodCustomLineCap(GraphicsPath, GraphicsPath, LineCap)Initializes a new instance of the CustomLineCap class from the specified existing LineCap enumeration with the specified outline and fill.
Public methodCustomLineCap(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.
Top

  NameDescription
Public propertyBaseCapGets or sets the LineCap enumeration on which this CustomLineCap is based.
Public propertyBaseInsetGets or sets the distance between the cap and the line.
Public propertyStrokeJoinGets or sets the LineJoin enumeration that determines how lines that compose this CustomLineCap object are joined.
Public propertyWidthScaleGets or sets the amount by which to scale this CustomLineCap Class object with respect to the width of the Pen object.
Top

  NameDescription
Public methodCloneCreates an exact copy of this CustomLineCap.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDispose()Releases all resources used by this CustomLineCap object.
Protected methodDispose(Boolean)Releases the unmanaged resources used by the CustomLineCap and optionally releases the managed resources.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an CustomLineCap to attempt to free resources and perform other cleanup operations before the CustomLineCap is reclaimed by garbage collection. (Overrides Object.Finalize().)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetStrokeCapsGets the caps used to start and end lines that make up this custom cap.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodSetStrokeCapsSets the caps used to start and end lines that make up this custom cap.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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 void DrawCaps(PaintEventArgs e)
{
    GraphicsPath hPath = 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.
    CustomLineCap HookCap = new CustomLineCap(null, 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.
    Pen customCapPen = 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.
    Pen capPen = new Pen(Color.Red, 10);
    LineCap startCap;
    LineCap endCap;
    HookCap.GetStrokeCaps(out startCap, out endCap);
    capPen.StartCap = startCap;
    capPen.EndCap = endCap;

    // Create a line to draw.
    Point[] points = { 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);

}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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