SizeF 結構
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
儲存已排序的浮點陣列,通常是矩形的寬度和高度。
public value class SizeF : IEquatable<System::Drawing::SizeF>
public value class SizeF
[System.ComponentModel.TypeConverter("System.Drawing.SizeFConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public struct SizeF : IEquatable<System.Drawing.SizeF>
public struct SizeF
public struct 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
[<System.ComponentModel.TypeConverter("System.Drawing.SizeFConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
type SizeF = struct
type SizeF = struct
[<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
Public Structure SizeF
Implements IEquatable(Of SizeF)
Public Structure SizeF
- 繼承
- 屬性
- 實作
範例
以下程式碼範例透過以下成員為 A ListBox 添加陰影:
此範例設計用於 Windows 表單。 要執行這個範例,請將這段程式碼貼到表單中,並在處理表單事件時呼叫AddShadow該Paint方法。 確認表單是否包含 ListBox 一個名為 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
備註
結構的SizeF單位取決於PageUnitPageScale所繪製物件的設定Graphics。
建構函式
| 名稱 | Description |
|---|---|
| SizeF(PointF) | |
| SizeF(Single, Single) |
初始化指定維度結構的新實例 SizeF 。 |
| SizeF(SizeF) | |
| SizeF(Vector2) |
欄位
| 名稱 | Description |
|---|---|
| Empty |
屬性
| 名稱 | Description |
|---|---|
| Height |
取得或設定此 SizeF 結構的垂直部分。 |
| IsEmpty |
會得到一個表示該 SizeF 結構寬度與高度為零的值。 |
| Width |
取得或設定此 SizeF 結構的水平成分。 |
方法
| 名稱 | Description |
|---|---|
| Add(SizeF, SizeF) | |
| Equals(Object) | |
| Equals(SizeF) |
指出目前的物件是否等於相同類型的另一個物件。 |
| GetHashCode() |
會回傳此 Size 結構的雜湊碼。 |
| Subtract(SizeF, SizeF) | |
| ToPointF() | |
| ToSize() | |
| ToString() |
建立一個人類可讀的字串,代表此 SizeF 結構。 |
| ToVector2() |
運算子
| 名稱 | Description |
|---|---|
| Addition(SizeF, SizeF) | |
| Division(SizeF, Single) |
將指定 SizeF 值除以指定的單精度浮點數。 |
| Equality(SizeF, SizeF) |
測試兩個 SizeF 結構是否相等。 |
| Explicit(SizeF to PointF) | |
| Explicit(SizeF to Vector2) | |
| Explicit(Vector2 to SizeF) | |
| Inequality(SizeF, SizeF) |
測試兩個 SizeF 結構是否不同。 |
| Multiply(Single, SizeF) |
將指定的單精度浮點數乘以指定的 SizeF。 |
| Multiply(SizeF, Single) |
將指定 SizeF 值乘以指定的單精度浮點數。 |
| Subtraction(SizeF, SizeF) |