Graphics.DrawLines 方法

定义

绘制连接 Point 结构的数组的一系列线段。

重载

DrawLines(Pen, ReadOnlySpan<Point>)
DrawLines(Pen, ReadOnlySpan<PointF>)
DrawLines(Pen, Point[])

绘制连接 Point 结构的数组的一系列线段。

DrawLines(Pen, PointF[])

绘制连接 PointF 结构的数组的一系列线段。

DrawLines(Pen, ReadOnlySpan<Point>)

Source:
Graphics.cs
Source:
Graphics.cs
C#
public void DrawLines (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.Point> points);

参数

pen
Pen

适用于

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

DrawLines(Pen, ReadOnlySpan<PointF>)

Source:
Graphics.cs
Source:
Graphics.cs
C#
public void DrawLines (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.PointF> points);

参数

pen
Pen

适用于

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

DrawLines(Pen, Point[])

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

绘制连接 Point 结构的数组的一系列线段。

C#
public void DrawLines (System.Drawing.Pen pen, System.Drawing.Point[] points);
C#
public void DrawLines (System.Drawing.Pen pen, params System.Drawing.Point[] points);

参数

pen
Pen

用于确定线段的颜色、宽度和样式的 Pen

points
Point[]

表示要连接的点的 Point 结构的数组。

例外

pen null

-或-

points null

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建黑色笔。

  • 创建线条段点数组。

  • 将连接的线条段绘制到屏幕。

C#
public void DrawLinesPoint(PaintEventArgs e)
{
             
    // Create pen.
    Pen pen = new Pen(Color.Black, 3);
             
    // Create array of points that define lines to draw.
    Point[] points =
             {
                 new Point(10,  10),
                 new Point(10, 100),
                 new Point(200,  50),
                 new Point(250, 300)
             };
             
    //Draw lines to screen.
    e.Graphics.DrawLines(pen, 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

DrawLines(Pen, PointF[])

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

绘制连接 PointF 结构的数组的一系列线段。

C#
public void DrawLines (System.Drawing.Pen pen, System.Drawing.PointF[] points);
C#
public void DrawLines (System.Drawing.Pen pen, params System.Drawing.PointF[] points);

参数

pen
Pen

用于确定线段的颜色、宽度和样式的 Pen

points
PointF[]

表示要连接的点的 PointF 结构的数组。

例外

pen null

-或-

points null

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 代码创建黑色笔。

  • 创建线条段点数组。

  • 将连接的线条段绘制到屏幕。

C#
public void DrawLinesPointF(PaintEventArgs e)
{
             
    // Create pen.
    Pen pen = new Pen(Color.Black, 3);
             
    // Create array of points that define lines to draw.
    PointF[] points =
             {
                 new PointF(10.0F,  10.0F),
                 new PointF(10.0F, 100.0F),
                 new PointF(200.0F,  50.0F),
                 new PointF(250.0F, 300.0F)
             };
             
    //Draw lines to screen.
    e.Graphics.DrawLines(pen, 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