Olvasás angol nyelven Szerkesztés

Megosztás a következőn keresztül:


GraphicsPath.AddPath(GraphicsPath, Boolean) Method

Definition

Appends the specified GraphicsPath to this path.

public void AddPath (System.Drawing.Drawing2D.GraphicsPath addingPath, bool connect);

Parameters

addingPath
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. A value of true specifies that (if possible) the first figure in the added path is part of the last figure in this path. A value of false specifies that the first figure in the added path is separate from the last figure in this path.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, 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.
    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);
}

Applies to

Termék Verziók
.NET 8 (package-provided), 9 (package-provided)
.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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9