Region.Translate メソッド

定義

指定した量でこの Region の座標をオフセットします。

オーバーロード

Translate(Int32, Int32)

指定した量でこの Region の座標をオフセットします。

Translate(Single, Single)

指定した量でこの Region の座標をオフセットします。

Translate(Int32, Int32)

ソース:
Region.cs
ソース:
Region.cs
ソース:
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 フォームで使用するように設計されており、イベント ハンドラーの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)

ソース:
Region.cs
ソース:
Region.cs
ソース:
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) 参照してください。

適用対象