コード例 #1
0
        internal static void GetElementPropertiesFromCssAttributes(XmlElement htmlElement, string elementName, CssStylesheet stylesheet, Hashtable localProperties, List <XmlElement> sourceContext)
        {
            string style     = stylesheet.GetStyle(elementName, sourceContext);
            string attribute = HtmlToXamlConverter.GetAttribute(htmlElement, "style");
            string text      = (style != null) ? style : null;

            if (attribute != null)
            {
                text = ((text == null) ? attribute : (text + ";" + attribute));
            }
            if (text != null)
            {
                string[] array = text.Split(new char[]
                {
                    ';'
                });
                for (int i = 0; i < array.Length; i++)
                {
                    string[] array2 = array[i].Split(new char[]
                    {
                        ':'
                    });
                    if (array2.Length == 2)
                    {
                        string text2      = array2[0].Trim().ToLower();
                        string text3      = array2[1].Trim();
                        string styleValue = text3.ToLower();
                        int    num        = 0;
                        string key;
                        switch (key = text2)
                        {
                        case "font":
                            HtmlCssParser.ParseCssFont(text3, localProperties);
                            break;

                        case "font-family":
                            HtmlCssParser.ParseCssFontFamily(text3, ref num, localProperties);
                            break;

                        case "font-size":
                            HtmlCssParser.ParseCssSize(styleValue, ref num, localProperties, "font-size", true);
                            break;

                        case "font-style":
                            HtmlCssParser.ParseCssFontStyle(styleValue, ref num, localProperties);
                            break;

                        case "font-weight":
                            HtmlCssParser.ParseCssFontWeight(styleValue, ref num, localProperties);
                            break;

                        case "font-variant":
                            HtmlCssParser.ParseCssFontVariant(styleValue, ref num, localProperties);
                            break;

                        case "line-height":
                            HtmlCssParser.ParseCssSize(styleValue, ref num, localProperties, "line-height", true);
                            break;

                        case "color":
                            HtmlCssParser.ParseCssColor(styleValue, ref num, localProperties, "color");
                            break;

                        case "text-decoration":
                            HtmlCssParser.ParseCssTextDecoration(styleValue, ref num, localProperties);
                            break;

                        case "text-transform":
                            HtmlCssParser.ParseCssTextTransform(styleValue, ref num, localProperties);
                            break;

                        case "background-color":
                            HtmlCssParser.ParseCssColor(styleValue, ref num, localProperties, "background-color");
                            break;

                        case "background":
                            HtmlCssParser.ParseCssColor(styleValue, ref num, localProperties, "background-color");
                            break;

                        case "text-align":
                            HtmlCssParser.ParseCssTextAlign(styleValue, ref num, localProperties);
                            break;

                        case "vertical-align":
                            HtmlCssParser.ParseCssVerticalAlign(styleValue, ref num, localProperties);
                            break;

                        case "text-indent":
                            HtmlCssParser.ParseCssSize(styleValue, ref num, localProperties, "text-indent", false);
                            break;

                        case "width":
                        case "height":
                            HtmlCssParser.ParseCssSize(styleValue, ref num, localProperties, text2, true);
                            break;

                        case "margin":
                            HtmlCssParser.ParseCssRectangleProperty(styleValue, ref num, localProperties, text2);
                            break;

                        case "margin-top":
                        case "margin-right":
                        case "margin-bottom":
                        case "margin-left":
                            HtmlCssParser.ParseCssSize(styleValue, ref num, localProperties, text2, true);
                            break;

                        case "padding":
                            HtmlCssParser.ParseCssRectangleProperty(styleValue, ref num, localProperties, text2);
                            break;

                        case "padding-top":
                        case "padding-right":
                        case "padding-bottom":
                        case "padding-left":
                            HtmlCssParser.ParseCssSize(styleValue, ref num, localProperties, text2, true);
                            break;

                        case "border":
                            HtmlCssParser.ParseCssBorder(styleValue, ref num, localProperties);
                            break;

                        case "border-style":
                        case "border-width":
                        case "border-color":
                            HtmlCssParser.ParseCssRectangleProperty(styleValue, ref num, localProperties, text2);
                            break;

                        case "border-top":
                        case "border-right":
                        case "border-left":
                        case "border-bottom":
                            HtmlCssParser.ParseCssRectangleSideProperty(styleValue, ref num, localProperties, text2);
                            break;

                        case "float":
                            HtmlCssParser.ParseCssFloat(styleValue, ref num, localProperties);
                            break;

                        case "clear":
                            HtmlCssParser.ParseCssClear(styleValue, ref num, localProperties);
                            break;
                        }
                    }
                }
            }
        }