Point 構造体

定義

2 次元面の 1 点を定義する、順序付けされた整数の 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 フォームで使用するように設計されています。 という名前subtractButtonの を含むフォームをButton作成します。 コードをフォームに貼り付け、フォームのCreatePointsAndSizesイベント処理メソッドから メソッドを呼び出し、 を としてPaintEventArgs渡しますePaint

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

注釈

Point に変換するには、 を PointF使用します Implicit

コンストラクター

Point(Int32)

整数値で指定された座標を使用して、Point 構造体の新しいインスタンスを初期化します。

Point(Int32, Int32)

指定した座標を使用して Point 構造体の新しいインスタンスを初期化します。

Point(Size)

Size から Point 構造体の新しいインスタンスを初期化します。

フィールド

Empty

Point および X の値をゼロに設定した Y を表します。

プロパティ

IsEmpty

この Point が空かどうかを示す値を取得します。

X

この Point の x 座標を取得または設定します。

Y

この Point の y 座標を取得または設定します。

メソッド

Add(Point, Size)

指定した Size を指定した Point に追加します。

Ceiling(PointF)

指定された PointF の値を整数値に切り上げることで、その PointPointF に変換します。

Equals(Object)

このポイントに、指定したオブジェクトと同じ座標が含まれているかどうかを示します。

Equals(Point)

このポイント インスタンスに別の点と同じ座標が含まれているかどうかを指定します。

GetHashCode()

この Point のハッシュ コードを返します。

Offset(Int32, Int32)

この Point を指定の量だけ変換します。

Offset(Point)

この Point を指定した Point だけ移動します。

Round(PointF)

指定された PointF の値を最も近い整数に丸めることで、その PointPointF オブジェクトに変換します。

Subtract(Point, Size)

指定した Size から指定した Point を減算した結果を返します。

ToString()

この Point をユーザーが判読できる文字列に変換します。

Truncate(PointF)

指定された PointF の値を切り捨てることで、その PointPointF に変換します。

演算子

Addition(Point, Size)

Point を指定の Size だけ移動します。

Equality(Point, Point)

2 つの Point オブジェクトを比較します。 この結果は、2 つの X オブジェクトの Y プロパティと Point プロパティの値が等しいかどうかを示します。

Explicit(Point to Size)

指定した Point 構造体を Size 構造体に変換します。

Implicit(Point to PointF)

指定した Point 構造体を PointF 構造体に変換します。

Inequality(Point, Point)

2 つの Point オブジェクトを比較します。 この結果は、2 つの X オブジェクトの Y プロパティと Point プロパティの値が異なるかどうかを示します。

Subtraction(Point, Size)

Point を指定の Size だけ負の方向へ移動します。

適用対象