Region.Translate Metodo

Definizione

Esegue l'offset delle coordinate di questa classe Region in base al valore specificato.

Overload

Translate(Int32, Int32)

Esegue l'offset delle coordinate di questa classe Region in base al valore specificato.

Translate(Single, Single)

Esegue l'offset delle coordinate di questa classe Region in base al valore specificato.

Translate(Int32, Int32)

Origine:
Region.cs
Origine:
Region.cs
Origine:
Region.cs

Esegue l'offset delle coordinate di questa classe Region in base al valore specificato.

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)

Parametri

dx
Int32

Valore di offset orizzontale di questa classe Region.

dy
Int32

Valore di offset verticale di questa classe Region.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, che è un parametro del Paint gestore eventi. Il codice esegue le azioni seguenti:

  • Crea un rettangolo e lo disegna sullo schermo in blu.

  • Crea un'area dal rettangolo.

  • Applica la traduzione all'area.

  • Riempie l'area tradotta con rosso e disegna l'area tradotta sullo schermo in rosso.

Si noti che il rettangolo rosso viene spostato verso il basso e verso destra dal rettangolo originale, visualizzato in blu.

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

Si applica a

Translate(Single, Single)

Origine:
Region.cs
Origine:
Region.cs
Origine:
Region.cs

Esegue l'offset delle coordinate di questa classe Region in base al valore specificato.

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)

Parametri

dx
Single

Valore di offset orizzontale di questa classe Region.

dy
Single

Valore di offset verticale di questa classe Region.

Esempio

Per un esempio di codice, vedere il Translate(Single, Single) metodo .

Si applica a