GraphicsPath.CloseAllFigures Method

Closes all open figures in this path and starts a new figure. It closes each open figure by connecting a line from its endpoint to its starting point.

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

public void CloseAllFigures ()
public void CloseAllFigures ()
public function CloseAllFigures ()
Not applicable.

The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. The code performs the following actions:

  • Creates a path.

  • Adds several open figures to the path.

  • Closes all figures in the path.

  • Draws the path to the screen.

private void CloseAllFiguresExample(PaintEventArgs e)
{
             
    // Create a path containing several open-ended figures.
    GraphicsPath myPath = new GraphicsPath();
    myPath.StartFigure();
    myPath.AddLine(new Point(10, 10), new Point(150, 10));
    myPath.AddLine(new Point(150, 10), new Point(10, 150));
    myPath.StartFigure();
    myPath.AddArc(200, 200, 100, 100, 0, 90);
    myPath.StartFigure();
    Point point1 = new Point(300, 300);
    Point point2 = new Point(400, 325);
    Point point3 = new Point(400, 375);
    Point point4 = new Point(300, 400);
    Point[] points = {point1, point2, point3, point4};
    myPath.AddCurve(points);
             
    // Close all the figures.
    myPath.CloseAllFigures();
             
    // Draw the path to the screen.
    e.Graphics.DrawPath(new Pen(Color.Black, 3), myPath);
}

private void CloseAllFiguresExample(PaintEventArgs e)
{
    // Create a path containing several open-ended figures.
    GraphicsPath myPath = new GraphicsPath();

    myPath.StartFigure();
    myPath.AddLine(new Point(10, 10), new Point(150, 10));
    myPath.AddLine(new Point(150, 10), new Point(10, 150));
    myPath.StartFigure();
    myPath.AddArc(200, 200, 100, 100, 0, 90);
    myPath.StartFigure();

    Point point1 = new Point(300, 300);
    Point point2 = new Point(400, 325);
    Point point3 = new Point(400, 375);
    Point point4 = new Point(300, 400);
    Point points[] =  { point1, point2, point3, point4 };

    myPath.AddCurve(points);

    // Close all the figures.
    myPath.CloseAllFigures();

    // Draw the path to the screen.
    e.get_Graphics().DrawPath(new Pen(Color.get_Black(), 3), myPath);
} //CloseAllFiguresExample

Windows 98, Windows Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: