SizeF Konstruktorer
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.
Överlagringar
| Name | Description |
|---|---|
| SizeF(PointF) |
Initierar en ny instans av SizeF strukturen från den angivna PointF strukturen. |
| SizeF(SizeF) |
Initierar en ny instans av SizeF strukturen från den angivna befintliga SizeF strukturen. |
| SizeF(Vector2) |
Initierar en ny instans av SizeF struct från den angivna Vector2. |
| SizeF(Single, Single) |
Initierar en ny instans av SizeF strukturen från de angivna dimensionerna. |
SizeF(Vector2)
- Källa:
- SizeF.cs
- Källa:
- SizeF.cs
- Källa:
- SizeF.cs
- Källa:
- SizeF.cs
- Källa:
- SizeF.cs
public:
SizeF(System::Numerics::Vector2 vector);
public SizeF(System.Numerics.Vector2 vector);
new System.Drawing.SizeF : System.Numerics.Vector2 -> System.Drawing.SizeF
Public Sub New (vector As Vector2)
Parametrar
- vector
- Vector2
Källvektorn.
Gäller för
SizeF(Single, Single)
- Källa:
- SizeF.cs
- Källa:
- SizeF.cs
- Källa:
- SizeF.cs
- Källa:
- SizeF.cs
- Källa:
- SizeF.cs
Initierar en ny instans av SizeF strukturen från de angivna dimensionerna.
public:
SizeF(float width, float height);
public SizeF(float width, float height);
new System.Drawing.SizeF : single * single -> System.Drawing.SizeF
Public Sub New (width As Single, height As Single)
Parametrar
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