Share via


GraphicsPathIterator.HasCurve Metodo

Definizione

Indica se il percorso associato a questa classe GraphicsPathIterator contiene una curva.

public:
 bool HasCurve();
public bool HasCurve ();
member this.HasCurve : unit -> bool
Public Function HasCurve () As Boolean

Restituisce

Questo metodo restituisce true se il sottopercorso corrente contiene una curva. In caso contrario, restituisce false.

Esempio

L'esempio seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, un OnPaint oggetto evento. Il codice esegue le azioni seguenti:

  • Crea un GraphicsPath oggetto , myPath.

  • Aggiunge tre righe, un rettangolo e un ellisse.

  • Crea un GraphicsPathIterator oggetto per myPath.

  • Verifica se il percorso myPath corrente contiene una curva.

  • Mostra il risultato del test in una finestra di messaggio.

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.
    bool myHasCurve = myPathIterator.HasCurve();
             
    // Show the test result.
    MessageBox.Show(myHasCurve.ToString());
}
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

Commenti

Tutte le curve in un percorso vengono archiviate come sequenze di spline bézier. Ad esempio, quando si aggiunge un puntino di sospensione a un percorso, si specifica l'angolo superiore sinistro, la larghezza e l'altezza del rettangolo di delimitazione dell'ellisse. Tali numeri (angolo superiore sinistro, larghezza e altezza) non vengono archiviati nel percorso; Invece; i puntini di sospensione vengono convertiti in una sequenza di quattro spline bézier. Il percorso archivia gli endpoint e i punti di controllo di tali spline bézier.

Un percorso archivia una matrice di punti dati, ognuno dei quali appartiene a una linea o a una spline Bézier. Se alcuni dei punti della matrice appartengono agli spline di Bézier, restituisce HasCurvetrue. Se tutti i punti della matrice appartengono alle righe, HasCurve restituisce false.

Alcuni metodi appiattino un percorso, che significa che tutte le curve nel percorso vengono convertite in sequenze di righe. Dopo che un percorso è stato appiattito, HasCurve restituirà falsesempre . La chiamata al Flattenmetodo , Wideno Warp della GraphicsPath classe appiattirà un percorso.

Si applica a