CloseAllFigures Method

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()

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.AddLine(new Point(10, 10), new Point(150, 10));
    myPath.AddLine(new Point(150, 10), new Point(10, 150));
    myPath.AddArc(200, 200, 100, 100, 0, 90);
    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};

    // Close all the figures.

    // Draw the path to the screen.
    e.Graphics.DrawPath(new Pen(Color.Black, 3), myPath);

.NET Framework
Available since 1.1
Return to top
© 2016 Microsoft