SizeF Estrutura

Definição

Armazena um par ordenado de números de ponto flutuante, normalmente 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 nome 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 configurações e PageUnit do PageScaleGraphics objeto usado para desenhar.

Construtores

Nome Description
SizeF(PointF)

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

SizeF(Single, Single)

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

SizeF(SizeF)

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

SizeF(Vector2)

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

Campos

Nome Description
Empty

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

Propriedades

Nome Description
Height

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

IsEmpty

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

Width

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

Métodos

Nome Description
Add(SizeF, SizeF)

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

Equals(Object)

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

Equals(SizeF)

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

GetHashCode()

Retorna um código hash para essa Size estrutura.

Subtract(SizeF, SizeF)

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

ToPointF()

Converte uma SizeF estrutura em uma PointF estrutura.

ToSize()

Converte uma SizeF estrutura em uma Size estrutura.

ToString()

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

ToVector2()

Cria um novo Vector2 com base nisso SizeF.

Operadores

Nome Description
Addition(SizeF, SizeF)

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

Division(SizeF, Single)

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

Equality(SizeF, SizeF)

Testa se duas SizeF estruturas são iguais.

Explicit(SizeF to PointF)

Converte a estrutura especificada SizeF em uma PointF estrutura.

Explicit(SizeF to Vector2)

Converte o especificado SizeF em um Vector2.

Explicit(Vector2 to SizeF)

Converte o especificado Vector2 em um SizeF.

Inequality(SizeF, SizeF)

Testa se duas SizeF estruturas são diferentes.

Multiply(Single, SizeF)

Multiplica o número de ponto flutuante de precisão única especificado pelo SizeFespecificado.

Multiply(SizeF, Single)

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

Subtraction(SizeF, SizeF)

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

Aplica-se a