GraphicsPathIterator.NextPathType(Byte, Int32, Int32) 메서드

정의

형식이 모두 같은 데이터 지점의 다음 그룹에 대한 시작 인덱스와 끝 인덱스를 가져옵니다.

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

매개 변수

pathType
Byte

[out] 그룹 내 모든 점이 공유하는 점 종류를 받습니다. 가능한 종류는 PathPointType 열거형에서 검색할 수 있습니다.

startIndex
Int32

[out] 점 그룹의 시작 인덱스를 받습니다.

endIndex
Int32

[out] 점 그룹의 끝 인덱스를 받습니다.

반환

이 메서드는 그룹에 있는 데이터 지점 수를 반환합니다. 경로에 그룹이 더 이상 없으면 이 메서드는 0을 반환합니다.

예제

다음 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 개체인 이 OnPaint 필요합니다PaintEventArgse. 코드는 다음 작업을 수행합니다.

  • GraphicsPath 개체를 만듭니다.

  • 세 줄, 사각형 및 타원을 추가합니다.

  • 모든 점의 값을 화면 왼쪽에 Lists.

  • GraphicsPathIterator 만들고 되 감습니다.

  • for 루프에서 는 및 NextPathType 메서드를 사용하여 NextPathType 지점을 반복합니다.

  • 반복 호출에서 반환된 값을 사용하여 하위 경로 번호, 그 안에 있는 점 수 및 화면 오른쪽을 가리키는 경로 형식을 나열합니다.

  • 화면에 대한 총 점 수의 값을 표시합니다.

ListPathPoints 는 표시 코드의 대부분(전부는 아님)을 그래픽 경로 코드와 분리하는 도우미 함수입니다.

public:
   void NextPathTypeExample( 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, and an ellipse.
      myPath->AddLines( myPoints );
      myPath->AddRectangle( myRect );
      myPath->AddEllipse( 220, 220, 100, 100 );

      // List all of the path points to the screen.
      ListPathPoints( e, myPath, nullptr, 20, 1 );

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

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

      // Iterate the subpaths and types, and list the results to
      // the screen.
            int i;
      int j = 20;
      int mySubPaths;
      int subPathStartIndex;
      int subPathEndIndex;
      Boolean IsClosed;
      Byte subPathPointType;
      int pointTypeStartIndex;
      int pointTypeEndIndex;
      int numPointsFound;
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",8 );
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Black );
      j = 20;
      for ( i = 0; i < 3; i++ )
      {
         mySubPaths = myPathIterator->NextSubpath( subPathStartIndex, subPathEndIndex, IsClosed );
         numPointsFound = myPathIterator->NextPathType( subPathPointType, pointTypeStartIndex, pointTypeEndIndex );
         e->Graphics->DrawString( String::Format( "SubPath: {0}  Points Found: {1}  Type of Points: {2}", i,
               numPointsFound, subPathPointType ), myFont, myBrush, 200.0f, (float)j );
         j += 20;
      }

      // List the total number of path points to the screen.
      ListPathPoints( e, myPath, myPathIterator, 200, 2 );
   }

   //-------------------------------------------------------
   //This function is a helper function used by
   // NextPathTypeExample.
   //-------------------------------------------------------
   void ListPathPoints( PaintEventArgs^ e, GraphicsPath^ myPath, GraphicsPathIterator^ myPathIterator, int xOffset, int listType )
   {
      // 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 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 );
      if ( listType == 1 )
      {
         // 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, (float)xOffset, (float)j );
            j += 20;
         }
      }
      else
      if ( listType == 2 )
      {
         // Draw the total number of points to the screen.
         int myPathTotalPoints = myPathIterator->Count;
         e->Graphics->DrawString( String::Format( "Total Points = {0}", myPathTotalPoints ), myFont, myBrush, (float)xOffset, 100.0f );
      }
      else
      {
         e->Graphics->DrawString( "Wrong or no list type argument.", myFont, myBrush, (float)xOffset, 200.0f );
      }
   }
public void NextPathTypeExample(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, and an ellipse.
    myPath.AddLines(myPoints);
    myPath.AddRectangle(myRect);
    myPath.AddEllipse(220, 220, 100, 100);
             
    // List all of the path points to the screen.
    ListPathPoints(e, myPath, null, 20, 1);
             
    // Create a GraphicsPathIterator.
    GraphicsPathIterator myPathIterator = new
        GraphicsPathIterator(myPath);
             
    // Rewind the Iterator.
    myPathIterator.Rewind();
             
    // Iterate the subpaths and types, and list the results to
             
    // the screen.
    int i, j = 20;
    int mySubPaths, subPathStartIndex, subPathEndIndex;
    Boolean IsClosed;
    byte subPathPointType;
    int pointTypeStartIndex,  pointTypeEndIndex, numPointsFound;
    Font myFont = new Font("Arial", 8);
    SolidBrush myBrush = new SolidBrush(Color.Black);
    j = 20;
    for(i = 0;i < 3; i++)
    {
        mySubPaths = myPathIterator.NextSubpath(
            out subPathStartIndex,
            out subPathEndIndex,
            out IsClosed);
        numPointsFound = myPathIterator.NextPathType(
            out subPathPointType,
            out pointTypeStartIndex,
            out pointTypeEndIndex);
        e.Graphics.DrawString(
            "SubPath: " + i +
            "  Points Found: " + numPointsFound.ToString() +
            "  Type of Points: " + subPathPointType.ToString(),
            myFont,
            myBrush,
            200,
            j);
        j+=20;
    }
             
    // List the total number of path points to the screen.
    ListPathPoints(e, myPath, myPathIterator, 200, 2);
}
             
//-------------------------------------------------------
//This function is a helper function used by
// NextPathTypeExample.
//-------------------------------------------------------
public void ListPathPoints(
    PaintEventArgs e,
    GraphicsPath myPath,
    GraphicsPathIterator myPathIterator,
    int xOffset,
    int listType)
{
             
    // 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 points to the screen.
    int i;
    float j = 20;
    Font myFont = new Font("Arial", 8);
    SolidBrush myBrush = new SolidBrush(Color.Black);
    if (listType == 1) 
        // List all the path points to the screen.
    {
             
        // 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,
                xOffset,
                j);
            j+=20;
        }
    }
    else if (listType == 2) 
        // Display the total number of path points.
    {
             
        // Draw the total number of points to the screen.
        int myPathTotalPoints = myPathIterator.Count;
        e.Graphics.DrawString("Total Points = " +
            myPathTotalPoints.ToString(),
            myFont,
            myBrush,
            xOffset,
            100);
    }
    else
    {
        e.Graphics.DrawString("Wrong or no list type argument.",
            myFont, myBrush, xOffset, 200);
    }
}
Public Sub NextPathTypeExample(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, and an ellipse.
    myPath.AddLines(myPoints)
    myPath.AddRectangle(myRect)
    myPath.AddEllipse(220, 220, 100, 100)

    ' List all of the path points to the screen.
    ListPathPointsHelper(e, myPath, Nothing, 20, 1)

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

    ' Rewind the Iterator.
    myPathIterator.Rewind()

    ' Iterate the subpaths and types, and list the results
    ' to the screen.
    Dim j As Integer = 20
    Dim i As Integer
    Dim mySubPaths, subPathStartIndex, subPathEndIndex As Integer
    Dim IsClosed As [Boolean]
    Dim subPathPointType As Byte
    Dim pointTypeStartIndex, pointTypeEndIndex, _
    numPointsFound As Integer
    Dim myFont As New Font("Arial", 8)
    Dim myBrush As New SolidBrush(Color.Black)
    j = 20
    For i = 0 To 2
        mySubPaths = myPathIterator.NextSubpath(subPathStartIndex, _
            subPathEndIndex, IsClosed)
        numPointsFound = myPathIterator.NextPathType(subPathPointType, _
            pointTypeStartIndex, pointTypeEndIndex)
        e.Graphics.DrawString("SubPath: " & i & "  Points Found: " & _
            numPointsFound.ToString() & "  Type of Points: " & _
        subPathPointType.ToString(), myFont, myBrush, 200, j)
        j += 20
    Next i

    ' List the total number of path points to the screen.
    ListPathPointsHelper(e, myPath, myPathIterator, 200, 2)
End Sub

' This is a helper function used by NextPathTypeExample.
Public Sub ListPathPointsHelper(ByVal e As PaintEventArgs, _
ByVal myPath As GraphicsPath, ByVal myPathIterator As GraphicsPathIterator, _
ByVal xOffset As Integer, ByVal listType As Integer)

    ' 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 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)
    If listType = 1 Then
        ' List all the path points to the screen.

        ' 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, xOffset, j)
            j += 20
        Next i
    Else
        If listType = 2 Then
            ' Display the total number of path points.

            ' Draw the total number of points to the screen.
            Dim myPathTotalPoints As Integer = myPathIterator.Count
            e.Graphics.DrawString("Total Points = " + _
                myPathTotalPoints.ToString(), myFont, myBrush, xOffset, _
                100)
        Else
            e.Graphics.DrawString("Wrong or no list type argument.", _
                myFont, myBrush, xOffset, 200)
        End If
    End If
End Sub

적용 대상