GraphicsPath.AddPath(GraphicsPath, Boolean) 方法
定义
将指定的 GraphicsPath 追加到该路径。Appends the specified GraphicsPath to this path.
public:
void AddPath(System::Drawing::Drawing2D::GraphicsPath ^ addingPath, bool connect);
public void AddPath (System.Drawing.Drawing2D.GraphicsPath addingPath, bool connect);
member this.AddPath : System.Drawing.Drawing2D.GraphicsPath * bool -> unit
Public Sub AddPath (addingPath As GraphicsPath, connect As Boolean)
参数
- addingPath
- GraphicsPath
要添加的 GraphicsPath。The GraphicsPath to add.
- connect
- Boolean
一个布尔值,它指定添加的路径中的第一个图形是否是该路径中最后一个图形的一部分。A Boolean value that specifies whether the first figure in the added path is part of the last figure in this path. true 的值指定(如果可能)添加的路径中的第一个图形是该路径中最后一个图形的一部分。A value of true specifies that (if possible) the first figure in the added path is part of the last figure in this path. false 的值指定添加的路径中的第一个图形与该路径中最后一个图形不同。A value of false specifies that the first figure in the added path is separate from the last figure in this path.
示例
下面的代码示例旨在与 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 two paths one a right-side-up triangle and the other an up-side-down triangle.
向第一个路径添加第二个路径。Adds the second path to the first.
将生成的路径绘制到屏幕上。Draws the resultant path to the screen.
private:
void AddPathExample( PaintEventArgs^ e )
{
// Create the first pathright side up triangle.
array<Point>^ myArray = {Point(30,30),Point(60,60),Point(0,60),Point(30,30)};
GraphicsPath^ myPath = gcnew GraphicsPath;
myPath->AddLines( myArray );
// Create the second pathinverted triangle.
array<Point>^ myArray2 = {Point(30,30),Point(0,0),Point(60,0),Point(30,30)};
GraphicsPath^ myPath2 = gcnew GraphicsPath;
myPath2->AddLines( myArray2 );
// Add the second path to the first path.
myPath->AddPath( myPath2, true );
// Draw the combined path to the screen.
Pen^ myPen = gcnew Pen( Color::Black,2.0f );
e->Graphics->DrawPath( myPen, myPath );
}
private void AddPathExample(PaintEventArgs e)
{
// Create the first pathright side up triangle.
Point[] myArray =
{
new Point(30,30),
new Point(60,60),
new Point(0,60),
new Point(30,30)
};
GraphicsPath myPath = new GraphicsPath();
myPath.AddLines(myArray);
// Create the second pathinverted triangle.
Point[] myArray2 =
{
new Point(30,30),
new Point(0,0),
new Point(60,0),
new Point(30,30)
};
GraphicsPath myPath2 = new GraphicsPath();
myPath2.AddLines(myArray2);
// Add the second path to the first path.
myPath.AddPath(myPath2,true);
// Draw the combined path to the screen.
Pen myPen = new Pen(Color.Black, 2);
e.Graphics.DrawPath(myPen, myPath);
}
Public Sub AddPathExample(ByVal e As PaintEventArgs)
' Creates a symetrical triangle and adds an inverted triangle.
' Create the first path - right side up triangle.
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)
' Create the second path - inverted triangle.
Dim myArray2 As Point() = {New Point(30, 30), New Point(0, 0), _
New Point(60, 0), New Point(30, 30)}
Dim myPath2 As New GraphicsPath
myPath2.AddLines(myArray2)
' Add the second path to the first path.
myPath.AddPath(myPath2, True)
' Draw the combined path to the screen.
Dim myPen As New Pen(Color.Black, 2)
e.Graphics.DrawPath(myPen, myPath)
End Sub