Freigeben über


GraphicsPathIterator.HasCurve-Methode

Gibt an, ob der diesem GraphicsPathIterator zugeordnete Pfad eine Kurve enthält.

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

Syntax

'Declaration
Public Function HasCurve As Boolean
'Usage
Dim instance As GraphicsPathIterator
Dim returnValue As Boolean

returnValue = instance.HasCurve
public bool HasCurve ()
public:
bool HasCurve ()
public boolean HasCurve ()
public function HasCurve () : boolean

Rückgabewert

Diese Methode gibt true zurück, wenn der aktuelle untergeordnete Pfad eine Kurve enthält, andernfalls false.

Hinweise

Alle Kurven in einem Pfad werden als Folgen von Béziersplinekurven gespeichert. Wenn Sie z. B. einem Pfad eine Ellipse hinzufügen, geben Sie die obere linke Ecke, die Breite und die Höhe des die Ellipse umschließenden Rechtecks an. Diese Zahlen (obere linke Ecke, Breite und Höhe) werden nicht im Pfad gespeichert. Stattdessen wird die Ellipse in eine Folge von vier Béziersplinekurven konvertiert. Die End- und Kontrollpunkte dieser Béziersplinekurven werden im Pfad gespeichert.

Ein Pfad speichert ein Array von Datenpunkten, von denen jeder einzelne entweder zu einer Linie oder einer Béziersplinekurve gehört. Wenn einige der Punkte im Array zu Béziersplinekurven gehören, gibt HasCurve den Wert true zurück. Wenn alle Punkte im Array zu Linien gehören, gibt HasCurve den Wert false zurück.

Bestimmte Methoden flachen den Pfad ab. Dies bedeutet, dass alle Kurven im Pfad in Abfolgen von Linien konvertiert werden. Nachdem ein Pfad abgeflacht wurde, gibt HasCurve immer false zurück. Ein Pfad wird durch Aufruf der Methoden Flatten, Widen oder Warp der GraphicsPath-Klasse abgeflacht.

Beispiel

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

  • Erstellt das GraphicsPath-Objekt myPath.

  • Fügt drei Linien, ein Rechteck und eine Ellipse hinzu.

  • Erstellt das GraphicsPathIterator-Objekt für myPath.

  • Überprüft, ob der aktuelle Pfad myPath eine Kurve enthält.

  • Zeigt das Ergebnis der Überprüfung in einem Meldungsfenster an.

Public Sub HasCurveExample(ByVal e As PaintEventArgs)
    Dim myPath As New GraphicsPath
    Dim myPoints As Point() = {New Point(20, 20), _
        New Point(120, 120), New Point(20, 120), New Point(20, 20)}
    Dim myRect As New Rectangle(120, 120, 100, 100)
    myPath.AddLines(myPoints)
    myPath.AddRectangle(myRect)
    myPath.AddEllipse(220, 220, 100, 100)

    ' Create a GraphicsPathIterator for myPath.
    Dim myPathIterator As New GraphicsPathIterator(myPath)
    Dim myHasCurve As Boolean = myPathIterator.HasCurve()
    MessageBox.Show(myHasCurve.ToString())
End Sub
private void HasCurveExample(PaintEventArgs e)
{
             
    // Create a path and add three lines,
    // a rectangle and an ellipse.
    GraphicsPath myPath = new GraphicsPath();
    
    Point[] myPoints = {new Point(20, 20), new Point(120, 120), 
        new Point(20, 120),new Point(20, 20) }; 

    Rectangle myRect = new Rectangle(120, 120, 100, 100);
    myPath.AddLines(myPoints);
    myPath.AddRectangle(myRect);
    myPath.AddEllipse(220, 220, 100, 100);
             
    // Create a GraphicsPathIterator for myPath.
    GraphicsPathIterator myPathIterator = new
        GraphicsPathIterator(myPath);
             
    // Test for a curve.
    bool myHasCurve = myPathIterator.HasCurve();
             
    // Show the test result.
    MessageBox.Show(myHasCurve.ToString());
}
private:
   void HasCurveExample( PaintEventArgs^ /*e*/ )
   {
      // Create a path and add three lines,
      // a rectangle and an ellipse.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      array<Point>^ myPoints = {Point(20,20),Point(120,120),Point(20,120),Point(20,20)};
      Rectangle myRect = Rectangle(120,120,100,100);
      myPath->AddLines( myPoints );
      myPath->AddRectangle( myRect );
      myPath->AddEllipse( 220, 220, 100, 100 );

      // Create a GraphicsPathIterator for myPath.
      GraphicsPathIterator^ myPathIterator = gcnew GraphicsPathIterator( myPath );

      // Test for a curve.
      bool myHasCurve = myPathIterator->HasCurve();

      // Show the test result.
      MessageBox::Show( myHasCurve.ToString() );
   }
private void HasCurveExample(PaintEventArgs e)
{
    // Create a path and add three lines,
    // a rectangle and an ellipse.
    GraphicsPath myPath = new GraphicsPath();
    Point myPoints[] = { new Point(20, 20), new Point(120, 120), 
                        new Point(20, 120), new Point(20, 20) };
    Rectangle myRect = new Rectangle(120, 120, 100, 100);

    myPath.AddLines(myPoints);
    myPath.AddRectangle(myRect);
    myPath.AddEllipse(220, 220, 100, 100);

    // Create a GraphicsPathIterator for myPath.
    GraphicsPathIterator myPathIterator = new GraphicsPathIterator(myPath);

    // Test for a curve.
    boolean myHasCurve = myPathIterator.HasCurve();

    // Show the test result.
    MessageBox.Show(System.Convert.ToString(myHasCurve));
} //HasCurveExample

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

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