GraphicsPath.CloseFigure Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Stänger den aktuella figuren och startar en ny bild. Om den aktuella figuren innehåller en sekvens med anslutna linjer och kurvor stänger metoden loopen genom att ansluta en linje från slutpunkten till startpunkten.
public:
void CloseFigure();
public void CloseFigure();
member this.CloseFigure : unit -> unit
Public Sub CloseFigure ()
Exempel
Följande kodexempel är utformat för användning med Windows Forms och kräver PaintEventArgse, ett OnPaint händelseobjekt. Koden skapar en triangel genom att skapa en ny sökväg, starta en bild, lägga till två korsande linjer i figuren och sedan stänga figuren för att bilda en triangel. Sökvägen ritas sedan till skärmen.
private:
void CloseFigureExample( PaintEventArgs^ e )
{
// Create a path consisting of two, open-ended lines and close
// the lines using CloseFigure.
GraphicsPath^ myPath = gcnew GraphicsPath;
myPath->StartFigure();
myPath->AddLine( Point(10,10), Point(200,10) );
myPath->AddLine( Point(200,10), Point(200,200) );
myPath->CloseFigure();
// Draw the path to the screen.
e->Graphics->DrawPath( Pens::Black, myPath );
}
private void CloseFigureExample(PaintEventArgs e)
{
// Create a path consisting of two, open-ended lines and close
// the lines using CloseFigure.
GraphicsPath myPath = new GraphicsPath();
myPath.StartFigure();
myPath.AddLine(new Point(10, 10), new Point(200, 10));
myPath.AddLine(new Point(200, 10), new Point(200, 200));
myPath.CloseFigure();
// Draw the path to the screen.
e.Graphics.DrawPath(Pens.Black, myPath);
}
Public Sub CloseFigureExample(ByVal e As PaintEventArgs)
' Create a path consisting of two, open-ended lines and close
' the lines using CloseFigure.
Dim myPath As New GraphicsPath
myPath.StartFigure()
myPath.AddLine(New Point(10, 10), New Point(200, 10))
myPath.AddLine(New Point(200, 10), New Point(200, 200))
myPath.CloseFigure()
' Draw the path to the screen.
e.Graphics.DrawPath(Pens.Black, myPath)
End Sub