CustomLineCap.Clone Metodo

Definizione

Crea una copia esatta di questo CustomLineCap.Creates an exact copy of this CustomLineCap.

public:
 virtual System::Object ^ Clone();
public object Clone ();
abstract member Clone : unit -> obj
override this.Clone : unit -> obj
Public Function Clone () As Object

Restituisce

Oggetto CustomLineCap creato da questo metodo di cui viene eseguito il cast come oggetto.The CustomLineCap this method creates, cast as an object.

Implementazioni

Esempi

L'esempio seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, un oggetto evento Paint.The following example is designed for use with Windows Forms, and it requires PaintEventArgse, an Paint event object. Nel codice vengono eseguite le seguenti azioni:The code performs the following actions:

  • Consente di creare un limite di riga personalizzato utilizzando l'oggetto GraphicsPath.Creates a custom line cap by using the GraphicsPath object.

  • Crea un oggetto CustomLineCap, firstCap, utilizzando l'oggetto GraphicsPath appena creato.Creates a CustomLineCap object, firstCap,using the GraphicsPath object just created.

  • Crea un clone di firstCap usando il metodo Clone.Creates a clone of firstCap by using the Clone method.

  • Imposta le proprietà CustomStartCap e CustomEndCap dell'oggetto Pen e utilizza tale penna per creare una linea e le estremità personalizzate sullo schermo.Sets up the CustomStartCap and CustomEndCap properties of the Pen object, and uses that pen to draw a line and the custom caps to the screen.

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);  
 }  

Si applica a