Rect.Offset 메서드

정의

사각형을 지정된 크기만큼 이동합니다.

오버로드

Name Description
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

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

반품

결과 사각형입니다.

예외

rectEmpty입니다.

예제

다음 예제에서는 메서드를 사용 하 여 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

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

반품

결과 사각형입니다.

예외

rectEmpty입니다.

예제

다음 예제에서는 메서드를 사용 하 여 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)을 사용하여 이 메서드를 호출할 수 없습니다.

적용 대상