Bibliothèque de classes .NET Framework
GraphicsPath..::.Reset, méthode

Mise à jour : novembre 2007

Vide les tableaux PathPoints et PathTypes et assigne la valeur Alternate à FillMode.

Espace de noms :  System.Drawing.Drawing2D
Assembly :  System.Drawing (dans System.Drawing.dll)

Syntaxe

Visual Basic (Déclaration)
Public Sub Reset
Visual Basic (Utilisation)
Dim instance As GraphicsPath

instance.Reset()
C#
public void Reset()
VisualC++
public:
void Reset()
J#
public void Reset()
JScript
public function Reset()
Exemples

L'exemple de code suivant est destiné à une utilisation avec les Windows Forms et nécessite PaintEventArgse, un objet événement OnPaint. Le code exécute les actions suivantes :

  • Crée un tracé.

  • Ajoute plusieurs primitives au tracé.

  • Dessine le tableau de points du tracé à l'écran.

  • Réinitialise le tracé à l'état vide.

  • Réacquiert le tableau de points (s'il existe).

  • Dessine le tableau à l'écran.

Notez qu'aucun autre tableau n'est trouvé après l'appel de réinitialisation.

Visual Basic
Public Sub GraphicsPathResetExample(ByVal e As PaintEventArgs)
    Dim myFont As New Font("Arial", 8)

    ' Create a path and add a line, an ellipse, and an arc.
    Dim myPath As New GraphicsPath
    myPath.AddLine(New Point(0, 0), New Point(100, 100))
    myPath.AddEllipse(100, 100, 200, 250)
    myPath.AddArc(300, 250, 100, 100, 0, 90)

    ' Draw the pre-reset points array to the screen.
    DrawPointsHelper1(e, myPath.PathPoints, 20)

    ' Reset the path.
    myPath.Reset()

    ' See if any points remain.
    If myPath.PointCount > 0 Then

        ' Draw the post-reset points array to the screen.
        DrawPointsHelper1(e, myPath.PathPoints, 150)

        ' If there are no points, say so.
    Else
        e.Graphics.DrawString("No Points", myFont, Brushes.Black, _
        150, 20)
    End If
End Sub

' A helper function used by GraphicsPathResetExample to draw points.
Public Sub DrawPointsHelper1(ByVal e As PaintEventArgs, _
ByVal pathPoints() As PointF, ByVal xOffset As Integer)
    Dim y As Integer = 20
    Dim myFont As New Font("Arial", 8)
    Dim i As Integer
    For i = 0 To pathPoints.Length - 1
        e.Graphics.DrawString(pathPoints(i).X.ToString() + _
        ", " + pathPoints(i).Y.ToString(), myFont, Brushes.Black, _
        xOffset, y)
        y += 20
    Next i
End Sub
C#
public void GraphicsPathResetExample(PaintEventArgs e)
{
    Font myFont = new Font("Arial", 8);

    // Create a path and add a line, an ellipse, and an arc.
    GraphicsPath myPath = new GraphicsPath();
    myPath.AddLine(new Point(0, 0), new Point(100, 100));
    myPath.AddEllipse(100, 100, 200, 250);
    myPath.AddArc(300, 250, 100, 100, 0, 90);

    // Draw the pre-reset points array to the screen.
    DrawPoints1(e, myPath.PathPoints, 20);

    // Reset the path.
    myPath.Reset();

    // See if any points remain.
    if(myPath.PointCount > 0)
    {

        // Draw the post-reset points array to the screen.
        DrawPoints1(e, myPath.PathPoints, 150);
    }
    else

        // If there are no points, say so.
        e.Graphics.DrawString("No Points",
            myFont,
            Brushes.Black,
            150,
            20);
} 
//End GraphicsPathResetExample

// A helper function GraphicsPathResetExample uses to draw the points.

// to the screen.
public void DrawPoints1(PaintEventArgs e, PointF[] pathPoints, int xOffset)
{
    int y = 20;
    Font myFont = new Font("Arial", 8);
    for(int i=0;i < pathPoints.Length; i++)
    {
        e.Graphics.DrawString(pathPoints[i].X.ToString() + ", " +
            pathPoints[i].Y.ToString(),
            myFont,
            Brushes.Black,
            xOffset,
            y);
        y += 20;
    }
} 
// End DrawPoints
VisualC++
public:
   void GraphicsPathResetExample( PaintEventArgs^ e )
   {
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",8 );

      // Create a path and add a line, an ellipse, and an arc.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      myPath->AddLine( Point(0,0), Point(100,100) );
      myPath->AddEllipse( 100, 100, 200, 250 );
      myPath->AddArc( 300, 250, 100, 100, 0, 90 );

      // Draw the pre-reset points array to the screen.
      DrawPoints1( e, myPath->PathPoints, 20 );

      // Reset the path.
      myPath->Reset();

      // See if any points remain.
      if ( myPath->PointCount > 0 )
      {

         // Draw the post-reset points array to the screen.
         DrawPoints1( e, myPath->PathPoints, 150 );
      }
      else
            e->Graphics->DrawString( "No Points", myFont, Brushes::Black, 150, 20 );
      // If there are no points, say so.
   }


   //End GraphicsPathResetExample
   // A helper function GraphicsPathResetExample uses to draw the points.
   // to the screen.
   void DrawPoints1( PaintEventArgs^ e, array<PointF>^ pathPoints, int xOffset )
   {
      int y = 20;
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",8 );
      for ( int i = 0; i < pathPoints->Length; i++ )
      {
         e->Graphics->DrawString( String::Concat( pathPoints[ i ].X, ", ", pathPoints[ i ].Y ), myFont, Brushes::Black, (float)xOffset, (float)y );
         y += 20;

      }
   }
   // End DrawPoints
J#
public void GraphicsPathResetExample(PaintEventArgs e)
{
    Font myFont = new Font("Arial", 8);

    // Create a path and add a line, an ellipse, and an arc.
    GraphicsPath myPath = new GraphicsPath();

    myPath.AddLine(new Point(0, 0), new Point(100, 100));
    myPath.AddEllipse(100, 100, 200, 250);
    myPath.AddArc(300, 250, 100, 100, 0, 90);

    // Draw the pre-reset points array to the screen.
    DrawPoints1(e, myPath.get_PathPoints(), 20);

    // Reset the path.
    myPath.Reset();

    // See if any points remain.
    if (myPath.get_PointCount() > 0) {
        // Draw the post-reset points array to the screen.
        DrawPoints1(e, myPath.get_PathPoints(), 150);
    }
    // If there are no points, say so.
    else {
        e.get_Graphics().DrawString("No Points", myFont,
            Brushes.get_Black(), 150, 20);
    }
} //GraphicsPathResetExample
//End GraphicsPathResetExample

// A helper function GraphicsPathResetExample uses to draw the points.

// to the screen.
public void DrawPoints1(PaintEventArgs e, PointF pathPoints[], int xOffset)
{
    int y = 20;
    Font myFont = new Font("Arial", 8);

    for (int i = 0; i < pathPoints.length; i++) {
        e.get_Graphics().DrawString(
            System.Convert.ToString(pathPoints[i].get_X())  
            + ", " + System.Convert.ToString(pathPoints[i].get_Y()), myFont, 
            Brushes.get_Black(), xOffset, y);
        y += 20;
    }
} //DrawPoints1
// End DrawPoints
Plateformes

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professionnel Édition x64, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Informations de version

.NET Framework

Pris en charge dans : 3.5, 3.0, 2.0, 1.1, 1.0
Voir aussi

Référence

Mots clés :


Page view tracker