SizeF Struct
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Archivia una coppia ordinata di numeri a virgola mobile, in genere la larghezza e l'altezza di un rettangolo.
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)
- Ereditarietà
- Attributi
- Implementazioni
Esempio
Nell'esempio di codice seguente viene aggiunta un'ombreggiatura a un ListBox oggetto usando i membri seguenti:
Questo esempio è progettato per essere usato con un Windows Form. Per eseguire questo esempio, incollare questo codice in una maschera e chiamare il metodo quando si gestisce l'evento AddShadow del Paint modulo. Verificare che il modulo contenga un ListBox oggetto denominato 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
Commenti
L'unità per una SizeF struttura dipende dalle PageUnit impostazioni e PageScale per l'oggetto utilizzato per disegnare Graphics .
Costruttori
| Nome | Descrizione |
|---|---|
| SizeF(PointF) |
Inizializza una nuova istanza della SizeF struttura dalla struttura specificata PointF . |
| SizeF(Single, Single) |
Inizializza una nuova istanza della SizeF struttura dalle dimensioni specificate. |
| SizeF(SizeF) |
Inizializza una nuova istanza della SizeF struttura dalla struttura esistente SizeF specificata. |
Campi
| Nome | Descrizione |
|---|---|
| Empty |
Ottiene una SizeF struttura con valore Height e Width pari a 0. |
Proprietà
| Nome | Descrizione |
|---|---|
| Height |
Ottiene o imposta il componente verticale di questa SizeF struttura. |
| IsEmpty |
Ottiene un valore che indica se questa SizeF struttura ha larghezza e altezza zero. |
| Width |
Ottiene o imposta il componente orizzontale di questa SizeF struttura. |
Metodi
| Nome | Descrizione |
|---|---|
| Add(SizeF, SizeF) |
Aggiunge la larghezza e l'altezza di una SizeF struttura alla larghezza e all'altezza di un'altra SizeF struttura. |
| Equals(Object) |
Verifica se l'oggetto specificato è una SizeF struttura con le stesse dimensioni di questa SizeF struttura. |
| Equals(SizeF) |
Indica se l'oggetto corrente è uguale a un altro oggetto dello stesso tipo. |
| GetHashCode() |
Restituisce un codice hash per questa Size struttura. |
| Subtract(SizeF, SizeF) |
Sottrae la larghezza e l'altezza di una SizeF struttura dalla larghezza e dall'altezza di un'altra SizeF struttura. |
| ToPointF() | |
| ToSize() | |
| ToString() |
Crea una stringa leggibile che rappresenta questa SizeF struttura. |
Operatori
| Nome | Descrizione |
|---|---|
| Addition(SizeF, SizeF) |
Aggiunge la larghezza e l'altezza di una SizeF struttura alla larghezza e all'altezza di un'altra SizeF struttura. |
| Division(SizeF, Single) |
Divide l'oggetto specificato SizeF in base al numero a virgola mobile e precisione singola specificato. |
| Equality(SizeF, SizeF) |
Verifica se due SizeF strutture sono uguali. |
| Explicit(SizeF to PointF) |
Converte la struttura specificata SizeF in una PointF struttura. |
| Inequality(SizeF, SizeF) |
Verifica se due SizeF strutture sono diverse. |
| Multiply(Single, SizeF) |
Moltiplica il numero a virgola mobile e precisione singola specificato per l'oggetto specificato SizeF. |
| Multiply(SizeF, Single) |
Moltiplica l'oggetto specificato SizeF per il numero a virgola mobile e precisione singola specificato. |
| Subtraction(SizeF, SizeF) |
Sottrae la larghezza e l'altezza di una SizeF struttura dalla larghezza e dall'altezza di un'altra SizeF struttura. |