Region::Exclude Method (RectangleF)
Updates this Region to contain only the portion of its interior that does not intersect with the specified RectangleF structure.
Assembly: System.Drawing (in System.Drawing.dll)
Parameters
- rect
-
Type:
System.Drawing::RectangleF
The RectangleF structure to exclude from this Region.
The following 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 a rectangle and draws it to the screen in black
Creates a second rectangle that intersects with the first and draws it to the screen in red.
Creates a region using the first rectangle.
Gets the nonexcluded area of the region when combined with the second rectangle.
Fills the nonexcluded area with blue and draws it to the screen.
Notice that the area of the area of the region that does not intersect with the rectangle is colored blue.
public: void Exclude_RectF_Example( PaintEventArgs^ e ) { // Create the first rectangle and draw it to the screen in black. Rectangle regionRect = Rectangle(20,20,100,100); e->Graphics->DrawRectangle( Pens::Black, regionRect ); // Create the second rectangle and draw it to the screen in red. RectangleF complementRect = RectangleF(90,30,100,100); e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( complementRect ) ); // Create a region using the first rectangle. System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect ); // Get the nonexcluded area of myRegion when combined with // complementRect. myRegion->Exclude( complementRect ); // Fill the nonexcluded area of myRegion with blue. SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue ); e->Graphics->FillRegion( myBrush, myRegion ); }
Available since 1.1