Exemple #1
0
 private void AddToPackages(HtmlElement elem, int packageKey)
 {
     this.dicPackage.Add(elem, packageKey);
     elem.MouseEnter += new HtmlElementEventHandler(this.Package_MouseEnter);
     elem.MouseLeave += new HtmlElementEventHandler(this.Package_MouseLeave);
     elem.Click += new HtmlElementEventHandler(this.Package_Click);
 }
        public override HtmlElement locate(HtmlElement parent)
        {
            HtmlElement ret = null;
            if (null != parent)
            {
                HtmlElement toMatch = null;
                foreach (HtmlElement child in parent.All)
                {
                    toMatch = child;
                    if (null != Filter)
                    {
                        toMatch = Filter.locate(child);
                    }
                    if (null != toMatch)
                    {
                        if (null == Matcher || Matcher.match(toMatch))
                        {
                            ret = toMatch;
                            break;
                        }
                    }

                }
            }
            return ret;
        }
Exemple #3
0
 private void AddToContents(HtmlElement elem, int contentKey)
 {
     this.dicContent.Add(elem, contentKey);
     elem.Click += new HtmlElementEventHandler(this.Content_Click);
     elem.MouseEnter += new HtmlElementEventHandler(this.Content_MouseEnter);
     elem.MouseLeave += new HtmlElementEventHandler(this.Content_MouseLeave);
 }
Exemple #4
0
 public TreeNodeEx(HtmlElement htmlElement)
     : base()
 {
     this.htmlElement = htmlElement;
     this.Text = htmlElement.TagName;
     this.PrepareChildrenNodes();
 }
Exemple #5
0
        void SecondNavigation(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            string value = string.Empty;

            System.Windows.Forms.HtmlElement resultTable1 = ieBrowser.Document.GetElementById("nav-typeahead-wormhole");

            System.Windows.Forms.HtmlElement resultTable = ieBrowser.Document.GetElementById("block-system-main");

            if (resultTable != null)
            {
                HtmlElementCollection input1 = resultTable.GetElementsByTagName("DIV");



                foreach (System.Windows.Forms.HtmlElement input2 in input1)
                {
                    if (input2.GetAttribute("class") == "information")
                    {
                        System.Windows.Forms.HtmlElement mainelement = input2;
                    }
                }
            }
            else
            {
                value = "Not Found";
            }

            Details = value;

            this.resultEvent.Set();
        }
Exemple #6
0
 public void Click(HtmlElement h)
 {
     Focus(h);
     Over(h);
     Down(h);
     h.InvokeMember("click");
 }
        public static HtmlInputElement GetInputElement(HtmlElement element)
        {
            if (!element.TagName.Equals("input", StringComparison.OrdinalIgnoreCase))
            {
                return null;
            }

            HtmlInputElement input = null;

            string type = element.GetAttribute("type").ToLower();

            switch (type)
            {
                case "checkbox":
                    input = new HtmlCheckBox(element);
                    break;
                case "password":
                    input = new HtmlPassword(element);
                    break;
                case "submit":
                    input = new HtmlSubmit(element);
                    break;
                case "text":
                    input = new HtmlText(element);
                    break;
                default:
                    break;

            }
            return input;
        }
Exemple #8
0
            public static List<TRow> Convert(HtmlElement table) {
                List<TRow> alRow = new List<TRow>();

                foreach (HtmlElement el in table.Children) {
                    if (String.Compare(el.TagName, "thead", true) == 0) {
                        foreach (HtmlElement elChild in el.Children) {
                            if (String.Compare(elChild.TagName, "tr", true) == 0) {
                                ReadTr(alRow, TRowType.Head, elChild);
                            }
                        }
                    }
                    if (String.Compare(el.TagName, "tfoot", true) == 0) {
                        foreach (HtmlElement elChild in el.Children) {
                            if (String.Compare(elChild.TagName, "tr", true) == 0) {
                                ReadTr(alRow, TRowType.Tail, elChild);
                            }
                        }
                    }
                    else if (String.Compare(el.TagName, "tbody", true) == 0) {
                        foreach (HtmlElement elChild in el.Children) {
                            if (String.Compare(elChild.TagName, "tr", true) == 0) {
                                ReadTr(alRow, TRowType.None, elChild);
                            }
                        }
                    }
                    else if (String.Compare(el.TagName, "tr", true) == 0) {
                        ReadTr(alRow, TRowType.None, el);
                    }
                }
                return alRow;
            }
Exemple #9
0
        private void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            WebBrowser myBrowser = (WebBrowser)sender;

            System.Windows.Forms.HtmlElement html = myBrowser.Document.CreateElement("div");
            html.InnerHtml += "<a id=\"popLink\" href=\"\" target=\"_blank\" style=\"display:none;\"></a>";
            myBrowser.Document.Body.AppendChild(html);

            string jsHtml = "";

            jsHtml += "window.open=function(url, title, prop)  ";
            jsHtml += "{";
            jsHtml += "obj = document.getElementById('popLink');  ";
            jsHtml += "obj.style.display='block';  ";
            jsHtml += "obj.href=url;  ";
            jsHtml += "obj.focus();  ";
            jsHtml += "obj.click();  ";
            jsHtml += "obj.style.display='none'  ";
            jsHtml += "} ";
            mshtml.IHTMLDocument2 doc = myBrowser.Document.DomDocument as mshtml.IHTMLDocument2;
            mshtml.IHTMLWindow2   win = doc.parentWindow as mshtml.IHTMLWindow2;
            win.execScript(jsHtml, "javascript");
            if (tctlControl.SelectedTabPage.Text == "")
            {
                tctlControl.SelectedTabPage.Text = "加载失败";
            }
        }
        private void AttachContextMenu(HtmlElement he)
        {
            if (he.TagName.Equals(TagNames.BodyTagName))
            {
                if (bodyContextMenu == null)
                {
                    InitializeBodyContextMenu();
                }
            }

            if (he.TagName.Equals(TagNames.AnchorTagName))
            {
                if (!he.GetAttribute("href").Equals(string.Empty))
                {
                    if (linkContextMenu == null)
                    {
                        InitializeLinkContextMenu();
                    }
                }
            }

            if (he.TagName.Equals(TagNames.ImageTagName))
            {
                if (!he.GetAttribute("longdesc").Equals(string.Empty))
                {
                    InitializeEquationContextMenu();
                }
            }
        }
Exemple #11
0
 public static void SetElementValue(HtmlElement htmlElement, string value)
 {
     if (htmlElement != null)
     {
         htmlElement.SetAttribute("value", value);
     }
 }
Exemple #12
0
        public IList<HistoryInfo> GetHistoryFromTable(HtmlElement table)
        {
            IList<HistoryInfo> result = new List<HistoryInfo>();
            if (table == null)
            {
                throw new ArgumentException();
            }

            HtmlElementCollection rows = table.GetElementsByTagName("tr");
            if (rows == null || rows.Count == 0)
            {
                return result;
            }

            ///The 1st row are columns' name
            for (int i = 1; i < rows.Count; i++)
            {
                HtmlElement currentRow = rows[i];
                HistoryInfo item = GetItemFromRow(currentRow);
                if (item != null)
                    result.Add(item);
            }

            return result;
        }
 public HtmlElementCollection GetElementsByName(string name)
 {
     int count = this.Count;
     HtmlElement[] elementArray = new HtmlElement[count];
     int index = 0;
     for (int i = 0; i < count; i++)
     {
         HtmlElement element = this[i];
         if (element.GetAttribute("name") == name)
         {
             elementArray[index] = element;
             index++;
         }
     }
     if (index == 0)
     {
         return new HtmlElementCollection(this.shimManager);
     }
     HtmlElement[] array = new HtmlElement[index];
     for (int j = 0; j < index; j++)
     {
         array[j] = elementArray[j];
     }
     return new HtmlElementCollection(this.shimManager, array);
 }
Exemple #14
0
 public HtmlCheckBox(HtmlElement element)
     : base(element.Id)
 {
     // 如果checkbox的有属性是“checked”它将被检查。
     string chekced = element.GetAttribute("checked");
     Checked = !string.IsNullOrEmpty(chekced);
 }
        public HtmlElement FindChildWithId(HtmlElement htmlElement, string idToFind)
        {
            if (htmlElement.Id != null && htmlElement.Id.Equals(idToFind))
            {
                return htmlElement;
            }

            HtmlElement returnHtmlElement = null;
            foreach (HtmlElement item in htmlElement.Children)
            {
                returnHtmlElement = FindChildWithId(item, idToFind);
            }

            if (returnHtmlElement != null)
            {
                return returnHtmlElement;
            }

            while ((htmlElement = htmlElement.NextSibling) != null)
            {
                returnHtmlElement = FindChildWithId(htmlElement, idToFind);
            }

            if (returnHtmlElement != null)
            {
                return returnHtmlElement;
            }

            return null;
        }
Exemple #16
0
    //Method "Browse()" provided by assignment description
    private String Browse()
    {
        // Can't find System.Windows.Controls.WebBrowser, which might be nice.
        // See http://stackoverflow.com/questions/8645926/how-to-create-and-use-webbrowser-in-background-thread
        WebBrowser myWebBrowser = null;
        String     innerHTML    = "";

        txtTitle.Text = "???";
        txtValue.Text = "???";
        Thread thread = new Thread(delegate() {
            int elapsedTime;
            DateTime startTime = new DateTime(), endTime = new DateTime();
            startTime          = DateTime.Now;
            System.Windows.Forms.HtmlElement htmlElement = null;

            //WebBrowser foo = new System.Net.HttpWebRequest(); // deprecated. Seems to work for Desktop Apps and .Net Framework 2.0

            // This causes major crashing of the web server
            //foo.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DocumentComplete);
            myWebBrowser = new System.Windows.Forms.WebBrowser();    // Must be instantiated inside the Thread

            myWebBrowser.AllowNavigation = true;
            myWebBrowser.Navigate(txtURL.Text, false);

            while (myWebBrowser.ReadyState != WebBrowserReadyState.Complete)
            //while (foo.ReadyState != WebBrowserReadyState.Interactive)  // We don't care if the graphics are loaded
            //while (foo.IsBusy == true)
            {
                txtValue.Text = myWebBrowser.ReadyState.ToString();
                System.Windows.Forms.Application.DoEvents();
                endTime     = DateTime.Now;
                elapsedTime = (endTime - startTime).Seconds;
                if (elapsedTime > 30)
                {
                    break;
                }
            }
            // When we get this far we have hopefully loaded the web page into the browser object
            try
            {
                txtTitle.Text = myWebBrowser.Document.Title;
                //System.Windows.Forms.HtmlElement x = foo.Document.GetElementById("yfs_l84_csco");
                htmlElement = myWebBrowser.Document.Body;
                innerHTML   = htmlElement.InnerHtml;
            }
            catch (Exception ex)
            {
                txtValue.Text += "<p> Exception: " + ex.ToString();
            }
        });

        thread.SetApartmentState(ApartmentState.STA);
        thread.Start();
        thread.Join();

        // We won't get here until the Thread completes.
        // This might be interesting: http://www.charith.gunasekara.web-sphere.co.uk/2010/09/how-to-convert-html-page-to-image-using.html
        return(innerHTML);
    }
 /// <summary>
 /// List, for debugging purposes, the parameters passed to a Denni Hlasatel Death Index query
 /// </summary>
 /// <param name="elemTarg">the HTML element into which the list outut will be directed</param>
 /// <param name="sPath">the Denni Hlasatel Death Index query to be executed</param>
 /// <param name="lQuery">the arguments to the query, as name/value pairs</param>
 /// <param name="sBaseMessage">a header string that will be prepended to the list output</param>
 private static void ListQueryParameters(HtmlElement elemTarg, string sPath, NameValueCollection lQuery, string sBaseMessage)
 {
     var sMessage = sBaseMessage + "Path: " + sPath + "<br>" + Environment.NewLine;
     var items = lQuery.AllKeys.SelectMany(lQuery.GetValues, (k, v) => new { key = k, value = v });
     sMessage = items.Aggregate(sMessage, (current, item) => current + (item.key + " = " + item.value + "<br>" + Environment.NewLine));
     // MessageBox.Show(sMessage, "DH Death Index URL", MessageBoxButtons.OK, MessageBoxIcon.Information);
     elemTarg.InnerHtml = sMessage;
 }
Exemple #18
0
 protected override bool OnTextElementFinded(System.Windows.Forms.HtmlElement textElement, Stack <KeyValuePair <System.Windows.Forms.HtmlElement, string> > textNode)
 {
     if (textElement.Id == "inputPageNo")
     {
         inputPageNo = textElement;
     }
     return(!isMatch);;
 }
Exemple #19
0
 private void initbroswer()
 {
     HtmlElementCollection collection = webBrowser1.Document.Body.Children;
     flashdoc = collection[2];
     flashdoc.Children[0].Style = "display:none";
     flashdoc.Children[1].Style = "display:none";
     webBrowser1.Visible = true;
 }
Exemple #20
0
		/// <summary>
		/// 根据 HtmlElement 创建标记对象.
		/// </summary>
		/// <param name="element">用于创建标记对象的 HtmlElement.</param>
		/// <returns>ElementMark 对象.</returns>
		public static ElementMark Create ( HtmlElement element )
		{

			if ( null == element )
				throw new ArgumentNullException ( "element", "HtmlElement 不能为空" );

			return new ElementMark ( element.Id, element.TagName, element.Name, element.GetAttribute ( "class" ), element.GetAttribute ( "type" ), ( element.GetAttribute ( "type" ) == "text" || element.GetAttribute ( "type" ) == "password" ) ? string.Empty : element.GetAttribute ( "value" ), element.GetAttribute ( "href" ), IEBrowser.GetFramePath ( element ) );
		}
        private void SetValue(HtmlElement element, string attr, string attrValue)
        {
            DebugElement(element);

            this.Call<HtmlElement>(delegate(HtmlElement e)
            {
                e.SetAttribute(attr, attrValue);
            }, element);
        }
 public static void fireEvent(HtmlElement elm, string ev)
 {
     if (elm.Id == "")
     {
         elm.Id = RndNext();
     }
     string evalStr = string.Format("document.getElementById('{0}').fireEvent('{1}');", elm.Id, ev);
     execScript(elm.Document, evalStr);
 }
Exemple #23
0
		public static string SafeInnerText(HtmlElement htmlNode)
		{
			Debug.Assert(htmlNode != null); if(htmlNode == null) return string.Empty;

			string strInner = htmlNode.InnerText;
			if(strInner == null) return string.Empty;

			return strInner;
		}
        public static List<HtmlElement> GetHtmlElementsByPath(HtmlElement parent, string path)
        {
            string[] tag_index_pairs = path.Split('/');
            List<HtmlElement> level_hes = new List<HtmlElement>();
            level_hes.Add(parent);
            foreach (string tag_index_pair in tag_index_pairs)
            {
                string[] p = tag_index_pair.Split('[', ']', ',');
                string tag = p[0].Trim();
                string _index = null;
                if (p.Length < 2)
                    _index = "*";
                else
                    _index = p[1].Trim();
                List<HtmlElement> child_hes = new List<HtmlElement>();
                if (_index == "*")
                {
                    foreach (HtmlElement lhe in level_hes)
                    {
                        HtmlElementCollection hes = lhe.Children;
                        foreach (HtmlElement he in hes)
                        {
                            if (he.TagName != tag)
                                continue;
                            child_hes.Add(he);
                        }
                    }
                }
                else
                {
                    int index = -1;
                    if (!int.TryParse(_index, out index) || index < 0)
                        throw (new Exception("Index '" + _index + "' in the path '" + path + "' is inadmissible. Index might be non-negative integer or '*' only."));

                    foreach (HtmlElement lhe in level_hes)
                    {
                        HtmlElementCollection hes = lhe.Children;
                        if (hes.Count <= index)
                            continue;
                        int count = 0;
                        foreach (HtmlElement he in hes)
                        {
                            if (he.TagName != tag)
                                continue;
                            if (count++ < index)
                                continue;
                            child_hes.Add(he);
                            break;
                        }
                    }
                }
                level_hes = child_hes;
            }

            return level_hes;
        }
 private void GetAllValuesSelectBairro(HtmlElement el)
 {
     var AllItems = el.All;
     foreach (HtmlElement item in AllItems)
     {
         if (!item.InnerHtml.Contains("SELECIONE"))
             valuesSelectBairro.Add(item.GetAttribute("value"), "n");
     }
     getValuesSelectBairro = false;
 }
Exemple #26
0
        protected override bool OnButtonElementFinded(System.Windows.Forms.HtmlElement buttonElement, Stack <KeyValuePair <System.Windows.Forms.HtmlElement, string> > textNode)
        {
            IHTMLInputElement element = buttonElement.DomElement as IHTMLInputElement;

            if (element.value == "跳转")
            {
                jumpButton = buttonElement;
            }
            return(!isMatch);
        }
        //public static object Invoke(Control c, Func<object> code)
        //{
        //    if (c.InvokeRequired)
        //    {
        //        return c.Invoke(code);
        //    }
        //    return code.Invoke();
        //}

        public static Point GetOffset(HtmlElement e)
        {
            Point p = new Point(0, 0);
            for (; e != null; e = e.OffsetParent)
            {
                p.X += e.OffsetRectangle.X;
                p.Y += e.OffsetRectangle.Y;
            }
            return p;
        }
Exemple #28
0
 private static void ReadTr(List<TRow> alRow, TRowType rowType, HtmlElement elParent) {
     TRow row = new TRow();
     row.RowType = rowType;
     foreach (HtmlElement el in elParent.Children) {
         if (String.Compare(el.TagName, "td", true) == 0 || String.Compare(el.TagName, "th", true) == 0) {
             row.Cells.Add(el.InnerText);
         }
     }
     alRow.Add(row);
 }
Exemple #29
0
 public int getXoffset(HtmlElement el)
 {
     int xPos = el.OffsetRectangle.Left;
     HtmlElement tempEl = el.OffsetParent;
     while (tempEl != null)
     {
         xPos += tempEl.OffsetRectangle.Left;
         tempEl = tempEl.OffsetParent;
     }
     return xPos;
 }
Exemple #30
0
        protected override bool OnRadioElementFinded(System.Windows.Forms.HtmlElement radioElement, Stack <KeyValuePair <System.Windows.Forms.HtmlElement, string> > textNode)
        {
            IHTMLDOMNode       node = radioElement.DomElement as IHTMLDOMNode;
            IHTMLDOMAttribute2 attr = node.attributes == null ? null : node.attributes.getNamedItem("title");

            if (attr != null && attr.value != "null" && string.IsNullOrEmpty(attr.value) == false)
            {
                textNode.Push(new KeyValuePair <HtmlElement, string>(radioElement, attr.value));
            }
            return(base.OnRadioElementFinded(radioElement, textNode));
        }
Exemple #31
0
 public override void SetValue(HtmlElement element)
 {
     // 如果checkbox的有属性是“checked”它将被检查。
     if (Checked)
     {
         element.SetAttribute("checked", "checked");
     }
     else
     {
         element.SetAttribute("checked", null);
     }
 }
Exemple #32
0
 public void AccountTurnovers(HtmlElement b)
 {
     BodyHandler = DetailsOn;
     HtmlElement detailsOn = b.Find(x => x.Name == "allDetailsOn");
     if (detailsOn != null)
     {
         detailsOn.ClickElement();
     }
     else
     {
         DetailsOn(b);
     }
 }
Exemple #33
0
 protected override bool OnCheckBoxElementFinded(System.Windows.Forms.HtmlElement checkElement, Stack <KeyValuePair <System.Windows.Forms.HtmlElement, string> > textNode)
 {
     if (isMatch)
     {
         return(false);
     }
     textNode.Clear();
     checkBox     = checkElement;
     beginMatch   = true;
     matchedIndex = 0;
     isMatch      = false;
     return(true);
 }
Exemple #34
0
		public static string SafeAttribute(HtmlElement htmlNode, string strName)
		{
			if(htmlNode == null) { Debug.Assert(false); return string.Empty; }
			if(string.IsNullOrEmpty(strName)) { Debug.Assert(false); return string.Empty; }

			string strValue = (htmlNode.GetAttribute(strName) ?? string.Empty);

			// http://msdn.microsoft.com/en-us/library/ie/ms536429.aspx
			if((strValue.Length == 0) && strName.Equals("class", StrUtil.CaseIgnoreCmp))
				strValue = (htmlNode.GetAttribute("className") ?? string.Empty);

			return strValue;
		}
        private static HtmlElement GetKontoEntriesElement(HtmlElement baseElement)
        {
            var kontoEntriesElement = baseElement.NextSibling;
            if (kontoEntriesElement.TagName.Equals("UL")) // .GetAttribute("link-list") != null)
            {
            }
            else
            {
                kontoEntriesElement = kontoEntriesElement.NextSibling;
            }

            return kontoEntriesElement;
        }
Exemple #36
0
 private void Content_Click(object sender, HtmlElementEventArgs e)
 {
     this.ttId.Hide(this);
     if (this.ignoreMenuFlag) {
         return;
     }
     if (Keys.None == (Keys.Alt & Control.ModifierKeys)) {
         this.clickedContent = sender as HtmlElement;
         this.cmsContent.Show(Control.MousePosition);
         e.BubbleEvent = false;
         e.ReturnValue = false;
     }
 }
Exemple #37
0
 public O2FormInputField(HtmlElement heForm_InputField)
 {
     //String asd = heForm_InputField.DomElement.GetType().FullName;
     if (heForm_InputField.DomElement.GetType().FullName == "mshtml.HTMLInputElementClass")
     {
         hieForm_InputField = (HTMLInputElementClass) heForm_InputField.DomElement;
     }
     else
     {
         DI.log.error("in O2FormInputField(), provided object was not a Input Form element: {0}",
                         heForm_InputField.DomElement.GetType().FullName);
     }
 }
Exemple #38
0
        void IEBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            HtmlDocument doc = ((WebBrowser)sender).Document;

            ieBrowser.DocumentCompleted -= IEBrowser_DocumentCompleted;

            System.Windows.Forms.HtmlElement search = ieBrowser.Document.GetElementById("results");
            if (search != null)
            {

                HtmlElementCollection input1 = search.GetElementsByTagName("TD");

                //input1[2].InvokeMember("click");

                //ieBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(SecondNavigation);
                ieBrowser.Navigate("https://www.zaubacorp.com/company/VERINON%20TECHNOLOGY%20SOLUTIONS%20PRIVATE%20LIMITED/U72200TG2004FTC042623");

                while (ieBrowser.ReadyState != WebBrowserReadyState.Complete)
                {
                    Application.DoEvents();
                }

                //ieBrowser.Navigate("https://www.google.com/");
                ieBrowser.DocumentCompleted += IeBrowser_DocumentCompleted;

                //foreach (System.Windows.Forms.HtmlElement input2 in input1)
                //{
                //}

                //search.SetAttribute("value", "VERINON TECHNOLOGY SOLUTIONS PRIVATE LIMITED");
                //System.Windows.Forms.HtmlElement searchButton = ieBrowser.Document.GetElementById("edit-submit--3");

            }

            //HtmlDocument doc = ((WebBrowser)sender).Document;

            //ieBrowser.DocumentCompleted -= IEBrowser_DocumentCompleted;

            //System.Windows.Forms.HtmlElement search = ieBrowser.Document.GetElementById("searchid");
            //if (search != null)
            //{
            //    search.SetAttribute("value", "VERINON TECHNOLOGY SOLUTIONS PRIVATE LIMITED");
            //    System.Windows.Forms.HtmlElement searchButton = ieBrowser.Document.GetElementById("edit-submit--3");

            //    ieBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(SecondNavigation);
            //    searchButton.InvokeMember("click");

            //}
        }
Exemple #39
0
        public int GetYOffset(System.Windows.Forms.HtmlElement el)
        {
            //get element pos
            int yPos = el.OffsetRectangle.Top;

            //get the parents pos
            System.Windows.Forms.HtmlElement tempEl = el.OffsetParent;
            while (tempEl != null)
            {
                yPos  += tempEl.OffsetRectangle.Top;
                tempEl = tempEl.OffsetParent;
            }

            return(yPos);
        }
Exemple #40
0
        // DocumentCompleted event handle
        void IEBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            HtmlDocument doc = ((WebBrowser)sender).Document;

            ieBrowser.DocumentCompleted -= IEBrowser_DocumentCompleted;

            System.Windows.Forms.HtmlElement search = ieBrowser.Document.GetElementById("name1");
            if (search != null)
            {
                search.SetAttribute("value", "verinon");
                System.Windows.Forms.HtmlElement searchButton = ieBrowser.Document.GetElementById("checkCompanyName_0");

                searchButton.InvokeMember("click");

                ieBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(IEBrowser_DocumentCompleted1);
            }
        }
        private bool IsElementVisible(System.Windows.Forms.HtmlElement argElement)
        {
            Debug.Assert(null != argElement);

            bool Result = true;

            try
            {
                IHTMLElement iElement = (IHTMLElement)argElement.DomElement;
                IHTMLStyle   iStyle   = iElement.style;
                if (!string.IsNullOrEmpty(iStyle.display) &&
                    iStyle.display.Equals("none", StringComparison.OrdinalIgnoreCase))
                {
                    Result = false;
                }
                else
                {
                    Result = true;
                }

                iElement = null;
                iStyle   = null;
            }
            catch (System.Exception ex)
            {
                Trace.Write(ex.Message);
                return(true);
            }

            //if (!string.IsNullOrEmpty(argElement.Style))
            //{
            //    string style = argElement.Style;
            //    style = style.ToLowerInvariant();
            //    int index = style.IndexOf(HtmlRender.s_hideStyle);
            //    if (-1 != index)
            //    {
            //        Result = false;
            //    }
            //}

            return(Result);
        }
Exemple #42
0
        private void IeBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            ieBrowser.DocumentCompleted -= IeBrowser_DocumentCompleted;

            string value = string.Empty;

            System.Windows.Forms.HtmlElement loginCallOut = ieBrowser.Document.GetElementById("login-callout");
            if (loginCallOut != null && loginCallOut.InnerText.Contains("Trying to sign in?"))
            {
                System.Windows.Forms.HtmlElement cntrlEnail    = ieBrowser.Document.GetElementById("login-email");
                System.Windows.Forms.HtmlElement cntrlPassword = ieBrowser.Document.GetElementById("login-password");
                System.Windows.Forms.HtmlElement cntrlSubmit   = ieBrowser.Document.GetElementById("login-submit");


                if (cntrlEnail != null && cntrlPassword != null && cntrlSubmit != null)
                {
                    cntrlEnail.SetAttribute("value", "*****@*****.**");
                    cntrlPassword.SetAttribute("value", "kareti1024");
                    cntrlSubmit.InvokeMember("click");

                    ieBrowser.DocumentCompleted += IeBrowser_DocumentCompleted1;
                }
            }
        }
Exemple #43
0
        void IEBrowser_DocumentCompleted1(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            string value = string.Empty;

            System.Windows.Forms.HtmlElement resultTable = ieBrowser.Document.GetElementById("companyList");

            if (resultTable != null)
            {
                HtmlElementCollection input1 = resultTable.GetElementsByTagName("TD");

                foreach (System.Windows.Forms.HtmlElement input2 in input1)
                {
                    value += input2.InnerText + "\n";
                }
            }
            else
            {
                value = "Not Found";
            }

            Details = value;

            this.resultEvent.Set();
        }
Exemple #44
0
        void IEBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            HtmlDocument doc = ((WebBrowser)sender).Document;

            ieBrowser.DocumentCompleted -= IEBrowser_DocumentCompleted;

            //System.Windows.Forms.HtmlElement cntrlEnail = ieBrowser.Document.GetElementById("login-email");
            //System.Windows.Forms.HtmlElement cntrlPassword = ieBrowser.Document.GetElementById("login-password");
            //System.Windows.Forms.HtmlElement cntrlSubmit = ieBrowser.Document.GetElementById("login-submit");

            System.Windows.Forms.HtmlElement cntrlEnail    = ieBrowser.Document.GetElementById("session_key-login");
            System.Windows.Forms.HtmlElement cntrlPassword = ieBrowser.Document.GetElementById("session_password-login");
            System.Windows.Forms.HtmlElement cntrlSubmit   = ieBrowser.Document.GetElementById("btn-primary");


            if (cntrlEnail != null && cntrlPassword != null && cntrlSubmit != null)
            {
                cntrlEnail.SetAttribute("value", "*****@*****.**");
                cntrlPassword.SetAttribute("value", "kareti1024");
                cntrlSubmit.InvokeMember("click");

                ieBrowser.DocumentCompleted += IeBrowser_DocumentCompleted;
            }
        }
Exemple #45
0
    public void Html(string value, Label label, System.Windows.Forms.HtmlElement html)
    {
        // BAD
        label.Text = Encode(value);
        label.Text = HttpUtility.UrlEncode(value);
        label.Text = HttpUtility.UrlEncode(HttpUtility.HtmlEncode(value));
        var encodedValue = HttpUtility.UrlEncode(value);

        html.SetAttribute("a", encodedValue);
        label.Text = "<img src=\"" + encodedValue + "\" />";
        label.Text = string.Format("<img src=\"{0}\" />", encodedValue);

        // GOOD
        label.Text   = HttpUtility.HtmlEncode(value);
        label.Text   = HttpUtility.HtmlEncode(HttpUtility.UrlEncode(value));
        encodedValue = HttpUtility.HtmlAttributeEncode(encodedValue);
        html.SetAttribute("a", encodedValue);
        label.Text   = "<img src=\"" + encodedValue + "\" />";
        label.Text   = string.Format("<img src=\"{0}\" />", encodedValue);
        encodedValue = HttpUtility.HtmlEncode(encodedValue);
        html.SetAttribute("a", encodedValue);
        label.Text = "<img src=\"" + encodedValue + "\" />";
        label.Text = string.Format("<img src=\"{0}\" />", encodedValue);
    }
Exemple #46
0
        /// <summary>
        /// 快捷登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void wfBrowser_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
        {
            //wfBrowser.Document.Body.Style = "overflow:hidden";
            #region 控制网站根据窗体大小加载窗体大小
            if (wfBrowser.ReadyState != WebBrowserReadyState.Complete)
            {
                return;
            }
            System.Drawing.Size szb = new System.Drawing.Size(wfBrowser.Document.Body.OffsetRectangle.Width,
                                                              wfBrowser.Document.Body.OffsetRectangle.Height);
            System.Drawing.Size sz = (System.Drawing.Size)wfBrowser.Size;

            int xbili = (int)((float)sz.Width / (float)szb.Width * 100);   //水平方向缩小比例
            int ybili = (int)((float)sz.Height / (float)szb.Height * 100); //垂直方向缩小比例
            wfBrowser.Document.Body.Style = "zoom:" + xbili.ToString() + "%";
            wfBrowser.Invalidate();
            #endregion
            #region 博客园登录
            if (Common.instance.Apply == 1)
            {
                string BlogKey     = "sadf";//加密博客园密码
                string BlogDecrypt = Common.instance.DESCDecrypt(Common.instance.GetKey(), BlogKey);
                System.Windows.Forms.HtmlElement ClickBtn = null;
                if (e.Url.ToString().ToLower().IndexOf("/user/signin") > 0)
                {
                    System.Windows.Forms.HtmlDocument doc = wfBrowser.Document;
                    for (int i = 0; i < doc.All.Count; i++)
                    {
                        if (doc.All[i].TagName.ToUpper().Equals("INPUT"))
                        {
                            switch (doc.All[i].Id)
                            {
                            case "input1":
                                doc.All[i].InnerText = "sdf";     // 用户名
                                break;

                            case "input2":
                                doc.All[i].InnerText = BlogDecrypt;     // 密码
                                break;

                            case "signin":
                                ClickBtn = doc.All[i];
                                break;
                            }
                        }
                    }
                    ClickBtn.InvokeMember("Click"); // 点击“登录”按钮
                }
            }
            #endregion
            #region 新浪微博登录
            else if (Common.instance.Apply == 2)
            {
                string SinaKey     = "123123";//加密新浪微博密码
                string SinaDecrypt = Common.instance.DESCDecrypt(Common.instance.GetKey(), SinaKey);
                System.Windows.Forms.HtmlElement ClickBtn = null;
                if (e.Url.ToString().ToLower().IndexOf("/weibo.com") > 0)
                {
                    System.Windows.Forms.HtmlDocument doc = wfBrowser.Document;
                    for (int i = 0; i < doc.All.Count; i++)
                    {
                        if (doc.All[i].TagName.ToUpper().Equals("INPUT"))
                        {
                            switch (doc.All[i].TabIndex)
                            {
                            case 1:
                                doc.All[i].InnerText = "sdf";     // 用户名
                                break;

                            case 2:
                                doc.All[i].InnerText = SinaDecrypt;     // 密码
                                break;

                            case 6:
                                ClickBtn = doc.All[i];
                                break;
                            }
                        }
                    }
                    ClickBtn.InvokeMember("Click"); // 点击“登录”按钮
                }
            }
            #endregion
            #region 网易邮箱登录
            else if (Common.instance.Apply == 3)
            {
                string MailKey     = "123";//加密网易邮箱密码
                string MailDecrypt = Common.instance.DESCDecrypt(Common.instance.GetKey(), MailKey);
                System.Windows.Forms.HtmlElement ClickBtn = null;
                if (e.Url.ToString().ToLower().IndexOf("/mail.163.com") > 0)
                {
                    System.Windows.Forms.HtmlDocument doc = wfBrowser.Document;
                    for (int i = 0; i < doc.All.Count; i++)
                    {
                        if (doc.All[i].TagName.ToUpper().Equals("INPUT"))
                        {
                            switch (doc.All[i].TabIndex)
                            {
                            case 1:
                                doc.All[i].InnerText = "sdf";     // 用户名
                                break;

                            case 2:
                                doc.All[i].InnerText = MailDecrypt;     // 密码
                                break;

                            case 8:
                                ClickBtn = doc.All[i];
                                break;
                            }
                        }
                    }
                    ClickBtn.InvokeMember("Click"); // 点击“登录”按钮
                }
            }
            #endregion
        }
 public HtmlScreenListElement(System.Windows.Forms.HtmlElement argElement,
                              HtmlRender argRender)
     : base(argElement, argRender)
 {
 }
Exemple #48
0
 public HtmlElement AppendChild(HtmlElement newElement)
 {
     return(InsertAdjacentElement(HtmlElementInsertionOrientation.BeforeEnd, newElement));
 }
Exemple #49
0
        public HtmlElement InsertAdjacentElement(HtmlElementInsertionOrientation orient, HtmlElement newElement)
        {
            IHTMLElement iHtmlElement = ((IHTMLElement2)NativeHtmlElement).InsertAdjacentElement(orient.ToString(),
                                                                                                 (IHTMLElement)newElement.DomElement);

            return(iHtmlElement != null ? new HtmlElement(shimManager, iHtmlElement) : null);
        }
Exemple #50
0
        private void IeBrowser_DocumentCompleted1(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            string value = string.Empty;

            System.Windows.Forms.HtmlElement resultTable1 = ieBrowser.Document.GetElementById("nav-typeahead-wormhole");
        }
Exemple #51
0
 protected override bool OnTextAreaElementDetected(System.Windows.Forms.HtmlElement textAreaElement, Stack <KeyValuePair <System.Windows.Forms.HtmlElement, string> > textNode)
 {
     return(!isMatch);;
 }
Exemple #52
0
 protected override bool OnLinkElementFinded(System.Windows.Forms.HtmlElement linkElement, Stack <KeyValuePair <System.Windows.Forms.HtmlElement, string> > textNode)
 {
     return(!isMatch);;
 }
Exemple #53
0
 protected override bool OnFormElementDetected(System.Windows.Forms.HtmlElement formElement)
 {
     return(!isMatch);;
 }
Exemple #54
0
 private void IeBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 {
     string value = string.Empty;
     System.Windows.Forms.HtmlElement resultTable = ieBrowser.Document.GetElementById("block-system-main");
 }