Rectangle.Offset メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
この四角形の位置を指定した量だけ調整します。
オーバーロード
| 名前 | 説明 |
|---|---|
| Offset(Point) |
この四角形の位置を指定した量だけ調整します。 |
| Offset(Int32, Int32) |
この四角形の位置を指定した量だけ調整します。 |
Offset(Point)
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
この四角形の位置を指定した量だけ調整します。
public:
void Offset(System::Drawing::Point pos);
public void Offset(System.Drawing.Point pos);
member this.Offset : System.Drawing.Point -> unit
Public Sub Offset (pos As Point)
パラメーター
- pos
- Point
位置をオフセットする量。
例
次のコード例は、 Containsメソッドと Offset メソッドと SystemPens クラスを示しています。 この例は、Windows フォームで使用するように設計されています。 このコードを、Button1という名前のボタンを含むフォームに貼り付け、フォームのコンストラクターまたはDrawFirstRectangle メソッドからLoadを呼び出し、Button1_Click メソッドをボタンのClick イベントに関連付けます。
private:
[UIPermission(SecurityAction::Demand, Window=UIPermissionWindow::AllWindows)]
void DrawFirstRectangle()
{
Rectangle rectangle1 = Rectangle(70,70,100,150);
ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );
}
void Button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
Rectangle rectangle1 = Rectangle(70,70,100,150);
// Get the bounds of the screen.
Rectangle screenRectangle = Screen::PrimaryScreen->Bounds;
// Check to see if the rectangle is within the bounds of the screen.
if ( screenRectangle.Contains( rectangle1 ) )
{
ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );
// Call the Offset method to move the rectangle.
rectangle1.Offset( 20, 20 );
// Draw the new, offset rectangle.
ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );
}
}
Rectangle rectangle1 = new Rectangle(70, 70, 100, 150);
private void DrawFirstRectangle()
{
ControlPaint.DrawReversibleFrame(rectangle1,
SystemColors.Highlight, FrameStyle.Thick);
}
private void Button1_Click(object sender, EventArgs e)
{
// Get the bounds of the screen.
Rectangle screenRectangle = Screen.PrimaryScreen.Bounds;
// Check to see if the rectangle is within the bounds of the screen.
if (screenRectangle.Contains(rectangle1))
// If so, erase the previous rectangle.
{
ControlPaint.DrawReversibleFrame(rectangle1,
SystemColors.Highlight, FrameStyle.Thick);
// Call the Offset method to move the rectangle.
rectangle1.Offset(20, 20);
// Draw the new, offset rectangle.
ControlPaint.DrawReversibleFrame(rectangle1,
SystemColors.Highlight, FrameStyle.Thick);
}
}
Dim rectangle1 As New Rectangle(70, 70, 100, 150)
Private Sub DrawFirstRectangle()
ControlPaint.DrawReversibleFrame(rectangle1, _
SystemColors.Highlight, FrameStyle.Thick)
End Sub
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles Button1.Click
' Get the bounds of the screen.
Dim screenRectangle As Rectangle = Screen.PrimaryScreen.Bounds
' Check to see if the rectangle is within the bounds of the screen.
If (screenRectangle.Contains(rectangle1)) Then
' If so, erase the previous rectangle.
ControlPaint.DrawReversibleFrame(rectangle1, _
SystemColors.Highlight, FrameStyle.Thick)
' Call the Offset method to move the rectangle.
rectangle1.Offset(20, 20)
' Draw the new, offset rectangle.
ControlPaint.DrawReversibleFrame(rectangle1, _
SystemColors.Highlight, FrameStyle.Thick)
End If
End Sub
注釈
このメソッドは、左上隅の位置を、指定した点の x 座標で水平方向に調整し、指定した点の y 座標で垂直方向に調整します。
適用対象
Offset(Int32, Int32)
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
この四角形の位置を指定した量だけ調整します。
public:
void Offset(int x, int y);
public void Offset(int x, int y);
member this.Offset : int * int -> unit
Public Sub Offset (x As Integer, y As Integer)
パラメーター
- x
- Int32
水平方向のオフセット。
- y
- Int32
垂直方向のオフセット。