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 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • 사각형을 만들고 파란색으로 화면에 그립니다.

  • 사각형에서 영역을 만듭니다.

  • 번역을 지역에 적용합니다.

  • 번역된 영역을 빨간색으로 채우고 번역된 영역을 화면에 빨간색으로 그립니다.

빨간색 사각형이 파란색으로 표시된 원래 사각형에서 오른쪽으로 아래로 이동됩니다.

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) .

적용 대상