Color.Equality(Color, Color) Оператор
Определение
public:
static bool operator ==(System::Drawing::Color left, System::Drawing::Color right);
public static bool operator == (System.Drawing.Color left, System.Drawing.Color right);
static member ( = ) : System.Drawing.Color * System.Drawing.Color -> bool
Public Shared Operator == (left As Color, right As Color) As Boolean
Параметры
- left
- Color
Цвет Color, который находится слева от оператора равенства.The Color that is to the left of the equality operator.
- right
- Color
Цвет Color, который находится справа от оператора равенства.The Color that is to the right of the equality operator.
Возвращаемое значение
true
, если обе структуры Color равны; в противном случае — false
.true
if the two Color structures are equal; otherwise, false
.
Примеры
В следующем примере кода демонстрируется использование Equality оператора и SystemColors класса.The following code example demonstrates the Equality operator and the SystemColors class. Этот пример предназначен для использования с формой Windows Forms, содержащей кнопку с именем Button1
.This example is designed to be used with a Windows Form that contains a button named Button1
. Вставьте следующий код в форму и свяжите Button1_Click
метод с Click событием кнопки.Paste the following code into your form and associate the Button1_Click
method with the button's Click event.
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
if ( this->BackColor == SystemColors::ControlDark )
{
this->BackColor = SystemColors::Control;
}
}
private void Button1_Click(System.Object sender, System.EventArgs e)
{
if (this.BackColor == SystemColors.ControlDark)
{
this.BackColor = SystemColors.Control;
}
}
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If (Color.op_Equality(Me.BackColor, SystemColors.ControlDark)) Then
Me.BackColor = SystemColors.Control
End If
End Sub
Комментарии
Этот метод сравнивает больше значений ARGB Color структур.This method compares more than the ARGB values of the Color structures. Он также выполняет сравнение некоторых флагов состояния.It also does a comparison of some state flags. Если требуется сравнить только значения ARGB двух Color структур, Сравните их с помощью ToArgb метода.If you want to compare just the ARGB values of two Color structures, compare them using the ToArgb method.