private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            MessageBox.Show("Loaded!");

            string testHtml = @"
                    <html>
                        <head>
                            <script type=""text/javascript"">
                                var a=2;var b=3;
                                document.write(a+""_""+b);
                            </script>
                        </head>
                        <body>Hello there!</body>
                    </html>";


            mshtml.IHTMLDocument2 htmlDoc = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;     // IHTMLDocument2 has the write capability (IHTMLDocument3 does not)
            htmlDoc.close();
            htmlDoc.open("about:blank");

            object html = testHtml;

            htmlDoc.write(html);
            html = null;
        }
        public clsSnoTelStateTable(string url)
        {
            URL = url;

            WebClient client = new WebClient();

            byte[] data = client.DownloadData(URL);
            mshtml.HTMLDocumentClass Doc = new mshtml.HTMLDocumentClass();
            string sHtml = System.Text.Encoding.ASCII.GetString(data);

            mshtml.IHTMLDocument2 oDoc = (mshtml.IHTMLDocument2)Doc;
            oDoc.write(sHtml);

            bool tableFound = false;

            foreach (mshtml.IHTMLElement element in (mshtml.IHTMLElementCollection)oDoc.body.all)
            {
                if (element is mshtml.HTMLPhraseElement && element.innerText == "Status")
                {
                    tableFound = true;
                }
                else if (element is mshtml.HTMLTableClass && tableFound && element.innerText.Contains("Site Map"))
                {
                    tableFound = false;
                }
                else if (element is mshtml.HTMLTableRowClass && tableFound)
                {
                    Records.Add(new SnoTelRecord((mshtml.HTMLTableRowClass)element, Records.Count));
                }
            }
        }
        public string HTT(string HTML)
        {
            //using microsoft.mshtml
            mshtml.HTMLDocument   htmldoc  = new mshtml.HTMLDocument();
            mshtml.IHTMLDocument2 htmldoc2 = (mshtml.IHTMLDocument2)htmldoc;
            htmldoc2.write(new object[] { HTML });

            string txt = htmldoc2.body.outerText;

            return(txt);
        }
示例#4
0
        private void File_Print(object sender, RoutedEventArgs e)
        {
            string printContents;

            printContents = ViewModel.GetPrintContents();

            mshtml.IHTMLDocument2 doc = webBrowser1.Document as mshtml.IHTMLDocument2;
            doc.clear();
            doc.write(printContents);
            doc.execCommand("Print", true, 0);
            doc.close();
        }
示例#5
0
        private void File_PrintPreview(object sender, RoutedEventArgs e)
        {
            string printContents;

            printContents = ViewModel.GetPrintContents();

            mshtml.IHTMLDocument2 doc = webBrowser1.Document as mshtml.IHTMLDocument2;
            doc.clear();
            doc.write(printContents);
            doc.close();

            ViewModel.SetPrintControlsVisibility(true);
        }
示例#6
0
        public clsSnoTelStateList(string url)
        {
            URL = url;

            WebClient client = new WebClient();

            byte[] data = client.DownloadData(URL);
            mshtml.HTMLDocumentClass Doc = new mshtml.HTMLDocumentClass();
            string sHtml = System.Text.Encoding.ASCII.GetString(data);

            mshtml.IHTMLDocument2 oDoc = (mshtml.IHTMLDocument2)Doc;
            oDoc.write(sHtml);

            bool tableFound = false;

            foreach (mshtml.IHTMLElement element in (mshtml.IHTMLElementCollection)oDoc.body.all)
            {
                //if(element is mshtml.HTMLTableCellClass && element.innerText.Contains("SNOTEL Site List")) { tableFound=true;}
                if (element is mshtml.HTMLPhraseElement && element.innerText == "SNOTEL Site List")
                {
                    tableFound = true;
                }
                //if (element is mshtml.HTMLHeaderElementClass && element.innerText=="SNOTEL Site List") { tableFound = true; }
                else if (element is mshtml.HTMLTableClass && tableFound && element.innerText.Contains("Site Map"))
                {
                    tableFound = false;
                }
                else if (element is mshtml.HTMLParaElementClass && tableFound)
                {
                    if (!element.innerText.Contains("Please select"))
                    {
                        stateList.Add(new SnoTelState(element.innerText, element.innerHTML));
                    }
                }
            }
        }
示例#7
0
 public HTMLParser(string text)
 {
     mshtml.IHTMLDocument2 htmldoc2 = _document as mshtml.IHTMLDocument2;
     htmldoc2.write(new object[] { text });
 }
 public CHtmlPraseDemo(string url)
 {
     GetWebContent(url);
     oHtmlDoc = (IHTMLDocument2) new HTMLDocument();
     oHtmlDoc.write(strHtmlSource);
 }