示例#1
0
        void ContentClick(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("On Content Click.");

            SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
            //遍历所有选项卡
            foreach (SHDocVw.InternetExplorer Browser in shellWindows)
            {
                if (Browser.LocationURL.Contains("www.baidu.com"))
                {
                    MSHTML.IHTMLDocument2         doc2   = (MSHTML.IHTMLDocument2)Browser.Document;
                    MSHTML.IHTMLElementCollection inputs = (MSHTML.IHTMLElementCollection)doc2.all.tags("INPUT");
                    MSHTML.HTMLInputElement       input1 = (MSHTML.HTMLInputElement)inputs.item("kw", 0);
                    input1.value = "刘德华";
                    MSHTML.IHTMLElement element2 = (MSHTML.IHTMLElement)inputs.item("su", 0);
                    element2.click();
                }
            }
        }
示例#2
0
        private void LoadCompleted(object sender, NavigationEventArgs args)
        {
            IsLoading = false;

            AdjustResizableContent((int)Math.Round(_webView.ActualHeight));

            Uri    newUri = args.Uri;
            string newStoreHost;

            if ("file".Equals(newUri.Scheme, StringComparison.CurrentCultureIgnoreCase))
            {
                newStoreHost = "file";
            }
            else
            {
                newStoreHost = newUri.Host;
            }

            if (StoreHost == null)
            {
                StoreHost = newStoreHost;
                if (DidLoadStore != null)
                {
                    DidLoadStore(this, new DidLoadStoreEventArgs(newUri));
                }
            }
            else
            {
                PageType newPageType;
                if (newStoreHost.Equals(StoreHost, StringComparison.CurrentCultureIgnoreCase))
                {
                    newPageType = PageType.FS;
                }
                else if (newStoreHost.EndsWith("paypal.com"))
                {
                    newPageType = PageType.PayPal;
                }
                else
                {
                    newPageType = PageType.Unknown;
                }
                if (DidLoadPage != null)
                {
                    DidLoadPage(this, new DidLoadPageEventArgs(newUri, newPageType));
                }
            }

            string aMimetype;

            try {
                MSHTML.IHTMLDocument2 doc = (MSHTML.IHTMLDocument2)_webView.Document;
                aMimetype = doc.mimeType;
            } catch (Exception e1) {
                try {
                    aMimetype = ((HTMLDocument)_webView.Document).mimeType;
                } catch (Exception e2) {
                    // The document has no valid mime type, so it's likely a PayPal page. No problem.
                    aMimetype = "Undefined";
                }
            }

            if (aMimetype.ToLower().IndexOf("xml") > -1)
            {
                string data = ((HTMLDocument)_webView.Document).documentElement.innerText;

                data = data.Replace("<!DOCTYPE plist (View Source for full doctype...)>", "");
                data = data.Replace("\r\n-", "");
                data = data.Substring(data.IndexOf("<?xml version="));

                Order order = Order.Parse(data);
                if (DidReceiveOrder != null)
                {
                    DidReceiveOrder(this, new DidReceiveOrderEventArgs(order));
                }
            }
        }