예제 #1
0
 internal CSSFontProperty()
     : base(PropertyNames.Font)
 {
     _style     = new CSSFontStyleProperty();
     _variant   = new CSSFontVariantProperty();
     _weight    = new CSSFontWeightProperty();
     _stretch   = new CSSFontStretchProperty();
     _size      = new CSSFontSizeProperty();
     _family    = new CSSFontFamilyProperty();
     _height    = new CSSLineHeightProperty();
     _inherited = true;
 }
예제 #2
0
        protected override Boolean IsValid(CSSValue value)
        {
            SystemSetting setting;

            if (value is CSSIdentifierValue && _parts.TryGetValue(((CSSIdentifierValue)value).Value, out setting))
            {
                SetTo(setting);
            }
            else if (value is CSSValueList)
            {
                var list       = (CSSValueList)value;
                var index      = 0;
                var startGroup = new List <CSSProperty>(4);
                var style      = new CSSFontStyleProperty();
                var variant    = new CSSFontVariantProperty();
                var weight     = new CSSFontWeightProperty();
                var stretch    = new CSSFontStretchProperty();
                var size       = new CSSFontSizeProperty();
                var height     = new CSSLineHeightProperty();
                var family     = new CSSFontFamilyProperty();
                startGroup.Add(style);
                startGroup.Add(variant);
                startGroup.Add(weight);
                startGroup.Add(stretch);

                while (true)
                {
                    var length = startGroup.Count;

                    for (int i = 0; i < length; i++)
                    {
                        if (CheckSingleProperty(startGroup[i], index, list))
                        {
                            startGroup.RemoveAt(i);
                            index++;
                            break;
                        }
                    }

                    if (length == startGroup.Count)
                    {
                        break;
                    }
                }

                startGroup.Clear();

                if (!CheckSingleProperty(size, index, list) || ++index == list.Length)
                {
                    return(false);
                }

                if (list[index] == CSSValue.Delimiter && (!CheckSingleProperty(height, ++index, list) || ++index == list.Length))
                {
                    return(false);
                }

                if (!CheckLastProperty(family, index, list))
                {
                    return(false);
                }

                _style   = style;
                _variant = variant;
                _weight  = weight;
                _stretch = stretch;
                _size    = size;
                _height  = height;
                _family  = family;
            }
            else if (value != CSSValue.Inherit)
            {
                return(false);
            }

            return(true);
        }