SizeF Estrutura

Definição

Armazena um par ordenado de números em ponto flutuante, tipicamente da largura e altura de um retângulo.

public value class SizeF
public value class 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
public struct SizeF
public struct SizeF : IEquatable<System.Drawing.SizeF>
[<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
type SizeF = struct
Public Structure SizeF
Public Structure SizeF
Implements IEquatable(Of SizeF)
Herança
Atributos
Implementações

Exemplos

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

Este exemplo foi concebido para ser usado com um Windows Form. Para executar este exemplo, cole este código num formulário e chame o AddShadow método ao tratar o evento do Paint formulário. Verifique se a forma contém um ListBox .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

Observações

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

Construtores

Name Description
SizeF(PointF)

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

SizeF(Single, Single)

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

SizeF(SizeF)

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

Campos

Name Description
Empty

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

Propriedades

Name Description
Height

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

IsEmpty

Obtém um valor que indica se esta SizeF estrutura tem largura e altura nulas.

Width

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

Métodos

Name Description
Add(SizeF, SizeF)

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

Equals(Object)

Testes para verificar se o objeto especificado é uma SizeF estrutura com as mesmas dimensões que esta SizeF estrutura.

Equals(SizeF)

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

GetHashCode()

Devolve um código de hash para esta Size estrutura.

Subtract(SizeF, SizeF)

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

ToPointF()

Converte uma SizeF estrutura numa PointF estrutura.

ToSize()

Converte uma SizeF estrutura numa Size estrutura.

ToString()

Cria uma cadeia legível por humanos que representa esta SizeF estrutura.

Operadores

Name Description
Addition(SizeF, SizeF)

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

Division(SizeF, Single)

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

Equality(SizeF, SizeF)

Testa se duas SizeF estruturas são iguais.

Explicit(SizeF to PointF)

Converte a estrutura especificada SizeF numa PointF estrutura.

Inequality(SizeF, SizeF)

Testa se duas SizeF estruturas são diferentes.

Multiply(Single, SizeF)

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

Multiply(SizeF, Single)

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

Subtraction(SizeF, SizeF)

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

Aplica-se a