Partage via


GraphicsPath.GetBounds Méthode

Définition

Retourne un rectangle qui limite cette GraphicsPath.

Surcharges

GetBounds()

Retourne un rectangle qui limite cette GraphicsPath.

GetBounds(Matrix)

Retourne un rectangle qui limite cette GraphicsPath lorsque ce chemin d’accès est transformé par le Matrixspécifié.

GetBounds(Matrix, Pen)

Retourne un rectangle qui limite cette GraphicsPath lorsque le chemin actuel est transformé par le Matrix spécifié et dessiné avec le Penspécifié.

GetBounds()

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Retourne un rectangle qui limite cette GraphicsPath.

public:
 System::Drawing::RectangleF GetBounds();
public System.Drawing.RectangleF GetBounds ();
member this.GetBounds : unit -> System.Drawing.RectangleF
Public Function GetBounds () As RectangleF

Retours

Un RectangleF qui représente un rectangle qui limite cette GraphicsPath.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, un objet d’événement OnPaint. Le code effectue les actions suivantes :

  • Crée un chemin d’accès graphique.

  • Ajoute un ellipse (cercle) à celui-ci et le dessine à l’écran.

  • Récupère le rectangle englobant du cercle avec un appel à GetBounds et dessine le rectangle à l’écran.

  • Crée un deuxième chemin graphique.

  • Ajoute un cercle et élargit le chemin à une largeur de 10.

  • Dessine le chemin d’accès à l’écran.

  • Récupère le rectangle englobant pour le deuxième cercle.

  • Dessine le rectangle englobant à l’écran.

  • Affiche la taille du rectangle dans une boîte de dialogue.

Notez que le rectangle englobant à droite est plus grand (pour tenir compte de la largeur supplémentaire de la ligne).

public:
   void GetBoundsExample( PaintEventArgs^ e )
   {
      // Create path number 1 and a Pen for drawing.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Pen^ pathPen = gcnew Pen( Color::Black,1.0f );

      // Add an Ellipse to the path and Draw it (circle in start
      // position).
      myPath->AddEllipse( 20, 20, 100, 100 );
      e->Graphics->DrawPath( pathPen, myPath );

      // Get the path bounds for Path number 1 and draw them.
      RectangleF boundRect = myPath->GetBounds();
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red,1.0f ), boundRect.X, boundRect.Y, boundRect.Height, boundRect.Width );

      // Create a second graphics path and a wider Pen.
      GraphicsPath^ myPath2 = gcnew GraphicsPath;
      Pen^ pathPen2 = gcnew Pen( Color::Black,10.0f );

      // Create a new ellipse with a width of 10.
      myPath2->AddEllipse( 150, 20, 100, 100 );
      myPath2->Widen( pathPen2 );
      e->Graphics->FillPath( Brushes::Black, myPath2 );

      // Get the second path bounds.
      RectangleF boundRect2 = myPath2->GetBounds();

      // Draw the bounding rectangle.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red,1.0f ), boundRect2.X, boundRect2.Y, boundRect2.Height, boundRect2.Width );

      // Display the rectangle size.
      MessageBox::Show( boundRect2.ToString() );
   }
public void GetBoundsExample(PaintEventArgs e)
{
             
    // Create path number 1 and a Pen for drawing.
    GraphicsPath myPath = new GraphicsPath();
    Pen pathPen = new Pen(Color.Black, 1);
             
    // Add an Ellipse to the path and Draw it (circle in start
             
    // position).
    myPath.AddEllipse(20, 20, 100, 100);
    e.Graphics.DrawPath(pathPen, myPath);
             
    // Get the path bounds for Path number 1 and draw them.
    RectangleF boundRect = myPath.GetBounds();
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1),
        boundRect.X,
        boundRect.Y,
        boundRect.Height,
        boundRect.Width);
             
    // Create a second graphics path and a wider Pen.
    GraphicsPath myPath2 = new GraphicsPath();
    Pen pathPen2 = new Pen(Color.Black, 10);
             
    // Create a new ellipse with a width of 10.
    myPath2.AddEllipse(150, 20, 100, 100);
    myPath2.Widen(pathPen2);
    e.Graphics.FillPath(Brushes.Black, myPath2);
             
    // Get the second path bounds.
    RectangleF boundRect2 = myPath2.GetBounds();
             
    // Draw the bounding rectangle.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1),
        boundRect2.X,
        boundRect2.Y,
        boundRect2.Height,
        boundRect2.Width);
             
    // Display the rectangle size.
    MessageBox.Show(boundRect2.ToString());
}
Public Sub GetBoundsExample(ByVal e As PaintEventArgs)

    ' Create path number 1 and a Pen for drawing.
    Dim myPath As New GraphicsPath
    Dim pathPen As New Pen(Color.Black, 1)

    ' Add an Ellipse to the path and Draw it (circle in start

    ' position).
    myPath.AddEllipse(20, 20, 100, 100)
    e.Graphics.DrawPath(pathPen, myPath)

    ' Get the path bounds for Path number 1 and draw them.
    Dim boundRect As RectangleF = myPath.GetBounds()
    e.Graphics.DrawRectangle(New Pen(Color.Red, 1), boundRect.X, _
    boundRect.Y, boundRect.Height, boundRect.Width)

    ' Create a second graphics path and a wider Pen.
    Dim myPath2 As New GraphicsPath
    Dim pathPen2 As New Pen(Color.Black, 10)

    ' Create a new ellipse with a width of 10.
    myPath2.AddEllipse(150, 20, 100, 100)
    myPath2.Widen(pathPen2)
    e.Graphics.FillPath(Brushes.Black, myPath2)

    ' Get the second path bounds.
    Dim boundRect2 As RectangleF = myPath2.GetBounds()

    ' Show the bounds in a message box.
    e.Graphics.DrawString("Rectangle2 Bounds: " + _
    boundRect2.ToString(), New Font("Arial", 8), Brushes.Black, _
    20, 150)

    ' Draw the bounding rectangle.
    e.Graphics.DrawRectangle(New Pen(Color.Red, 1), boundRect2.X, _
    boundRect2.Y, boundRect2.Height, boundRect2.Width)
End Sub

Remarques

La taille du rectangle englobant retourné est influencée par le type de limite de fin, la largeur du stylet et la limite de mitreur de stylet, et produit donc un « ajustement libre » au chemin délimité. La formule approximative est la suivante : le rectangle englobant initial est gonflé par la largeur du stylet, et ce résultat est multiplié par la limite de mitreur, plus une marge supplémentaire pour permettre les majuscules de fin.

S’applique à

GetBounds(Matrix)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Retourne un rectangle qui limite cette GraphicsPath lorsque ce chemin d’accès est transformé par le Matrixspécifié.

public:
 System::Drawing::RectangleF GetBounds(System::Drawing::Drawing2D::Matrix ^ matrix);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix? matrix);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix matrix);
member this.GetBounds : System.Drawing.Drawing2D.Matrix -> System.Drawing.RectangleF
Public Function GetBounds (matrix As Matrix) As RectangleF

Paramètres

matrix
Matrix

La Matrix qui spécifie une transformation à appliquer à ce chemin avant que le rectangle englobant ne soit calculé. Ce chemin n’est pas transformé définitivement ; la transformation est utilisée uniquement pendant le processus de calcul du rectangle englobant.

Retours

Un RectangleF qui représente un rectangle qui limite cette GraphicsPath.

Exemples

Pour obtenir un exemple, consultez GetBounds().

Remarques

La taille du rectangle englobant retourné est influencée par le type de limite de fin, la largeur du stylet et la limite de mitreur de stylet, et produit donc un « ajustement libre » au chemin délimité. La formule approximative est la suivante : le rectangle englobant initial est gonflé par la largeur du stylet, et ce résultat est multiplié par la limite de mitreur, plus une marge supplémentaire pour permettre les majuscules de fin.

S’applique à

GetBounds(Matrix, Pen)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Retourne un rectangle qui limite cette GraphicsPath lorsque le chemin actuel est transformé par le Matrix spécifié et dessiné avec le Penspécifié.

public:
 System::Drawing::RectangleF GetBounds(System::Drawing::Drawing2D::Matrix ^ matrix, System::Drawing::Pen ^ pen);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Pen? pen);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Pen pen);
member this.GetBounds : System.Drawing.Drawing2D.Matrix * System.Drawing.Pen -> System.Drawing.RectangleF
Public Function GetBounds (matrix As Matrix, pen As Pen) As RectangleF

Paramètres

matrix
Matrix

La Matrix qui spécifie une transformation à appliquer à ce chemin avant que le rectangle englobant ne soit calculé. Ce chemin n’est pas transformé définitivement ; la transformation est utilisée uniquement pendant le processus de calcul du rectangle englobant.

pen
Pen

Le Pen avec lequel dessiner le GraphicsPath.

Retours

Un RectangleF qui représente un rectangle qui limite cette GraphicsPath.

Exemples

Pour obtenir un exemple, consultez GetBounds().

Remarques

La taille du rectangle englobant retourné est influencée par le type de limite de fin, la largeur du stylet et la limite de mitreur de stylet, et produit donc un « ajustement libre » au chemin délimité. La formule approximative est la suivante : le rectangle englobant initial est gonflé par la largeur du stylet, et ce résultat est multiplié par la limite de mitreur, plus une marge supplémentaire pour permettre les majuscules de fin.

S’applique à