GraphicsPath::AddPolygon Method (array<Point>^)

 

Adds a polygon to this path.

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

public:
void AddPolygon(
	array<Point>^ points
)

Parameters

points
Type: array<System.Drawing::Point>^

An array of Point structures that defines the polygon to add.

The points in the points array specify the vertices of a polygon. If the first point in the array is not the same as the last point, those two points are connected to close the polygon.

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 an array of points that defines a polygon.

  • Creates a path and adds the polygon to the path.

  • Draws the path to the screen.

private:
   void AddPolygonExample( PaintEventArgs^ e )
   {
      // Create an array of points.
      array<Point>^ myArray = {Point(23,20),Point(40,10),Point(57,20),Point(50,40),Point(30,40)};

      // Create a GraphicsPath object and add a polygon.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      myPath->AddPolygon( myArray );

      // Draw the path to the screen.
      Pen^ myPen = gcnew Pen( Color::Black,2.0f );
      e->Graphics->DrawPath( myPen, myPath );
   }

.NET Framework
Available since 1.1
Return to top
Show: