Exemple #1
0
        public void PrintItems()
        {
            for (Int32 i = 0; i < Count; i++)
            {
                CssStyleType       c     = this[i];
                CssHeaderStyleType style = new CssHeaderStyleType(c.styleTagName);
                style.PrintItems();

                for (Int32 j = 0; j < c.styles.Count; j++)
                {
                    string output = String.Format("[key: {0} = {1}]",
                                                  c.styles[j].key, c.styles[j].value);
                    Console.WriteLine(output);
                }
                Console.WriteLine("");
            }
        }
Exemple #2
0
        public CssHeaderStyleType(string header)
        {
            elements       = ElementType.Unknown;
            familyTag      = false;
            noOtherClassID = false;
            tagID          = "";
            tagClass       = "";

            string k = header;

            char lastChar = k[k.Length - 1];

            switch (lastChar)
            {
            case '+':
                familyTag = true;
                k         = k.Substring(0, k.Length - 1);
                break;

            case '>':
                noOtherClassID = true;
                k = k.Substring(0, k.Length - 1);
                break;
            }

            if (k.IndexOf('#') > -1)
            {
                tagID = Utils.ExtractAfter(ref k, '#');
            }
            if (k.IndexOf('.') > -1)
            {
                tagClass = Utils.ExtractAfter(ref k, '.');
            }
            if (k.IndexOf(':') > -1)
            {
                elements = CssHeaderStyleType.ElementsToCssElementType(
                    Utils.ExtractAfter(ref k, ':'));
            }
            tagName = k;
            if (tagName.Trim() == "")
            {
                tagName = UnspecifiedTagName;
            }
        }
Exemple #3
0
        public string Css()
        {
            string retVal = "";

            for (Int32 i = 0; i < Count; i++)
            {
                CssStyleType       c     = this[i];
                CssHeaderStyleType style = new CssHeaderStyleType(c.styleTagName);
                retVal += style.Css() + "{ ";

                for (Int32 j = 0; j < c.styles.Count; j++)
                {
                    retVal += c.styles[j].key + ":" + c.styles[j].value + ";";
                }

                retVal += " }" + Defines.lineBreak;
            }
            return(retVal);
        }
Exemple #4
0
 private static bool matchHeader(HtmlTag input, CssHeaderStyleType chs)
 {
     return (((chs.tagName == CssHeaderStyleType.UnspecifiedTagName) ||
               (input.Name == chs.tagName)) &&
               ((chs.tagClass == "") || (chs.tagClass == input["class"])) &&
               ((chs.tagID == "") || (chs.tagID == input["id"])));
 }
Exemple #5
0
 private static bool haveOtherClassID(HtmlTag input, CssHeaderStyleType chs)
 {
     bool retVal = false;
     if ((chs.tagClass != "") && (input["class"] != ""))
         retVal = (chs.tagClass == input["class"]);
     if ((chs.tagID != "") && (input["id"] != ""))
         retVal = (chs.tagID == input["id"]);
     return retVal;
 }
Exemple #6
0
        //        /// <summary>
        //        /// Loop and check if currenTag matched the list ParentTagNames
        //        /// </summary>
        //        internal static bool MatchParentTags(HtmlTag currentTag, ArrayList parentTagNames)
        //        {
        //            if (parentTagNames == null) return false;
        //            
        //            HtmlTag tempTag;
        //            for (Int32 i = parentTagNames.Count -1; i >= 0; i--)
        //                if (!(Utils.MatchParentTag(currentTag, (string)parentTagNames[i], out tempTag)))
        //                    return false;
        //            
        //            return true;
        //        }
        /// <summary>
        /// Check if currentTag matches the header
        /// </summary>
        internal static bool MatchCurrentTag(HtmlTag currentTag, string header)
        {
            CssHeaderStyleType chs = new CssHeaderStyleType(header);
            bool retVal = true;//((chs.tagClass == "") && (chs.tagID == ""));

            retVal = retVal && ((chs.tagClass == "") ||
                                ((currentTag.Contains("class")) &&
                                 (chs.tagClass == currentTag["class"])));
            retVal = retVal && ((chs.tagID == "") ||
                                ((currentTag.Contains("id")) &&
                                                     (chs.tagID == currentTag["id"])));

            return retVal;
        }
Exemple #7
0
        public void PrintItems()
        {
            for (Int32 i = 0; i < Count; i++)
            {
                CssStyleType c = this[i];
                CssHeaderStyleType style = new CssHeaderStyleType(c.styleTagName);
                style.PrintItems();

                for (Int32 j = 0; j < c.styles.Count; j++)
                {
                    string output = String.Format("[key: {0} = {1}]",
                                                  c.styles[j].key, c.styles[j].value);
                    Console.WriteLine(output);
                }
                Console.WriteLine("");
            }
        }
Exemple #8
0
        public string Css()
        {
            string retVal = "";
            for (Int32 i = 0; i < Count; i++)
            {
                CssStyleType c = this[i];
                CssHeaderStyleType style = new CssHeaderStyleType(c.styleTagName);
                retVal += style.Css() + "{ ";

                for (Int32 j = 0; j < c.styles.Count; j++)
                    retVal += c.styles[j].key + ":" + c.styles[j].value + ";";

                retVal += " }" + Defines.lineBreak;
            }
            return retVal;
        }