Rectangle.Truncate(RectangleF) Rectangle.Truncate(RectangleF) Rectangle.Truncate(RectangleF) Rectangle.Truncate(RectangleF) Method

Definição

Converte o RectangleF especificado como um Rectangle truncando os valores RectangleF.Converts the specified RectangleF to a Rectangle by truncating the RectangleF values.

public:
 static System::Drawing::Rectangle Truncate(System::Drawing::RectangleF value);
public static System.Drawing.Rectangle Truncate (System.Drawing.RectangleF value);
static member Truncate : System.Drawing.RectangleF -> System.Drawing.Rectangle
Public Shared Function Truncate (value As RectangleF) As Rectangle

Parâmetros

value
RectangleF RectangleF RectangleF RectangleF

O RectangleF a ser convertido.The RectangleF to be converted.

Retornos

O valor truncado do Rectangle.The truncated value of the Rectangle.

Exemplos

O exemplo de código a seguir demonstra como usar Round os Truncate métodos e.The following code example demonstrates how to use the Round and Truncate methods. Este exemplo foi projetado para uso com um Windows Form.This example is designed for use with a Windows Form. Cole esse código em um formulário e chame o RoundingAndTruncatingRectangles método ao manipular o evento do Paint formulário, passando e como PaintEventArgs.Paste this code into a form and call the RoundingAndTruncatingRectangles method when handling the form's Paint event, passing e as PaintEventArgs.

private:
   void RoundingAndTruncatingRectangles( PaintEventArgs^ e )
   {
      // Construct a new RectangleF.
      RectangleF myRectangleF = RectangleF(30.6F,30.7F,40.8F,100.9F);

      // Call the Round method.
      Rectangle roundedRectangle = Rectangle::Round( myRectangleF );

      // Draw the rounded rectangle in red.
      Pen^ redPen = gcnew Pen( Color::Red,4.0f );
      e->Graphics->DrawRectangle( redPen, roundedRectangle );

      // Call the Truncate method.
      Rectangle truncatedRectangle = Rectangle::Truncate( myRectangleF );

      // Draw the truncated rectangle in white.
      Pen^ whitePen = gcnew Pen( Color::White,4.0f );
      e->Graphics->DrawRectangle( whitePen, truncatedRectangle );

      // Dispose of the custom pens.
      delete redPen;
      delete whitePen;
   }
private void RoundingAndTruncatingRectangles(PaintEventArgs e)
{

    // Construct a new RectangleF.
    RectangleF myRectangleF = 
        new RectangleF(30.6F, 30.7F, 40.8F, 100.9F);

    // Call the Round method.
    Rectangle roundedRectangle = Rectangle.Round(myRectangleF);

    // Draw the rounded rectangle in red.
    Pen redPen = new Pen(Color.Red, 4);
    e.Graphics.DrawRectangle(redPen, roundedRectangle);

    // Call the Truncate method.
    Rectangle truncatedRectangle = Rectangle.Truncate(myRectangleF);

    // Draw the truncated rectangle in white.
    Pen whitePen = new Pen(Color.White, 4);
    e.Graphics.DrawRectangle(whitePen, truncatedRectangle);

    // Dispose of the custom pens.
    redPen.Dispose();
    whitePen.Dispose();
}
Private Sub RoundingAndTruncatingRectangles( _
    ByVal e As PaintEventArgs)

    ' Construct a new RectangleF.
    Dim myRectangleF As New RectangleF(30.6F, 30.7F, 40.8F, 100.9F)

    ' Call the Round method.
    Dim roundedRectangle As Rectangle = Rectangle.Round(myRectangleF)

    ' Draw the rounded rectangle in red.
    Dim redPen As New Pen(Color.Red, 4)
    e.Graphics.DrawRectangle(redPen, roundedRectangle)

    ' Call the Truncate method.
    Dim truncatedRectangle As Rectangle = _
        Rectangle.Truncate(myRectangleF)

    ' Draw the truncated rectangle in white.
    Dim whitePen As New Pen(Color.White, 4)
    e.Graphics.DrawRectangle(whitePen, truncatedRectangle)

    ' Dispose of the custom pens.
    redPen.Dispose()
    whitePen.Dispose()
End Sub

Aplica-se a