次の方法で共有


GraphicsPath.AddPath メソッド

指定された GraphicsPath オブジェクトをこのパスに追加します。

Public Sub AddPath( _
   ByVal addingPath As GraphicsPath, _   ByVal connect As Boolean _)
[C#]
public void AddPath(GraphicsPathaddingPath,boolconnect);
[C++]
public: void AddPath(GraphicsPath* addingPath,boolconnect);
[JScript]
public function AddPath(
   addingPath : GraphicsPath,connect : Boolean);

パラメータ

  • addingPath
    追加する GraphicsPath
  • connect
    追加されたパスの最初の図形が、このパスの最後の図形の一部になるかどうかを指定する Boolean 値。値が true の場合は、追加されたパスの最初の図形が、このパスの最後の図形の一部になります (可能な場合)。値が false の場合は、追加されたパスの最初の図形が、このパスの最後の図形から分離されます。

使用例

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

  • 2 つのパスを作成します。1 つは右上がりの三角形、もう 1 つは上下逆の三角形です。
  • 最初のパスに 2 番目のパスを追加します。
  • できあがったパスを画面に描画します。
 
Public Sub AddPathExample(e As PaintEventArgs)
' Creates a symetrical triangle and adds an inverted triangle.
' Create the first path - right side up triangle.
Dim myArray As Point() =  {New Point(30, 30), New Point(60, 60), _
New Point(0, 60), New Point(30, 30)}
Dim myPath As New GraphicsPath()
myPath.AddLines(myArray)
' Create the second path - inverted triangle.
Dim myArray2 As Point() =  {New Point(30, 30), New Point(0, 0), _
New Point(60, 0), New Point(30, 30)}
Dim myPath2 As New GraphicsPath()
myPath2.AddLines(myArray2)
' Add the second path to the first path.
myPath.AddPath(myPath2, True)
' Draw the combined path to the screen.
Dim myPen As New Pen(Color.Black, 2)
e.Graphics.DrawPath(myPen, myPath)
End Sub
        
[C#] 
private void AddPathExample(PaintEventArgs e)
{
// Create the first path - right side up triangle.
Point[] myArray =
{
new Point(30,30),
new Point(60,60),
new Point(0,60),
new Point(30,30)
};
GraphicsPath myPath = new GraphicsPath();
myPath.AddLines(myArray);
// Create the second path - inverted triangle.
Point[] myArray2 =
{
new Point(30,30),
new Point(0,0),
new Point(60,0),
new Point(30,30)
};
GraphicsPath myPath2 = new GraphicsPath();
myPath2.AddLines(myArray2);
// Add the second path to the first path.
myPath.AddPath(myPath2,true);
// Draw the combined path to the screen.
Pen myPen = new Pen(Color.Black, 2);
e.Graphics.DrawPath(myPen, 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 名前空間