次の方法で共有


Region.Translate メソッド (Int32, Int32)

指定した量による Region オブジェクトの座標のオフセット。

Overloads Public Sub Translate( _
   ByVal dx As Integer, _   ByVal dy As Integer _)
[C#]
public void Translate(intdx,intdy);
[C++]
public: void Translate(intdx,intdy);
[JScript]
public function Translate(
   dx : int,dy : int);

パラメータ

  • dx
    この Region オブジェクトの水平方向のオフセット量。
  • dy
    この Region オブジェクトの垂直方向のオフセット量。

戻り値

このメソッドは値を返しません。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • 四角形を作成し、青で画面に描画します。
  • 四角形から領域を作成します。
  • 変換を領域に適用します。
  • 変換領域を赤で塗りつぶした上で画面に赤で描画します。

[Visual Basic, C#] 赤の四角形は下方にシフトされて元の四角形の右側に配置され、青で表示されます。

 
Public Sub TranslateExample(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
        
[C#] 
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);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

Region クラス | Region メンバ | System.Drawing 名前空間 | Region.Translate オーバーロードの一覧