SizeF Estrutura

Definição

Armazena um par ordenado de números de ponto flutuante, normalmente com a largura e a altura de um retângulo.

public value class SizeF : IEquatable<System::Drawing::SizeF>
public value class SizeF
[System.ComponentModel.TypeConverter("System.Drawing.SizeFConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public struct SizeF : IEquatable<System.Drawing.SizeF>
public struct SizeF
public struct SizeF : IEquatable<System.Drawing.SizeF>
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct SizeF
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
[System.ComponentModel.TypeConverter(typeof(System.Drawing.SizeFConverter))]
public struct SizeF
[<System.ComponentModel.TypeConverter("System.Drawing.SizeFConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
type SizeF = struct
type SizeF = struct
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type SizeF = struct
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.SizeFConverter))>]
type SizeF = struct
Public Structure SizeF
Implements IEquatable(Of SizeF)
Public Structure SizeF
Herança
Atributos
Implementações

Exemplos

O exemplo de código a seguir adiciona uma sombra a um ListBox usando os seguintes membros:

Este exemplo foi projetado para ser usado com um Formulário do Windows. Para executar este exemplo, cole esse código em um formulário e chame o AddShadow método ao manipular o evento do Paint formulário. Verifique se o formulário contém um ListBox chamado listBox1.

private:
   void AddShadow( PaintEventArgs^ e )
   {
      // Create two SizeF objects.
      SizeF shadowSize = listBox1->Size;
      SizeF addSize = SizeF(10.5F,20.8F);

      // Add them together and save the result in shadowSize.
      shadowSize = shadowSize + addSize;

      // Get the location of the ListBox and convert it to a PointF.
      PointF shadowLocation = listBox1->Location;

      // Add two points to get a new location.
      shadowLocation = shadowLocation + System::Drawing::Size( 5, 5 );

      // Create a rectangleF. 
      RectangleF rectFToFill = RectangleF(shadowLocation,shadowSize);

      // Create a custom brush using a semi-transparent color, and 
      // then fill in the rectangle.
      Color customColor = Color::FromArgb( 50, Color::Gray );
      SolidBrush^ shadowBrush = gcnew SolidBrush( customColor );
      array<RectangleF>^ temp0 = {rectFToFill};
      e->Graphics->FillRectangles( shadowBrush, temp0 );

      // Dispose of the brush.
      delete shadowBrush;
   }
private void AddShadow(PaintEventArgs e)
{

    // Create two SizeF objects.
    SizeF shadowSize = listBox1.Size;
    SizeF addSize = new SizeF(10.5F, 20.8F);

    // Add them together and save the result in shadowSize.
    shadowSize = shadowSize + addSize;

    // Get the location of the ListBox and convert it to a PointF.
    PointF shadowLocation = listBox1.Location;

    // Add two points to get a new location.
    shadowLocation = shadowLocation + new Size(5, 5);

    // Create a rectangleF. 
    RectangleF rectFToFill = 
        new RectangleF(shadowLocation, shadowSize);

    // Create a custom brush using a semi-transparent color, and 
    // then fill in the rectangle.
    Color customColor = Color.FromArgb(50, Color.Gray);
    SolidBrush shadowBrush = new SolidBrush(customColor);
    e.Graphics.FillRectangles(shadowBrush, new RectangleF[]{rectFToFill});

    // Dispose of the brush.
    shadowBrush.Dispose();
}
Private Sub AddShadow(ByVal e As PaintEventArgs)

    ' Create two SizeF objects.
    Dim shadowSize As SizeF = Size.op_Implicit(listBox1.Size)
    Dim addSize As New SizeF(10.5F, 20.8F)

    ' Add them together and save the result in shadowSize.
    shadowSize = SizeF.op_Addition(shadowSize, addSize)

    ' Get the location of the ListBox and convert it to a PointF.
    Dim shadowLocation As PointF = Point.op_Implicit(listBox1.Location)

    ' Add a Size to the Point to get a new location.
    shadowLocation = PointF.op_Addition(shadowLocation, New Size(5, 5))

    ' Create a rectangleF. 
    Dim rectFToFill As New RectangleF(shadowLocation, shadowSize)

    ' Create a custom brush using a semi-transparent color, and 
    ' then fill in the rectangle.
    Dim customColor As Color = Color.FromArgb(50, Color.Gray)
    Dim shadowBrush As SolidBrush = New SolidBrush(customColor)
    e.Graphics.FillRectangles(shadowBrush, _
        New RectangleF() {rectFToFill})

    ' Dispose of the brush.
    shadowBrush.Dispose()
End Sub

Comentários

A unidade de uma SizeF estrutura depende das PageUnit configurações e PageScale do Graphics objeto usado para desenhar.

Construtores

SizeF(PointF)

Inicializa uma nova instância da estrutura SizeF da estrutura PointF especificada.

SizeF(Single, Single)

Inicializa uma nova instância da estrutura SizeF das dimensões especificadas.

SizeF(SizeF)

Inicializa uma nova instância da estrutura SizeF da estrutura existente SizeF especificada.

SizeF(Vector2)

Inicializa uma nova instância do SizeF struct do especificado Vector2.

Campos

Empty

Obtém uma estrutura SizeF que tem um valor Height e Width de 0.

Propriedades

Height

Obtém ou define o componente vertical desta estrutura de SizeF.

IsEmpty

Obtém um valor que indica se essa estrutura SizeF tem largura e altura igual a zero.

Width

Obtém ou define o componente horizontal desta estrutura de SizeF.

Métodos

Add(SizeF, SizeF)

Adiciona a largura e altura de uma estrutura SizeF à largura e altura de outra estrutura SizeF.

Equals(Object)

Testa para verificar se o objeto especificado é uma estrutura SizeF com as mesmas dimensões dessa estrutura SizeF.

Equals(SizeF)

Indica se o objeto atual é igual a outro objeto do mesmo tipo.

GetHashCode()

Retorna o código hash desta estrutura Size.

Subtract(SizeF, SizeF)

Subtrai a largura e altura de uma estrutura SizeF da largura e altura de outra estrutura SizeF.

ToPointF()

Converte uma estrutura SizeF em uma estrutura PointF.

ToSize()

Converte uma estrutura SizeF em uma estrutura Size.

ToString()

Cria uma cadeia de caracteres legível que representa essa estrutura SizeF.

ToVector2()

Cria um novo Vector2 com base neste SizeF.

Operadores

Addition(SizeF, SizeF)

Adiciona a largura e altura de uma estrutura SizeF à largura e altura de outra estrutura SizeF.

Division(SizeF, Single)

Divide o SizeF especificado pelo número de ponto flutuante de precisão simples especificado.

Equality(SizeF, SizeF)

Testa se duas estruturas SizeF são iguais.

Explicit(SizeF to PointF)

Converte a estrutura especificada SizeF em uma estrutura PointF.

Explicit(SizeF to Vector2)

Converte o SizeF especificado em um Vector2.

Explicit(Vector2 to SizeF)

Converte o Vector2 especificado em um SizeF.

Inequality(SizeF, SizeF)

Testa se as duas estruturas SizeF são diferentes.

Multiply(Single, SizeF)

Multiplica o número de ponto flutuante de precisão simples pelo SizeF especificado.

Multiply(SizeF, Single)

Multiplica o SizeF especificado pelo número de ponto flutuante de precisão simples especificado.

Subtraction(SizeF, SizeF)

Subtrai a largura e altura de uma estrutura SizeF da largura e altura de outra estrutura SizeF.

Aplica-se a