示例#1
0
        private void Parse(string html)
        {
            Inlines.Clear();
            //html = HtmlToXamlConverter.ConvertHtmlToXaml(html, false);
            //try
            //{
            //    TextRange tr = new TextRange(ContentStart, ContentEnd);
            //    using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(html)))
            //    {
            //        tr.Load(ms, DataFormats.Xaml);
            //    }
            //}
            //catch
            //{
            //    throw new InvalidDataException("data provided is not in the correct Html format.");
            //}
            HtmlTagTree tree   = new HtmlTagTree();
            HtmlParser1 parser = new HtmlParser1(tree);  //output

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

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

            updater.Update(tree);
        }
示例#2
0
        private void Parse(string html)
        {
            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);
        }
示例#3
0
        public static void OnHtmlChanged(DependencyObject s, DependencyPropertyChangedEventArgs e)
        {
            HtmlTextBlock sender = (HtmlTextBlock)s;

            sender.Inlines.Clear();


            HtmlTagTree tree   = new HtmlTagTree();
            HtmlParser  parser = new HtmlParser(tree);            //output

            parser.Parse(new StringReader(e.NewValue as string)); //input

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

            updater.Update(tree);                                 //input
        }
示例#4
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();
            HtmlParser1 parser = new HtmlParser1(tree);  //output

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

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

            updater.Update(tree);
        }