Point Point Point Point Struct

Definição

Representa um par ordenado de coordenadas x e y de inteiros que define um ponto em um 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)
Herança
Atributos
Implementações

Exemplos

O exemplo de código a seguir cria pontos e tamanhos usando vários operadores sobrecarregados definidos para esses tipos.The following code example creates points and sizes using several of the overloaded operators defined for these types. Ele também demonstra como usar a SystemPens classe.It also demonstrates how to use the SystemPens class.

Este exemplo foi projetado para ser usado com Windows Forms.This example is designed to be used with Windows Forms. Crie um formulário que contenha Button um subtractButtonnome.Create a form that contains a Button named subtractButton. Cole o código no formulário CreatePointsAndSizes e chame o método do método de manipulação de eventos do Paint formulário, passando 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

Comentários

Para converter um Point PointFpara, use Implicit.To convert a Point to a PointF, use Implicit.

Construtores

Point(Size) Point(Size) Point(Size) Point(Size)

Inicializa uma nova instância da classe Point de um Size.Initializes a new instance of the Point class from a Size.

Point(Int32) Point(Int32) Point(Int32) Point(Int32)

Inicializa uma nova instância da classe Point usando coordenadas especificadas por um valor inteiro.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 uma nova instância da classe Point com as coordenadas especificadas.Initializes a new instance of the Point class with the specified coordinates.

Campos

Empty Empty Empty Empty

Representa um Point que tem valores X e Y definidos como zero.Represents a Point that has X and Y values set to zero.

Propriedades

IsEmpty IsEmpty IsEmpty IsEmpty

Obtém um valor que indica se este Point está vazio.Gets a value indicating whether this Point is empty.

X X X X

Obtém ou define a coordenada X este Point.Gets or sets the x-coordinate of this Point.

Y Y Y Y

Obtém ou define a coordenada Y deste Point.Gets or sets the y-coordinate of this Point.

Métodos

Add(Point, Size) Add(Point, Size) Add(Point, Size) Add(Point, Size)

Adiciona o Size especificado no Point especificado.Adds the specified Size to the specified Point.

Ceiling(PointF) Ceiling(PointF) Ceiling(PointF) Ceiling(PointF)

Converte o PointF especificado em um Point arredondando os valores do PointF para os valores de inteiro mais próximos.Converts the specified PointF to a Point by rounding the values of the PointF to the next higher integer values.

Equals(Point) Equals(Point) Equals(Point) Equals(Point)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Especifica se este Point contém as mesmas coordenadas que o Object especificado.Specifies whether this Point contains the same coordinates as the specified Object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Retorna um código hash para este Point.Returns a hash code for this Point.

Offset(Int32, Int32) Offset(Int32, Int32) Offset(Int32, Int32) Offset(Int32, Int32)

Converte esse Point pela quantidade especificada.Translates this Point by the specified amount.

Offset(Point) Offset(Point) Offset(Point) Offset(Point)

Converte esse Point pelo Point especificado.Translates this Point by the specified Point.

Round(PointF) Round(PointF) Round(PointF) Round(PointF)

Converte o PointF especificado em um objeto Point, arredondando os valores PointF para o inteiro mais próximo.Converts the specified PointF to a Point object by rounding the PointF values to the nearest integer.

Subtract(Point, Size) Subtract(Point, Size) Subtract(Point, Size) Subtract(Point, Size)

Retorna o resultado da subtração do Size especificado do Point especificado.Returns the result of subtracting specified Size from the specified Point.

ToString() ToString() ToString() ToString()

Converte este Point em uma cadeia de caracteres legível por humanos.Converts this Point to a human-readable string.

Truncate(PointF) Truncate(PointF) Truncate(PointF) Truncate(PointF)

Converte o PointF especificado em um Point truncando os valores de PointF.Converts the specified PointF to a Point by truncating the values of the PointF.

Operadores

Addition(Point, Size) Addition(Point, Size) Addition(Point, Size) Addition(Point, Size)

Move um Point por um Size determinado.Translates a Point by a given Size.

Equality(Point, Point) Equality(Point, Point) Equality(Point, Point) Equality(Point, Point)

Compara dois objetos Point.Compares two Point objects. O resultado especifica se os valores das propriedades X e Y dos dois objetos Point são iguais.The result specifies whether the values of the X and Y properties of the two Point objects are equal.

Explicit(Point to Size) Explicit(Point to Size) Explicit(Point to Size) Explicit(Point to Size)

Converte a estrutura especificada Point em uma estrutura Size.Converts the specified Point structure to a Size structure.

Implicit(Point to PointF) Implicit(Point to PointF) Implicit(Point to PointF) Implicit(Point to PointF)

Converte a estrutura especificada Point em uma estrutura PointF.Converts the specified Point structure to a PointF structure.

Inequality(Point, Point) Inequality(Point, Point) Inequality(Point, Point) Inequality(Point, Point)

Compara dois objetos Point.Compares two Point objects. Especifica o resultado se os valores das propriedades X ou Y dos dois objetos Point são diferentes.The result specifies whether the values of the X or Y properties of the two Point objects are unequal.

Subtraction(Point, Size) Subtraction(Point, Size) Subtraction(Point, Size) Subtraction(Point, Size)

Converte um Point pelo negativo de um Size fornecido.Translates a Point by the negative of a given Size.

Aplica-se a