Export (0) Print
Expand All

GraphicsPath.CloseFigure Method

Closes the current figure and starts a new figure. If the current figure contains a sequence of connected lines and curves, the method closes the loop by connecting a line from the endpoint to the starting point.

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

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

The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. The code creates a triangle by creating a new path, starting a figure, adding two intersecting lines to the figure, and then closing the figure to form a triangle. The path is then drawn to the screen.

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 = 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

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:
© 2014 Microsoft