Sdílet prostřednictvím


Region.Translate Metoda

Definice

Posune souřadnice tohoto Region o zadanou částku.

Přetížení

Translate(Int32, Int32)

Posune souřadnice tohoto Region o zadanou částku.

Translate(Single, Single)

Posune souřadnice tohoto Region o zadanou částku.

Translate(Int32, Int32)

Zdroj:
Region.cs
Zdroj:
Region.cs
Zdroj:
Region.cs
Zdroj:
Region.cs
Zdroj:
Region.cs

Posune souřadnice tohoto Region o zadanou částku.

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)

Parametry

dx
Int32

Částka, která se má vodorovně odsazení tohoto Region.

dy
Int32

Velikost posunu tohoto Region svisle.

Příklady

Následující příklad kódu je určený pro použití s Windows Forms a vyžaduje PaintEventArgse, což je parametr obslužné rutiny události Paint. Kód provede následující akce:

  • Vytvoří obdélník a nakreslí ho na obrazovku modře.

  • Vytvoří oblast z obdélníku.

  • Použije překlad do oblasti.

  • Vyplní přeloženou oblast červenou barvou a nakreslí přeloženou oblast na obrazovku červeně.

Všimněte si, že červený obdélník se posune dolů a vpravo od původního obdélníku, který je zobrazený modře.

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

Platí pro

Translate(Single, Single)

Zdroj:
Region.cs
Zdroj:
Region.cs
Zdroj:
Region.cs
Zdroj:
Region.cs
Zdroj:
Region.cs

Posune souřadnice tohoto Region o zadanou částku.

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)

Parametry

dx
Single

Částka, která se má vodorovně odsazení tohoto Region.

dy
Single

Velikost posunu tohoto Region svisle.

Příklady

Příklad kódu najdete v Translate(Single, Single) metodě.

Platí pro