Region.Translate Método

Definição

Desloca as coordenadas deste Region pelo valor especificado.Offsets the coordinates of this Region by the specified amount.

Sobrecargas

Translate(Int32, Int32)

Desloca as coordenadas deste Region pelo valor especificado.Offsets the coordinates of this Region by the specified amount.

Translate(Single, Single)

Desloca as coordenadas deste Region pelo valor especificado.Offsets the coordinates of this Region by the specified amount.

Translate(Int32, Int32)

Desloca as coordenadas deste Region pelo valor especificado.Offsets the coordinates of this Region by the specified amount.

public:
 void Translate(int dx, int dy);
public void Translate (int dx, int dy);
member this.Translate : int * int -> unit
Public Sub Translate (dx As Integer, dy As Integer)

Parâmetros

dx
Int32

A quantidade para deslocar este Region horizontalmente.The amount to offset this Region horizontally.

dy
Int32

A quantidade para deslocar este Region verticalmente.The amount to offset this Region vertically.

Exemplos

O exemplo de código a seguir foi projetado para uso com Windows Forms, e ele requer PaintEventArgs e , que é um parâmetro do Paint manipulador de eventos.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. O código executa as seguintes ações:The code performs the following actions:

  • Cria um retângulo e o desenha na tela em azul.Creates a rectangle and draws it to the screen in blue.

  • Cria uma região a partir do retângulo.Creates a region from the rectangle.

  • Aplica a tradução à região.Applies the translation to the region.

  • Preenche a região traduzida com vermelho e desenha a região traduzida para a tela em vermelho.Fills the translated region with red and draws the translated region to the screen in red.

Observe que o retângulo vermelho é deslocado para baixo e para a direita do retângulo original, mostrado em azul.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 );
}
public void TranslateExample(PaintEventArgs e)
{
             
    // Create the first rectangle and draw it to the screen in blue.
    Rectangle regionRect = new Rectangle(100, 50, 100, 100);
    e.Graphics.DrawRectangle(Pens.Blue, regionRect);
             
    // Create a region using the first rectangle.
    Region myRegion = new 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 = new SolidBrush(Color.Red);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub TranslateExample(ByVal e As PaintEventArgs)

    ' Create the first rectangle and draw it to the screen in blue.
    Dim regionRect As New Rectangle(100, 50, 100, 100)
    e.Graphics.DrawRectangle(Pens.Blue, regionRect)

    ' Create a region using the first rectangle.
    Dim myRegion As New [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.
    Dim myBrush As New SolidBrush(Color.Red)
    e.Graphics.FillRegion(myBrush, myRegion)
End Sub

Aplica-se a

Translate(Single, Single)

Desloca as coordenadas deste Region pelo valor especificado.Offsets the coordinates of this Region by the specified amount.

public:
 void Translate(float dx, float dy);
public void Translate (float dx, float dy);
member this.Translate : single * single -> unit
Public Sub Translate (dx As Single, dy As Single)

Parâmetros

dx
Single

A quantidade para deslocar este Region horizontalmente.The amount to offset this Region horizontally.

dy
Single

A quantidade para deslocar este Region verticalmente.The amount to offset this Region vertically.

Exemplos

Para obter um exemplo de código, consulte o Translate(Single, Single) método.For a code example, see the Translate(Single, Single) method.

Aplica-se a