FontWeight.Compare(FontWeight, FontWeight) Metoda

Definicja

Porównuje dwa wystąpienia klasy FontWeight.

public:
 static int Compare(System::Windows::FontWeight left, System::Windows::FontWeight right);
public static int Compare (System.Windows.FontWeight left, System.Windows.FontWeight right);
static member Compare : System.Windows.FontWeight * System.Windows.FontWeight -> int
Public Shared Function Compare (left As FontWeight, right As FontWeight) As Integer

Parametry

left
FontWeight

Pierwszy FontWeight obiekt do porównania.

right
FontWeight

Drugi FontWeight obiekt do porównania.

Zwraca

Int32

Int32 Wartość wskazująca relację między dwoma wystąpieniami klasy FontWeight. Gdy wartość zwracana jest mniejsza niż zero, left jest mniejsza niż right. Gdy ta wartość jest równa zero, oznacza to, że oba operandy są równe. Gdy wartość jest większa od zera, oznacza to, że left wartość jest większa niż right.

Przykłady

W poniższym przykładzie Compare kodu metoda jest używana do oceny dwóch FontWeight obiektów.

// Return the typefaces for the selected font family name and font values.
Typeface typeface1 = new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
Typeface typeface2 = new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.UltraBold, FontStretches.Normal);

if (FontWeight.Compare(typeface1.Weight, typeface2.Weight) < 0)
{
    // Code execution follows this path because
    // the FontWeight of typeface1 (Normal) is less than of typeface2 (UltraBold).
}
' Return the typefaces for the selected font family name and font values.
Dim typeface1 As New Typeface(New FontFamily("Arial"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal)
Dim typeface2 As New Typeface(New FontFamily("Arial"), FontStyles.Normal, FontWeights.UltraBold, FontStretches.Normal)

If FontWeight.Compare(typeface1.Weight, typeface2.Weight) < 0 Then
    ' Code execution follows this path because
    ' the FontWeight of typeface1 (Normal) is less than of typeface2 (UltraBold).
End If

Uwagi

Lżejsze wagi czcionek są mniejsze niż cięższe wagi czcionek. Na przykład grubość czcionki "Light" lub "Normal" jest mniejsza niż grubość czcionki "UltraBold".

Dotyczy