コード例 #1
0
ファイル: CssParser.cs プロジェクト: rajeshwarn/Creek
 /// <summary>
 /// Parse color property to add only valid color.
 /// </summary>
 /// <param name="propName">the name of the css property to add</param>
 /// <param name="propValue">the value of the css property to add</param>
 /// <param name="properties">the properties collection to add to</param>
 private static void ParseColorProperty(string propName, string propValue, Dictionary <string, string> properties)
 {
     if (CssValueParser.IsColorValid(propValue))
     {
         properties[propName] = propValue;
     }
 }
コード例 #2
0
ファイル: CssParser.cs プロジェクト: rajeshwarn/Creek
 /// <summary>
 /// Parse length property to add only valid lengths.
 /// </summary>
 /// <param name="propName">the name of the css property to add</param>
 /// <param name="propValue">the value of the css property to add</param>
 /// <param name="properties">the properties collection to add to</param>
 private static void ParseLengthProperty(string propName, string propValue, Dictionary <string, string> properties)
 {
     if (CssValueParser.IsValidLength(propValue) ||
         propValue.Equals(CssConstants.Auto, StringComparison.OrdinalIgnoreCase))
     {
         properties[propName] = propValue;
     }
 }
コード例 #3
0
ファイル: CssParser.cs プロジェクト: rajeshwarn/Creek
        /// <summary>
        /// Parse a complex border property value that contains multiple css properties into specific css properties.
        /// </summary>
        /// <param name="propValue">the value of the property to parse to specific values</param>
        /// <param name="direction">the left, top, right or bottom direction of the border to parse</param>
        /// <param name="properties">the properties collection to add the specific properties to</param>
        private static void ParseBorderProperty(string propValue, string direction,
                                                Dictionary <string, string> properties)
        {
            string borderWidth;
            string borderStyle;
            string borderColor;

            CssValueParser.ParseBorder(propValue, out borderWidth, out borderStyle, out borderColor);

            if (direction != null)
            {
                if (borderWidth != null)
                {
                    properties["border" + direction + "-width"] = borderWidth;
                }
                if (borderStyle != null)
                {
                    properties["border" + direction + "-style"] = borderStyle;
                }
                if (borderColor != null)
                {
                    properties["border" + direction + "-color"] = borderColor;
                }
            }
            else
            {
                if (borderWidth != null)
                {
                    ParseBorderWidthProperty(borderWidth, properties);
                }
                if (borderStyle != null)
                {
                    ParseBorderStyleProperty(borderStyle, properties);
                }
                if (borderColor != null)
                {
                    ParseBorderColorProperty(borderColor, properties);
                }
            }
        }
コード例 #4
0
ファイル: DomParser.cs プロジェクト: rajeshwarn/Creek
        /// <summary>
        /// Set the selected text style (selection text color and background color).
        /// </summary>
        /// <param name="htmlContainer"> </param>
        /// <param name="cssData">the style data</param>
        private static void SetTextSelectionStyle(HtmlContainer htmlContainer, CssData cssData)
        {
            htmlContainer.SelectionForeColor = Color.Empty;
            htmlContainer.SelectionBackColor = Color.Empty;

            if (cssData.ContainsCssBlock("::selection"))
            {
                IEnumerable <CssBlock> blocks = cssData.GetCssBlock("::selection");
                foreach (CssBlock block in blocks)
                {
                    if (block.Properties.ContainsKey("color"))
                    {
                        htmlContainer.SelectionForeColor = CssValueParser.GetActualColor(block.Properties["color"]);
                    }
                    if (block.Properties.ContainsKey("background-color"))
                    {
                        htmlContainer.SelectionBackColor =
                            CssValueParser.GetActualColor(block.Properties["background-color"]);
                    }
                }
            }
        }