RectangleF.op_Equality-Methode
Überprüft, ob zwei RectangleF-Strukturen die gleiche Position und Größe haben.
Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)
Syntax
'Declaration
Public Shared Operator = ( _
left As RectangleF, _
right As RectangleF _
) As Boolean
'Usage
Dim left As RectangleF
Dim right As RectangleF
Dim returnValue As Boolean
returnValue = (left = right)
public static bool operator == (
RectangleF left,
RectangleF right
)
public:
static bool operator == (
RectangleF left,
RectangleF right
)
J# unterstützt keine überladenen Operatoren.
JScript unterstützt die Verwendung von überladenen Operatoren, aber nicht die Deklaration von neuen überladenen Operatoren.
Parameter
- left
Die RectangleF-Struktur auf der linken Seite des Gleichheitsoperators.
- right
Die RectangleF-Struktur auf der rechten Seite des Gleichheitsoperators.
Rückgabewert
Dieser Operator gibt true zurück, wenn die beiden angegebenen RectangleF-Strukturen die gleiche X-Eigenschaft, Y-Eigenschaft, Width-Eigenschaft und Height-Eigenschaft haben.
Beispiel
Im folgenden Codebeispiel wird die Verwendung des op_Implicit-Members, des RectangleF-Members und des op_Equality-Members 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 CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, 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
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
RectangleF-Struktur
RectangleF-Member
System.Drawing-Namespace