Exemplo n.º 1
0
        internal static bool FontWeightStringToKnownWeight(string s, IFormatProvider provider, ref XFontWeight fontWeight)
        {
            int num;

            switch (s.ToLower())
            {
            case "thin":
                fontWeight = Thin;
                return(true);

            case "extralight":
                fontWeight = ExtraLight;
                return(true);

            case "ultralight":
                fontWeight = UltraLight;
                return(true);

            case "light":
                fontWeight = Light;
                return(true);

            case "normal":
                fontWeight = Normal;
                return(true);

            case "regular":
                fontWeight = Regular;
                return(true);

            case "medium":
                fontWeight = Medium;
                return(true);

            case "semibold":
                fontWeight = SemiBold;
                return(true);

            case "demibold":
                fontWeight = DemiBold;
                return(true);

            case "bold":
                fontWeight = Bold;
                return(true);

            case "extrabold":
                fontWeight = ExtraBold;
                return(true);

            case "ultrabold":
                fontWeight = UltraBold;
                return(true);

            case "heavy":
                fontWeight = Heavy;
                return(true);

            case "black":
                fontWeight = Black;
                return(true);

            case "extrablack":
                fontWeight = ExtraBlack;
                return(true);

            case "ultrablack":
                fontWeight = UltraBlack;
                return(true);
            }

            if (Int32.TryParse(s, NumberStyles.Integer, provider, out num))
            {
                fontWeight = new XFontWeight(num);
                return(true);
            }
            return(false);
        }
 /// <summary>
 /// Determines whether the specified <see cref="XFontWeight"/> is equal to the current <see cref="XFontWeight"/>.
 /// </summary>
 public bool Equals(XFontWeight obj)
 {
     return(this == obj);
 }
        //public static XFontWeight FromOpenTypeWeight(int weightValue)
        //{
        //  if (weightValue < 1 || weightValue > 999)
        //    throw new ArgumentOutOfRangeException("weightValue", "Parameter must be between 1 and 999.");
        //  return new XFontWeight(weightValue);
        //}

        /// <summary>
        /// Compares the specified font weights.
        /// </summary>
        public static int Compare(XFontWeight left, XFontWeight right)
        {
            return(left._weight - right._weight);
        }
Exemplo n.º 4
0
        internal static bool FontWeightStringToKnownWeight(string s, IFormatProvider provider, ref XFontWeight fontWeight)
        {
            int num;
            switch (s.ToLower())
            {
                case "thin":
                    fontWeight = Thin;
                    return true;

                case "extralight":
                    fontWeight = ExtraLight;
                    return true;

                case "ultralight":
                    fontWeight = UltraLight;
                    return true;

                case "light":
                    fontWeight = Light;
                    return true;

                case "normal":
                    fontWeight = Normal;
                    return true;

                case "regular":
                    fontWeight = Regular;
                    return true;

                case "medium":
                    fontWeight = Medium;
                    return true;

                case "semibold":
                    fontWeight = SemiBold;
                    return true;

                case "demibold":
                    fontWeight = DemiBold;
                    return true;

                case "bold":
                    fontWeight = Bold;
                    return true;

                case "extrabold":
                    fontWeight = ExtraBold;
                    return true;

                case "ultrabold":
                    fontWeight = UltraBold;
                    return true;

                case "heavy":
                    fontWeight = Heavy;
                    return true;

                case "black":
                    fontWeight = Black;
                    return true;

                case "extrablack":
                    fontWeight = ExtraBlack;
                    return true;

                case "ultrablack":
                    fontWeight = UltraBlack;
                    return true;
            }

            if (Int32.TryParse(s, NumberStyles.Integer, provider, out num))
            {
                fontWeight = new XFontWeight(num);
                return true;
            }
            return false;
        }