GraphicsPathIterator.NextMarker 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將 Iterator 移至路徑中的下一個資料標記。
多載
NextMarker(GraphicsPath) |
這個 GraphicsPathIterator 具有與其相關聯的 GraphicsPath 物件。 NextMarker(GraphicsPath) 方法會將關聯的 GraphicsPath 遞增至其路徑中的下一個資料標記,並將目前資料標記和下一個資料標記 (或路徑端點) 之間包含的所有點複製至傳入至參數的第二個 GraphicsPath 物件。 |
NextMarker(Int32, Int32) |
將 GraphicsPathIterator 遞增至路徑中的下一個資料標記,並經由 [out] 參數傳回開始和停止索引。 |
NextMarker(GraphicsPath)
這個 GraphicsPathIterator 具有與其相關聯的 GraphicsPath 物件。 NextMarker(GraphicsPath) 方法會將關聯的 GraphicsPath 遞增至其路徑中的下一個資料標記,並將目前資料標記和下一個資料標記 (或路徑端點) 之間包含的所有點複製至傳入至參數的第二個 GraphicsPath 物件。
public:
int NextMarker(System::Drawing::Drawing2D::GraphicsPath ^ path);
public int NextMarker (System.Drawing.Drawing2D.GraphicsPath path);
member this.NextMarker : System.Drawing.Drawing2D.GraphicsPath -> int
Public Function NextMarker (path As GraphicsPath) As Integer
參數
- path
- GraphicsPath
點複製至的 GraphicsPath 物件。
傳回
在這個資料標記和下一個資料標記之間的點數。
範例
下列範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse
事件OnPaint物件。 此程式碼會執行下列動作:
建立 GraphicsPath 物件。
新增三行、矩形、橢圓形和兩個標記。
清單 所有路徑指向畫面左側的值。
建立 GraphicsPathIterator 物件。
GraphicsPath建立物件
myPathSection
,以接收複製的點。NextMarker呼叫 方法,這個方法會逐一查看第一個標記,並複製該標記和旁邊
myPathSection
所包含的所有點。傳回復制到
markerPoints
的點數。清單標記編號 (第一個標記) ,以及畫面右側包含的點數。
public:
void NextMarkerExample2( 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 the values 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 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 + ", " + myPathPoints[ i ].Y + ", " + myPathTypes[ i ], myFont, myBrush, 20, j );
j += 20;
}
// Create a GraphicsPathIterator.
GraphicsPathIterator^ myPathIterator = gcnew GraphicsPathIterator( myPath );
// Rewind the iterator.
myPathIterator->Rewind();
// Create a GraphicsPath to receive a section of myPath.
GraphicsPath^ myPathSection = gcnew 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( String::Format( "Marker: 1 Num Points: {0}", markerPoints ), myFont, myBrush, 200, 20 );
}
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);
}
Public Sub NextMarkerExample2(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.
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
備註
SetMarkers使用方法在路徑中設定標記。 標記可用來建立子路徑的群組。 一或多個子路徑可以在兩個標記之間。
適用於
NextMarker(Int32, Int32)
將 GraphicsPathIterator 遞增至路徑中的下一個資料標記,並經由 [out] 參數傳回開始和停止索引。
public:
int NextMarker([Runtime::InteropServices::Out] int % startIndex, [Runtime::InteropServices::Out] int % endIndex);
public int NextMarker (out int startIndex, out int endIndex);
member this.NextMarker : int * int -> int
Public Function NextMarker (ByRef startIndex As Integer, ByRef endIndex As Integer) As Integer
參數
- startIndex
- Int32
[out] 提供給這個參數的整數參考會接收開始子路徑的點索引。
- endIndex
- Int32
[out] 提供給這個參數的整數參考會接收結束 startIndex
所指向的子路徑之點索引。
傳回
在這個資料標記和下一個資料標記之間的點數。
範例
下列範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse
事件OnPaint物件。 此程式碼會執行下列動作:
建立 GraphicsPath 物件。
新增三行、矩形和橢圓形 3/4,其中各有標記。
繪製指向畫面之點陣列的值。
建立 GraphicsPathIterator 物件。
呼叫 NextMarker 方法。
使用從反覆呼叫傳回的值, NextMarker 將每個標記的開始和停止點繪製到畫面。
繪製螢幕點總數的值。
private:
void NextMarkerExample( 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->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 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;
// Rewind the Iterator.
myPathIterator->Rewind();
// Draw the Markers and their start and end points
// to the screen.
j = 20;
for ( i = 0; i < 3; i++ )
{
myPathIterator->NextMarker( myStartIndex, myEndIndex );
e->Graphics->DrawString( String::Format( "Marker {0}: Start: {1} End: {2}", i, myStartIndex, myEndIndex ),
myFont, myBrush, 200, j );
j += 20;
}
// Draw the total number of points to the screen.
j += 20;
int myPathTotalPoints = myPathIterator->Count;
e->Graphics->DrawString( String::Format( "Total Points = {0}", myPathTotalPoints ), myFont, myBrush, 200, j );
}
private void NextMarkerExample(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.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 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;
// Rewind the Iterator.
myPathIterator.Rewind();
// Draw the Markers and their start and end points
// to the screen.
j=20;
for(i=0;i<3;i++)
{
myPathIterator.NextMarker(out myStartIndex, out myEndIndex);
e.Graphics.DrawString("Marker " + i.ToString() +
": Start: " + myStartIndex.ToString()+
" End: " + myEndIndex.ToString(),
myFont,
myBrush,
200,
j);
j += 20;
}
// Draw the total number of points to the screen.
j += 20;
int myPathTotalPoints = myPathIterator.Count;
e.Graphics.DrawString("Total Points = " +
myPathTotalPoints.ToString(),
myFont,
myBrush,
200,
j);
}
Public Sub NextMarkerExample(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.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)
Dim myStartIndex As Integer
Dim myEndIndex As Integer
' Rewind the Iterator.
myPathIterator.Rewind()
' Draw the Markers and their start and end points to the screen.
j = 20
For i = 0 To 2
myPathIterator.NextMarker(myStartIndex, myEndIndex)
e.Graphics.DrawString("Marker " + i.ToString() + _
": Start: " + myStartIndex.ToString() + " End: " + _
myEndIndex.ToString(), myFont, myBrush, 200, j)
j += 20
Next i
' Draw the total number of points to the screen.
j += 20
Dim myPathTotalPoints As Integer = myPathIterator.Count
e.Graphics.DrawString("Total Points = " + _
myPathTotalPoints.ToString(), myFont, myBrush, 200, j)
End Sub
備註
SetMarkers使用方法在路徑中設定標記。 標記可用來建立子路徑的群組。 一或多個子路徑可以在兩個標記之間。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應