GraphicsPath.Reverse 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
反转此 GraphicsPathPathPoints 数组中点的顺序。
public:
void Reverse();
public void Reverse ();
member this.Reverse : unit -> unit
Public Sub Reverse ()
示例
下面的代码示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgse
OnPaint 事件对象。 该代码执行以下操作:
创建一个路径,并将多个基元添加到路径。
将路径的点数组绘制到屏幕。
将反向点数组绘制到屏幕。
请注意,第二个点列表与第一个列表相反。
void GraphicsPathReverseExample( PaintEventArgs^ e )
{
// Create a path and add a line, ellipse, and arc.
GraphicsPath^ myPath = gcnew GraphicsPath;
myPath->AddLine( Point(0,0), Point(100,100) );
myPath->AddEllipse( 100, 100, 200, 250 );
myPath->AddArc( 300, 250, 100, 100, 0, 90 );
// Draw the first set of points to the screen.
DrawPoints2( e, myPath->PathPoints, 20 );
// Call GraphicsPath.Reverse.
myPath->Reverse();
// Draw the reversed set of points to the screen.
DrawPoints2( e, myPath->PathPoints, 150 );
}
//End GraphicsPathReverseExample.
// A helper function GraphicsPathReverseExample is used to draw the
// points to the screen.
void DrawPoints2( PaintEventArgs^ e, array<PointF>^ pathPoints, int xOffset )
{
int y = 20;
System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",8 );
for ( int i = 0; i < pathPoints->Length; i++ )
{
e->Graphics->DrawString( String::Concat( pathPoints[ i ].X, ", ", pathPoints[ i ].Y ), myFont, Brushes::Black, (float)xOffset, (float)y );
y += 20;
}
}
// End DrawPoints
public void GraphicsPathReverseExample(PaintEventArgs e)
{
// Create a path and add a line, ellipse, and arc.
GraphicsPath myPath = new GraphicsPath();
myPath.AddLine(new Point(0, 0), new Point(100, 100));
myPath.AddEllipse(100, 100, 200, 250);
myPath.AddArc(300, 250, 100, 100, 0, 90);
// Draw the first set of points to the screen.
DrawPoints2(e, myPath.PathPoints, 20);
// Call GraphicsPath.Reverse.
myPath.Reverse();
// Draw the reversed set of points to the screen.
DrawPoints2(e, myPath.PathPoints, 150);
}
//End GraphicsPathReverseExample.
// A helper function GraphicsPathReverseExample is used to draw the
// points to the screen.
public void DrawPoints2(PaintEventArgs e, PointF[] pathPoints, int xOffset)
{
int y = 20;
Font myFont = new Font("Arial", 8);
for(int i=0;i < pathPoints.Length; i++)
{
e.Graphics.DrawString(pathPoints[i].X.ToString() + ", " +
pathPoints[i].Y.ToString(),
myFont,
Brushes.Black,
xOffset,
y);
y += 20;
}
}
// End DrawPoints
Public Sub GraphicsPathReverseExample(ByVal e As PaintEventArgs)
' Create a path and add a line, ellipse, and arc.
Dim myPath As New GraphicsPath
myPath.AddLine(New Point(0, 0), New Point(100, 100))
myPath.AddEllipse(100, 100, 200, 250)
myPath.AddArc(300, 250, 100, 100, 0, 90)
' Draw the first set of points to the screen.
DrawPointsHelper2(e, myPath.PathPoints, 20)
' Call GraphicsPath.Reverse.
myPath.Reverse()
' Draw the reversed set of points to the screen.
DrawPointsHelper2(e, myPath.PathPoints, 150)
End Sub
' A helper function used by GraphicsPathReverseExample to draw points.
Public Sub DrawPointsHelper2(ByVal e As PaintEventArgs, _
ByVal pathPoints() As PointF, ByVal xOffset As Integer)
Dim y As Integer = 20
Dim myFont As New Font("Arial", 8)
Dim i As Integer
For i = 0 To pathPoints.Length - 1
e.Graphics.DrawString(pathPoints(i).X.ToString() + _
", " + pathPoints(i).Y.ToString(), myFont, Brushes.Black, _
xOffset, y)
y += 20
Next i
End Sub