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

 

Appends a series of connected line segments to the end of this GraphicsPath.

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

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

Parameters

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

An array of Point structures that represents the points that define the line segments to add.

If there are previous lines or curves in the figure, a line is added to connect the endpoint of the previous segment the starting point of the line. The points parameter specifies an array of endpoints. The first two specify the first line. Each additional point specifies the endpoint of a line segment whose starting point is the endpoint of the previous line.

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 four points that describe a triangle.

  • Creates a path and adds the array of lines.

  • Draws the path to screen.

Notice that each line after the first point uses the previous point as the starting point and the new point as the endpoint.

private:
   void AddLinesExample( PaintEventArgs^ e )
   {
      // Create a symetrical triangle using an array of points.
      array<Point>^ myArray = {Point(30,30),Point(60,60),Point(0,60),Point(30,30)};

      //Create a path and add lines.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      myPath->AddLines( 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: