Freigeben über


CustomLineCap.Clone-Methode

Erstellt eine genaue Kopie von diesem CustomLineCap.

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

Syntax

'Declaration
Public Function Clone As Object
'Usage
Dim instance As CustomLineCap
Dim returnValue As Object

returnValue = instance.Clone
public Object Clone ()
public:
virtual Object^ Clone () sealed
public final Object Clone ()
public final function Clone () : Object

Rückgabewert

Das von dieser Methode erstellte CustomLineCap, umgewandelt in ein Objekt.

Beispiel

Das folgende Beispiel ist für die Verwendung mit Windows Forms vorgesehen und erfordert das Paint-Ereignisobjekt PaintEventArgse. Der Code führt die folgenden Aktionen aus:

  • Erstellt mithilfe des GraphicsPath-Objekts ein benutzerdefiniertes Ende.

  • Erstellt mithilfe des gerade erstellten GraphicsPath-Objekts ein CustomLineCap-Objekt mit der Bezeichnung firstCap.

  • Erstellt mithilfe der Clone-Methode einen Klon von firstCap.

  • Richtet die CustomStartCap-Eigenschaft und die CustomEndCap-Eigenschaft des Pen-Objekts ein und verwendet den Stift, um eine Linie und die benutzerdefinierten Enden auf den Bildschirm zu zeichnen.

Public Sub CloneExample(e As PaintEventArgs)
 Dim points As Point() = New Point(- 5, - 5) New Point(0, 0) _
 New Point(5, - 5)
 Dim capPath As New GraphicsPath()
 ' Create a Path and add two lines to it,
 ' forming a custom line cap.
 capPath.AddLines(points)
 ' Create a CustomLineCap object.
 Dim firstCap As New CustomLineCap(Nothing, capPath)
 ' Create a copy of firstCap.
 Dim secondCap As CustomLineCap = CType(firstCap.Clone(), _
 CustomLineCap)
 ' Create a Pen object.
 Dim pen As New Pen(Color.Black, 3F)
 'Set up the line.
 Dim point1 As New Point(20, 20)
 Dim point2 As New Point(100, 100)
 ' Set up the caps.
 pen.CustomStartCap = firstCap
 pen.CustomEndCap = secondCap
 ' Draw the line and caps to the screen.
 e.Graphics.DrawLine(pen, point1, point2)
 End Sub
private void CloneExample(PaintEventArgs e)
 {
 // Create a Path and add two lines to it,
 // forming a custom line cap.
 Point[] points =
 {
 new Point(-5, -5),
 new Point(0, 0),
 new Point(5, -5)
 };
 GraphicsPath capPath = new GraphicsPath();
 capPath.AddLines(points);
 // Create a CustomLineCap object.
 CustomLineCap firstCap = new CustomLineCap(null, capPath);
 // Create a copy of firstCap.
 CustomLineCap secondCap = (CustomLineCap)firstCap.Clone();
 // Create a Pen object.
 Pen pen = new Pen(Color.Black, 3.0f);
 // Set up the line.
 Point point1 = new Point(20, 20);
 Point point2 = new Point(100, 100);
 // Set up the caps.
 pen.CustomStartCap = firstCap;
 pen.CustomEndCap = secondCap;
 // Draw the line and caps to the screen.
 e.Graphics.DrawLine(pen, point1, point2);
 }

Plattformen

Windows 98, Windows 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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

CustomLineCap-Klasse
CustomLineCap-Member
System.Drawing.Drawing2D-Namespace