GraphicsPath.CloseFigure メソッド

定義

現在の図形を閉じ、新しい図形を開始します。Closes the current figure and starts a new figure. 現在の図形に接続された直線と曲線のシーケンスが含まれる場合、このメソッドは終了点と開始点を直線で接続することでループを閉じます。If the current figure contains a sequence of connected lines and curves, the method closes the loop by connecting a line from the endpoint to the starting point.

public:
 void CloseFigure();
public void CloseFigure ();
member this.CloseFigure : unit -> unit
Public Sub CloseFigure ()

次のコード例は、Windows フォームで使用するように設計されており、イベントオブジェクトを必要とし PaintEventArgs e OnPaint ます。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. このコードでは、新しいパスを作成し、図を開始し、交差する2本の線を図に追加してから、図形を閉じて三角形を形成することで三角形を作成します。The code creates a triangle by creating a new path, starting a figure, adding two intersecting lines to the figure, and then closing the figure to form a triangle. 次に、パスが画面に描画されます。The path is then drawn to the screen.

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

適用対象