Sdílet prostřednictvím


FontWeight.Compare(FontWeight, FontWeight) Metoda

Definice

Porovná dvě instance .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

První FontWeight objekt, který chcete porovnat.

right
FontWeight

Druhý FontWeight objekt, který chcete porovnat.

Návraty

Int32

Hodnota Int32 , která označuje vztah mezi dvěma instancemi FontWeight. Pokud je vrácená hodnota menší než nula, left je menší než right. Pokud je tato hodnota nula, znamená to, že oba operandy jsou stejné. Pokud je hodnota větší než nula, znamená to, že left je větší než right.

Příklady

V následujícím příkladu Compare kódu se metoda používá k vyhodnocení dvou FontWeight objektů.

// 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

Poznámky

Světlejší váhy písma jsou menší než těžší váhy písma. Například váha písma "Light" nebo "Normal" je menší než hmotnost písma UltraBold.

Platí pro