GraphicsPath.Clone Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee maakt u een exacte kopie van dit pad.
public:
virtual System::Object ^ Clone();
public object Clone();
abstract member Clone : unit -> obj
override this.Clone : unit -> obj
Public Function Clone () As Object
Retouren
Met GraphicsPath deze methode maakt u cast als een object.
Implementeringen
Voorbeelden
Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een OnPaint-gebeurtenisobject. De code voert de volgende acties uit:
Hiermee maakt u een pad.
Hiermee voegt u meerdere cijfers toe aan het pad.
Hiermee tekent u het pad naar het scherm.
Kloont een kopie van dat pad.
Hiermee tekent u het nieuwe pad naar het scherm.
U ziet dat de aanroep van de Clone methode moet worden gecast als een GraphicsPath.
private:
void CloneExample( PaintEventArgs^ e )
{
// Set several markers in a path.
GraphicsPath^ myPath = gcnew GraphicsPath;
myPath->AddEllipse( 0, 0, 100, 200 );
myPath->AddLine( Point(100,100), Point(200,100) );
Rectangle rect = Rectangle(200,0,100,200);
myPath->AddRectangle( rect );
myPath->AddLine( Point(250,200), Point(250,300) );
// Draw the path to the screen.
Pen^ myPen = gcnew Pen( Color::Black,2.0f );
e->Graphics->DrawPath( myPen, myPath );
// Clone a copy of myPath.
GraphicsPath^ myPath2 = dynamic_cast<GraphicsPath^>(myPath->Clone());
// Draw the path to the screen.
Pen^ myPen2 = gcnew Pen( Color::Red,4.0f );
e->Graphics->DrawPath( myPen2, myPath2 );
}
private void CloneExample(PaintEventArgs e)
{
// Set several markers in a path.
GraphicsPath myPath = new GraphicsPath();
myPath.AddEllipse(0, 0, 100, 200);
myPath.AddLine(new Point(100, 100), new Point(200, 100));
Rectangle rect = new Rectangle(200, 0, 100, 200);
myPath.AddRectangle(rect);
myPath.AddLine(new Point(250, 200), new Point(250, 300));
// Draw the path to the screen.
Pen myPen = new Pen(Color.Black, 2);
e.Graphics.DrawPath(myPen, myPath);
// Clone a copy of myPath.
GraphicsPath myPath2 = (GraphicsPath)myPath.Clone();
// Draw the path to the screen.
Pen myPen2 = new Pen(Color.Red, 4);
e.Graphics.DrawPath(myPen2, myPath2);
}
Public Sub CloneExample(ByVal e As PaintEventArgs)
' Set several markers in a path.
Dim myPath As New GraphicsPath
myPath.AddEllipse(0, 0, 100, 200)
myPath.AddLine(New Point(100, 100), New Point(200, 100))
Dim rect As New Rectangle(200, 0, 100, 200)
myPath.AddRectangle(rect)
myPath.AddLine(New Point(250, 200), New Point(250, 300))
' Draw the path to the screen.
Dim myPen As New Pen(Color.Black, 2)
e.Graphics.DrawPath(myPen, myPath)
' Clone a copy of myPath.
Dim myPath2 As GraphicsPath = CType(myPath.Clone(), GraphicsPath)
' Draw the path to the screen.
Dim myPen2 As New Pen(Color.Red, 4)
e.Graphics.DrawPath(myPen2, myPath2)
End Sub