Esempio n. 1
0
        public override string ToString()
        {
            string retVal = "";

            foreach (HtmlTagNode subnode in this)
            {
                retVal += HtmlTagTree.printNode(0, subnode);
            }

            return(retVal);
        }
Esempio n. 2
0
        private void Parse(string html)
        {
            Inlines.Clear();
            if (html == null)
            {
                return;
            }
            HtmlTagTree tree   = new HtmlTagTree();
            HtmlParser  parser = new HtmlParser(tree);   //output

            parser.Parse(new StringReader(html));        //input

            HtmlUpdater updater = new HtmlUpdater(this); //output

            updater.Update(tree);
        }
Esempio n. 3
0
        public void Update(HtmlTagTree tagTree)
        {
            List <HtmlTag> tagList = tagTree.ToHtmlTagList();

            foreach (HtmlTag tag in tagList)
            {
                if (tag.ID != -1)
                {
                    switch (Defines.BuiltinTags[tag.ID].flags)
                    {
                    case HTMLFlag.TextFormat: UpdateStyle(tag); break;

                    case HTMLFlag.Element: textBlock.Inlines.Add(UpdateElement(tag)); break;
                    }
                }
            }
        }
Esempio n. 4
0
        private static string printNode(Int32 level, HtmlTagNode node)
        {
            string spacing = " ";
            string retVal  = "";

            for (int i = 0; i < level; i++)
            {
                spacing += "  ";
            }

            retVal += spacing + node.ToString() + '\r' + '\n';

            foreach (HtmlTagNode subnode in node)
            {
                retVal += HtmlTagTree.printNode(level + 1, subnode);
            }

            return(retVal);
        }
Esempio n. 5
0
        private void Parse(string html)
        {
            if (!String.IsNullOrEmpty(Highlight))
            {
                int idx = html.IndexOf(Highlight, StringComparison.InvariantCultureIgnoreCase);
                while (idx != -1)
                {
                    html = String.Format("{0}[b]{1}[/b]{2}",
                                         html.Substring(0, idx), html.Substring(idx, Highlight.Length), html.Substring(idx + Highlight.Length));
                    idx = html.IndexOf(Highlight, idx + 7 + Highlight.Length, StringComparison.InvariantCultureIgnoreCase);
                }
            }

            Inlines.Clear();
            HtmlTagTree tree   = new HtmlTagTree();
            HtmlParser  parser = new HtmlParser(tree);   //output

            parser.Parse(new StringReader(html));        //input

            HtmlUpdater updater = new HtmlUpdater(this); //output

            updater.Update(tree);
        }
Esempio n. 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 public HtmlParser(HtmlTagTree aTree)
 {
     tree = aTree;
 }