Rect.Offset 메서드

정의

사각형을 지정된 거리만큼 이동합니다.

오버로드

Offset(Vector)

사각형을 지정된 벡터만큼 이동합니다.

Offset(Double, Double)

사각형을 지정된 가로 및 세로 거리만큼 이동합니다.

Offset(Rect, Vector)

지정된 사각형에서 지정된 벡터만큼 오프셋된 사각형을 반환합니다.

Offset(Rect, Double, Double)

지정된 사각형에서 지정된 가로 및 세로 거리만큼 오프셋된 사각형을 반환합니다.

Offset(Vector)

사각형을 지정된 벡터만큼 이동합니다.

public:
 void Offset(System::Windows::Vector offsetVector);
public void Offset (System.Windows.Vector offsetVector);
member this.Offset : System.Windows.Vector -> unit
Public Sub Offset (offsetVector As Vector)

매개 변수

offsetVector
Vector

사각형을 이동할 가로 및 세로 거리를 지정하는 벡터입니다.

예외

Empty 사각형에 대해 이 메서드를 호출한 경우

예제

다음 예제에서는 사용 하는 방법의 Offset(Vector) 사각형의 위치를 변경 하는 방법입니다.

private Point offsetExample1()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle.Size = new Size(200, 50);

    // Create a vector to use to offset the position of the rectangle.
    Vector vector1 = new Vector(20, 30);

    // The Offset method translates this rectangle by the specified vector.
    // myRectangle location changed from 10,5 to 30,35.
    myRectangle.Offset(vector1);

    // This rectangle's location changed from 10,5 to 30,35.
    return myRectangle.Location;
}

설명

빈 사각형에서이 메서드를 호출 (Rect.Empty) 허용 되지 않습니다.

호출 하는 Offset 메서드는 변경할 수 있는 경우에 효과가 있습니다 합니다 XY 속성을 직접. 때문에 Rect 값 형식인를 참조 하는 경우는 Rect 개체 속성 또는 인덱서를 사용 하 여 개체에 대 한 참조가 아니라 개체의 복사본을 얻을 있습니다. 변경 하려는 경우 X 또는 Y 속성 또는 인덱서에서 참조에서 컴파일러 오류가 발생 합니다. 마찬가지로, 호출 Offset 속성 또는 인덱서에 기본 개체는 변경 되지 것입니다. 값을 변경 하려는 경우는 Rect 속성 또는 인덱서를으로 참조 되는, 새 Rect, 해당 필드를 수정 하 고 할당을 Rect 속성 또는 인덱서를 다시 합니다.

적용 대상

Offset(Double, Double)

사각형을 지정된 가로 및 세로 거리만큼 이동합니다.

public:
 void Offset(double offsetX, double offsetY);
public void Offset (double offsetX, double offsetY);
member this.Offset : double * double -> unit
Public Sub Offset (offsetX As Double, offsetY As Double)

매개 변수

offsetX
Double

사각형을 가로 방향으로 이동할 거리입니다.

offsetY
Double

사각형을 세로 방향으로 이동할 거리입니다.

예외

Empty 사각형에 대해 이 메서드를 호출한 경우

예제

다음 예제에서는 사용 하는 방법의 Offset(Double, Double) 사각형의 위치를 변경 하는 방법입니다.

private Point offsetExample2()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle.Size = new Size(200, 50);

    // The Offset method translates this rectangle by the specified horizontal and 
    // vertical amounts. 
    // myRectangle location changed from 10,5 to 30,35.
    myRectangle.Offset(20,30);

    // This rectangle's location changed from 10,5 to 30,35.
    return myRectangle.Location;
}

설명

빈 사각형에서이 메서드를 호출 (Rect.Empty) 허용 되지 않습니다.

호출 하는 Offset 메서드는 변경할 수 있는 경우에 효과가 있습니다 합니다 XY 속성을 직접. 때문에 Rect 값 형식인를 참조 하는 경우는 Rect 개체 속성 또는 인덱서를 사용 하 여 개체에 대 한 참조가 아니라 개체의 복사본을 얻을 있습니다. 변경 하려는 경우 X 또는 Y 속성 또는 인덱서에서 참조에서 컴파일러 오류가 발생 합니다. 마찬가지로, 호출 Offset 속성 또는 인덱서에 기본 개체는 변경 되지 것입니다. 값을 변경 하려는 경우는 Rect 속성 또는 인덱서를으로 참조 되는, 새 Rect, 해당 필드를 수정 하 고 할당을 Rect 속성 또는 인덱서를 다시 합니다.

적용 대상

Offset(Rect, Vector)

지정된 사각형에서 지정된 벡터만큼 오프셋된 사각형을 반환합니다.

public:
 static System::Windows::Rect Offset(System::Windows::Rect rect, System::Windows::Vector offsetVector);
public static System.Windows.Rect Offset (System.Windows.Rect rect, System.Windows.Vector offsetVector);
static member Offset : System.Windows.Rect * System.Windows.Vector -> System.Windows.Rect
Public Shared Function Offset (rect As Rect, offsetVector As Vector) As Rect

매개 변수

rect
Rect

원래 사각형입니다.

offsetVector
Vector

새 사각형의 가로 및 세로 오프셋을 지정하는 벡터입니다.

반환

Rect

결과 사각형입니다.

예외

rect이(가) Empty인 경우

예제

다음 예제에서는 사용 하는 방법의 Offset(Rect, Vector) 사각형의 위치를 변경 하는 방법입니다.

private Point offsetExample3()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle.Size = new Size(200, 50);

    // Create a vector to use to offset the position of the rectangle.
    Vector vector1 = new Vector(20, 30);

    // The Offset method translates the specified rectangle by the specified amount 
    // and returns the resulting Rect. 
    // resultRect location changed from 10,5 to 30,35.
    Rect resultRect = Rect.Offset(myRectangle, vector1);

    // This rectangle's location changed from 10,5 to 30,35.
    return resultRect.Location;
}

설명

빈 사각형을 사용 하 여이 메서드를 호출 (Rect.Empty) 허용 되지 않습니다.

적용 대상

Offset(Rect, Double, Double)

지정된 사각형에서 지정된 가로 및 세로 거리만큼 오프셋된 사각형을 반환합니다.

public:
 static System::Windows::Rect Offset(System::Windows::Rect rect, double offsetX, double offsetY);
public static System.Windows.Rect Offset (System.Windows.Rect rect, double offsetX, double offsetY);
static member Offset : System.Windows.Rect * double * double -> System.Windows.Rect
Public Shared Function Offset (rect As Rect, offsetX As Double, offsetY As Double) As Rect

매개 변수

rect
Rect

이동할 사각형입니다.

offsetX
Double

새 사각형의 가로 오프셋입니다.

offsetY
Double

새 사각형의 세로 오프셋입니다.

반환

Rect

결과 사각형입니다.

예외

rect이(가) Empty인 경우

예제

다음 예제에서는 사용 하는 방법의 Offset(Rect, Double, Double) 사각형의 위치를 변경 하는 방법입니다.

private Point offsetExample4()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle.Size = new Size(200, 50);

    // Create a vector to use to offset the position of the rectangle.
    Vector vector1 = new Vector(20, 30);

    // The Offset method translates the specified rectangle by the specified horizontal 
    // and vertical amounts and returns the resulting Rect. 
    // resultRect location changed from 10,5 to 30,35.
    Rect resultRect = Rect.Offset(myRectangle, 20, 30);

    // This rectangle's location changed from 10,5 to 30,35.
    return resultRect.Location;
}

설명

빈 사각형을 사용 하 여이 메서드를 호출 (Rect.Empty) 허용 되지 않습니다.

적용 대상