GraphicsPathIterator.NextSubpath Metoda

Definicja

Przenosi ścieżkę podrzędną do następnej ścieżki podrzędnej w określonej GraphicsPathścieżce .

Przeciążenia

NextSubpath(GraphicsPath, Boolean)

Pobiera następny rysunek (ścieżkę podrzędną) ze skojarzonej ścieżki tego GraphicsPathIteratorelementu .

NextSubpath(Int32, Int32, Boolean)

Przenosi element GraphicsPathIterator do następnej ścieżki podrzędnej. Indeks początkowy i indeks końcowy następnej ścieżki podrzędnej znajdują się w parametrach [out].

NextSubpath(GraphicsPath, Boolean)

Źródło:
GraphicsPathIterator.cs
Źródło:
GraphicsPathIterator.cs
Źródło:
GraphicsPathIterator.cs

Pobiera następny rysunek (ścieżkę podrzędną) ze skojarzonej ścieżki tego GraphicsPathIteratorelementu .

public:
 int NextSubpath(System::Drawing::Drawing2D::GraphicsPath ^ path, [Runtime::InteropServices::Out] bool % isClosed);
public int NextSubpath (System.Drawing.Drawing2D.GraphicsPath path, out bool isClosed);
member this.NextSubpath : System.Drawing.Drawing2D.GraphicsPath * bool -> int
Public Function NextSubpath (path As GraphicsPath, ByRef isClosed As Boolean) As Integer

Parametry

path
GraphicsPath

Element GraphicsPath , który ma mieć ustawione punkty danych, aby pasowały do punktów danych pobranego rysunku (podścieżki) dla tego iteratora.

isClosed
Boolean

[out] Wskazuje, czy bieżąca ścieżka podrzędna jest zamknięta. true Jeśli rysunek jest zamknięty, w przeciwnym razie jest falseto .

Zwraca

Liczba punktów danych na pobranej ilustracji (podścieżka). Jeśli nie ma więcej danych do pobrania, zwracany jest zero.

Przykłady

Poniższy przykład jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgseOnPaint obiektu zdarzenia . Kod wykonuje następujące akcje:

  • Tworzy obiekt GraphicsPath.

  • Dodaje trzy linie, prostokąt, wielokropek i dwa znaczniki.

  • Listy wartości wszystkich punktów ścieżki po lewej stronie ekranu.

  • Tworzy obiekt GraphicsPathIterator.

  • GraphicsPath Tworzy obiekt , myPathSectionaby otrzymywać skopiowane punkty.

  • Wywołuje metodę NextSubpath , która iteruje trzecią ścieżkę podrzędną (rysunek) i kopiuje wszystkie punkty zawarte w tej ścieżce myPathSection podrzędnej, a także zwraca liczbę punktów skopiowanych do subpathPoints.

  • Listy numer ścieżki podrzędnej i liczbę punktów, które zawiera po prawej stronie ekranu.

void NextSubpathExample2( 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 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 of all the 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 for myPath.
   GraphicsPathIterator^ myPathIterator = gcnew GraphicsPathIterator( myPath );

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

   // Create the GraphicsPath section.
   GraphicsPath^ myPathSection = gcnew GraphicsPath;

   // Iterate to the 3rd subpath and list the number of points therein
   // to the screen.
   int subpathPoints;
   bool IsClosed2;

   // Iterate to the third subpath.
   subpathPoints = myPathIterator->NextSubpath( myPathSection, IsClosed2 );
   subpathPoints = myPathIterator->NextSubpath( myPathSection, IsClosed2 );
   subpathPoints = myPathIterator->NextSubpath( myPathSection, IsClosed2 );

   // Write the number of subpath points to the screen.
   e->Graphics->DrawString( String::Format( "Subpath: 3   Num Points: {0}", subpathPoints ), myFont, myBrush, 200, 20 );
}
public void NextSubpathExample2(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 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 of all the 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 for myPath.
    GraphicsPathIterator myPathIterator = new
        GraphicsPathIterator(myPath);
         
    // Rewind the iterator.
    myPathIterator.Rewind();
         
    // Create the GraphicsPath section.
    GraphicsPath myPathSection = new GraphicsPath();
         
    // Iterate to the 3rd subpath and list the number of points therein
         
    // to the screen.
    int subpathPoints;
    bool IsClosed2;
         
    // Iterate to the third subpath.
    subpathPoints = myPathIterator.NextSubpath(
        myPathSection, out IsClosed2);
    subpathPoints = myPathIterator.NextSubpath(
        myPathSection, out IsClosed2);
    subpathPoints = myPathIterator.NextSubpath(
        myPathSection, out IsClosed2);
         
    // Write the number of subpath points to the screen.
    e.Graphics.DrawString("Subpath: 3"  +
        "   Num Points: " +
        subpathPoints.ToString(),
        myFont,
        myBrush,
        200,
        20);
}
Public Sub NextSubpathExample2(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 for myPath.
    Dim myPathIterator As New GraphicsPathIterator(myPath)

    ' Rewind the iterator.
    myPathIterator.Rewind()

    ' Create the GraphicsPath section.
    Dim myPathSection As New GraphicsPath

    ' Draw the 3rd subpath and the number of points therein
    ' to the screen.
    Dim subpathPoints As Integer
    Dim IsClosed2 As Boolean

    ' Iterate to the third subpath.
    subpathPoints = myPathIterator.NextSubpath(myPathSection, _
        IsClosed2)
    subpathPoints = myPathIterator.NextSubpath(myPathSection, _
        IsClosed2)
    subpathPoints = myPathIterator.NextSubpath(myPathSection, _
        IsClosed2)

    ' Write the number of subpath points to the screen.
    e.Graphics.DrawString("Subpath: 3" + "   Num Points: " + _
    subpathPoints.ToString(), myFont, myBrush, 200, 20)
End Sub

Dotyczy

NextSubpath(Int32, Int32, Boolean)

Źródło:
GraphicsPathIterator.cs
Źródło:
GraphicsPathIterator.cs
Źródło:
GraphicsPathIterator.cs

Przenosi element GraphicsPathIterator do następnej ścieżki podrzędnej. Indeks początkowy i indeks końcowy następnej ścieżki podrzędnej znajdują się w parametrach [out].

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

Parametry

startIndex
Int32

[out] Odbiera indeks początkowy następnej ścieżki podrzędnej.

endIndex
Int32

[out] Odbiera końcowy indeks następnej ścieżki podrzędnej.

isClosed
Boolean

[out] Wskazuje, czy ścieżka podrzędna jest zamknięta.

Zwraca

Liczba ścieżek podrzędnych w GraphicsPath obiekcie.

Przykłady

Poniższy przykład jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgseOnPaint obiektu zdarzenia . Kod wykonuje następujące akcje:

  • Tworzy obiekt GraphicsPath.

  • Dodaje trzy linie, prostokąt i wielokropek.

  • Rysuje wartości tablicy punktów na ekranie.

  • Tworzy obiekt GraphicsPathIterator.

  • Wywołuje metodę NextSubpath .

  • Używa wartości zwracanych z iteracyjnych wywołań, aby NextSubpath narysować wartości początkowe i zatrzymane dla każdej ścieżki podrzędnej do ekranu.

  • Rysuje wartość dla całkowitej liczby ścieżek podrzędnych na ekranie.

private:
   void NextSubpathExample( 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->AddRectangle( myRect );
      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;
      bool myIsClosed;

      // get the number of Subpaths.
      int numSubpaths = myPathIterator->NextSubpath( myPath, myIsClosed );
      numSubpaths -= 1;

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

      // List the Subpaths to the screen.
      j = 20;
      for ( i = 0; i < numSubpaths; i++ )
      {
         myPathIterator->NextSubpath( myStartIndex, myEndIndex, myIsClosed );
         String^ s = String::Format( "Subpath {0}:  Start: {1}", i, myStartIndex );
         s = s + String::Format( "  End: {0}  IsClosed: {1}", myEndIndex, myIsClosed );
         e->Graphics->DrawString( s, myFont, myBrush, 200, j );
         j += 20;
      }

      // Draw the total number of Subpaths to the screen.
      j += 20;
      e->Graphics->DrawString( String::Format( "Number Subpaths = {0}", numSubpaths ), myFont, myBrush, 200, j );
   }
private void NextSubpathExample(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.AddRectangle(myRect);
    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;
    bool myIsClosed;
             
    // get the number of Subpaths.
    int numSubpaths = myPathIterator.NextSubpath(myPath,
        out myIsClosed);
    numSubpaths -= 1;
             
    // Rewind the Iterator.
    myPathIterator.Rewind();
             
    // List the Subpaths to the screen.
    j=20;
    for(i=0;i<numSubpaths;i++)
    {
        myPathIterator.NextSubpath(out myStartIndex,
            out myEndIndex,
            out myIsClosed);
        e.Graphics.DrawString("Subpath " + i.ToString() +
            ":  Start: " + myStartIndex.ToString()+
            "  End: " + myEndIndex.ToString() +
            "  IsClosed: " + myIsClosed.ToString(),
            myFont,
            myBrush,
            200,
            j);
        j += 20;
    }
             
    // Draw the total number of Subpaths to the screen.
    j += 20;
    e.Graphics.DrawString("Number Subpaths = " +
        numSubpaths.ToString(),
        myFont,
        myBrush,
        200,
        j);
}
Public Sub NextSubpathExample(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.AddRectangle(myRect)
    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
    Dim myIsClosed As Boolean

    ' get the number of Subpaths.
    Dim numSubpaths As Integer = myPathIterator.NextSubpath(myPath, _
        myIsClosed)
    numSubpaths -= 1

    ' Rewind the Iterator.
    myPathIterator.Rewind()

    ' List the Subpaths to the screen.
    j = 20
    For i = 0 To numSubpaths - 1
        myPathIterator.NextSubpath(myStartIndex, myEndIndex, _
        myIsClosed)
        e.Graphics.DrawString("Subpath " + i.ToString() + _
            ":  Start: " + myStartIndex.ToString() + "  End: " + _
            myEndIndex.ToString() + "  IsClosed: " + _
            myIsClosed.ToString(), myFont, myBrush, 200, j)
        j += 20
    Next i

    ' Draw the total number of Subpaths to the screen.
    j += 20
    e.Graphics.DrawString("Number Subpaths = " + _
        numSubpaths.ToString(), myFont, myBrush, 200, j)
End Sub

Dotyczy