次の方法で共有


GraphicsPathIterator.NextMarker メソッド (GraphicsPath)

GraphicsPathIterator オブジェクトには、 GraphicsPath オブジェクトが関連付けられています。 NextMarker メソッドは、関連付けられている GraphicsPath オブジェクトのパス内の次のマーカーを指すように反復子をインクリメントし、現在のマーカーと次のマーカー (またはパスの終点) の間に含まれているすべての点を、パラメータに渡された 2 番目の GraphicsPath オブジェクトにコピーします。

Overloads Public Function NextMarker( _
   ByVal path As GraphicsPath _) As Integer
[C#]
public int NextMarker(GraphicsPathpath);
[C++]
public: int NextMarker(GraphicsPath* path);
[JScript]
public function NextMarker(
   path : GraphicsPath) : int;

パラメータ

  • path
    点のコピー先の GraphicsPath オブジェクト。

戻り値

現在のマーカーと次のマーカーの間にある点の数。

解説

SetMarkers メソッドを使用して、パスにマーカーを設定します。マーカーは、サブパスのグループを作成するために使用します。2 つのマーカー間には、1 つ以上のサブパスを含めることができます。

使用例

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

  • GraphicsPath オブジェクトを作成します。
  • 3 本の直線、1 つの四角形、1 つの楕円、および 1 組のマーカーを追加します。
  • すべてのパス内の点の値を画面の左側に一覧表示します。
  • GraphicsPathIterator オブジェクトを作成します。
  • 点のコピー先として、 GraphicsPath オブジェクト myPathSection を作成します。
  • NextMarker(GraphicsPath) メソッドを呼び出します。このメソッドは、マーカーの位置を先頭に戻し、そのマーカーから次のマーカーまでに含まれているすべての点を myPathSection にコピーします。
  • markerPoints にコピーした点の数を返します。
  • マーカー番号 (先頭マーカー) と、先頭パスに含まれている点の数を画面の右側に一覧表示します。
 
Public Sub NextMarkerExample2(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
        
[C#] 
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);
}
        

[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.NextMarker オーバーロードの一覧