次の方法で共有


GraphicsPath.CloseAllFigures メソッド

このパスで開いているすべての図形を閉じ、新しい図形を開始します。開いている各図形は、その終了点と開始点を直線で接続することで閉じられます。

Public Sub CloseAllFigures()
[C#]
public void CloseAllFigures();
[C++]
public: void CloseAllFigures();
[JScript]
public function CloseAllFigures();

使用例

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

  • パスを作成します。
  • 複数の開いた図形をパスに追加します。
  • パスのすべての図形を閉じます。
  • 画面にパスを描画します。
 
Public Sub CloseAllFiguresExample(e As PaintEventArgs)
' Create a path containing several open-ended figures.
Dim myPath As New GraphicsPath()
myPath.StartFigure()
myPath.AddLine(New Point(10, 10), New Point(150, 10))
myPath.AddLine(New Point(150, 10), New Point(10, 150))
myPath.StartFigure()
myPath.AddArc(200, 200, 100, 100, 0, 90)
myPath.StartFigure()
Dim point1 As New Point(300, 300)
Dim point2 As New Point(400, 325)
Dim point3 As New Point(400, 375)
Dim point4 As New Point(300, 400)
Dim points As Point() =  {point1, point2, point3, point4}
myPath.AddCurve(points)
' close all the figures.
myPath.CloseAllFigures()
' Draw the path to the screen.
e.Graphics.DrawPath(New Pen(Color.Black, 3), myPath)
End Sub
        
[C#] 
private void CloseAllFiguresExample(PaintEventArgs e)
{
// Create a path containing several open-ended figures.
GraphicsPath myPath = new GraphicsPath();
myPath.StartFigure();
myPath.AddLine(new Point(10, 10), new Point(150, 10));
myPath.AddLine(new Point(150, 10), new Point(10, 150));
myPath.StartFigure();
myPath.AddArc(200, 200, 100, 100, 0, 90);
myPath.StartFigure();
Point point1 = new Point(300, 300);
Point point2 = new Point(400, 325);
Point point3 = new Point(400, 375);
Point point4 = new Point(300, 400);
Point[] points = {point1, point2, point3, point4};
myPath.AddCurve(points);
// Close all the figures.
myPath.CloseAllFigures();
// Draw the path to the screen.
e.Graphics.DrawPath(new Pen(Color.Black, 3), myPath);
}
        

[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 ファミリ

参照

GraphicsPath クラス | GraphicsPath メンバ | System.Drawing.Drawing2D 名前空間