Region.Translate Метод

Определение

Смещает координаты области Region на указанную величину.

Перегрузки

Translate(Int32, Int32)

Смещает координаты области Region на указанную величину.

Translate(Single, Single)

Смещает координаты области Region на указанную величину.

Translate(Int32, Int32)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

Смещает координаты области Region на указанную величину.

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)

Параметры

dx
Int32

Величина смещения области Region в горизонтальном направлении.

dy
Int32

Величина смещения области Region в вертикальном направлении.

Примеры

Следующий пример кода предназначен для использования с Windows Forms и требует PaintEventArgse, который является параметром обработчика Paint событий. Код выполняет следующие действия.

  • Создает прямоугольник и рисует его на экране синим цветом.

  • Создает область из прямоугольника.

  • Применяет перевод к региону.

  • Заполняет переведенную область красным цветом и рисует переведенную область на экран красным цветом.

Обратите внимание, что красный прямоугольник смещается вниз и вправо от исходного прямоугольника, показанного синим цветом.

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

Применяется к

Translate(Single, Single)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

Смещает координаты области Region на указанную величину.

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)

Параметры

dx
Single

Величина смещения области Region в горизонтальном направлении.

dy
Single

Величина смещения области Region в вертикальном направлении.

Примеры

Пример кода см. в описании Translate(Single, Single) метода .

Применяется к