CustomLineCap Class
.NET Framework 2.0
Encapsulates a custom user-defined line cap.
Namespace: System.Drawing.Drawing2D
Assembly: System.Drawing (in system.drawing.dll)
Assembly: System.Drawing (in system.drawing.dll)
'Declaration Public Class CustomLineCap Inherits MarshalByRefObject Implements ICloneable, IDisposable 'Usage Dim instance As CustomLineCap
public class CustomLineCap extends MarshalByRefObject implements ICloneable, IDisposable
public class CustomLineCap extends MarshalByRefObject implements ICloneable, IDisposable
Not applicable.
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
System.Object
System.MarshalByRefObject
System.Drawing.Drawing2D.CustomLineCap
System.Drawing.Drawing2D.AdjustableArrowCap
System.MarshalByRefObject
System.Drawing.Drawing2D.CustomLineCap
System.Drawing.Drawing2D.AdjustableArrowCap
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: