GraphicsPath::AddLine Method (Int32, Int32, Int32, Int32)
.NET Framework (current version)
Appends a line segment to the current figure.
Assembly: System.Drawing (in System.Drawing.dll)
Parameters
- x1
-
Type:
System::Int32
The x-coordinate of the starting point of the line.
- y1
-
Type:
System::Int32
The y-coordinate of the starting point of the line.
- x2
-
Type:
System::Int32
The x-coordinate of the endpoint of the line.
- y2
-
Type:
System::Int32
The y-coordinate of the endpoint of the line.
This method adds the line segment defined by the specified points to the end of the current figure. If there are previous lines or curves in the GraphicsPath, a line segment is drawn to connect the last point in the path to the first point in the new line segment.
The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. The code creates a path, adds three lines that form a triangle, and then draws the path to the screen.
private: void AddLineExample( PaintEventArgs^ e ) { //Create a path and add a symetrical triangle using AddLine. GraphicsPath^ myPath = gcnew GraphicsPath; myPath->AddLine( 30, 30, 60, 60 ); myPath->AddLine( 60, 60, 0, 60 ); myPath->AddLine( 0, 60, 30, 30 ); // 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: