SizeF 結構
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
儲存已排序的浮點數值 (Floating-Point Number) 配對,通常是矩形的寬度和高度。
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
- 繼承
- 屬性
- 實作
範例
下列程式代碼範例會使用下列成員,將陰影新增至 ListBox :
此範例的設計目的是要與 Windows Form 搭配使用。 若要執行此範例,請將此程式代碼貼到窗體中,並在處理表單的 Paint 事件時呼叫 AddShadow
方法。 確認表單包含 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 取決於 PageUnit 用來繪製之物件的 和 PageScale 設定 Graphics 。
建構函式
SizeF(PointF) | |
SizeF(Single, Single) |
從指定的維度,初始化 SizeF 結構的新執行個體。 |
SizeF(SizeF) | |
SizeF(Vector2) |
欄位
Empty |
屬性
Height |
取得或設定這個 SizeF 結構的垂直元件。 |
IsEmpty |
取得值,指出這個 SizeF 結構是否具有零的寬度和高度。 |
Width |
取得或設定這個 SizeF 結構的水平元件。 |
方法
Add(SizeF, SizeF) | |
Equals(Object) | |
Equals(SizeF) |
指出目前的物件是否等於另一個相同類型的物件。 |
GetHashCode() |
傳回這個 Size 結構的雜湊程式碼。 |
Subtract(SizeF, SizeF) | |
ToPointF() | |
ToSize() | |
ToString() |
建立表示這個 SizeF 結構之人類看得懂的字串。 |
ToVector2() |
運算子
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) |