Adds a polygon to this path.
Namespace:
System.Drawing.Drawing2D
Assembly:
System.Drawing (in System.Drawing.dll)
Visual Basic (Declaration)
Public Sub AddPolygon ( _
points As Point() _
)
Dim instance As GraphicsPath
Dim points As Point()
instance.AddPolygon(points)
public void AddPolygon(
Point[] points
)
public:
void AddPolygon(
array<Point>^ points
)
public function AddPolygon(
points : Point[]
)
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 PaintEventArgs e, 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.
Public Sub AddPolygonExample(ByVal e As PaintEventArgs)
' Create an array of points.
Dim myArray As Point() = {New Point(23, 20), New Point(40, 10), _
New Point(57, 20), New Point(50, 40), New Point(30, 40)}
' Create a GraphicsPath object and add a polygon.
Dim myPath As New GraphicsPath
myPath.AddPolygon(myArray)
' Draw the path to the screen.
Dim myPen As New Pen(Color.Black, 2)
e.Graphics.DrawPath(myPen, myPath)
End Sub
private void AddPolygonExample(PaintEventArgs e)
{
// Create an array of points.
Point[] myArray =
{
new Point(23, 20),
new Point(40, 10),
new Point(57, 20),
new Point(50, 40),
new Point(30, 40)
};
// Create a GraphicsPath object and add a polygon.
GraphicsPath myPath = new GraphicsPath();
myPath.AddPolygon(myArray);
// Draw the path to the screen.
Pen myPen = new Pen(Color.Black, 2);
e.Graphics.DrawPath(myPen, myPath);
}
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 );
}
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Reference