RectangleF-Konstruktor (PointF, SizeF)
Initialisiert eine neue Instanz der RectangleF-Klasse mit der angegebenen Position und Größe.
Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)
Syntax
'Declaration
Public Sub New ( _
location As PointF, _
size As SizeF _
)
'Usage
Dim location As PointF
Dim size As SizeF
Dim instance As New RectangleF(location, size)
public RectangleF (
PointF location,
SizeF size
)
public:
RectangleF (
PointF location,
SizeF size
)
public RectangleF (
PointF location,
SizeF size
)
public function RectangleF (
location : PointF,
size : SizeF
)
Parameter
- location
Ein PointF, der die linke obere Ecke des rechteckigen Bereichs darstellt.
- size
Eine SizeF, die die Breite und Höhe des rechteckigen Bereichs darstellt.
Beispiel
Im folgenden Codebeispiel wird die Verwendung der Member op_Implicit, RectangleF und op_Equality veranschaulicht. Dieses Beispiel ist für die Verwendung mit einem Windows Form vorgesehen. Fügen Sie diesen Code in ein Formular ein, und rufen Sie beim Behandeln des Paint-Ereignisses des Formulars die ConvertRectangleToRectangleF
-Methode auf, wobei Sie e als PaintEventArgs übergeben.
Private Sub ConvertRectangleToRectangleF( _
ByVal e As PaintEventArgs)
' Create a rectangle.
Dim rectangle1 As New Rectangle(30, 40, 50, 100)
' Convert it to a RectangleF.
Dim convertedRectangle As RectangleF = _
RectangleF.op_Implicit(rectangle1)
' Create a new RectangleF.
Dim rectangle2 As New RectangleF(New PointF(30.0F, 40.0F), _
New SizeF(50.0F, 100.0F))
' Create a custom, partially transparent brush.
Dim redBrush As New SolidBrush(Color.FromArgb(40, Color.Red))
' Compare the converted rectangle with the new one. If they
' are equal, draw and fill the rectangles on the form.
If (RectangleF.op_Equality(convertedRectangle, rectangle2)) Then
e.Graphics.FillRectangle(redBrush, rectangle2)
End If
' Dispose of the custom brush.
redBrush.Dispose()
End Sub
private void ConvertRectangleToRectangleF(PaintEventArgs e)
{
// Create a rectangle.
Rectangle rectangle1 = new Rectangle(30, 40, 50, 100);
// Convert it to a RectangleF.
RectangleF convertedRectangle = rectangle1;
// Create a new RectangleF.
RectangleF rectangle2 = new RectangleF(new PointF(30.0F, 40.0F),
new SizeF(50.0F, 100.0F));
// Create a custom, partially transparent brush.
SolidBrush redBrush = new SolidBrush(Color.FromArgb(40, Color.Red));
// Compare the converted rectangle with the new one. If they
// are equal draw and fill the rectangles on the form.
if (convertedRectangle == rectangle2)
{
e.Graphics.FillRectangle(redBrush, rectangle2);
}
// Dispose of the custom brush.
redBrush.Dispose();
}
private:
void ConvertRectangleToRectangleF( PaintEventArgs^ e )
{
// Create a rectangle.
Rectangle rectangle1 = Rectangle(30,40,50,100);
// Convert it to a RectangleF.
RectangleF convertedRectangle = rectangle1;
// Create a new RectangleF.
RectangleF rectangle2 = RectangleF(PointF(30.0F,40.0F),SizeF(50.0F,100.0F));
// Create a custom, partially transparent brush.
SolidBrush^ redBrush = gcnew SolidBrush( Color::FromArgb( 40, Color::Red ) );
// Compare the converted rectangle with the new one. If they
// are equal draw and fill the rectangles on the form.
if ( convertedRectangle == rectangle2 )
{
e->Graphics->FillRectangle( redBrush, rectangle2 );
}
// Dispose of the custom brush.
delete redBrush;
}
};
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
RectangleF-Struktur
RectangleF-Member
System.Drawing-Namespace