Point 구조체

정의

2차원 평면의 점을 정의하는 순서가 지정된 정수 x 좌표와 y 좌표 쌍을 나타냅니다.

public value class Point : IEquatable<System::Drawing::Point>
public value class Point
[System.ComponentModel.TypeConverter("System.Drawing.PointConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public struct Point : IEquatable<System.Drawing.Point>
public struct Point
public struct Point : IEquatable<System.Drawing.Point>
[System.ComponentModel.TypeConverter(typeof(System.Drawing.PointConverter))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct Point
[<System.ComponentModel.TypeConverter("System.Drawing.PointConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
type Point = struct
type Point = struct
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.PointConverter))>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type Point = struct
Public Structure Point
Implements IEquatable(Of Point)
Public Structure Point
상속
특성
구현

예제

다음 코드 예제에서는 이러한 형식에 대해 정의된 여러 오버로드된 연산자를 사용하여 점과 크기를 만듭니다. 또한 클래스를 사용하는 방법을 보여 줍니다 SystemPens .

이 예제는 Windows Forms와 함께 사용하도록 설계되었습니다. 이름이 Button지정된 폼을 subtractButton 만듭니다. 코드를 양식에 붙여넣고 양식의 CreatePointsAndSizes 이벤트 처리 메서드에서 메서드를 호출 Paint 하여 다음과 같이 e전달 PaintEventArgs 합니다.

void CreatePointsAndSizes( PaintEventArgs^ e )
{
   // Create the starting point.
   Point startPoint = Point(subtractButton->Size);
   
   // Use the addition operator to get the end point.
   Point endPoint = startPoint + System::Drawing::Size( 140, 150 );
   
   // Draw a line between the points.
   e->Graphics->DrawLine( SystemPens::Highlight, startPoint, endPoint );
   
   // Convert the starting point to a size and compare it to the
   // subtractButton size.  
   System::Drawing::Size buttonSize = (System::Drawing::Size)startPoint;
   if ( buttonSize == subtractButton->Size )
   {
      e->Graphics->DrawString( "The sizes are equal.", gcnew System::Drawing::Font( this->Font,FontStyle::Italic ), Brushes::Indigo, 10.0F, 65.0F );
   }
}
private void CreatePointsAndSizes(PaintEventArgs e)
{

    // Create the starting point.
    Point startPoint = new Point(subtractButton.Size);

    // Use the addition operator to get the end point.
    Point endPoint = startPoint + new Size(140, 150);

    // Draw a line between the points.
    e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint);

    // Convert the starting point to a size and compare it to the
    // subtractButton size.  
    Size buttonSize = (Size)startPoint;
    if (buttonSize == subtractButton.Size)

        // If the sizes are equal, tell the user.
    {
        e.Graphics.DrawString("The sizes are equal.", 
            new Font(this.Font, FontStyle.Italic), 
            Brushes.Indigo, 10.0F, 65.0F);
    }
}
Private Sub CreatePointsAndSizes(ByVal e As PaintEventArgs)

    ' Create the starting point.
    Dim startPoint As New Point(subtractButton.Size)

    ' Use the addition operator to get the end point.
    Dim endPoint As Point = Point.op_Addition(startPoint, _
        New Size(140, 150))

    ' Draw a line between the points.
    e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint)

    ' Convert the starting point to a size and compare it to the
    ' subtractButton size.  
    Dim buttonSize As Size = Point.op_Explicit(startPoint)
    If (Size.op_Equality(buttonSize, subtractButton.Size)) Then

        ' If the sizes are equal, tell the user.
        e.Graphics.DrawString("The sizes are equal.", _
            New Font(Me.Font, FontStyle.Italic), _
            Brushes.Indigo, 10.0F, 65.0F)
    End If

End Sub

설명

를 변환하려면 .를 PointPointF사용합니다 Implicit.

생성자

Name Description
Point(Int32, Int32)

지정된 좌표를 사용하여 구조체의 Point 새 인스턴스를 초기화합니다.

Point(Int32)

정수 값으로 지정된 좌표를 사용하여 구조체의 Point 새 인스턴스를 초기화합니다.

Point(Size)

에서 구조체의 Point 새 인스턴스를 Size초기화합니다.

필드

Name Description
Empty

값이 0으로 Point 설정된 값을 XY 나타냅니다.

속성

Name Description
IsEmpty

비어 Point 있는지 여부를 나타내는 값을 가져옵니다.

X

Point좌표의 x 좌표를 가져오거나 설정합니다.

Y

PointY 좌표를 가져오거나 설정합니다.

메서드

Name Description
Add(Point, Size)

지정된 에 지정된 Size 값을 추가합니다 Point.

Ceiling(PointF)

값을 다음으로 더 높은 정수 값 PointF 으로 반올림하여 지정된 PointPointF 값을 a로 변환합니다.

Equals(Object)

이 점 인스턴스가 지정된 개체와 동일한 좌표를 포함하는지 여부를 지정합니다.

Equals(Point)

이 점 인스턴스에 다른 점과 동일한 좌표가 포함되어 있는지 여부를 지정합니다.

GetHashCode()

이에 Point대한 해시 코드를 반환합니다.

Offset(Int32, Int32)

지정된 양만큼 이 Point 값을 변환합니다.

Offset(Point)

지정된 을 사용하여 이 Point 값을 변환합니다 Point.

Round(PointF)

값을 가장 가까운 정수로 PointF 반올림하여 Point 지정된 PointF 값을 개체로 변환합니다.

Subtract(Point, Size)

지정된 SizePoint빼기의 결과를 반환합니다.

ToString()

Point 문자열을 사람이 읽을 수 있는 문자열로 변환합니다.

Truncate(PointF)

의 값을 잘라내어 지정된 PointFPoint 값을 PointF변환합니다.

연산자

Name Description
Addition(Point, Size)

지정된 Point으로 변환합니다Size.

Equality(Point, Point)

Point 개체를 비교합니다. 결과는 두 X 개체의 Y 값과 Point 속성이 같은지 여부를 지정합니다.

Explicit(Point to Size)

지정된 Point 구조를 구조체로 Size 변환합니다.

Implicit(Point to PointF)

지정된 Point 구조를 구조체로 PointF 변환합니다.

Inequality(Point, Point)

Point 개체를 비교합니다. 결과는 두 X 개체의 속성 값이 YPoint 같지 않은지 여부를 지정합니다.

Subtraction(Point, Size)

지정된 Point값의 음수로 변환합니다Size.

적용 대상