Freigeben über


GraphicsPath.AddPath-Methode

Fügt den angegebenen GraphicsPath an diesen Pfad an.

Namespace: System.Drawing.Drawing2D
Assembly: System.Drawing (in system.drawing.dll)

Syntax

'Declaration
Public Sub AddPath ( _
    addingPath As GraphicsPath, _
    connect As Boolean _
)
'Usage
Dim instance As GraphicsPath
Dim addingPath As GraphicsPath
Dim connect As Boolean

instance.AddPath(addingPath, connect)
public void AddPath (
    GraphicsPath addingPath,
    bool connect
)
public:
void AddPath (
    GraphicsPath^ addingPath, 
    bool connect
)
public void AddPath (
    GraphicsPath addingPath, 
    boolean connect
)
public function AddPath (
    addingPath : GraphicsPath, 
    connect : boolean
)

Parameter

  • connect
    Ein boolescher Wert, der angibt, ob die erste Figur im hinzugefügten Pfad Teil der letzten Figur in diesem Pfad ist. Der Wert true gibt an, dass die erste Figur im hinzugefügten Pfad Teil der letzten Figur in diesem Pfad ist, sofern möglich. Der Wert false gibt an, dass die erste Figur im hinzugefügten Pfad von der letzten Figur in diesem Pfad getrennt ist.

Beispiel

Das folgende Codebeispiel ist für die Verwendung mit Windows Forms vorgesehen und erfordert das OnPaint-Ereignisobjekt PaintEventArgse. Der Code führt die folgenden Aktionen aus:

  • Erstellt zwei Pfade: ein Dreieck mit der Spitze nach oben und ein Dreieck, das auf der Spitze steht.

  • Fügt dem ersten Pfad den zweiten hinzu.

  • Zeichnet den resultierenden Pfad auf dem Bildschirm.

Public Sub AddPathExample(ByVal 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
private void AddPathExample(PaintEventArgs e)
{
             
    // Create the first pathright 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 pathinverted 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);
}
private:
   void AddPathExample( PaintEventArgs^ e )
   {
      // Create the first pathright side up triangle.
      array<Point>^ myArray = {Point(30,30),Point(60,60),Point(0,60),Point(30,30)};
      GraphicsPath^ myPath = gcnew GraphicsPath;
      myPath->AddLines( myArray );

      // Create the second pathinverted triangle.
      array<Point>^ myArray2 = {Point(30,30),Point(0,0),Point(60,0),Point(30,30)};
      GraphicsPath^ myPath2 = gcnew 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 = gcnew Pen( Color::Black,2.0f );
      e->Graphics->DrawPath( myPen, myPath );
   }
private void AddPathExample(PaintEventArgs e)
{
    // Create the first pathright 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 pathinverted 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.get_Black(), 2);

    e.get_Graphics().DrawPath(myPen, myPath);
} //AddPathExample

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

GraphicsPath-Klasse
GraphicsPath-Member
System.Drawing.Drawing2D-Namespace