次の方法で共有


GraphicsPathIterator.NextSubpath メソッド (Int32, Int32, Boolean)

GraphicsPathIterator オブジェクトをパス内の次のサブパスに移動します。次のサブパスの開始インデックスおよび終了インデックスが、[out] パラメータに格納されます。

Overloads Public Function NextSubpath( _
   <Out()> ByRef startIndex As Integer, _   <Out()> ByRef endIndex As Integer, _   <Out()> ByRef isClosed As Boolean _) As Integer
[C#]
public int NextSubpath(   out intstartIndex,   out intendIndex,   out boolisClosed);
[C++]
public: int NextSubpath(   [   Out] int* startIndex,   [   Out] int* endIndex,   [   Out] bool* isClosed);
[JScript]
public function NextSubpath(
   startIndex : int,endIndex : int,isClosed : Boolean) : int;

パラメータ

  • startIndex
    [出力] 次のサブパスの開始インデックスを受け取ります。
  • endIndex
    [出力] 次のサブパスの終了インデックスを受け取ります。
  • isClosed
    [出力] サブパスが閉じられているかどうかを示します。

戻り値

GraphicsPath オブジェクト内のサブパスの数。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • GraphicsPath オブジェクトを作成します。
  • 3 本の直線、1 つの四角形、および 1 つの楕円を追加します。
  • 画面に点の配列の値を描画します。
  • GraphicsPathIterator オブジェクトを作成します。
  • NextSubpath メソッドを呼び出します。
  • NextSubPath の反復呼び出しによって返された値を使用して、各サブパスの開始値と終了値を画面に描画します。
  • 画面にサブパスの合計数を表す値を描画します。
 
Public Sub NextSubpathExample(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
        
[C#] 
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);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

GraphicsPathIterator クラス | GraphicsPathIterator メンバ | System.Drawing.Drawing2D 名前空間 | GraphicsPathIterator.NextSubpath オーバーロードの一覧