GraphicsPathIterator.NextSubpath 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
하위 경로를 지정된 GraphicsPath에 있는 다음 하위 경로로 이동합니다.
오버로드
NextSubpath(GraphicsPath, Boolean) |
이 GraphicsPathIterator의 연결된 경로에서 다음 그림(하위 경로)을 가져옵니다. |
NextSubpath(Int32, Int32, Boolean) |
GraphicsPathIterator를 경로에 있는 다음 하위 경로로 이동합니다. 다음 하위 경로의 시작 인덱스와 끝 인덱스는 [out] 매개 변수에 들어 있습니다. |
NextSubpath(GraphicsPath, Boolean)
- Source:
- GraphicsPathIterator.cs
- Source:
- GraphicsPathIterator.cs
- Source:
- GraphicsPathIterator.cs
이 GraphicsPathIterator의 연결된 경로에서 다음 그림(하위 경로)을 가져옵니다.
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
매개 변수
- path
- GraphicsPath
이 반복기에 대해 가져온 그림(하위 경로)의 데이터 지점과 일치하도록 해당 데이터 지점을 설정하는 GraphicsPath입니다.
- isClosed
- Boolean
[out] 현재 하위 경로가 닫혀 있는지 여부를 나타냅니다. 그림이 닫혀 있으면 true
이고, 그렇지 않으면 false
입니다.
반환
가져온 그림(하위 경로)에 있는 데이터 지점 수입니다. 가져올 그림이 더 이상 없으면 0이 반환됩니다.
예제
다음 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 개체인 이 OnPaint 필요합니다PaintEventArgse
. 코드는 다음 작업을 수행합니다.
GraphicsPath 개체를 만듭니다.
세 줄, 사각형, 타원 및 두 개의 표식을 추가합니다.
모든 경로의 값을 화면 왼쪽에 Lists.
GraphicsPathIterator 개체를 만듭니다.
복사된 GraphicsPath 지점을 수신하는 개체 를
myPathSection
만듭니다.메서드를 NextSubpath 호출하여 세 번째 하위 경로(그림)로 반복하고 해당 하위 경로에 포함된 모든 점을 경로에
myPathSection
복사하고 에 복사된subpathPoints
포인트 수도 반환합니다.화면 오른쪽에 포함된 하위 경로 번호와 포인트 수를 Lists.
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
적용 대상
NextSubpath(Int32, Int32, Boolean)
- Source:
- GraphicsPathIterator.cs
- Source:
- GraphicsPathIterator.cs
- Source:
- GraphicsPathIterator.cs
GraphicsPathIterator를 경로에 있는 다음 하위 경로로 이동합니다. 다음 하위 경로의 시작 인덱스와 끝 인덱스는 [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
매개 변수
- startIndex
- Int32
[out] 다음 하위 경로의 시작 인덱스를 받습니다.
- endIndex
- Int32
[out] 다음 하위 경로의 끝 인덱스를 받습니다.
- isClosed
- Boolean
[out] 하위 경로가 닫혀 있는지 여부를 나타냅니다.
반환
GraphicsPath 개체의 하위 경로 수입니다.
예제
다음 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 개체인 이 OnPaint 필요합니다PaintEventArgse
. 코드는 다음 작업을 수행합니다.
GraphicsPath 개체를 만듭니다.
세 줄, 사각형 및 타원을 추가합니다.
화면에 점 배열의 값을 그립니다.
GraphicsPathIterator 개체를 만듭니다.
NextSubpath 메서드를 호출합니다.
반복 호출 NextSubpath 에서 반환된 값을 사용하여 화면에 각 하위 경로의 시작 및 중지 값을 그립니다.
화면에 대한 총 하위 경로 수에 대한 값을 그립니다.
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
적용 대상
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기