Region::Translate Method (Int32, Int32)
.NET Framework (current version)
Offsets the coordinates of this Region by the specified amount.
Assembly: System.Drawing (in System.Drawing.dll)
Parameters
- dx
-
Type:
System::Int32
The amount to offset this Region horizontally.
- dy
-
Type:
System::Int32
The amount to offset this Region vertically.
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 a rectangle and draws it to the screen in blue.
Creates a region from the rectangle.
Applies the translation to the region.
Fills the translated region with red and draws the translated region to the screen in red.
Notice that the red rectangle is shifted down and to the right from the original rectangle, shown in blue.
void TranslateExample( PaintEventArgs^ e ) { // Create the first rectangle and draw it to the screen in blue. Rectangle regionRect = Rectangle(100,50,100,100); e->Graphics->DrawRectangle( Pens::Blue, regionRect ); // Create a region using the first rectangle. System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect ); // Apply the translation to the region. myRegion->Translate( 150, 100 ); // Fill the transformed region with red and draw it to the screen in red. SolidBrush^ myBrush = gcnew SolidBrush( Color::Red ); e->Graphics->FillRegion( myBrush, myRegion ); }
.NET Framework
Available since 1.1
Available since 1.1
Show: