Point Estructura

Definición

Representa un par ordenado de coordenadas enteras x e y que define un punto en un plano bidimensional.Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional plane.

``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 : IEquatable<System.Drawing.Point>``````
``type Point = struct``
``````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.The following code example creates points and sizes using several of the overloaded operators defined for these types. También se muestra cómo usar la clase SystemPens.It also demonstrates how to use the SystemPens class.

Este ejemplo está diseñado para usarse con Windows Forms.This example is designed to be used with Windows Forms. Cree un formulario que contenga un Button denominado `subtractButton`.Create a form that contains a Button named `subtractButton`. Pegue el código en el formulario y llame al método `CreatePointsAndSizes` desde el método de control de eventos Paint del formulario, pasando `e` como PaintEventArgs.Paste the code into the form and call the `CreatePointsAndSizes` method from the form's Paint event-handling method, passing `e` as 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 Point en un PointF, utilice Implicit.To convert a Point to a PointF, use Implicit.

Constructores

 Inicializa una nueva instancia de la clase Point con las coordenadas que especifica un valor entero.Initializes a new instance of the Point class using coordinates specified by an integer value. Inicializa una nueva instancia de la clase Point con las coordenadas especificadas.Initializes a new instance of the Point class with the specified coordinates. Inicializa una nueva instancia de la clase Point a partir de un objeto Size.Initializes a new instance of the Point class from a Size.

Campos

 Representa Point que hace X y los valores Y establecer para poner a cero.Represents a Point that has X and Y values set to zero.

 Obtiene un valor que indica si esta Point está vacía.Gets a value indicating whether this Point is empty. Obtiene o establece la coordenada x de este objeto Point.Gets or sets the x-coordinate of this Point. Obtiene o establece la coordenada y de este objeto Point.Gets or sets the y-coordinate of this Point.

Métodos

 Convierte un Point según el valor de Size especificado.Translates a Point by a given Size. Compara dos objetos Point.Compares two Point objects. El resultado especifica si los valores de las propiedades X y Y de los dos objetos Point son iguales.The result specifies whether the values of the X and Y properties of the two Point objects are equal. Convierte la estructura Point especificada en una estructura Size.Converts the specified Point structure to a Size structure. Convierte la estructura Point especificada en una estructura PointF.Converts the specified Point structure to a PointF structure. Compara dos objetos Point.Compares two Point objects. El resultado especifica si los valores de las propiedades X y Y de los dos objetos Point no son iguales.The result specifies whether the values of the X or Y properties of the two Point objects are unequal. Convierte una estructura Point según el valor negativo del Size especificado.Translates a Point by the negative of a given Size.