Region.Translate Método

Definição

Desloca as coordenadas disto Region pela quantidade especificada.

Sobrecargas

Name Description
Translate(Int32, Int32)

Desloca as coordenadas disto Region pela quantidade especificada.

Translate(Single, Single)

Desloca as coordenadas disto Region pela quantidade especificada.

Translate(Int32, Int32)

Desloca as coordenadas disto Region pela quantidade especificada.

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 compensar isto Region horizontalmente.

dy
Int32

A quantidade para compensar isto Region verticalmente.

Exemplos

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

  • Cria um retângulo e desenha-o para o ecrã em azul.

  • Cria uma região a partir do retângulo.

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

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

Note que o retângulo vermelho está deslocado para baixo e para a direita em relação ao 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)

Desloca as coordenadas disto Region pela quantidade especificada.

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 compensar isto Region horizontalmente.

dy
Single

A quantidade para compensar isto Region verticalmente.

Exemplos

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

Aplica-se a