Example #1
0
        public static EdgeValues GetBorderWidths(Dictionary <string, List <Value> > specifiedValues)
        {
            var properties = specifiedValues.Keys.ToList();

            var borderWidths = new EdgeValues(new List <Value>(0));

            // Assign from specified shorthand property
            var borderWidthShorthand = Property.GetValues(specifiedValues, "border-width");

            if (borderWidthShorthand != null && borderWidthShorthand.TrueForAll(v => v is Length))
            {
                borderWidths = new EdgeValues(borderWidthShorthand);
            }

            // Overwrite with any subsequently specified specific borderWidths
            var borderWidthTop = Property.GetValue(specifiedValues, "border-top-width");

            if (borderWidthTop != null && properties.IndexOf("border-top-width") > properties.IndexOf("border-width"))
            {
                borderWidths.Top = borderWidthTop;
            }

            var borderWidthRight = Property.GetValue(specifiedValues, "border-right-width");

            if (borderWidthRight != null && properties.IndexOf("border-right-width") > properties.IndexOf("border-width"))
            {
                borderWidths.Right = borderWidthRight;
            }

            var borderWidthBottom = Property.GetValue(specifiedValues, "border-bottom-width");

            if (borderWidthBottom != null && properties.IndexOf("border-bottom-width") > properties.IndexOf("border-width"))
            {
                borderWidths.Bottom = borderWidthBottom;
            }

            var borderWidthLeft = Property.GetValue(specifiedValues, "border-left-width");

            if (borderWidthLeft != null && properties.IndexOf("border-left-width") > properties.IndexOf("border-width"))
            {
                borderWidths.Left = borderWidthLeft;
            }

            return(borderWidths);
        }
Example #2
0
        public static EdgeValues GetPaddings(Dictionary <string, List <Value> > specifiedValues)
        {
            var properties = specifiedValues.Keys.ToList();

            var paddings = new EdgeValues(new List <Value>(0));

            // Assign from specified shorthand property
            var paddingShorthand = Property.GetValues(specifiedValues, "padding");

            if (paddingShorthand != null && paddingShorthand.TrueForAll(v => v is Length))
            {
                paddings = new EdgeValues(paddingShorthand);
            }

            // Overwrite with any subsequently specified specific paddings
            var paddingTop = Property.GetValue(specifiedValues, "padding-top");

            if (paddingTop != null && properties.IndexOf("padding-top") > properties.IndexOf("padding"))
            {
                paddings.Top = paddingTop;
            }

            var paddingRight = Property.GetValue(specifiedValues, "padding-right");

            if (paddingRight != null && properties.IndexOf("padding-right") > properties.IndexOf("padding"))
            {
                paddings.Right = paddingRight;
            }

            var paddingBottom = Property.GetValue(specifiedValues, "padding-bottom");

            if (paddingBottom != null && properties.IndexOf("padding-bottom") > properties.IndexOf("padding"))
            {
                paddings.Bottom = paddingBottom;
            }

            var paddingLeft = Property.GetValue(specifiedValues, "padding-left");

            if (paddingLeft != null && properties.IndexOf("padding-left") > properties.IndexOf("padding"))
            {
                paddings.Left = paddingLeft;
            }

            return(paddings);
        }
Example #3
0
        public static EdgeValues GetMargins(Dictionary <string, List <Value> > specifiedValues)
        {
            var properties = specifiedValues.Keys.ToList();

            var margins = new EdgeValues(new List <Value>(0));

            // Assign from specified shorthand property
            var marginShorthand = Property.GetValues(specifiedValues, "margin");

            if (marginShorthand != null && marginShorthand.TrueForAll(v => v is Length))
            {
                margins = new EdgeValues(marginShorthand);
            }

            // Overwrite with any subsequently specified specific margins
            var marginTop = Property.GetValue(specifiedValues, "margin-top");

            if (marginTop != null && properties.IndexOf("margin-top") > properties.IndexOf("margin"))
            {
                margins.Top = marginTop;
            }

            var marginRight = Property.GetValue(specifiedValues, "margin-right");

            if (marginRight != null && properties.IndexOf("margin-right") > properties.IndexOf("margin"))
            {
                margins.Right = marginRight;
            }

            var marginBottom = Property.GetValue(specifiedValues, "margin-bottom");

            if (marginBottom != null && properties.IndexOf("margin-bottom") > properties.IndexOf("margin"))
            {
                margins.Bottom = marginBottom;
            }

            var marginLeft = Property.GetValue(specifiedValues, "margin-left");

            if (marginLeft != null && properties.IndexOf("margin-left") > properties.IndexOf("margin"))
            {
                margins.Left = marginLeft;
            }

            return(margins);
        }