예제 #1
0
        protected override Boolean IsValid(CSSValue value)
        {
            if (value == CSSValue.Inherit)
            {
                return(true);
            }

            var values = value as CSSValueList ?? new CSSValueList(value);
            var top    = new CSSBorderTopWidthProperty();
            var bottom = new CSSBorderBottomWidthProperty();
            var right  = new CSSBorderRightWidthProperty();
            var left   = new CSSBorderLeftWidthProperty();

            if (values.Length == 1)
            {
                if (!CheckSingleProperty(top, 0, values))
                {
                    return(false);
                }

                right.Value = left.Value = bottom.Value = top.Value;
            }
            else if (values.Length == 2)
            {
                if (!CheckSingleProperty(top, 0, values) || !CheckSingleProperty(right, 1, values))
                {
                    return(false);
                }

                bottom.Value = top.Value;
                left.Value   = right.Value;
            }
            else if (values.Length == 3)
            {
                if (!CheckSingleProperty(top, 0, values) || !CheckSingleProperty(right, 1, values) || !CheckSingleProperty(bottom, 2, values))
                {
                    return(false);
                }

                left.Value = right.Value;
            }
            else if (values.Length == 4)
            {
                if (!CheckSingleProperty(top, 0, values) || !CheckSingleProperty(right, 1, values) || !CheckSingleProperty(bottom, 2, values) || !CheckSingleProperty(left, 3, values))
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            _top    = top;
            _bottom = bottom;
            _right  = right;
            _left   = left;
            return(true);
        }
예제 #2
0
 internal CSSBorderWidthProperty()
     : base(PropertyNames.BorderWidth)
 {
     _inherited = false;
     _top       = new CSSBorderTopWidthProperty();
     _right     = new CSSBorderRightWidthProperty();
     _bottom    = new CSSBorderBottomWidthProperty();
     _left      = new CSSBorderLeftWidthProperty();
 }