Actualización: noviembre 2007
Representa un par ordenado de coordenadas x e y de enteros que define un punto en un plano bidimensional.
Espacio de nombres:
System.Drawing
Ensamblado:
System.Drawing (en System.Drawing.dll)
Visual Basic (Declaración)
<SerializableAttribute> _
<TypeConverterAttribute(GetType(PointConverter))> _
<ComVisibleAttribute(True)> _
Public Structure Point
[SerializableAttribute]
[TypeConverterAttribute(typeof(PointConverter))]
[ComVisibleAttribute(true)]
public struct Point
[SerializableAttribute]
[TypeConverterAttribute(typeof(PointConverter))]
[ComVisibleAttribute(true)]
public value class Point
/** @attribute SerializableAttribute */
/** @attribute TypeConverterAttribute(PointConverter) */
/** @attribute ComVisibleAttribute(true) */
public final class Point extends ValueType
JScript admite el uso de estructuras, pero no admite la declaración de estructuras nuevas.
En el ejemplo de código siguiente se crean puntos y tamaños utilizando algunos de los operadores sobrecargados definidos para estos tipos. También se muestra cómo utilizar la clase SystemPens.
Este ejemplo se ha diseñado para utilizarlo con formularios Windows Forms. Cree un formulario que contenga un objeto Button denominado subtractButton. Pegue este código en el formulario y llame al método CreatePointsAndSizes desde el método controlador del evento Paint del formulario, pasando e como parámetro de PaintEventArgs.
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
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);
}
}
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.get_Size());
// Use the addition operator to get the end point.
Point endPoint = Point.op_Addition(startPoint, new Size(140, 150));
// Draw a line between the points.
e.get_Graphics().DrawLine(SystemPens.get_Highlight(), startPoint,
endPoint);
// Convert the starting point to a size and compare it to the
// subtractButton size.
Size buttonSize = new Size(startPoint);
if (buttonSize.Equals(subtractButton.get_Size())) {
// If the sizes are equal, tell the user.
e.get_Graphics().DrawString("The sizes are equal.",
new Font(this.get_Font(), FontStyle.Italic),
Brushes.get_Indigo(), 10, 65);
}
} //CreatePointsAndSizes
Seguridad para subprocesos
Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
.NET Framework
Compatible con: 3.5, 3.0, 2.0, 1.1, 1.0
.NET Compact Framework
Compatible con: 3.5, 2.0, 1.0
Referencia