# Rect 구조체

## 정의

사각형의 너비, 높이 및 위치를 설명합니다.Describes the width, height, and location of a rectangle.

``public value class Rect : IFormattable``
``````[System.ComponentModel.TypeConverter(typeof(System.Windows.RectConverter))]
public struct Rect : IFormattable``````
``````[System.ComponentModel.TypeConverter(typeof(System.Windows.RectConverter))]
[System.Serializable]
public struct Rect : IFormattable``````
``````[<System.ComponentModel.TypeConverter(typeof(System.Windows.RectConverter))>]
type Rect = struct
interface IFormattable``````
``````[<System.ComponentModel.TypeConverter(typeof(System.Windows.RectConverter))>]
[<System.Serializable>]
type Rect = struct
interface IFormattable``````
``````Public Structure Rect
Implements IFormattable``````
상속
특성
구현

## 예제

다음 예제에서는 사용 하는 방법을 보여 줍니다는 Rect 차원 및 XAML을 사용 하 여 사각형의 위치를 지정 하는 구조입니다.The following example shows how to use a Rect structure to specify the dimensions and location of a rectangle using XAML.

``````using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace SDKSample
{
public partial class RectExample : Page
{
public RectExample()
{
Path myPath1 = new Path();
myPath1.Stroke = Brushes.Black;
myPath1.StrokeThickness = 1;
SolidColorBrush mySolidColorBrush = new SolidColorBrush();
mySolidColorBrush.Color = Color.FromArgb(255, 204, 204, 255);
myPath1.Fill = mySolidColorBrush;

// Create the rectangle.
// This RectangleGeometry specifies a rectangle that is 100 pixels high and
// 150 wide. The left side of the rectangle is 10 pixels from the left of the
// Canvas and the top side of the rectangle is 100 pixels from the top of the Canvas.
// Note: You could alternatively use the Rect Constructor to create this:
// Rect my Rect1 = new Rect(10,100,150,100");
Rect myRect1 = new Rect();
myRect1.X = 10;
myRect1.Y = 100;
myRect1.Width = 150;
myRect1.Height = 100;
RectangleGeometry myRectangleGeometry1 = new RectangleGeometry();
myRectangleGeometry1.Rect = myRect1;

GeometryGroup myGeometryGroup1 = new GeometryGroup();

myPath1.Data = myGeometryGroup1;

Path myPath2 = new Path();
myPath2.Stroke = Brushes.Black;
myPath2.StrokeThickness = 1;
myPath2.Fill = mySolidColorBrush;

// Create the rectangle.
// This Rect uses the Size property to specify a height of 50 and width
// of 200. The Location property uses a Point value to determine the location of the
// top-left corner of the rectangle.
Rect myRect2 = new Rect();
myRect2.Size = new Size(50, 200);
myRect2.Location = new Point(300, 100);
RectangleGeometry myRectangleGeometry2 = new RectangleGeometry();
myRectangleGeometry2.Rect = myRect2;

GeometryGroup myGeometryGroup2 = new GeometryGroup();

myPath2.Data = myGeometryGroup2;

// Add path shape to the UI.
Canvas myCanvas = new Canvas();
this.Content = myCanvas;
}
}
}
``````
``````
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Media
Imports System.Windows.Shapes

Namespace SDKSample
Partial Public Class RectExample
Inherits Page
Public Sub New()
Dim myPath1 As New Path()
myPath1.Stroke = Brushes.Black
myPath1.StrokeThickness = 1
Dim mySolidColorBrush As New SolidColorBrush()
mySolidColorBrush.Color = Color.FromArgb(255, 204, 204, 255)
myPath1.Fill = mySolidColorBrush

' Create the rectangle.
' This RectangleGeometry specifies a rectangle that is 100 pixels high and
' 150 wide. The left side of the rectangle is 10 pixels from the left of the
' Canvas and the top side of the rectangle is 100 pixels from the top of the Canvas.
' Note: You could alternatively use the Rect Constructor to create this:
' Dim myRect1 As New Rect(10,100,150,100")
Dim myRect1 As New Rect()
myRect1.X = 10
myRect1.Y = 100
myRect1.Width = 150
myRect1.Height = 100
Dim myRectangleGeometry1 As New RectangleGeometry()
myRectangleGeometry1.Rect = myRect1

Dim myGeometryGroup1 As New GeometryGroup()

myPath1.Data = myGeometryGroup1

Dim myPath2 As New Path()
myPath2.Stroke = Brushes.Black
myPath2.StrokeThickness = 1
myPath2.Fill = mySolidColorBrush

' Create the rectangle.
' This Rect uses the Size property to specify a height of 50 and width
' of 200. The Location property uses a Point value to determine the location of the
' top-left corner of the rectangle.
Dim myRect2 As New Rect()
myRect2.Size = New Size(50, 200)
myRect2.Location = New Point(300, 100)
Dim myRectangleGeometry2 As New RectangleGeometry()
myRectangleGeometry2.Rect = myRect2

Dim myGeometryGroup2 As New GeometryGroup()

myPath2.Data = myGeometryGroup2

' Add path shape to the UI.
Dim myCanvas As New Canvas()
Me.Content = myCanvas
End Sub
End Class

End Namespace
``````
``````<Page  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas>

<!-- This rectangle demonstrates using the X, Y, Width, and Height properties
of a Rect object. -->
<Path Stroke="Black" StrokeThickness="1" Fill="LemonChiffon">
<Path.Data>

<!-- This RectangleGeometry specifies a rectangle that is 100 pixels high and
150 wide. The left side of the rectangle is 10 pixels from the left of the
Canvas and the top side of the rectangle is 100 pixels from the top of the Canvas.
Note: An abbreviated syntax for creating an equivalent rectangle is:
<RectangleGeometry Rect="10,100,150,100" /> -->
<RectangleGeometry>
<RectangleGeometry.Rect>
<Rect X="10" Y="100" Width="150" Height="100" />
</RectangleGeometry.Rect>
</RectangleGeometry>
</Path.Data>
</Path>

<!-- This rectangle demonstrates using the Size and Location properties of a Rect object. -->
<Path Stroke="Black" StrokeThickness="1" Fill="LemonChiffon">
<Path.Data>

<!-- This RectangleGeometry uses the Size property to specify a height of 50 and width
of 200. The Location property uses a Point value to determine the location of the
top-left corner of the rectangle. /> -->
<RectangleGeometry>
<RectangleGeometry.Rect>
<Rect Size="50,200" Location="300,100" />
</RectangleGeometry.Rect>
</RectangleGeometry>
</Path.Data>
</Path>
</Canvas>
</Page>

``````

다음 예제에서는 코드를 사용 하 여 사각형을 만들고 페이지에 추가 하는 방법을 보여 줍니다.The following example shows how to use code to create a rectangle and add it to the page. 이 예제에서는 새 사각형에 대 한 크기 및 좌표 정보를 찾아의 정보를 렌더링 하는 방법을 보여 줍니다는 TextBox 사각형 아래의 합니다.The example also illustrates how to find size and coordinate information about the new rectangle and render the information in a TextBox below the rectangle.

``````// Create a rectangle and add it to the page. Also,
// new rectangle and render information in a TextBox
// below the rectangle.
private StackPanel createRectExample1()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();

// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle. Set the Location property to an X coordinate of 10 and a
// Y coordinate of 5.
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);

RectangleGeometry myRectangleGeometry = new RectangleGeometry();
myRectangleGeometry.Rect = myRectangle;

// This path is defined by the rectangle.
Path myPath = new Path();
myPath.Fill = Brushes.LemonChiffon;
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myRectangleGeometry;

//////////// Create string of rectangle property information /////////////
// This string will contain all the size and coordinate property
/////////////////////////////////////////////////////////////////////////
string rectInfo = "Rectangle Property Information: ";

// Bottom property gets the y-axis value of the bottom of the rectangle.
// For this rectangle the value is 55.
rectInfo = rectInfo + "Bottom: " + myRectangle.Bottom;

// BottomLeft property gets the coordinates of the bottom left corner of the rectangle.
// For this rectangle the value is 10,55.
rectInfo = rectInfo + "| BottomLeft: " + myRectangle.BottomLeft;

// BottomRight property gets the coordinates of the bottom right corner of the rectangle.
// For this rectangle the value is 210,55.
rectInfo = rectInfo + "| BottomRight: " + myRectangle.BottomRight;

// Height property gets or sets the height of the rectangle.
// For this rectangle the value is 50.
rectInfo = rectInfo + "| Height: " + myRectangle.Height;

// Width property gets or sets the width of the rectangle.
// For this rectangle the value is 200.
rectInfo = rectInfo + "| Width: " + myRectangle.Width;

// Left property gets the x-axis position of the left side of the rectangle which is
// equivalent to getting the rectangle's X property.
// For this rectangle the value is 10.
rectInfo = rectInfo + "| Left: " + myRectangle.Left;

// Location property gets or sets the position of the rectangle's top-left corner.
// For this rectangle the value is 10,5.
rectInfo = rectInfo + "| Location: " + myRectangle.Location;

// Right property gets the x-axis value of the right side of the rectangle.
// For this rectangle the value is 210.
rectInfo = rectInfo + "| Right: " + myRectangle.Right;

// Size property gets or sets the width and height of the rectangle.
// For this rectangle the value is 200,50.
rectInfo = rectInfo + "| Size: " + myRectangle.Size;

// Top property gets the y-axis position of the top of the rectangle which is
// equivalent to getting the rectangle's Y property.
// For this rectangle the value is 5.
rectInfo = rectInfo + "| Top: " + myRectangle.Top;

// TopLeft property gets the position of the top-left corner of the rectangle, which
// is equivalent to (X, Y).
// For this rectangle the value is 10,5.
rectInfo = rectInfo + "| TopLeft: " + myRectangle.TopLeft;

// TopRight property gets the position of the top-left corner of the rectangle, which
// is equivalent to (X + Width, Y).
// For this rectangle the value is 210,5.
rectInfo = rectInfo + "| TopRight: " + myRectangle.TopRight;

// X property gets or sets the location of the rectangle's left side.
// For this rectangle the value is 10.
rectInfo = rectInfo + "| X: " + myRectangle.X;

// Y property gets or sets the location of the rectangle's top side.
// For this rectangle the value is 5.
rectInfo = rectInfo + "| Y: " + myRectangle.Y;

//////// End of creating string containing rectangle property information ////////

// This StackPanel will contain the rectangle and TextBlock.
StackPanel parentPanel = new StackPanel();

// Add the rectangle path to the StackPanel. This will display the rectangle.

// Add a TextBlock to display the rectangle's size and coordinate information.
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = rectInfo;

// Return the parent container to be displayed to the screen.
return parentPanel;
}
``````

## 설명

### XAML 특성 사용XAML Attribute Usage

``````<object property="x,y,width,height"/>
``````

### XAML 값XAML Values

사각형의 왼쪽의 x 좌표 위치입니다.The x-coordinate location of the left side of the rectangle.

사각형의 위쪽의 y 좌표 위치입니다.The y-coordinate location of the top side of the rectangle.

widthwidth
System.Double

나타내는 음수가 아닌 값을 Width 사각형입니다.A non-negative value that represents the Width of the rectangle.

높이로height
System.Double

나타내는 음수가 아닌 값을 Height 사각형입니다.A non-negative value that represents the Height of the rectangle.

## 생성자

 지정된 x좌표, y좌표, 너비 및 높이를 갖는 Rect 구조체의 새 인스턴스를 초기화합니다.Initializes a new instance of the Rect structure that has the specified x-coordinate, y-coordinate, width, and height. 지정된 두 지점을 정확히 포함할 수 있는 크기의 Rect 구조체의 새 인스턴스를 초기화합니다.Initializes a new instance of the Rect structure that is exactly large enough to contain the two specified points. 지정된 왼쪽 위 모퉁이 좌표 및 지정된 너비와 높이를 갖는 Rect 구조체의 새 인스턴스를 초기화합니다.Initializes a new instance of the Rect structure that has the specified top-left corner location and the specified width and height. 지정된 지점 및 지정된 지점과 지정된 벡터의 합을 정확히 포함할 수 있는 크기의 Rect 구조체의 새 인스턴스를 초기화합니다.Initializes a new instance of the Rect structure that is exactly large enough to contain the specified point and the sum of the specified point and the specified vector. 지정된 크기를 가지며 위치가 (0,0)인 Rect 구조체의 새 인스턴스를 초기화합니다.Initializes a new instance of the Rect structure that is of the specified size and is located at (0,0).

## 속성

 사각형 아래쪽의 y축 값을 가져옵니다.Gets the y-axis value of the bottom of the rectangle. 사각형의 왼쪽 아래 모퉁이 위치를 가져옵니다.Gets the position of the bottom-left corner of the rectangle. 사각형의 오른쪽 아래 모퉁이 위치를 가져옵니다.Gets the position of the bottom-right corner of the rectangle. 위치와 넓이가 없는 사각형을 나타내는 특수 값을 가져옵니다.Gets a special value that represents a rectangle with no position or area. 사각형의 높이를 가져오거나 설정합니다.Gets or sets the height of the rectangle. 사각형이 Empty 사각형인지 여부를 나타내는 값을 가져옵니다.Gets a value that indicates whether the rectangle is the Empty rectangle. 사각형 왼쪽의 x축 값을 가져옵니다.Gets the x-axis value of the left side of the rectangle. 사각형의 왼쪽 위 모퉁이 위치를 가져오거나 설정합니다.Gets or sets the position of the top-left corner of the rectangle. 사각형 오른쪽의 x축 값을 가져옵니다.Gets the x-axis value of the right side of the rectangle. 사각형의 너비와 높이를 가져오거나 설정합니다.Gets or sets the width and height of the rectangle. 사각형 위쪽의 y축 좌표를 가져옵니다.Gets the y-axis position of the top of the rectangle. 사각형의 왼쪽 위 모퉁이 위치를 가져옵니다.Gets the position of the top-left corner of the rectangle. 사각형의 오른쪽 위 모퉁이 위치를 가져옵니다.Gets the position of the top-right corner of the rectangle. 사각형의 너비를 가져오거나 설정합니다.Gets or sets the width of the rectangle. 사각형 왼쪽의 x축 값을 가져오거나 설정합니다.Gets or sets the x-axis value of the left side of the rectangle. 사각형 위쪽의 y축 값을 가져오거나 설정합니다.Gets or sets the y-axis value of the top side of the rectangle.

## 메서드

 지정된 x좌표와 y좌표가 사각형에 들어 있는지 여부를 나타냅니다.Indicates whether the rectangle contains the specified x-coordinate and y-coordinate. 지정된 지점이 사각형에 들어 있는지 여부를 나타냅니다.Indicates whether the rectangle contains the specified point. 지정된 사각형이 사각형에 들어 있는지 여부를 나타냅니다.Indicates whether the rectangle contains the specified rectangle. 지정된 개체가 현재 사각형과 같은지 여부를 나타냅니다.Indicates whether the specified object is equal to the current rectangle. 지정된 사각형이 현재 사각형과 같은지 여부를 나타냅니다.Indicates whether the specified rectangle is equal to the current rectangle. 지정된 사각형이 서로 같은지 여부를 나타냅니다.Indicates whether the specified rectangles are equal. 사각형에 대한 해시 코드를 만듭니다.Creates a hash code for the rectangle. 사각형을 지정된 너비 및 높이만큼 모든 방향으로 확장하거나 축소합니다.Expands or shrinks the rectangle by using the specified width and height amounts, in all directions. 지정된 사각형을 지정된 너비 및 높이만큼 모든 방향으로 확장하거나 축소한 사각형을 만듭니다.Creates a rectangle that results from expanding or shrinking the specified rectangle by the specified width and height amounts, in all directions. 지정된 사각형을 지정된 Size만큼 모든 방향으로 확장하여 만들어지는 사각형을 반환합니다.Returns the rectangle that results from expanding the specified rectangle by the specified Size, in all directions. 지정된 Size를 사용하여 모든 방향으로 사각형을 확장합니다.Expands the rectangle by using the specified Size, in all directions. 현재 사각형과 지정된 사각형이 겹치는 부분을 찾아 결과를 현재 사각형으로 저장합니다.Finds the intersection of the current rectangle and the specified rectangle, and stores the result as the current rectangle. 지정된 사각형이 겹치는 부분을 반환합니다.Returns the intersection of the specified rectangles. 지정된 사각형이 현재 사각형과 겹치는지 여부를 나타냅니다.Indicates whether the specified rectangle intersects with the current rectangle. 사각형을 지정된 가로 및 세로 거리만큼 이동합니다.Moves the rectangle by the specified horizontal and vertical amounts. 지정된 사각형에서 지정된 가로 및 세로 거리만큼 오프셋된 사각형을 반환합니다.Returns a rectangle that is offset from the specified rectangle by using the specified horizontal and vertical amounts. 지정된 사각형에서 지정된 벡터만큼 오프셋된 사각형을 반환합니다.Returns a rectangle that is offset from the specified rectangle by using the specified vector. 사각형을 지정된 벡터만큼 이동합니다.Moves the rectangle by the specified vector. 지정된 문자열 표현을 사용하여 새 사각형을 만듭니다.Creates a new rectangle from the specified string representation. 현재 사각형의 크기에 지정된 x 및 y 값을 곱합니다.Multiplies the size of the current rectangle by the specified x and y values. 사각형의 문자열 표현을 반환합니다.Returns a string representation of the rectangle. 지정된 형식 공급자를 사용하여 사각형의 문자열 표현을 반환합니다.Returns a string representation of the rectangle by using the specified format provider. 지정된 매트릭스를 적용하여 사각형을 변환합니다.Transforms the rectangle by applying the specified matrix. 지정된 사각형에 지정된 매트릭스를 적용하여 만들어진 사각형을 반환합니다.Returns the rectangle that results from applying the specified matrix to the specified rectangle. 지정된 지점을 정확히 포함할 수 있는 크기로 현재 사각형을 확장합니다.Expands the current rectangle exactly enough to contain the specified point. 지정된 사각형을 정확히 포함할 수 있는 크기로 현재 사각형을 확장합니다.Expands the current rectangle exactly enough to contain the specified rectangle. 지정된 사각형과 지정된 지점을 정확히 포함할 수 있는 크기의 사각형을 만듭니다.Creates a rectangle that is exactly large enough to include the specified rectangle and the specified point. 지정된 두 사각형을 정확히 포함할 수 있는 크기의 사각형을 만듭니다.Creates a rectangle that is exactly large enough to contain the two specified rectangles.

## 연산자

 두 사각형이 정확히 같은지 비교합니다.Compares two rectangles for exact equality. 두 사각형이 다른지 비교합니다.Compares two rectangles for inequality.

## 명시적 인터페이스 구현

 지정한 형식을 사용하여 현재 인스턴스 값의 형식을 지정합니다.Formats the value of the current instance using the specified format.