Share via


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)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
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 Forms 使用,而且需要 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)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
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)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
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)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
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先前的線條或曲線,則會繪製線條線段,以將路徑中的最後一個點連接到新線段的第一個點。

適用於