Beispiel #1
0
        /// <summary>
        /// Compares the family, style, weight and stretch of two TypefacesItems.
        /// </summary>
        public int Compare(object face1Object, object face2Object)
        {
            TypefaceComboBoxItem face1 = face1Object as TypefaceComboBoxItem;
            TypefaceComboBoxItem face2 = face2Object as TypefaceComboBoxItem;

            if (face1.FamilyName != face2.FamilyName)
            {
                return(string.Compare(face1.FamilyName, face2.FamilyName, true, CultureInfo.InvariantCulture));
            }
            else if ((face1._face.IsBoldSimulated || face1._face.IsObliqueSimulated) != (face2._face.IsBoldSimulated || face2._face.IsObliqueSimulated))
            {
                // Put non-simulated faces first.
                return((face1._face.IsBoldSimulated || face1._face.IsObliqueSimulated) ? 1 : -1);
            }
            else if (face1.Stretch != face2.Stretch)
            {
                return(FontStretch.Compare(face1.Stretch, face2.Stretch));
            }
            else if (face1.Weight != face2.Weight)
            {
                return(FontWeight.Compare(face1.Weight, face2.Weight));
            }
            else
            {
                if (face1.Style == face2.Style)
                {
                    return(0);
                }
                else
                {
                    if (face1.Style == FontStyles.Normal)
                    {
                        return(-1);
                    }
                    else if (face1.Style == FontStyles.Oblique)
                    {
                        return(1);
                    }
                    else
                    {
                        return((face2.Style == FontStyles.Normal) ? 1 : -1);
                    }
                }
            }
        }
Beispiel #2
0
 public int GetHashCode(TypefaceComboBoxItem face)
 {
     return(_face.GetHashCode());
 }
Beispiel #3
0
 public static bool Equals(TypefaceComboBoxItem face1, TypefaceComboBoxItem face2)
 {
     return(face1.Stretch == face2.Stretch &&
            face1.Weight == face2.Weight &&
            face1.Style == face2.Style);
 }