GraphicsPath.AddLine 方法

定义

向此 GraphicsPath 追加一条线段。

重载

AddLine(Int32, Int32, Int32, Int32)

向当前图形追加一条线段。

AddLine(Single, Single, Single, Single)

向此 GraphicsPath 追加一条线段。

AddLine(Point, Point)

向此 GraphicsPath 追加一条线段。

AddLine(PointF, PointF)

向此 GraphicsPath 追加一条线段。

AddLine(Int32, Int32, Int32, Int32)

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

向当前图形追加一条线段。

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 坐标。

y1
Int32

直线起始点的 Y 坐标。

x2
Int32

直线终结点的 X 坐标。

y2
Int32

直线终结点的 Y 坐标。

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse事件OnPaint对象。 该代码创建一个路径,添加构成三角形的三条线,然后将路径绘制到屏幕。

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

注解

此方法将指定点定义的线段添加到当前图形的末尾。 如果 中存在以前的线条或曲线 GraphicsPath,则绘制一条线段以将路径中的最后一个点连接到新线段中的第一个点。

适用于

AddLine(Single, Single, Single, Single)

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

向此 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 坐标。

y1
Single

直线起始点的 Y 坐标。

x2
Single

直线终结点的 X 坐标。

y2
Single

直线终结点的 Y 坐标。

示例

有关示例,请参见 AddLine(Int32, Int32, Int32, Int32)

注解

此方法将指定点定义的线段添加到此 GraphicsPath的末尾。 如果 中存在以前的线条或曲线 GraphicsPath,则绘制一条线段以将路径中的最后一个点连接到新线段中的第一个点。

适用于

AddLine(Point, Point)

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

向此 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

表示直线起始点的 Point

pt2
Point

表示直线终结点的 Point

示例

有关示例,请参见 AddLine(Int32, Int32, Int32, Int32)

注解

此方法将指定点定义的线段添加到此 GraphicsPath的末尾。 如果 中存在以前的线条或曲线 GraphicsPath,则绘制一条线段以将路径中的最后一个点连接到新线段中的第一个点。

适用于

AddLine(PointF, PointF)

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

向此 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

表示直线起始点的 PointF

pt2
PointF

表示直线终结点的 PointF

示例

有关示例,请参见 AddLine(Int32, Int32, Int32, Int32)

注解

此方法将指定点定义的线段添加到此 GraphicsPath的末尾。 如果 中存在以前的线条或曲线 GraphicsPath,则绘制一条线段以将路径中的最后一个点连接到新线段中的第一个点。

适用于