GraphicsPathIterator.Enumerate Method

Definition

Overloads

Enumerate(PointF[], Byte[])

Copies the PathPoints property and PathTypes property arrays of the associated GraphicsPath into the two specified arrays.

Enumerate(Span<PointF>, Span<Byte>)

Copies the PathPoints property and PathTypes property arrays of the associated GraphicsPath into the two specified arrays.

Enumerate(PointF[], Byte[])

Source:
GraphicsPathIterator.cs
Source:
GraphicsPathIterator.cs
Source:
GraphicsPathIterator.cs
Source:
GraphicsPathIterator.cs
Source:
GraphicsPathIterator.cs
Source:
GraphicsPathIterator.cs

Copies the PathPoints property and PathTypes property arrays of the associated GraphicsPath into the two specified arrays.

C#
public int Enumerate(ref System.Drawing.PointF[] points, ref byte[] types);

Parameters

points
PointF[]

Upon return, contains an array of PointF structures that represents the points in the path.

types
Byte[]

Upon return, contains an array of bytes that represents the types of points in the path.

Returns

The number of points copied.

Examples

The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code performs the following actions:

  • Creates a graphics path.

  • Populates it with several primitives and some markers.

  • Lists the path data on the left side of the screen.

  • Creates a GraphicsPathIterator and rewinds it.

  • Increments the path data index to the second marker.

  • Calls the Enumerate method to copy the path data to the points and types arrays.

  • Lists this copied data on the right side of the screen.

C#
public void EnumerateExample(PaintEventArgs e)
{
    GraphicsPath myPath = new GraphicsPath();
    Point[] myPoints =
             {
                 new Point(20, 20),
                 new Point(120, 120),
                 new Point(20, 120),
                 new Point(20, 20)
             };
    Rectangle myRect = new Rectangle(120, 120, 100, 100);
    myPath.AddLines(myPoints);
    myPath.AddRectangle(myRect);
    myPath.AddEllipse(220, 220, 100, 100);
             
    // Get the total number of points for the path, and arrays of
    // the  points and types.
    int myPathPointCount = myPath.PointCount;
    PointF[] myPathPoints = myPath.PathPoints;
    byte[] myPathTypes = myPath.PathTypes;
             
    // Set up variables for listing the array of points on the left
    // side of the screen.
    int i;
    float j = 20;
    Font myFont = new Font("Arial", 8);
    SolidBrush myBrush = new SolidBrush(Color.Black);
             
    // List the set of points and types and types to the left side
    // of the screen.
    e.Graphics.DrawString("Original Data",
        myFont,
        myBrush,
        20,
        j);
    j += 20;
    for(i=0; i<myPathPointCount; i++)
    {
        e.Graphics.DrawString(myPathPoints[i].X.ToString()+
            ", " + myPathPoints[i].Y.ToString() + ", " +
            myPathTypes[i].ToString(),
            myFont,
            myBrush,
            20,
            j);
        j+=20;
    }
             
    // Create a GraphicsPathIterator for myPath.
    GraphicsPathIterator myPathIterator =
        new GraphicsPathIterator(myPath);
    myPathIterator.Rewind();
    PointF[] points = new PointF[myPathIterator.Count];
    byte[] types = new byte[myPathIterator.Count];
    int numPoints = myPathIterator.Enumerate(ref points, ref types);
             
    // Draw the set of copied points and types to the screen.
    j = 20;
    e.Graphics.DrawString("Copied Data",
        myFont,
        myBrush,
        200,
        j);
    j += 20;
    for(i=0; i<points.Length; i++)
    {
        e.Graphics.DrawString("Point: " + i +
            ", " + "Value: " + points[i].ToString() + ", " +
            "Type: " + types[i].ToString(),
            myFont,
            myBrush,
            200,
            j);
        j+=20;
    }
}

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (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, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Enumerate(Span<PointF>, Span<Byte>)

Source:
GraphicsPathIterator.cs
Source:
GraphicsPathIterator.cs
Source:
GraphicsPathIterator.cs

Copies the PathPoints property and PathTypes property arrays of the associated GraphicsPath into the two specified arrays.

C#
public int Enumerate(Span<System.Drawing.PointF> points, Span<byte> types);

Parameters

points
Span<PointF>

Upon return, contains an array of PointF structures that represents the points in the path.

types
Span<Byte>

Upon return, contains an array of bytes that represents the types of points in the path.

Returns

The number of points copied.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 9 (package-provided), 10 (package-provided)
Windows Desktop 9, 10