SizeF Estructura

Definición

Almacena un par ordenado de números de punto flotante, normalmente el ancho y el alto de un rectá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)
Herencia
Atributos
Implementaciones

Ejemplos

En el ejemplo de código siguiente se agrega una sombra a mediante ListBox los siguientes miembros:

Este ejemplo está diseñado para usarse con windows Forms. Para ejecutar este ejemplo, pegue este código en un formulario y llame al AddShadow método al controlar el evento del Paint formulario. Compruebe que el formulario contiene un ListBox objeto denominado 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

Comentarios

La unidad de una SizeF estructura depende de la PageUnit configuración y PageScale del Graphics objeto que se usa para dibujar.

Constructores

Nombre Description
SizeF(PointF)

Inicializa una nueva instancia de la SizeF estructura a partir de la estructura especificada PointF .

SizeF(Single, Single)

Inicializa una nueva instancia de la SizeF estructura a partir de las dimensiones especificadas.

SizeF(SizeF)

Inicializa una nueva instancia de la SizeF estructura a partir de la estructura existente SizeF especificada.

Campos

Nombre Description
Empty

Obtiene una SizeF estructura que tiene un Height valor y Width de 0.

Propiedades

Nombre Description
Height

Obtiene o establece el componente vertical de esta SizeF estructura.

IsEmpty

Obtiene un valor que indica si esta SizeF estructura tiene cero ancho y alto.

Width

Obtiene o establece el componente horizontal de esta SizeF estructura.

Métodos

Nombre Description
Add(SizeF, SizeF)

Agrega el ancho y alto de una SizeF estructura al ancho y alto de otra SizeF estructura.

Equals(Object)

Comprueba si el objeto especificado es una SizeF estructura con las mismas dimensiones que esta SizeF estructura.

Equals(SizeF)

Indica si el objeto actual es igual a otro objeto del mismo tipo.

GetHashCode()

Devuelve un código hash para esta Size estructura.

Subtract(SizeF, SizeF)

Resta el ancho y el alto de una SizeF estructura del ancho y alto de otra SizeF estructura.

ToPointF()

Convierte una SizeF estructura en una PointF estructura.

ToSize()

Convierte una SizeF estructura en una Size estructura.

ToString()

Crea una cadena legible que representa esta SizeF estructura.

Operadores

Nombre Description
Addition(SizeF, SizeF)

Agrega el ancho y alto de una SizeF estructura al ancho y alto de otra SizeF estructura.

Division(SizeF, Single)

Divide el especificado SizeF por el número de punto flotante de precisión sencilla especificado.

Equality(SizeF, SizeF)

Comprueba si dos SizeF estructuras son iguales.

Explicit(SizeF to PointF)

Convierte la estructura especificada SizeF en una PointF estructura.

Inequality(SizeF, SizeF)

Comprueba si dos SizeF estructuras son diferentes.

Multiply(Single, SizeF)

Multiplica el número de punto flotante de precisión sencilla especificado por el especificado SizeF.

Multiply(SizeF, Single)

Multiplica el especificado SizeF por el número de punto flotante de precisión sencilla especificado.

Subtraction(SizeF, SizeF)

Resta el ancho y el alto de una SizeF estructura del ancho y alto de otra SizeF estructura.

Se aplica a