Freigeben über


GraphicsPath.CloseFigure-Methode

Schließt die aktuelle Figur und beginnt eine neue. Wenn die aktuelle Figur eine Abfolge verbundener Linien und Kurven enthält, schließt die Methode die Schleife, indem End- und Anfangspunkt durch eine Linie verbunden werden.

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

Syntax

'Declaration
Public Sub CloseFigure
'Usage
Dim instance As GraphicsPath

instance.CloseFigure
public void CloseFigure ()
public:
void CloseFigure ()
public void CloseFigure ()
public function CloseFigure ()

Beispiel

Das folgende Codebeispiel ist für die Verwendung mit Windows Forms vorgesehen und erfordert das OnPaint-Ereignisobjekt PaintEventArgse. Der Code erstellt ein Dreieck, indem ein neuer Pfad erstellt und eine Figur begonnen wird, zwei überschneidende Linien hinzugefügt werden, die Figur dann geschlossen wird und ein Dreieck bildet. Anschließend wird der Pfad auf dem Bildschirm gezeichnet.

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
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);
}
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.get_Graphics().DrawPath(Pens.get_Black(), myPath);
} //CloseFigureExample

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

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