GraphicsPath.CloseFigure 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
關閉目前的模型並開始新的模型。 若目前圖包含一連串連通的線條與曲線,該方法透過將一條線從端點連接到起點來封閉迴路。
public:
void CloseFigure();
public void CloseFigure();
member this.CloseFigure : unit -> unit
Public Sub CloseFigure ()
範例
以下程式碼範例是為 Windows Forms 設計,並需要 PaintEventArgse,一個 OnPaint 事件物件。 該程式碼透過建立新路徑、開始圖形、在圖形上加入兩條相交線條,然後將圖形封閉形成三角形來建立三角形。 接著路徑會被繪製到螢幕上。
private:
void CloseFigureExample( PaintEventArgs^ e )
{
// Create a path consisting of two, open-ended lines and close
// the lines using CloseFigure.
GraphicsPath^ myPath = gcnew GraphicsPath;
myPath->StartFigure();
myPath->AddLine( Point(10,10), Point(200,10) );
myPath->AddLine( Point(200,10), Point(200,200) );
myPath->CloseFigure();
// Draw the path to the screen.
e->Graphics->DrawPath( Pens::Black, myPath );
}
private void CloseFigureExample(PaintEventArgs e)
{
// Create a path consisting of two, open-ended lines and close
// the lines using CloseFigure.
GraphicsPath myPath = new GraphicsPath();
myPath.StartFigure();
myPath.AddLine(new Point(10, 10), new Point(200, 10));
myPath.AddLine(new Point(200, 10), new Point(200, 200));
myPath.CloseFigure();
// Draw the path to the screen.
e.Graphics.DrawPath(Pens.Black, myPath);
}
Public Sub CloseFigureExample(ByVal e As PaintEventArgs)
' Create a path consisting of two, open-ended lines and close
' the lines using CloseFigure.
Dim myPath As New GraphicsPath
myPath.StartFigure()
myPath.AddLine(New Point(10, 10), New Point(200, 10))
myPath.AddLine(New Point(200, 10), New Point(200, 200))
myPath.CloseFigure()
' Draw the path to the screen.
e.Graphics.DrawPath(Pens.Black, myPath)
End Sub