SizeF Structure
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Stocke une paire ordonnée de nombres à virgule flottante, généralement la largeur et la hauteur d’un rectangle.
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)
- Héritage
- Attributs
- Implémente
Exemples
L’exemple de code suivant ajoute une ombre à un ListBox en utilisant les membres suivants :
Cet exemple est conçu pour être utilisé avec un Windows Form. Pour exécuter cet exemple, collez ce code dans un formulaire et appelez la méthode lors de la AddShadow gestion de l’événement du Paint formulaire. Vérifiez que le formulaire contient un ListBox nom 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
Remarques
L’unité d’une SizeF structure dépend des paramètres et PageScale des PageUnit paramètres de l’objet Graphics utilisé pour dessiner.
Constructeurs
| Nom | Description |
|---|---|
| SizeF(PointF) |
Initialise une nouvelle instance de la SizeF structure à partir de la structure spécifiée PointF . |
| SizeF(Single, Single) |
Initialise une nouvelle instance de la SizeF structure à partir des dimensions spécifiées. |
| SizeF(SizeF) |
Initialise une nouvelle instance de la SizeF structure à partir de la structure existante SizeF spécifiée. |
Champs
| Nom | Description |
|---|---|
| Empty |
Obtient une SizeF structure dont Height la valeur est Width 0. |
Propriétés
| Nom | Description |
|---|---|
| Height |
Obtient ou définit le composant vertical de cette SizeF structure. |
| IsEmpty |
Obtient une valeur qui indique si cette SizeF structure a une largeur et une hauteur nulles. |
| Width |
Obtient ou définit le composant horizontal de cette SizeF structure. |
Méthodes
| Nom | Description |
|---|---|
| Add(SizeF, SizeF) |
Ajoute la largeur et la hauteur d’une SizeF structure à la largeur et à la hauteur d’une autre SizeF structure. |
| Equals(Object) |
Teste si l’objet spécifié est une SizeF structure avec les mêmes dimensions que cette SizeF structure. |
| Equals(SizeF) |
Indique si l’objet actuel est égal à un autre objet du même type. |
| GetHashCode() |
Retourne un code de hachage pour cette Size structure. |
| Subtract(SizeF, SizeF) |
Soustrait la largeur et la hauteur d’une SizeF structure de la largeur et de la hauteur d’une autre SizeF structure. |
| ToPointF() | |
| ToSize() | |
| ToString() |
Crée une chaîne lisible par l’homme qui représente cette SizeF structure. |
Opérateurs
| Nom | Description |
|---|---|
| Addition(SizeF, SizeF) |
Ajoute la largeur et la hauteur d’une SizeF structure à la largeur et à la hauteur d’une autre SizeF structure. |
| Division(SizeF, Single) |
Divise le spécifié SizeF par le nombre à virgule flottante simple précision spécifié. |
| Equality(SizeF, SizeF) |
Teste si deux SizeF structures sont égales. |
| Explicit(SizeF to PointF) |
Convertit la structure spécifiée SizeF en structure PointF . |
| Inequality(SizeF, SizeF) |
Teste si deux SizeF structures sont différentes. |
| Multiply(Single, SizeF) |
Multiplie le nombre à virgule flottante simple précision spécifié par le nombre spécifié SizeF. |
| Multiply(SizeF, Single) |
Multiplie le nombre SizeF à virgule flottante simple précision spécifié. |
| Subtraction(SizeF, SizeF) |
Soustrait la largeur et la hauteur d’une SizeF structure de la largeur et de la hauteur d’une autre SizeF structure. |