Region::IsVisible Method (RectangleF)
Tests whether any portion of the specified RectangleF structure is contained within this Region.
Assembly: System.Drawing (in System.Drawing.dll)
Parameters
- rect
-
Type:
System.Drawing::RectangleF
The RectangleF structure to test.
Return Value
Type: System::Booleantrue when any portion of rect is contained within this Region; otherwise, false.
The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. The code performs the following actions:
Creates the first rectangle and draws it to the screen in blue.
Creates the second rectangle and draws it to the screen in red.
Creates a region from the first rectangle.
Determines if any portion of the rectangle intersects with the region.
Displays the true or false result on the screen.
Notice that the rectangle intersects the region, so the result is true.
public: void IsVisible_RectF_Example( PaintEventArgs^ e ) { // Create the first rectangle and draw it to the screen in blue. Rectangle regionRect = Rectangle(20,20,100,100); e->Graphics->DrawRectangle( Pens::Blue, regionRect ); // Create the second rectangle and draw it to the screen in red. RectangleF myRect = RectangleF(90,30,100,100); e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( myRect ) ); // Create a region using the first rectangle. System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect ); // Determine if myRect is contained in the region. bool contained = myRegion->IsVisible( myRect ); // Display the result. System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",8 ); SolidBrush^ myBrush = gcnew SolidBrush( Color::Black ); e->Graphics->DrawString( String::Format( "contained = {0}", contained ), myFont, myBrush, PointF(20,140) ); }
Available since 1.1