PointPointPointPoint Struct

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
PointPointPointPoint
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 SystemPens clase.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 Button un `subtractButton`denominado.Create a form that contains a Button named `subtractButton`. Pegue el código en el formulario y llame al `CreatePointsAndSizes` método desde el método de Paint control de eventos del formulario, `e` pasando PaintEventArgscomo.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, use Implicit.To convert a Point to a PointF, use Implicit.

Constructores

 Point(Size) Point(Size) Point(Size) Point(Size) 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. Point(Int32) Point(Int32) Point(Int32) Point(Int32) 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. Point(Int32, Int32) Point(Int32, Int32) Point(Int32, Int32) Point(Int32, Int32) Inicializa una nueva instancia de la clase Point con las coordenadas especificadas.Initializes a new instance of the Point class with the specified coordinates.

Campos

 Empty Empty Empty Empty 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.