SizeF 構造体

定義

順序付けられた浮動小数点数のペア (通常は四角形の幅と高さ) を格納します。

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)
継承
属性
実装

次のコード例では、次のメンバーを使用して、 ListBox にシャドウを追加します。

この例は、Windows フォームで使用するように設計されています。 この例を実行するには、フォームにこのコードを貼り付け、フォームのPaint イベントを処理するときにAddShadow メソッドを呼び出します。 フォームに listBox1 という名前のListBoxが含まれていることを確認します。

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構造体の単位は、描画に使用するGraphics オブジェクトのPageUnitPageScaleの設定によって異なります。

コンストラクター

名前 説明
SizeF(PointF)

指定したSizeF構造体からPointF構造体の新しいインスタンスを初期化します。

SizeF(Single, Single)

指定したディメンションから SizeF 構造体の新しいインスタンスを初期化します。

SizeF(SizeF)

指定した既存のSizeF構造体から、SizeF構造体の新しいインスタンスを初期化します。

フィールド

名前 説明
Empty

SizeF値とHeight値が 0 のWidth構造体を取得します。

プロパティ

名前 説明
Height

この SizeF 構造体の垂直コンポーネントを取得または設定します。

IsEmpty

この SizeF 構造体の幅と高さが 0 かどうかを示す値を取得します。

Width

この SizeF 構造体の水平コンポーネントを取得または設定します。

メソッド

名前 説明
Add(SizeF, SizeF)

1 つの SizeF 構造体の幅と高さを、別の SizeF 構造体の幅と高さに追加します。

Equals(Object)

指定したオブジェクトがこのSizeF構造体と同じディメンションを持つSizeF構造体であるかどうかをテストします。

Equals(SizeF)

現在のオブジェクトが同じ型の別のオブジェクトと等しいかどうかを示します。

GetHashCode()

この Size 構造体のハッシュ コードを返します。

Subtract(SizeF, SizeF)

ある SizeF 構造体の幅と高さを、別の SizeF 構造体の幅と高さから減算します。

ToPointF()

SizeF構造体をPointF構造体に変換します。

ToSize()

SizeF構造体をSize構造体に変換します。

ToString()

この SizeF 構造体を表す人間が判読できる文字列を作成します。

演算子

名前 説明
Addition(SizeF, SizeF)

1 つの SizeF 構造体の幅と高さを、別の SizeF 構造体の幅と高さに追加します。

Division(SizeF, Single)

指定した SizeF を、指定した単精度浮動小数点数で除算します。

Equality(SizeF, SizeF)

2 つの SizeF 構造体が等しいかどうかをテストします。

Explicit(SizeF to PointF)

指定した SizeF 構造体を PointF 構造体に変換します。

Inequality(SizeF, SizeF)

2 つの SizeF 構造体が異なるかどうかをテストします。

Multiply(Single, SizeF)

指定した単精度浮動小数点数に、指定した SizeFを乗算します。

Multiply(SizeF, Single)

指定した SizeF に、指定した単精度浮動小数点数を乗算します。

Subtraction(SizeF, SizeF)

ある SizeF 構造体の幅と高さを、別の SizeF 構造体の幅と高さから減算します。

適用対象