Region.Translate Método

Definição

Desloca as coordenadas deste Region pelo valor especificado.

Sobrecargas

Translate(Int32, Int32)

Desloca as coordenadas deste Region pelo valor especificado.

Translate(Single, Single)

Desloca as coordenadas deste Region pelo valor especificado.

Translate(Int32, Int32)

Origem:
Region.cs
Origem:
Region.cs
Origem:
Region.cs

Desloca as coordenadas deste Region pelo valor especificado.

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.

dy
Int32

A quantidade para deslocar este Region verticalmente.

Exemplos

O exemplo de código a seguir foi projetado para uso com Windows Forms e requer PaintEventArgse, que é um parâmetro do Paint manipulador de eventos. O código executa as seguintes ações:

  • Cria um retângulo e o desenha na tela em azul.

  • Cria uma região do retângulo.

  • Aplica a tradução para a região.

  • Preenche a região traduzida com vermelho e desenha a região traduzida para a tela em vermelho.

Observe que o retângulo vermelho é deslocado para baixo e para a direita do retângulo original, mostrado em azul.

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)

Origem:
Region.cs
Origem:
Region.cs
Origem:
Region.cs

Desloca as coordenadas deste Region pelo valor especificado.

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.

dy
Single

A quantidade para deslocar este Region verticalmente.

Exemplos

Para obter um exemplo de código, consulte o Translate(Single, Single) método .

Aplica-se a