GraphicsPath.AddLines 方法
定义
向此 GraphicsPath 末尾追加一系列相互连接的线段。Appends a series of connected line segments to the end of this GraphicsPath.
重载
| AddLines(PointF[]) |
向此 GraphicsPath 末尾追加一系列相互连接的线段。Appends a series of connected line segments to the end of this GraphicsPath. |
| AddLines(Point[]) |
向此 GraphicsPath 末尾追加一系列相互连接的线段。Appends a series of connected line segments to the end of this GraphicsPath. |
AddLines(PointF[])
向此 GraphicsPath 末尾追加一系列相互连接的线段。Appends a series of connected line segments to the end of this GraphicsPath.
public:
void AddLines(cli::array <System::Drawing::PointF> ^ points);
public void AddLines (System.Drawing.PointF[] points);
member this.AddLines : System.Drawing.PointF[] -> unit
Public Sub AddLines (points As PointF())
参数
- points
- PointF[]
一个 PointF 结构的数组,它表示定义要添加的线段的点。An array of PointF structures that represents the points that define the line segments to add.
示例
有关示例,请参见 AddLines(Point[])。For an example, see AddLines(Point[]).
注解
如果图中有前面的行或曲线,则会添加一条线来连接上一段的终结点,以将该行的起点连接起来。If there are previous lines or curves in the figure, a line is added to connect the endpoint of the previous segment the starting point of the line. points参数指定终结点的数组。The points parameter specifies an array of endpoints. 前两个指定第一行。The first two specify the first line. 每个附加点指定一个线段的端点,其起点是上一行的端点。Each additional point specifies the endpoint of a line segment whose starting point is the endpoint of the previous line.
适用于
AddLines(Point[])
向此 GraphicsPath 末尾追加一系列相互连接的线段。Appends a series of connected line segments to the end of this GraphicsPath.
public:
void AddLines(cli::array <System::Drawing::Point> ^ points);
public void AddLines (System.Drawing.Point[] points);
member this.AddLines : System.Drawing.Point[] -> unit
Public Sub AddLines (points As Point())
参数
- points
- Point[]
一个 Point 结构的数组,它表示定义要添加的线段的点。An array of Point structures that represents the points that define the line segments to add.
示例
下面的代码示例旨在与 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 performs the following actions:
创建描述三角形的四个点的数组。Creates an array of four points that describe a triangle.
创建一个路径并添加行的数组。Creates a path and adds the array of lines.
将路径绘制到屏幕上。Draws the path to screen.
请注意,第一个点后面的每行都使用上一点作为起点,并使用新点作为终结点。Notice that each line after the first point uses the previous point as the starting point and the new point as the endpoint.
private:
void AddLinesExample( PaintEventArgs^ e )
{
// Create a symetrical triangle using an array of points.
array<Point>^ myArray = {Point(30,30),Point(60,60),Point(0,60),Point(30,30)};
//Create a path and add lines.
GraphicsPath^ myPath = gcnew GraphicsPath;
myPath->AddLines( myArray );
// Draw the path to the screen.
Pen^ myPen = gcnew Pen( Color::Black,2.0f );
e->Graphics->DrawPath( myPen, myPath );
}
private void AddLinesExample(PaintEventArgs e)
{
// Create a symetrical 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);
}
Public Sub AddLinesExample(ByVal e As PaintEventArgs)
'Create a symetrical triangle using an array of points.
Dim myArray As Point() = {New Point(30, 30), New Point(60, 60), _
New Point(0, 60), New Point(30, 30)}
Dim myPath As New GraphicsPath
myPath.AddLines(myArray)
' Draw the path to the screen.
Dim myPen As New Pen(Color.Black, 2)
e.Graphics.DrawPath(myPen, myPath)
End Sub
注解
如果图中有前面的行或曲线,则会添加一条线来连接上一段的终结点,以将该行的起点连接起来。If there are previous lines or curves in the figure, a line is added to connect the endpoint of the previous segment the starting point of the line. points参数指定终结点的数组。The points parameter specifies an array of endpoints. 前两个指定第一行。The first two specify the first line. 每个附加点指定一个线段的端点,其起点是上一行的端点。Each additional point specifies the endpoint of a line segment whose starting point is the endpoint of the previous line.