英語で読む

次の方法で共有


SizeF.Addition(SizeF, SizeF) Operator

定義

ある SizeF 構造体の幅と高さを別の SizeF 構造体の幅と高さに加算します。

public static System.Drawing.SizeF operator + (System.Drawing.SizeF sz1, System.Drawing.SizeF sz2);

パラメーター

sz1
SizeF

最初に加算する SizeF 構造体。

sz2
SizeF

加算対象の 2 番目の SizeF 構造体。

戻り値

加算演算の結果を表す Size 構造体。

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

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

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();
}

適用対象

製品 バージョン
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1