Udostępnij przez


Region.Translate Metoda

Definicja

Przesunięcie współrzędnych tej Region wartości przez określoną kwotę.

Przeciążenia

Translate(Int32, Int32)

Przesunięcie współrzędnych tej Region wartości przez określoną kwotę.

Translate(Single, Single)

Przesunięcie współrzędnych tej Region wartości przez określoną kwotę.

Translate(Int32, Int32)

Źródło:
Region.cs
Źródło:
Region.cs
Źródło:
Region.cs

Przesunięcie współrzędnych tej Region wartości przez określoną kwotę.

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

Kwota do przesunięcia w Region poziomie.

dy
Int32

Kwota do przesunięcia w Region pionie.

Przykłady

Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgseparametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:

  • Tworzy prostokąt i rysuje go na ekranie na niebiesko.

  • Tworzy region z prostokąta.

  • Stosuje tłumaczenie do regionu.

  • Wypełnia przetłumaczony region kolorem czerwonym i rysuje przetłumaczony region na ekran na czerwono.

Zwróć uwagę, że czerwony prostokąt jest przesunięty w dół i z prawej strony od oryginalnego prostokąta, pokazany na niebiesko.

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

Dotyczy

Translate(Single, Single)

Źródło:
Region.cs
Źródło:
Region.cs
Źródło:
Region.cs

Przesunięcie współrzędnych tej Region wartości przez określoną kwotę.

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

Kwota do przesunięcia w Region poziomie.

dy
Single

Kwota do przesunięcia w Region pionie.

Przykłady

Aby zapoznać się z przykładem kodu, zobacz metodę Translate(Single, Single) .

Dotyczy