Exemplo n.º 1
0
        static SizeMode?Check(CSSValue value)
        {
            var distance = value.ToDistance();

            if (distance != null)
            {
                return new SizeMode {
                           Width = distance
                }
            }
            ;
            else if (value.Is(Keywords.Auto))
            {
                return new SizeMode {
                }
            }
            ;
            else if (value.Is(Keywords.Cover))
            {
                return new SizeMode {
                           IsCovered = true
                }
            }
            ;
            else if (value.Is(Keywords.Contain))
            {
                return new SizeMode {
                           IsContained = true
                }
            }
            ;

            return(null);
        }
        static IDistance GetMode(CSSValue value, String minIdentifier, String maxIdentifier)
        {
            var calc = value.ToDistance();

            if (calc == null && value is CSSPrimitiveValue)
            {
                var primitive = (CSSPrimitiveValue)value;

                if (primitive.Unit == UnitType.Ident)
                {
                    var ident = primitive.GetString();

                    if (ident.Equals(minIdentifier, StringComparison.OrdinalIgnoreCase))
                    {
                        calc = Percent.Zero;
                    }
                    else if (ident.Equals(maxIdentifier, StringComparison.OrdinalIgnoreCase))
                    {
                        calc = Percent.Hundred;
                    }
                    else if (ident.Equals(Keywords.Center, StringComparison.OrdinalIgnoreCase))
                    {
                        calc = Percent.Fifty;
                    }
                }
            }

            return(calc);
        }
        static IDistance GetMode(CSSValue value, String minIdentifier, String maxIdentifier)
        {
            var calc = value.ToDistance();

            if (calc == null)
            {
                var ident = value.ToIdentifier();

                if (ident != null)
                {
                    if (ident.Equals(minIdentifier, StringComparison.OrdinalIgnoreCase))
                    {
                        calc = Percent.Zero;
                    }
                    else if (ident.Equals(maxIdentifier, StringComparison.OrdinalIgnoreCase))
                    {
                        calc = Percent.Hundred;
                    }
                    else if (ident.Equals(Keywords.Center, StringComparison.OrdinalIgnoreCase))
                    {
                        calc = Percent.Fifty;
                    }
                }
            }

            return(calc);
        }
        Boolean SetSingle(CSSValue value)
        {
            var calc = value.ToDistance();

            if (calc != null)
            {
                _x = calc;
                _y = calc;
                return(true);
            }

            var ident = value.ToIdentifier();

            if (ident != null)
            {
                if (ident.Equals(Keywords.Left, StringComparison.OrdinalIgnoreCase))
                {
                    _x = Percent.Zero;
                    _y = Percent.Fifty;
                    _z = Percent.Zero;
                    return(true);
                }
                else if (ident.Equals(Keywords.Center, StringComparison.OrdinalIgnoreCase))
                {
                    _x = Percent.Fifty;
                    _y = Percent.Fifty;
                    _z = Percent.Zero;
                    return(true);
                }
                else if (ident.Equals(Keywords.Right, StringComparison.OrdinalIgnoreCase))
                {
                    _x = Percent.Hundred;
                    _y = Percent.Fifty;
                    _z = Percent.Zero;
                    return(true);
                }
                else if (ident.Equals(Keywords.Top, StringComparison.OrdinalIgnoreCase))
                {
                    _x = Percent.Fifty;
                    _y = Percent.Zero;
                    _z = Percent.Zero;
                    return(true);
                }
                else if (ident.Equals(Keywords.Bottom, StringComparison.OrdinalIgnoreCase))
                {
                    _x = Percent.Fifty;
                    _y = Percent.Hundred;
                    _z = Percent.Zero;
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            var distance = value.ToDistance();

            if (distance != null)
            {
                _padding = distance;
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            var indent = value.ToDistance();

            if (indent != null)
            {
                _indent = indent;
                return(true);
            }

            return(false);
        }
        Boolean SetSingle(CSSValue value)
        {
            var distance = value.ToDistance();

            if (distance != null)
            {
                _x = distance;
                _y = distance;
                return(true);
            }

            var primitive = value as CSSPrimitiveValue;

            if (primitive != null && primitive.Unit == UnitType.Ident)
            {
                var ident = primitive.GetString();

                if (ident.Equals(Keywords.Left, StringComparison.OrdinalIgnoreCase))
                {
                    _x = Percent.Zero;
                    _y = Percent.Fifty;
                    return(true);
                }
                else if (ident.Equals(Keywords.Right, StringComparison.OrdinalIgnoreCase))
                {
                    _x = Percent.Hundred;
                    _y = Percent.Fifty;
                    return(true);
                }
                else if (ident.Equals(Keywords.Center, StringComparison.OrdinalIgnoreCase))
                {
                    _x = Percent.Fifty;
                    _y = Percent.Fifty;
                    return(true);
                }
                else if (ident.Equals(Keywords.Top, StringComparison.OrdinalIgnoreCase))
                {
                    _x = Percent.Fifty;
                    _y = Percent.Zero;
                    return(true);
                }
                else if (ident.Equals(Keywords.Bottom, StringComparison.OrdinalIgnoreCase))
                {
                    _x = Percent.Fifty;
                    _y = Percent.Hundred;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 8
0
        static SizeMode?Check(CSSValue horizontal, CSSValue vertical)
        {
            var width  = horizontal.ToDistance();
            var height = vertical.ToDistance();

            if (width == null && !horizontal.Is(Keywords.Auto))
            {
                return(null);
            }
            else if (height == null && !vertical.Is(Keywords.Auto))
            {
                return(null);
            }

            return(new SizeMode {
                Width = width, Height = height
            });
        }
Exemplo n.º 9
0
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            var distance = value.ToDistance();

            if (distance != null)
            {
                _value = distance;
            }
            else if (value.Is(Keywords.Auto))
            {
                _value = null;
            }
            else
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            var calc = value.ToDistance();

            if (calc != null)
            {
                _top = _bottom = _right = _left = calc;
            }
            else if (value is CSSValueList)
            {
                return(Evaluate((CSSValueList)value));
            }
            else
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            VerticalAlignment mode;
            var distance = value.ToDistance();

            if (distance != null)
            {
                _shift = distance;
                _mode  = VerticalAlignment.Baseline;
            }
            else if (modes.TryGetValue(value, out mode))
            {
                _shift = Percent.Zero;
                _mode  = mode;
            }
            else
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            FontSize?size;
            var      distance = value.ToDistance();

            if (distance != null)
            {
                _size = distance;
                _mode = FontSize.Custom;
            }
            else if ((size = value.ToFontSize()).HasValue)
            {
                var mode = size.Value;
                _size = mode.ToDistance();
                _mode = mode;
            }
            else
            {
                return(false);
            }

            return(true);
        }