GraphicsPathIterator.NextMarker Метод

Определение

Перемещает итератор к следующему маркеру в контуре.

Перегрузки

NextMarker(GraphicsPath)

У этого объекта GraphicsPathIterator имеется связанный с ним объект GraphicsPath. Метод NextMarker(GraphicsPath) увеличивает связанный с ним объект GraphicsPath до следующего маркера в его контуре и копирует все точки, содержащиеся между текущим и следующим маркерами (или концом контура), во второй объект GraphicsPath, переданный в параметр.

NextMarker(Int32, Int32)

Увеличивает объект GraphicsPathIterator до следующего маркера в контуре и возвращает начальный и конечный индексы в виде параметров [out].

NextMarker(GraphicsPath)

Исходный код:
GraphicsPathIterator.cs
Исходный код:
GraphicsPathIterator.cs
Исходный код:
GraphicsPathIterator.cs

У этого объекта GraphicsPathIterator имеется связанный с ним объект GraphicsPath. Метод NextMarker(GraphicsPath) увеличивает связанный с ним объект GraphicsPath до следующего маркера в его контуре и копирует все точки, содержащиеся между текущим и следующим маркерами (или концом контура), во второй объект GraphicsPath, переданный в параметр.

public:
 int NextMarker(System::Drawing::Drawing2D::GraphicsPath ^ path);
public int NextMarker (System.Drawing.Drawing2D.GraphicsPath path);
member this.NextMarker : System.Drawing.Drawing2D.GraphicsPath -> int
Public Function NextMarker (path As GraphicsPath) As Integer

Параметры

path
GraphicsPath

Объект GraphicsPath, в который будут скопированы точки.

Возвращаемое значение

Количество точек между этим и следующим маркерами.

Примеры

Следующий пример предназначен для использования с Windows Forms, и для него требуется PaintEventArgseOnPaint объект события . Код выполняет следующие действия.

  • Создает объект GraphicsPath.

  • Добавляет три линии, прямоугольник, эллипс и два маркера.

  • Списки значения всех точек пути в левой части экрана.

  • Создает объект GraphicsPathIterator.

  • Создает GraphicsPath объект myPathSection, для получения скопированных точек.

  • NextMarker Вызывает метод , который выполняет итерацию к первому маркеру и копирует все точки, содержащиеся между этим маркером и рядом с myPathSection.

  • Возвращает количество точек, скопированных в markerPoints.

  • Списки номер маркера (первый маркер) и количество точек, которые он содержит в правой части экрана.

public:
   void NextMarkerExample2( PaintEventArgs^ e )
   {
      // Create a graphics path.
      GraphicsPath^ myPath = gcnew GraphicsPath;

      // Set up primitives to add to myPath.
      array<Point>^ myPoints = {Point(20,20),Point(120,120),Point(20,120),Point(20,20)};
      Rectangle myRect = 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;
      array<PointF>^myPathPoints = myPath->PathPoints;
      array<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;
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",8 );
      SolidBrush^ myBrush = gcnew 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 + ", " + myPathPoints[ i ].Y + ", " + myPathTypes[ i ], myFont, myBrush, 20, j );
         j += 20;
      }

      // Create a GraphicsPathIterator.
      GraphicsPathIterator^ myPathIterator = gcnew GraphicsPathIterator( myPath );

      // Rewind the iterator.
      myPathIterator->Rewind();

      // Create a GraphicsPath to receive a section of myPath.
      GraphicsPath^ myPathSection = gcnew 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( String::Format( "Marker: 1  Num Points: {0}", markerPoints ), myFont, myBrush, 200, 20 );
   }
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);
}
Public Sub NextMarkerExample2(ByVal e As PaintEventArgs)

    ' Create a graphics path.
    Dim myPath As New GraphicsPath

    ' Set up primitives to add to myPath.
    Dim myPoints As Point() = {New Point(20, 20), _
        New Point(120, 120), New Point(20, 120), New Point(20, 20)}
    Dim myRect As 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.
    Dim myPathPointCount As Integer = myPath.PointCount
    Dim myPathPoints As PointF() = myPath.PathPoints
    Dim myPathTypes As Byte() = myPath.PathTypes

    ' Set up variables for drawing the array
    ' of points to the screen.
    Dim i As Integer
    Dim j As Single = 20
    Dim myFont As New Font("Arial", 8)
    Dim myBrush As New SolidBrush(Color.Black)

    ' Draw the set of path points and types to the screen.
    For i = 0 To myPathPointCount - 1
        e.Graphics.DrawString(myPathPoints(i).X.ToString() + _
            ", " + myPathPoints(i).Y.ToString() + ", " + _
            myPathTypes(i).ToString(), myFont, myBrush, 20, j)
        j += 20
    Next i

    ' Create a GraphicsPathIterator.
    Dim myPathIterator As New GraphicsPathIterator(myPath)

    ' Rewind the iterator.
    myPathIterator.Rewind()

    ' Create a GraphicsPath section.
    Dim myPathSection As New GraphicsPath

    ' List the points contained in the first marker
    ' to the screen.
    Dim markerPoints As Integer
    markerPoints = myPathIterator.NextMarker(myPathSection)
    e.Graphics.DrawString("Marker: 1" + "  Num Points: " + _
        markerPoints.ToString(), myFont, myBrush, 200, 20)
End Sub

Комментарии

Используйте метод , SetMarkers чтобы задать маркеры в пути. Маркеры используются для создания групп вложенных путей. Один или несколько вложенных путей могут находиться между двумя маркерами.

Применяется к

NextMarker(Int32, Int32)

Исходный код:
GraphicsPathIterator.cs
Исходный код:
GraphicsPathIterator.cs
Исходный код:
GraphicsPathIterator.cs

Увеличивает объект GraphicsPathIterator до следующего маркера в контуре и возвращает начальный и конечный индексы в виде параметров [out].

public:
 int NextMarker([Runtime::InteropServices::Out] int % startIndex, [Runtime::InteropServices::Out] int % endIndex);
public int NextMarker (out int startIndex, out int endIndex);
member this.NextMarker : int * int -> int
Public Function NextMarker (ByRef startIndex As Integer, ByRef endIndex As Integer) As Integer

Параметры

startIndex
Int32

[out] Ссылка на целое число, предоставляемая данному параметру, получает индекс точки, с которой начинается субконтур.

endIndex
Int32

[out] Ссылка на целое число, предоставляемая данному параметру, получает индекс точки, которой заканчивается субконтур, на который указывает startIndex.

Возвращаемое значение

Количество точек между этим и следующим маркерами.

Примеры

Следующий пример предназначен для использования с Windows Forms, и для него требуется PaintEventArgseOnPaint объект события . Код выполняет следующие действия.

  • Создает объект GraphicsPath.

  • Добавляет три линии, прямоугольник и эллипс 3/4 с маркерами между ними.

  • Рисует значения для массива точек на экране.

  • Создает объект GraphicsPathIterator.

  • Вызывает метод NextMarker.

  • Использует значения, возвращаемые из итеративных вызовов , для NextMarker рисования начальной и стоп-точек для каждого маркера на экране.

  • Рисует значение для общего количества точек на экране.

private:
   void NextMarkerExample( PaintEventArgs^ e )
   {
      // Create the GraphicsPath.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      array<Point>^ myPoints = {Point(20,20),Point(120,120),Point(20,120),Point(20,20)};
      Rectangle myRect = 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;
      array<PointF>^myPathPoints = myPath->PathPoints;
      array<Byte>^myPathTypes = myPath->PathTypes;

      // Set up variables for drawing the array
      // of points to the screen.
      int i;
      float j = 20;
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",8 );
      SolidBrush^ myBrush = gcnew 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 + ", " + myPathPoints[ i ].Y + ", " + myPathTypes[ i ], myFont, myBrush, 20, j );
         j += 20;
      }

      // Create a GraphicsPathIterator.
      GraphicsPathIterator^ myPathIterator = gcnew 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( myStartIndex, myEndIndex );
         e->Graphics->DrawString( String::Format( "Marker {0}:  Start: {1}  End: {2}", i, myStartIndex, myEndIndex ),
               myFont, myBrush, 200, j );
         j += 20;
      }

      // Draw the total number of points to the screen.
      j += 20;
      int myPathTotalPoints = myPathIterator->Count;
      e->Graphics->DrawString( String::Format( "Total Points = {0}", myPathTotalPoints ), myFont, myBrush, 200, j );
   }
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);
}
Public Sub NextMarkerExample(ByVal e As PaintEventArgs)

    ' Create the GraphicsPath.
    Dim myPath As New GraphicsPath
    Dim myPoints As Point() = {New Point(20, 20), _
    New Point(120, 120), New Point(20, 120), New Point(20, 20)}
    Dim myRect As 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.
    Dim myPathPointCount As Integer = myPath.PointCount
    Dim myPathPoints As PointF() = myPath.PathPoints
    Dim myPathTypes As Byte() = myPath.PathTypes

    ' Set up variables for drawing the array of points to the screen.
    Dim i As Integer
    Dim j As Single = 20
    Dim myFont As New Font("Arial", 8)
    Dim myBrush As New SolidBrush(Color.Black)

    ' Draw the set of path points and types to the screen.
    For i = 0 To myPathPointCount - 1
        e.Graphics.DrawString(myPathPoints(i).X.ToString() + ", " + _
            myPathPoints(i).Y.ToString() + ", " + _
            myPathTypes(i).ToString(), myFont, myBrush, 20, j)
        j += 20
    Next i

    ' Create a GraphicsPathIterator.
    Dim myPathIterator As New GraphicsPathIterator(myPath)
    Dim myStartIndex As Integer
    Dim myEndIndex As Integer

    ' Rewind the Iterator.
    myPathIterator.Rewind()

    ' Draw the Markers and their start and end points to the screen.
    j = 20
    For i = 0 To 2
        myPathIterator.NextMarker(myStartIndex, myEndIndex)
        e.Graphics.DrawString("Marker " + i.ToString() + _
            ":  Start: " + myStartIndex.ToString() + "  End: " + _
            myEndIndex.ToString(), myFont, myBrush, 200, j)
        j += 20
    Next i

    ' Draw the total number of points to the screen.
    j += 20
    Dim myPathTotalPoints As Integer = myPathIterator.Count
    e.Graphics.DrawString("Total Points = " + _
        myPathTotalPoints.ToString(), myFont, myBrush, 200, j)
End Sub

Комментарии

Используйте метод , SetMarkers чтобы задать маркеры в пути. Маркеры используются для создания групп вложенных путей. Один или несколько вложенных путей могут находиться между двумя маркерами.

Применяется к