GraphicsPath::AddPolygon Method (array<Point>^)
.NET Framework (current version)
Adds a polygon to this path.
Assembly: System.Drawing (in System.Drawing.dll)
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
Available since 1.1
Show: