SizeF Struktur

Definisi

Menyimpan sepasang angka floating-point yang diurutkan, biasanya lebar dan tinggi persegi panjang.

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
Warisan
Atribut
Penerapan

Contoh

Contoh kode berikut menambahkan bayangan ke menggunakan ListBox anggota berikut:

Contoh ini dirancang untuk digunakan dengan Formulir Windows. Untuk menjalankan contoh ini, tempelkan kode ini ke dalam formulir dan panggil AddShadow metode saat menangani peristiwa formulir Paint . Verifikasi bahwa formulir berisi bernama ListBoxlistBox1.

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

Keterangan

Unit untuk SizeF struktur tergantung pada PageUnit pengaturan dan PageScale untuk Graphics objek yang digunakan untuk menggambar.

Konstruktor

SizeF(PointF)

Menginisialisasi instans SizeF baru struktur dari struktur yang ditentukan PointF .

SizeF(Single, Single)

Menginisialisasi instans SizeF baru struktur dari dimensi yang ditentukan.

SizeF(SizeF)

Menginisialisasi instans SizeF baru struktur dari struktur yang ada SizeF yang ditentukan.

SizeF(Vector2)

Menginisialisasi instans SizeF baru struct dari yang ditentukan Vector2.

Bidang

Empty

SizeF Mendapatkan struktur yang memiliki Height nilai dan Width 0.

Properti

Height

Mendapatkan atau mengatur komponen vertikal dari struktur ini SizeF .

IsEmpty

Mendapatkan nilai yang menunjukkan apakah struktur ini SizeF memiliki lebar dan tinggi nol.

Width

Mendapatkan atau mengatur komponen horizontal dari struktur ini SizeF .

Metode

Add(SizeF, SizeF)

Menambahkan lebar dan tinggi satu SizeF struktur ke lebar dan tinggi struktur lain SizeF .

Equals(Object)

Pengujian untuk melihat apakah objek yang ditentukan adalah SizeF struktur dengan dimensi yang sama dengan struktur ini SizeF .

Equals(SizeF)

Menunjukkan apakah objek saat ini sama dengan objek lain dengan jenis yang sama.

GetHashCode()

Mengembalikan kode hash untuk struktur ini Size .

Subtract(SizeF, SizeF)

Mengurangi lebar dan tinggi satu SizeF struktur dari lebar dan tinggi struktur lain SizeF .

ToPointF()

SizeF Mengonversi struktur menjadi PointF struktur.

ToSize()

SizeF Mengonversi struktur menjadi Size struktur.

ToString()

Membuat string yang dapat dibaca manusia yang mewakili struktur ini SizeF .

ToVector2()

Membuat baru Vector2 dari ini SizeF.

Operator

Addition(SizeF, SizeF)

Menambahkan lebar dan tinggi satu SizeF struktur ke lebar dan tinggi struktur lain SizeF .

Division(SizeF, Single)

Membagi yang ditentukan SizeF dengan angka floating-point presisi tunggal yang ditentukan.

Equality(SizeF, SizeF)

Menguji apakah dua SizeF struktur sama.

Explicit(SizeF to PointF)

Mengonversi struktur yang ditentukan SizeF menjadi PointF struktur.

Explicit(SizeF to Vector2)

Mengonversi yang ditentukan SizeF menjadi Vector2.

Explicit(Vector2 to SizeF)

Mengonversi yang ditentukan Vector2 menjadi SizeF.

Inequality(SizeF, SizeF)

Menguji apakah dua SizeF struktur berbeda.

Multiply(Single, SizeF)

Mengalikan angka floating-point presisi tunggal yang ditentukan dengan yang ditentukan SizeF.

Multiply(SizeF, Single)

Mengalikan yang ditentukan SizeF oleh angka floating-point presisi tunggal yang ditentukan.

Subtraction(SizeF, SizeF)

Mengurangi lebar dan tinggi satu SizeF struktur dari lebar dan tinggi struktur lain SizeF .

Berlaku untuk