GraphicsPath.AddLines 方法

定義

將一系列的連接線段附加至這個 GraphicsPath的結尾。

多載

AddLines(Point[])

將一系列的連接線段附加至這個 GraphicsPath的結尾。

AddLines(PointF[])

將一系列的連接線段附加至這個 GraphicsPath的結尾。

AddLines(ReadOnlySpan<Point>)
AddLines(ReadOnlySpan<PointF>)

AddLines(Point[])

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs

將一系列的連接線段附加至這個 GraphicsPath的結尾。

C#
public void AddLines (System.Drawing.Point[] points);
C#
public void AddLines (params System.Drawing.Point[] points);

參數

points
Point[]

Point 結構的陣列,表示定義要加入之線條線段的點。

範例

下列程式代碼範例的設計目的是要與 Windows Forms 搭配使用,而且需要 PaintEventArgseOnPaint 事件物件。 程式代碼會執行下列動作:

  • 建立描述三角形的四點陣列。

  • 建立路徑,並新增行陣列。

  • 繪製畫面的路徑。

請注意,第一個點後面的每一行都會使用前一個點做為起點,而新點作為端點。

C#
private void AddLinesExample(PaintEventArgs e)
{
             
    // Create a symmetrical triangle using an array of points.
    Point[] myArray =
             {
                 new Point(30,30),
                 new Point(60,60),
                 new Point(0,60),
                 new Point(30,30)
             };
             
    //Create a path and add lines.
    GraphicsPath myPath = new GraphicsPath();
    myPath.AddLines(myArray);
             
    // Draw the path to the screen.
    Pen myPen = new Pen(Color.Black, 2);
    e.Graphics.DrawPath(myPen, myPath);
}

備註

如果圖中有上一條線條或曲線,則會新增一條線來連接上一個線段的起點。 points 參數會指定端點陣列。 前兩個指定第一行。 每個額外的點都會指定線段的端點,其起點是上一行的端點。

適用於

.NET 9 及其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

AddLines(PointF[])

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs

將一系列的連接線段附加至這個 GraphicsPath的結尾。

C#
public void AddLines (System.Drawing.PointF[] points);
C#
public void AddLines (params System.Drawing.PointF[] points);

參數

points
PointF[]

PointF 結構的陣列,表示定義要加入之線條線段的點。

範例

如需範例,請參閱 AddLines(Point[])

備註

如果圖中有上一條線條或曲線,則會新增一條線來連接上一個線段的起點。 points 參數會指定端點陣列。 前兩個指定第一行。 每個額外的點都會指定線段的端點,其起點是上一行的端點。

適用於

.NET 9 及其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

AddLines(ReadOnlySpan<Point>)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
C#
public void AddLines (scoped ReadOnlySpan<System.Drawing.Point> points);

參數

適用於

.NET 9 和 Windows Desktop 9
產品 版本
.NET 9
Windows Desktop 9

AddLines(ReadOnlySpan<PointF>)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
C#
public void AddLines (scoped ReadOnlySpan<System.Drawing.PointF> points);

參數

適用於

.NET 9 和 Windows Desktop 9
產品 版本
.NET 9
Windows Desktop 9