Прочетете на английски Редактиране

Споделяне чрез


GraphicsPathIterator.NextMarker Method

Definition

Moves the iterator to the next marker in the path.

Overloads

NextMarker(GraphicsPath)

This GraphicsPathIterator object has a GraphicsPath object associated with it. The NextMarker(GraphicsPath) method increments the associated GraphicsPath to the next marker in its path and copies all the points contained between the current marker and the next marker (or end of path) to a second GraphicsPath object passed in to the parameter.

NextMarker(Int32, Int32)

Increments the GraphicsPathIterator to the next marker in the path and returns the start and stop indexes by way of the [out] parameters.

NextMarker(GraphicsPath)

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

This GraphicsPathIterator object has a GraphicsPath object associated with it. The NextMarker(GraphicsPath) method increments the associated GraphicsPath to the next marker in its path and copies all the points contained between the current marker and the next marker (or end of path) to a second GraphicsPath object passed in to the parameter.

C#
public int NextMarker(System.Drawing.Drawing2D.GraphicsPath path);

Parameters

path
GraphicsPath

The GraphicsPath object to which the points will be copied.

Returns

The number of points between this marker and the next.

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 GraphicsPath object.

  • Adds three lines, a rectangle, an ellipse, and two markers.

  • Lists the values of all the path's points to the left side of the screen.

  • Creates a GraphicsPathIterator object.

  • Creates a GraphicsPath object, myPathSection, to receive copied points.

  • Calls the NextMarker method, which iterates to the first marker and copies all the points contained between that marker and the next to myPathSection.

  • Returns the number of points copied to markerPoints.

  • Lists the marker number (the first marker) and number of points it contains to the right side of the screen.

C#
public void NextMarkerExample2(PaintEventArgs e)
{
             
    // Create a graphics path.
    GraphicsPath myPath = new GraphicsPath();
             
    // Set up primitives to add to myPath.
    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);
             
    // Add 3 lines, a rectangle, an ellipse, and 2 markers.
    myPath.AddLines(myPoints);
    myPath.SetMarkers();
    myPath.AddRectangle(myRect);
    myPath.SetMarkers();
    myPath.AddEllipse(220, 220, 100, 100);
             
    // Get the total number of points for the path,
    // and the arrays of the points and types.
    int myPathPointCount = myPath.PointCount;
    PointF[] myPathPoints = myPath.PathPoints;
    byte[] myPathTypes = myPath.PathTypes;
             
    // Set up variables for listing all the values of the path's
    // points to the screen.
    int i;
    float j = 20;
    Font myFont = new Font("Arial", 8);
    SolidBrush myBrush = new SolidBrush(Color.Black);
             
    // List the values for all of path points and types to
    // the left side of the screen.
    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.
    GraphicsPathIterator myPathIterator = new
        GraphicsPathIterator(myPath);
             
    // Rewind the iterator.
    myPathIterator.Rewind();
             
    // Create a GraphicsPath to receive a section of myPath.
    GraphicsPath myPathSection = new GraphicsPath();
             
    // Retrieve and list the number of points contained in
             
    // the first marker to the right side of the screen.
    int markerPoints;
    markerPoints = myPathIterator.NextMarker(myPathSection);
    e.Graphics.DrawString("Marker: 1" + "  Num Points: " +
        markerPoints.ToString(),  myFont, myBrush, 200, 20);
}

Remarks

Use the SetMarkers method to set markers in a path. Markers are used to create groups of subpaths. One or more subpaths can be between two markers.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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

NextMarker(Int32, Int32)

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

Increments the GraphicsPathIterator to the next marker in the path and returns the start and stop indexes by way of the [out] parameters.

C#
public int NextMarker(out int startIndex, out int endIndex);

Parameters

startIndex
Int32

[out] The integer reference supplied to this parameter receives the index of the point that starts a subpath.

endIndex
Int32

[out] The integer reference supplied to this parameter receives the index of the point that ends the subpath to which startIndex points.

Returns

The number of points between this marker and the next.

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 GraphicsPath object.

  • Adds three lines, a rectangle, and an ellipse ¾ with markers between each.

  • Draws the values for the array of points to the screen.

  • Creates a GraphicsPathIterator object.

  • Calls the NextMarker method.

  • Uses the values returned from the iterative calls to NextMarker to draw the start and stop points for each marker to the screen.

  • Draws the value for the total number of points to the screen.

C#
private void NextMarkerExample(PaintEventArgs e)
{
             
    // Create the GraphicsPath.
    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);
             
    // Add 3 lines, a rectangle, an ellipse, and 2 markers.
    myPath.AddLines(myPoints);
    myPath.SetMarkers();
    myPath.AddRectangle(myRect);
    myPath.SetMarkers();
    myPath.AddEllipse(220, 220, 100, 100);
             
    // Get the total number of points for the path,
             
    // and the arrays of the points and types.
    int myPathPointCount = myPath.PointCount;
    PointF[] myPathPoints = myPath.PathPoints;
    byte[] myPathTypes = myPath.PathTypes;
             
    // Set up variables for drawing the array
             
    // of points to the screen.
    int i;
    float j = 20;
    Font myFont = new Font("Arial", 8);
    SolidBrush myBrush = new SolidBrush(Color.Black);
             
    // Draw the set of path points and types to the screen.
    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.
    GraphicsPathIterator myPathIterator = new
        GraphicsPathIterator(myPath);
    int myStartIndex;
    int myEndIndex;
             
    // Rewind the Iterator.
    myPathIterator.Rewind();
             
    // Draw the Markers and their start and end points
             
    // to the screen.
    j=20;
    for(i=0;i<3;i++)
    {
        myPathIterator.NextMarker(out myStartIndex, out myEndIndex);
        e.Graphics.DrawString("Marker " + i.ToString() +
            ":  Start: " + myStartIndex.ToString()+
            "  End: " + myEndIndex.ToString(),
            myFont,
            myBrush,
            200,
            j);
        j += 20;
    }
             
    // Draw the total number of points to the screen.
    j += 20;
    int myPathTotalPoints = myPathIterator.Count;
    e.Graphics.DrawString("Total Points = " +
        myPathTotalPoints.ToString(),
        myFont,
        myBrush,
        200,
        j);
}

Remarks

Use the SetMarkers method to set markers in a path. Markers are used to create groups of subpaths. One or more subpaths can be between two markers.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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