Upraviť

Zdieľať cez


GraphicsPath.AddLine Method

Definition

Appends a line segment to this GraphicsPath.

Overloads

AddLine(Int32, Int32, Int32, Int32)

Appends a line segment to the current figure.

AddLine(Single, Single, Single, Single)

Appends a line segment to this GraphicsPath.

AddLine(Point, Point)

Appends a line segment to this GraphicsPath.

AddLine(PointF, PointF)

Appends a line segment to this GraphicsPath.

AddLine(Int32, Int32, Int32, Int32)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Appends a line segment to the current figure.

public:
 void AddLine(int x1, int y1, int x2, int y2);
public void AddLine (int x1, int y1, int x2, int y2);
member this.AddLine : int * int * int * int -> unit
Public Sub AddLine (x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer)

Parameters

x1
Int32

The x-coordinate of the starting point of the line.

y1
Int32

The y-coordinate of the starting point of the line.

x2
Int32

The x-coordinate of the endpoint of the line.

y2
Int32

The y-coordinate of the endpoint of the line.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, 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 );
   }
private void AddLineExample(PaintEventArgs e)
{
             
    //Create a path and add a symmetrical triangle using AddLine.
    GraphicsPath myPath = new 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 = new Pen(Color.Black, 2);
    e.Graphics.DrawPath(myPen, myPath);
}
Public Sub AddLineExample(ByVal e As PaintEventArgs)

    ' Create a path and add a symmetrical triangle using AddLine.
    Dim myPath As New 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.
    Dim myPen As New Pen(Color.Black, 2)
    e.Graphics.DrawPath(myPen, myPath)
End Sub

Remarks

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.

Applies to

AddLine(Single, Single, Single, Single)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Appends a line segment to this GraphicsPath.

public:
 void AddLine(float x1, float y1, float x2, float y2);
public void AddLine (float x1, float y1, float x2, float y2);
member this.AddLine : single * single * single * single -> unit
Public Sub AddLine (x1 As Single, y1 As Single, x2 As Single, y2 As Single)

Parameters

x1
Single

The x-coordinate of the starting point of the line.

y1
Single

The y-coordinate of the starting point of the line.

x2
Single

The x-coordinate of the endpoint of the line.

y2
Single

The y-coordinate of the endpoint of the line.

Examples

For an example, see AddLine(Int32, Int32, Int32, Int32).

Remarks

This method adds the line segment defined by the specified points to the end of this GraphicsPath. 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.

Applies to

AddLine(Point, Point)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Appends a line segment to this GraphicsPath.

public:
 void AddLine(System::Drawing::Point pt1, System::Drawing::Point pt2);
public void AddLine (System.Drawing.Point pt1, System.Drawing.Point pt2);
member this.AddLine : System.Drawing.Point * System.Drawing.Point -> unit
Public Sub AddLine (pt1 As Point, pt2 As Point)

Parameters

pt1
Point

A Point that represents the starting point of the line.

pt2
Point

A Point that represents the endpoint of the line.

Examples

For an example, see AddLine(Int32, Int32, Int32, Int32).

Remarks

This method adds the line segment defined by the specified points to the end of this GraphicsPath. 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.

Applies to

AddLine(PointF, PointF)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Appends a line segment to this GraphicsPath.

public:
 void AddLine(System::Drawing::PointF pt1, System::Drawing::PointF pt2);
public void AddLine (System.Drawing.PointF pt1, System.Drawing.PointF pt2);
member this.AddLine : System.Drawing.PointF * System.Drawing.PointF -> unit
Public Sub AddLine (pt1 As PointF, pt2 As PointF)

Parameters

pt1
PointF

A PointF that represents the starting point of the line.

pt2
PointF

A PointF that represents the endpoint of the line.

Examples

For an example, see AddLine(Int32, Int32, Int32, Int32).

Remarks

This method adds the line segment defined by the specified points to the end of this GraphicsPath. 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.

Applies to