Point Estructura

Definición

Representa un par ordenado de coordenadas X e Y ordenadas que definen un punto en un plano bidimensional.

public value class Point
public value class Point : IEquatable<System::Drawing::Point>
[System.ComponentModel.TypeConverter(typeof(System.Drawing.PointConverter))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct 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>]
type Point = struct
type Point = struct
Public Structure Point
Public Structure Point
Implements IEquatable(Of Point)
Herencia
Atributos
Implementaciones

Ejemplos

En el ejemplo de código siguiente se crean puntos y tamaños mediante varios de los operadores sobrecargados definidos para estos tipos. También muestra cómo usar la SystemPens clase .

Este ejemplo está diseñado para usarse con Windows Forms. Cree un formulario que contenga un Button objeto denominado subtractButton. Pegue el código en el formulario y llame al CreatePointsAndSizes método desde el método de control de eventos del Paint formulario, pasando e como 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

Comentarios

Para convertir un objeto Point en , PointFuse Implicit.

Constructores

Nombre Description
Point(Int32, Int32)

Inicializa una nueva instancia de la Point estructura con las coordenadas especificadas.

Point(Int32)

Inicializa una nueva instancia de la Point estructura utilizando coordenadas especificadas por un valor entero.

Point(Size)

Inicializa una nueva instancia del Point struct desde .Size

Campos

Nombre Description
Empty

Representa un Point objeto que tiene X los valores y Y establecidos en cero.

Propiedades

Nombre Description
IsEmpty

Obtiene un valor que indica si está Point vacío.

X

Obtiene o establece la coordenada x de este Pointobjeto .

Y

Obtiene o establece la coordenada y de este Pointobjeto .

Métodos

Nombre Description
Add(Point, Size)

Agrega el objeto especificado Size al especificado Point.

Ceiling(PointF)

Convierte el objeto especificado PointF en un Point redondeando los valores de PointF a los siguientes valores enteros superiores.

Equals(Object)

Especifica si esta instancia de punto contiene las mismas coordenadas que el objeto especificado.

Equals(Point)

Especifica si esta instancia de punto contiene las mismas coordenadas que otro punto.

GetHashCode()

Devuelve un código hash para este Pointobjeto .

Offset(Int32, Int32)

Traduce esto Point por la cantidad especificada.

Offset(Point)

Traduce esto Point por el especificado Point.

Round(PointF)

Convierte el objeto especificado PointF en un Point objeto redondeando los PointF valores al entero más cercano.

Subtract(Point, Size)

Devuelve el resultado de restar especificado Size del especificado Point.

ToString()

Convierte esto Point en una cadena legible.

Truncate(PointF)

Convierte el objeto especificado PointF en un Point mediante el truncamiento de los valores de .PointF

Operadores

Nombre Description
Addition(Point, Size)

Traduce un Point objeto por un determinado Size.

Equality(Point, Point)

Compara dos objetos Point. El resultado especifica si los valores de las X propiedades y Y de los dos Point objetos son iguales.

Explicit(Point to Size)

Convierte la estructura especificada Point en una Size estructura.

Implicit(Point to PointF)

Convierte la estructura especificada Point en una PointF estructura.

Inequality(Point, Point)

Compara dos objetos Point. El resultado especifica si los valores de las X propiedades o Y de los dos Point objetos no son iguales.

Subtraction(Point, Size)

Traduce un Point objeto por el negativo de un determinado Size.

Se aplica a