Point.Implicit(Point to PointF) Operatore

Definizione

Converte la struttura Point specificata in una struttura PointF.

C#
public static implicit operator System.Drawing.PointF (System.Drawing.Point p);

Parametri

p
Point

Oggetto Point da convertire.

Restituisce

Struttura PointF risultante dalla conversione.

Esempio

Nell'esempio di codice seguente viene aggiunta un'ombreggiatura a un ListBox oggetto utilizzando operatori di overload.

Questo esempio è progettato per essere usato con Windows Form. Per eseguire questo esempio, incollare questo codice in una maschera e chiamare il AddShadow metodo durante la gestione dell'evento del Paint modulo. Assicurarsi che il modulo contenga un ListBox oggetto denominato listBox1.

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

Si applica a

Prodotto Versioni
.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