GraphicsPath.GetBounds Metoda

Definicja

Zwraca prostokąt, który jest powiązany z tym GraphicsPathelementem .

Przeciążenia

GetBounds()

Zwraca prostokąt, który jest powiązany z tym GraphicsPathelementem .

GetBounds(Matrix)

Zwraca prostokąt, który jest powiązany z tą GraphicsPath ścieżką, gdy ta ścieżka jest przekształcana przez określony Matrixelement .

GetBounds(Matrix, Pen)

Zwraca prostokąt, który jest powiązany z tą GraphicsPath ścieżką, gdy bieżąca ścieżka jest przekształcana przez określony Matrix i rysowany przy użyciu określonego Penelementu .

GetBounds()

Źródło:
GraphicsPath.cs
Źródło:
GraphicsPath.cs
Źródło:
GraphicsPath.cs

Zwraca prostokąt, który jest powiązany z tym GraphicsPathelementem .

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

Zwraca

Obiekt RectangleF reprezentujący prostokąt, który jest powiązany z tym GraphicsPathelementem .

Przykłady

Poniższy przykład kodu jest przeznaczony do użytku z Windows Forms i wymaga PaintEventArgseobiektu OnPaint zdarzenia . Kod wykonuje następujące akcje:

  • Tworzy ścieżkę grafiki.

  • Dodaje do niego wielokropek (okrąg) i rysuje go na ekranie.

  • Pobiera prostokąt ograniczenia dla okręgu z wywołaniem metody GetBounds i rysuje prostokąt na ekran.

  • Tworzy drugą ścieżkę graficzną.

  • Dodaje okrąg i rozszerza ścieżkę do szerokości 10.

  • Rysuje ścieżkę do ekranu.

  • Pobiera prostokąt ograniczenia dla drugiego okręgu.

  • Rysuje prostokąt ograniczenia do ekranu.

  • Wyświetla rozmiar prostokąta w oknie dialogowym.

Zwróć uwagę, że prostokąt ograniczenia po prawej stronie jest większy (aby uwzględnić dodatkową szerokość linii).

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

Uwagi

Rozmiar zwracanego prostokąta ograniczenia ma wpływ na typ limitów końcowych, szerokości pióra i miter pióra, a w związku z tym tworzy "luźne dopasowanie" do powiązanej ścieżki. Przybliżona formuła to: początkowy prostokąt ograniczenia jest zawyżony przez szerokość pióra, a wynik jest mnożony przez limit miter, a także dodatkowy margines, aby zezwolić na limity końcowe.

Dotyczy

GetBounds(Matrix)

Źródło:
GraphicsPath.cs
Źródło:
GraphicsPath.cs
Źródło:
GraphicsPath.cs

Zwraca prostokąt, który jest powiązany z tą GraphicsPath ścieżką, gdy ta ścieżka jest przekształcana przez określony Matrixelement .

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

Parametry

matrix
Matrix

Określa Matrix przekształcenie, które ma zostać zastosowane do tej ścieżki przed obliczenie prostokąta ograniczenia. Ta ścieżka nie jest trwale przekształcana; transformacja jest używana tylko podczas obliczania prostokąta ograniczenia.

Zwraca

Obiekt RectangleF reprezentujący prostokąt, który jest powiązany z tym GraphicsPathelementem .

Przykłady

Aby zapoznać się z przykładem, zobacz GetBounds().

Uwagi

Rozmiar zwracanego prostokąta ograniczenia ma wpływ na typ limitów końcowych, szerokości pióra i miter pióra, a w związku z tym tworzy "luźne dopasowanie" do powiązanej ścieżki. Przybliżona formuła to: początkowy prostokąt ograniczenia jest zawyżony przez szerokość pióra, a wynik jest mnożony przez limit miter, a także dodatkowy margines, aby zezwolić na limity końcowe.

Dotyczy

GetBounds(Matrix, Pen)

Źródło:
GraphicsPath.cs
Źródło:
GraphicsPath.cs
Źródło:
GraphicsPath.cs

Zwraca prostokąt, który jest powiązany z tą GraphicsPath ścieżką, gdy bieżąca ścieżka jest przekształcana przez określony Matrix i rysowany przy użyciu określonego Penelementu .

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

Parametry

matrix
Matrix

Określa Matrix przekształcenie, które ma zostać zastosowane do tej ścieżki przed obliczenie prostokąta ograniczenia. Ta ścieżka nie jest trwale przekształcana; transformacja jest używana tylko podczas obliczania prostokąta ograniczenia.

pen
Pen

Element Pen , za pomocą którego należy narysować element GraphicsPath.

Zwraca

Obiekt RectangleF reprezentujący prostokąt, który jest powiązany z tym GraphicsPathelementem .

Przykłady

Aby zapoznać się z przykładem, zobacz GetBounds().

Uwagi

Rozmiar zwracanego prostokąta ograniczenia ma wpływ na typ limitów końcowych, szerokości pióra i miter pióra, a w związku z tym tworzy "luźne dopasowanie" do powiązanej ścieżki. Przybliżona formuła to: początkowy prostokąt ograniczenia jest zawyżony przez szerokość pióra, a wynik jest mnożony przez limit miter, a także dodatkowy margines, aby zezwolić na limity końcowe.

Dotyczy