Point Estrutura
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Representa um par ordenado de coordenadas inteiras x e y que define um ponto num plano bidimensional.
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
- Herança
- Atributos
- Implementações
Exemplos
O exemplo de código seguinte cria pontos e tamanhos usando vários dos operadores sobrecarregados definidos para estes tipos. Também demonstra como usar a SystemPens aula.
Este exemplo foi concebido para ser usado com Windows Forms. Crie uma forma que contenha um Button .subtractButton Cole o código no formulário e chame o CreatePointsAndSizes método a partir do método de gestão de eventos do Paint formulário, passando e por 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
Observações
Para converter a Point para um PointF, use Implicit.
Construtores
| Name | Description |
|---|---|
| Point(Int32, Int32) |
Inicializa uma nova instância da Point estrutura com as coordenadas especificadas. |
| Point(Int32) |
Inicializa uma nova instância da Point struct usando coordenadas especificadas por um valor inteiro. |
| Point(Size) |
Inicializa uma nova instância da Point estrutura a partir de um Size. |
Campos
| Name | Description |
|---|---|
| Empty |
Propriedades
| Name | Description |
|---|---|
| IsEmpty |
Recebe um valor que indica se isto Point está vazio. |
| X |
Obtém ou define a coordenada x desta Point. |
| Y |
Obtém ou define a coordenada y desta Point. |
Métodos
| Name | Description |
|---|---|
| Add(Point, Size) | |
| Ceiling(PointF) |
Converte o especificado PointF em a Point arredondando os valores de os PointF para os valores inteiros seguintes superiores. |
| Equals(Object) |
Especifica se esta instância pontual contém as mesmas coordenadas do objeto especificado. |
| Equals(Point) |
Especifica se esta instância de ponto contém as mesmas coordenadas que outro ponto. |
| GetHashCode() |
Devolve um código de hash para este Point. |
| Offset(Int32, Int32) |
Traduz isto Point pelo valor especificado. |
| Offset(Point) | |
| Round(PointF) |
Converte o especificado PointF num Point objeto arredondando os PointF valores para o inteiro mais próximo. |
| Subtract(Point, Size) |
Devolve o resultado da subtração especificada Size do especificado Point. |
| ToString() |
Converte isto Point numa cadeia legível por humanos. |
| Truncate(PointF) |
Converte o especificado PointF em a Point truncando os valores dos PointF. |
Operadores
| Name | Description |
|---|---|
| Addition(Point, Size) | |
| Equality(Point, Point) |
Compara dois Point objetos. O resultado especifica se os valores das X propriedades e Y dos dois Point objetos são iguais. |
| Explicit(Point to Size) |
Converte a estrutura especificada Point numa Size estrutura. |
| Implicit(Point to PointF) |
Converte a estrutura especificada Point numa PointF estrutura. |
| Inequality(Point, Point) |
Compara dois Point objetos. O resultado especifica se os valores das X propriedades ou Y dos dois Point objetos são desiguais. |
| Subtraction(Point, Size) |