RectangleF Constructor (PointF, SizeF)

 

Initializes a new instance of the RectangleF class with the specified location and size.

Namespace:   System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public:
RectangleF(
	PointF location,
	SizeF size
)

Parameters

location
Type: System.Drawing::PointF

A PointF that represents the upper-left corner of the rectangular region.

size
Type: System.Drawing::SizeF

A SizeF that represents the width and height of the rectangular region.

The following code example demonstrates how to use the Implicit(Rectangle to RectangleF), RectangleF, and Equality members. This example is designed for use with a Windows Form. Paste this code into a form and call the ConvertRectangleToRectangleF method when handling the form's Paint event, passing e as PaintEventArgs.

private:
   void ConvertRectangleToRectangleF( PaintEventArgs^ e )
   {
      // Create a rectangle.
      Rectangle rectangle1 = Rectangle(30,40,50,100);

      // Convert it to a RectangleF.
      RectangleF convertedRectangle = rectangle1;

      // Create a new RectangleF.
      RectangleF rectangle2 = RectangleF(PointF(30.0F,40.0F),SizeF(50.0F,100.0F));

      // Create a custom, partially transparent brush.
      SolidBrush^ redBrush = gcnew SolidBrush( Color::FromArgb( 40, Color::Red ) );

      // Compare the converted rectangle with the new one.  If they 
      // are equal draw and fill the rectangles on the form.
      if ( convertedRectangle == rectangle2 )
      {
         e->Graphics->FillRectangle( redBrush, rectangle2 );
      }

      // Dispose of the custom brush.
      delete redBrush;
   }
};

.NET Framework
Available since 1.1
Return to top
Show: