Share via


Region.Translate Metoda

Definice

Odsadí souřadnice o Region zadanou hodnotu.

Přetížení

Translate(Int32, Int32)

Odsadí souřadnice o Region zadanou hodnotu.

Translate(Single, Single)

Odsadí souřadnice o Region zadanou hodnotu.

Translate(Int32, Int32)

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

Odsadí souřadnice o Region zadanou hodnotu.

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

Jedná se o vodorovné vyrovnání Region .

dy
Int32

Částka, která má být posunutá Region svisle.

Příklady

Následující příklad kódu je navržený pro použití s model Windows Forms a vyžaduje PaintEventArgse, což je parametr obslužné rutiny Paint události. 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 na oblast.

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

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

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

Odsadí souřadnice o Region zadanou hodnotu.

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

Jedná se o vodorovné vyrovnání Region .

dy
Single

Částka, která má být posunutá Region svisle.

Příklady

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

Platí pro