PointF.Addition Operator

Definicja

Tłumaczy daną wartość PointF według określonego rozmiaru.

Przeciążenia

Addition(PointF, Size)

Tłumaczy element PointF według danego Sizeelementu .

Addition(PointF, SizeF)

Tłumaczy wartość PointF określonego SizeFelementu .

Addition(PointF, Size)

Źródło:
PointF.cs
Źródło:
PointF.cs
Źródło:
PointF.cs

Tłumaczy element PointF według danego Sizeelementu .

public:
 static System::Drawing::PointF operator +(System::Drawing::PointF pt, System::Drawing::Size sz);
public static System.Drawing.PointF operator + (System.Drawing.PointF pt, System.Drawing.Size sz);
static member ( + ) : System.Drawing.PointF * System.Drawing.Size -> System.Drawing.PointF
Public Shared Operator + (pt As PointF, sz As Size) As PointF

Parametry

pt
PointF

Element PointF do tłumaczenia.

sz
Size

Element Size określający parę liczb, które mają zostać dodane do współrzędnych .pt

Zwraca

Przetłumaczony PointFelement .

Przykłady

  • Poniższy przykład kodu dodaje cień do ListBox operatora przy użyciu Addition operatora . Ten przykład jest przeznaczony do użycia z formularzem systemu Windows. Aby uruchomić ten przykład, wklej ten kod do formularza i wywołaj AddShadow metodę podczas obsługi zdarzenia formularza Paint . Upewnij się, że formularz zawiera ListBox nazwę 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

Dotyczy

Addition(PointF, SizeF)

Źródło:
PointF.cs
Źródło:
PointF.cs
Źródło:
PointF.cs

Tłumaczy wartość PointF określonego SizeFelementu .

public:
 static System::Drawing::PointF operator +(System::Drawing::PointF pt, System::Drawing::SizeF sz);
public static System.Drawing.PointF operator + (System.Drawing.PointF pt, System.Drawing.SizeF sz);
static member ( + ) : System.Drawing.PointF * System.Drawing.SizeF -> System.Drawing.PointF
Public Shared Operator + (pt As PointF, sz As SizeF) As PointF

Parametry

pt
PointF

Element PointF do tłumaczenia.

sz
SizeF

Określa SizeF liczby, które mają zostać dodane do współrzędnych x i y wartości .PointF

Zwraca

Przetłumaczony PointFelement .

Przykłady

W poniższym przykładzie kodu pokazano, jak używać Addition operatora. Aby uruchomić ten przykład, wklej następujący kod do formularza systemu Windows. Obsłuż zdarzenie formularza Paint i wywołaj metodę opAdditionExample, przekazując e jako PaintEventArgs.

private void OpAdditionExample(PaintEventArgs e)
{
    PointF point1 = new PointF(120.5F, 120F);
    SizeF size1 = new SizeF(120.5F, 30.5F);
    RectangleF rect1 = new RectangleF(point1, size1);
    if (new PointF(rect1.Right, rect1.Bottom) == point1 + size1)
        e.Graphics.DrawString("They are equal", this.Font, Brushes.Black, rect1);
    else
        e.Graphics.DrawString("They are not equal", this.Font, Brushes.Red, rect1);
}
Private Sub OpAdditionExample(ByVal e As PaintEventArgs) 
    Dim size1 As New SizeF(120.5F, 30.5F)
    Dim point1 As New PointF(20.5F, 20F)
    Dim rect1 As New RectangleF(point1, size1)
    If New PointF(rect1.Right, rect1.Bottom) = point1 + size1 Then
        e.Graphics.DrawString("They are equal", Me.Font, Brushes.Black, rect1)
    Else
        e.Graphics.DrawString("They are not equal", Me.Font, Brushes.Red, rect1)
    End If
 
End Sub

Uwagi

Operator Addition dodaje Width określony rozmiar do współrzędnej x i Height do współrzędnej PointF y .PointF

Równoważna metoda dla tego operatora to PointF.Add(PointF, SizeF)

Dotyczy