語言

SizeF 結構

定義

儲存已排序的浮點陣列,通常是矩形的寬度和高度。

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結構初始化一個新的結構實例PointF。

SizeF(Single, Single)

初始化指定維度結構的新實例 SizeF 。

SizeF(SizeF)

從指定的現有SizeF結構初始化一個新的結構實例SizeF。

SizeF(Vector2)

初始化指定的Vector2結構體實例SizeF。

欄位

名稱 Description
Empty

得到 SizeF 一個結構,且 a Height 和 Width 值為 0。

屬性

名稱 Description
Height

取得或設定此 SizeF 結構的垂直部分。

IsEmpty

會得到一個表示該 SizeF 結構寬度與高度為零的值。

Width

取得或設定此 SizeF 結構的水平成分。

方法

名稱 Description
Add(SizeF, SizeF)

將一個 SizeF 結構的寬度與高度相加於另一個 SizeF 結構的寬度與高度。

Equals(Object)

測試該物件是否與 SizeF 該 SizeF 結構具有相同維度。

Equals(SizeF)

指出目前的物件是否等於相同類型的另一個物件。

GetHashCode()

會回傳此 Size 結構的雜湊碼。

Subtract(SizeF, SizeF)

用另一個SizeF結構的寬度和高度減去一個SizeF結構的寬度和高度。

ToPointF()

將結構 SizeF 轉換為結構 PointF 。

ToSize()

將結構 SizeF 轉換為結構 Size 。

ToString()

建立一個人類可讀的字串,代表此 SizeF 結構。

ToVector2()

從此Vector2產生新的 SizeF 。

運算子

名稱 Description
Addition(SizeF, SizeF)

將一個 SizeF 結構的寬度與高度相加於另一個 SizeF 結構的寬度與高度。

Division(SizeF, Single)

將指定 SizeF 值除以指定的單精度浮點數。

Equality(SizeF, SizeF)

測試兩個 SizeF 結構是否相等。

Explicit(SizeF to PointF)

將指定的 SizeF 結構轉換成結構 PointF 。

Explicit(SizeF to Vector2)

將指定的 SizeFVector2轉換為 。

Explicit(Vector2 to SizeF)

將指定的 Vector2SizeF轉換為 。

Inequality(SizeF, SizeF)

測試兩個 SizeF 結構是否不同。

Multiply(Single, SizeF)

將指定的單精度浮點數乘以指定的 SizeF。

Multiply(SizeF, Single)

將指定 SizeF 值乘以指定的單精度浮點數。

Subtraction(SizeF, SizeF)

用另一個SizeF結構的寬度和高度減去一個SizeF結構的寬度和高度。

適用於