GraphicsPath.Clone Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates an exact copy of this path.
public:
virtual System::Object ^ Clone();
public object Clone ();
abstract member Clone : unit -> obj
override this.Clone : unit -> obj
Public Function Clone () As Object
Returns
The GraphicsPath this method creates, cast as an object.
Implements
Examples
The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e
, an OnPaint event object. The code performs the following actions:
Creates a path.
Adds several figures to the path.
Draws the path to the screen.
Clones a copy of that path.
Draws the new path to the screen.
Notice that the call the Clone method must be cast as a 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
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기