GraphicsPath.AddLine 方法

定义

向此 GraphicsPath 追加一条线段。Appends a line segment to this GraphicsPath.

重载

AddLine(Point, Point)

向此 GraphicsPath 追加一条线段。Appends a line segment to this GraphicsPath.

AddLine(PointF, PointF)

向此 GraphicsPath 追加一条线段。Appends a line segment to this GraphicsPath.

AddLine(Int32, Int32, Int32, Int32)

向当前图形追加一条线段。Appends a line segment to the current figure.

AddLine(Single, Single, Single, Single)

向此 GraphicsPath 追加一条线段。Appends a line segment to this GraphicsPath.

AddLine(Point, Point)

向此 GraphicsPath 追加一条线段。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)

参数

pt1
Point

表示直线起始点的 PointA Point that represents the starting point of the line.

pt2
Point

表示直线终结点的 PointA Point that represents the endpoint of the line.

示例

有关示例,请参见 AddLine(Int32, Int32, Int32, Int32)For an example, see AddLine(Int32, Int32, Int32, Int32).

注解

此方法将指定点定义的线段添加到此的末尾 GraphicsPathThis method adds the line segment defined by the specified points to the end of this GraphicsPath. 如果中有前面的行或曲线 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.

适用于

AddLine(PointF, PointF)

向此 GraphicsPath 追加一条线段。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)

参数

pt1
PointF

表示直线起始点的 PointFA PointF that represents the starting point of the line.

pt2
PointF

表示直线终结点的 PointFA PointF that represents the endpoint of the line.

示例

有关示例,请参见 AddLine(Int32, Int32, Int32, Int32)For an example, see AddLine(Int32, Int32, Int32, Int32).

注解

此方法将指定点定义的线段添加到此的末尾 GraphicsPathThis method adds the line segment defined by the specified points to the end of this GraphicsPath. 如果中有前面的行或曲线 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.

适用于

AddLine(Int32, Int32, Int32, Int32)

向当前图形追加一条线段。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)

参数

x1
Int32

直线起始点的 X 坐标。The x-coordinate of the starting point of the line.

y1
Int32

直线起始点的 Y 坐标。The y-coordinate of the starting point of the line.

x2
Int32

直线终结点的 X 坐标。The x-coordinate of the endpoint of the line.

y2
Int32

直线终结点的 Y 坐标。The y-coordinate of the endpoint of the line.

示例

下面的代码示例旨在与 Windows 窗体一起使用,并且它需要 PaintEventArgs e 一个 OnPaint 事件对象。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 );
   }
private void AddLineExample(PaintEventArgs e)
{
             
    //Create a path and add a symetrical 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 symetrical 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

注解

此方法将指定点定义的线段添加到当前图形的末尾。This method adds the line segment defined by the specified points to the end of the current figure. 如果中有前面的行或曲线 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.

适用于

AddLine(Single, Single, Single, Single)

向此 GraphicsPath 追加一条线段。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)

参数

x1
Single

直线起始点的 X 坐标。The x-coordinate of the starting point of the line.

y1
Single

直线起始点的 Y 坐标。The y-coordinate of the starting point of the line.

x2
Single

直线终结点的 X 坐标。The x-coordinate of the endpoint of the line.

y2
Single

直线终结点的 Y 坐标。The y-coordinate of the endpoint of the line.

示例

有关示例,请参见 AddLine(Int32, Int32, Int32, Int32)For an example, see AddLine(Int32, Int32, Int32, Int32).

注解

此方法将指定点定义的线段添加到此的末尾 GraphicsPathThis method adds the line segment defined by the specified points to the end of this GraphicsPath. 如果中有前面的行或曲线 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.

适用于