SizeF Struct-datatyp
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Lagrar ett ordnat par flyttalsnummer, vanligtvis bredden och höjden på en rektangel.
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)
- Arv
- Attribut
- Implementeringar
Exempel
I följande kodexempel läggs en skugga till i en ListBox med hjälp av följande medlemmar:
Det här exemplet är utformat för att användas med ett Windows-formulär. Om du vill köra det här exemplet klistrar du in den här koden i ett formulär och anropar AddShadow metoden när du hanterar formulärets Paint händelse. Kontrollera att formuläret innehåller ett ListBox med namnet 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
Kommentarer
Enheten för en SizeF struktur beror på PageUnit inställningarna och PageScale för det Graphics objekt som används för att rita.
Konstruktorer
| Name | Description |
|---|---|
| SizeF(PointF) |
Initierar en ny instans av SizeF strukturen från den angivna PointF strukturen. |
| SizeF(Single, Single) |
Initierar en ny instans av SizeF strukturen från de angivna dimensionerna. |
| SizeF(SizeF) |
Initierar en ny instans av SizeF strukturen från den angivna befintliga SizeF strukturen. |
Fält
| Name | Description |
|---|---|
| Empty |
Egenskaper
| Name | Description |
|---|---|
| Height |
Hämtar eller anger den lodräta komponenten i den här SizeF strukturen. |
| IsEmpty |
Hämtar ett värde som anger om den här SizeF strukturen har noll bredd och höjd. |
| Width |
Hämtar eller anger den vågräta komponenten i den här SizeF strukturen. |
Metoder
| Name | Description |
|---|---|
| Add(SizeF, SizeF) |
Lägger till bredden och höjden på en SizeF struktur till bredden och höjden på en annan SizeF struktur. |
| Equals(Object) |
Testar för att se om det angivna objektet är en SizeF struktur med samma dimensioner som den här SizeF strukturen. |
| Equals(SizeF) |
Anger om det aktuella objektet är lika med ett annat objekt av samma typ. |
| GetHashCode() |
Returnerar en hash-kod för den här Size strukturen. |
| Subtract(SizeF, SizeF) |
Subtraherar bredden och höjden på en SizeF struktur från bredden och höjden på en annan SizeF struktur. |
| ToPointF() | |
| ToSize() | |
| ToString() |
Skapar en läsbar sträng som representerar den här SizeF strukturen. |
Operatorer
| Name | Description |
|---|---|
| Addition(SizeF, SizeF) |
Lägger till bredden och höjden på en SizeF struktur till bredden och höjden på en annan SizeF struktur. |
| Division(SizeF, Single) |
Delar det angivna SizeF flyttalnumret med enkel precision. |
| Equality(SizeF, SizeF) |
Testar om två SizeF strukturer är lika med. |
| Explicit(SizeF to PointF) |
Konverterar den angivna SizeF strukturen till en PointF struktur. |
| Inequality(SizeF, SizeF) |
Testar om två SizeF strukturer är olika. |
| Multiply(Single, SizeF) |
Multiplicerar det angivna flyttalsnumret med enkel precision med det angivna SizeF. |
| Multiply(SizeF, Single) |
Multiplicerar det angivna SizeF flyttalsnumret med enkel precision. |
| Subtraction(SizeF, SizeF) |
Subtraherar bredden och höjden på en SizeF struktur från bredden och höjden på en annan SizeF struktur. |