Beispiel #1
1
    static HObject ToHNode(mshtml.IHTMLDOMNode node)
    {
      if (node == null)
        return null;
      //dynamic x = element;
      //Console.WriteLine(MetaTech.Library.ReflectionExtension.ReflectionHelper._P<object>(element.DomElement, "textContent"));
      //var span = element.DomElement as mshtml.IHTMLDOMNode;
      switch (node.nodeType)
      {
        case 3:
          return new HText(node.nodeValue);
        case 1:
          {
            var element = node as mshtml.IHTMLElement;
            var childs = node.childNodes as System.Collections.IEnumerable;
            return new HElement(element.tagName,
              ToHAttribute("id", element.id),
              ToHAttribute("class", element.className),
              ToHAttribute("src", element.getAttribute("src")),
              //ToHAttribute("style", element.getAttribute("style")),
              childs != null ? childs.OfType<mshtml.IHTMLDOMNode>().Select(child => ToHNode(child)) : null
            );
          }
        default:
          return null;

      }
      ////Console.WriteLine(x.textContent);
      ////mshtml.HTMLTextAreaElement
      //return new HElement(element.TagName, 
      //  ToHAttribute("id", element.Id),
      //  ToHAttribute("name", element.Name),
      //  ToHAttribute("class", element.GetAttribute("class")),
      //  ToHAttribute("style", element.Style),
      //  element.Children.OfType<HtmlElement>().Select(e => ToHElement(e)),
      //  ToHAttribute("type", element.DomElement._f(_=>_.GetType().FullName))
      //);


    }
 public override void Bind(mshtml.HTMLDocument dom, string rawContent)
 {
     Clean();
     SessionDocument = new HtmlNodeHierarchy(rawContent.AsHtmlDocument().DocumentNode);
     String domDocStr = ("" + (dom as dynamic).documentElement.OuterHtml + "");
     DomDocument = new HtmlNodeHierarchy(domDocStr.AsHtmlDocument().DocumentNode);
 }
 public void Bind(mshtml.HTMLDocument dom)
 {
     Clean();
     var sess = Enumerable.First<FiddlerSessionHolder>(FiddlerHelper.GetSessionsStack());
     //TODO: diff
     SessionDocument = sess.BrowsingResponse.ResponseContent.AsFixedXML();
     String domDocStr = ("" + (dom as dynamic).documentElement.OuterHtml + "");
     DomDocument = domDocStr.AsFixedXML();
 }
 public override void Bind(mshtml.HTMLDocument dom, string content)
 {
     Clean();
     var sess = Enumerable.First<FiddlerSessionHolder>(FiddlerHelper.GetSessionsStack());
     
     //TODO: diff
     SessionDocument = new HtmlNodeHierarchy(sess.BrowsingResponse.ResponseContent.AsHtmlDocument().DocumentNode);
     String domDocStr = ("" + (dom as dynamic).documentElement.OuterHtml + "");
     DomDocument = new HtmlNodeHierarchy(domDocStr.AsHtmlDocument().DocumentNode);
 }
Beispiel #5
0
 public static void WaitForPageReady(mshtml.IHTMLDocument2 document, int secondWait = 30)
 {
     for (int i = 0; i < secondWait; i++)
     {
         if (document != null && document.readyState.Equals("complete"))
         {
             break;
         }
         System.Console.WriteLine("READY:" + document == null ? "null" : document.readyState);
         System.Threading.Thread.Sleep(1000);
     }
 }
Beispiel #6
0
        private static string getNode(mshtml.IHTMLElement node)
        {
            string nodeExpr = node.tagName;
            if (nodeExpr == null)  // Eg. node = #text
                return null;
            if (node.id != "" && node.id != null)
            {
                nodeExpr += "[@id='" + node.id + "']";
                // We don't really need to go back up to //HTML, since IDs are supposed
                // to be unique, so they are a good starting point.
                return "/" + nodeExpr;
            }

            // Find rank of node among its type in the parent
            int rank = 1;
            mshtml.IHTMLDOMNode nodeDom = node as mshtml.IHTMLDOMNode;
            mshtml.IHTMLDOMNode psDom = nodeDom.previousSibling;
            mshtml.IHTMLElement ps = psDom as mshtml.IHTMLElement;
            while (ps != null)
            {
                if (ps.tagName == node.tagName)
                {
                    rank++;
                }
                psDom = psDom.previousSibling;
                ps = psDom as mshtml.IHTMLElement;
            }
            if (rank > 1)
            {
                nodeExpr += "[" + rank + "]";
            }
            else
            { // First node of its kind at this level. Are there any others?
                mshtml.IHTMLDOMNode nsDom = nodeDom.nextSibling;
                mshtml.IHTMLElement ns = nsDom as mshtml.IHTMLElement;
                while (ns != null)
                {
                    if (ns.tagName == node.tagName)
                    { // Yes, mark it as being the first one
                        nodeExpr += "[1]";
                        break;
                    }
                    nsDom = nsDom.nextSibling;
                    ns = nsDom as mshtml.IHTMLElement;
                }
            }
            return nodeExpr;
        }
Beispiel #7
0
        private void MouseMoveEventHandler(mshtml.IHTMLEventObj e)
        {
            string preBlock = current_select_block;
            current_select_block = _webBrowser.InvokeScript("getSelectBlockName") as string;

            if (preBlock != current_select_block && current_select_block != " ")
            {
                ctrVM.functionMV.contain.Children.Clear();
                _tabControls.TabContols.SelectedIndex = 1;
                ctrVM.functionMV.initModel(current_select_block);
                //3D객체에 string 전송
                AddMouseMoveEvnet();
            }


        }
Beispiel #8
0
 public static void CheckMousePoint(IntPtr hwnd, ref Point fakeMousePoint, mshtml.IHTMLDocument2 doc)
 {
     int clientWidth = 0;
     int clientHeight = 0;
     int scrollWidth = 0;
     int scrollHeight = 0;
     Random random = new Random();
     if (GetWindowWidthAndHeight(hwnd, doc, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight) != null)
     {
         if (((fakeMousePoint.X <= 0) || (fakeMousePoint.X >= clientWidth)) && (clientWidth > 8))
         {
             fakeMousePoint.X = random.Next(4, clientWidth - 8);
         }
         if (((fakeMousePoint.Y <= 0) || (fakeMousePoint.Y >= clientHeight)) && (clientHeight > 8))
         {
             fakeMousePoint.Y = random.Next(4, clientHeight - 8);
         }
     }
 }
Beispiel #9
0
        public static string getXPath(mshtml.IHTMLElement element)
        {
            if (element == null)
                return "";
            mshtml.IHTMLElement currentNode = element;
            ArrayList path = new ArrayList();

            while (currentNode != null)
            {
                string pe = getNode(currentNode);
                if (pe != null)
                {
                    path.Add(pe);
                    //if (pe.IndexOf("@id") != -1)
                    //    break;  // Found an ID, no need to go upper, absolute path is OK
                }
                currentNode = currentNode.parentElement;
            }
            path.Reverse();
            return join(path, "/");
        }
Beispiel #10
0
 public static bool ClickCheckedRect(IntPtr hwnd, mshtml.IHTMLDocument2 doc, string itemName, string tagStr, string indexStr, ref bool isClick, ref Point fakeMousePoint, ClickEvent clickEvent)
 {
     mshtml.IHTMLElement elem = GetCheckedElement(doc, itemName, tagStr, indexStr);
     bool flag = false;
     if (elem != null)
     {
         flag = true;
         Rectangle elementRect = GetElementRect(doc.body, elem);
         isClick = false;
         if ((elementRect.Width > 0) && (elementRect.Height > 0))
         {
             Random random = new Random();
             int num = random.Next(elementRect.Width);
             int num2 = random.Next(elementRect.Height);
             SetMousePoint(hwnd, ref fakeMousePoint, elementRect.X + num, elementRect.Y + num2, doc);
             isClick = isClickElement(hwnd, doc, elem, elementRect.X + num, elementRect.Y + num2, clickEvent);
         }
     }
     if (elem != null)
     {
         Marshal.ReleaseComObject(elem);
     }
     return flag;
 }
Beispiel #11
0
 public HtmlControl(WATF.Core.Page.IPage page, mshtml.IHTMLElement elem)
 {
     this.m_Page = page;
     this.m_HtmlElement = elem;
 }
Beispiel #12
0
 internal Range(mshtml.IHTMLTxtRange range)
 {
     msHtmlTxRange = range;
 }
Beispiel #13
0
 private void RemoveBIS(mshtml.IHTMLElement element)
 {
     if (element.tagName == "B")
     {
         mshtml.IHTMLElement elem1 = element.parentElement;
         if (elem1.tagName == "I")
         {
             mshtml.IHTMLElement elem2 = elem1.parentElement;
             if (elem2.tagName == "SPAN" && elem2.getAttribute("id", 2).ToString() == "advanced_search")
             {
                 elem2.outerHTML = this.targetTerm;
             }
             Marshal.ReleaseComObject(elem2);
         }
         Marshal.ReleaseComObject(elem1);
     }
 }
Beispiel #14
0
 private void RemoveS(mshtml.IHTMLElement element)
 {
     if (element.tagName == "SPAN" && element.getAttribute("id", 2).ToString() == "advanced_search")
     {
         element.outerHTML = this.targetTerm;
     }
 }
Beispiel #15
0
 private void RemoveHTML(GlobalSettings settings,mshtml.IHTMLTxtRange range)
 {
     mshtml.IHTMLElement element = range.parentElement();
     if (settings.IsHightlightNonVisible)
     {
         if (settings.IsBold)
         {
             if (settings.IsItalic)
             {
                 RemoveBIS(element);
             }
             else
             {
                 RemoveBS(element);
             }
         }
         else
         {
             if (settings.IsItalic)
             {
                 RemoveIS(element);
             }
             else
             {
                 RemoveS(element);
             }
         }
     }
     else
     {
         if (element.offsetTop > Const.NotFound && element.offsetLeft > Const.NotFound && element.offsetHeight > Const.Ok && element.offsetWidth > Const.Ok)
         {
             if (settings.IsBold)
             {
                 if (settings.IsItalic)
                 {
                     RemoveBIS(element);
                 }
                 else
                 {
                     RemoveBS(element);
                 }
             }
             else
             {
                 if (settings.IsItalic)
                 {
                     RemoveIS(element);
                 }
                 else
                 {
                     RemoveS(element);
                 }
             }
         }
     }
     Marshal.ReleaseComObject(element);
 }
        bool iEvent_onclick(mshtml.IHTMLEventObj pEvtObj)
        {
            if (currentEl != null)
                currentEl.style.backgroundColor = "#ffffff";

            mshtml.HTMLDocument doc = (mshtml.HTMLDocument)webBrowser1.Document;
            mshtml.IHTMLWindow2 win = doc.parentWindow;
            richTextBox1.Document.Blocks.Clear();
            currentEl = [email protected];
            richTextBox1.AppendText([email protected]);

            foreach (IHTMLElement el in [email protected])
            {
                if(el.tagName == [email protected])
                    el.style.backgroundColor = "#F0FF06";

                foreach (IHTMLElement e in el.all)
                {
                    if (e.tagName == [email protected])
                        el.style.backgroundColor = "#F0FF06";
                }
            }

            [email protected] = "#F0FF06";
            return false;
        }
Beispiel #17
0
 private void MoveMouseToBottom(IntPtr hwnd, mshtml.IHTMLDocument2 doc)
 {
     if ((this._curTenDayBrowser.Document.GetElementsByTagName("HTML").Count > 0) && (!HtmlUtil.ScrollToBottom(hwnd, doc, this._curTenDayBrowser.Document.GetElementsByTagName("HTML")[0], this._fakeMousePoint, this.GetLoadPercent(), this.FindTimeOut()) || !this._isDocCompleted))
     {
         this._scrollTime = this._now;
     }
     this.SetFakeScroll();
 }
Beispiel #18
0
 private bool GetDeepClickLinkInfo(TenDayBrowser parent, mshtml.IHTMLDocument2 doc2, string keyword)
 {
     bool flag = false;
     if (((this._curTenDayBrowser != null) && (this._curTenDayBrowser.Document != null)) && (doc2 != null))
     {
         IntPtr windowHwnd = GetWindowHwnd(this._curTenDayBrowser.Handle.ToInt32());
         int clientWidth = 0;
         int clientHeight = 0;
         int scrollWidth = 0;
         int scrollHeight = 0;
         mshtml.IHTMLElement2 element = HtmlUtil.GetWindowWidthAndHeight(windowHwnd, doc2, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight);
         mshtml.IHTMLElementCollection links = doc2.links;
         ArrayList list = new ArrayList();
         if (string.IsNullOrEmpty(keyword))
         {
             keyword = "";
         }
         Regex regex = new Regex(keyword + @"(\w)?");
         foreach (mshtml.IHTMLElement element2 in links)
         {
             if ((((element2.getAttribute("href", 0) != null) && (element2.getAttribute("target", 0) != null)) && element2.getAttribute("target", 0).ToString().ToLower().Equals("_blank")) && (string.IsNullOrEmpty(keyword) || regex.IsMatch(element2.getAttribute("href", 0).ToString())))
             {
                 Rectangle elementRect = HtmlUtil.GetElementRect(doc2.body, element2);
                 if ((((elementRect.Height > 0) && (elementRect.Width > 0)) && (((elementRect.X + element.scrollLeft) > 0) && ((elementRect.X + element.scrollLeft) < scrollWidth))) && (((elementRect.Y + element.scrollTop) > 0) && ((elementRect.Y + element.scrollTop) < scrollHeight)))
                 {
                     list.Add(element2);
                 }
             }
         }
         if (list.Count > 0)
         {
             Random random = new Random();
             int num5 = random.Next(list.Count);
             random = null;
             mshtml.IHTMLElement ele = list[num5] as mshtml.IHTMLElement;
             if (!string.IsNullOrEmpty(ele.outerText) && !string.IsNullOrEmpty(ele.outerText.Trim()))
             {
                 this._randomClickLink = ele.outerText;
                 this._randomClickLinkTag = ElementTag.outerText;
             }
             else
             {
                 this._randomClickLinkTag = ElementTag.href;
                 this._randomClickLink = ele.getAttribute("href", 0).ToString();
             }
             this._randomClickLinkIndex = HtmlUtil.GetLinkElementIndex(doc2, ele, this._randomClickLink, ((int)this._randomClickLinkTag).ToString());
             this._status = IEStatus.IEStatus_MoveToDest;
             this._beforeWaitTime = this._now;
             list = null;
             random = null;
             return flag;
         }
         if (doc2 != null)
         {
             this.MoveMouseToBottom(windowHwnd, doc2);
             if (this.MoveTimeOut() && this.FindTimeOut())
             {
                 parent.ShowTip2("不存在 " + keyword);
                 this._loop = false;
                 flag = true;
             }
         }
         return flag;
     }
     if (this.FindTimeOut())
     {
         flag = true;
     }
     return flag;
 }
 public KeyUpHandler(mshtml.IHTMLDocument2 doc)
     : base(doc)
 {
 }
Beispiel #20
0
 private void DrawCaptureBox(IntPtr fromHandle, mshtml.IHTMLElement ele)
 {
     if (ele == null)
     {
         WindowUtil.RedrawWindow(fromHandle, null, IntPtr.Zero, 0x85);
     }
     else
     {
         mshtml.IHTMLDocument2 iEWindowDocument = HtmlUtil.GetIEWindowDocument(fromHandle);
         Rectangle elementRect = HtmlUtil.GetElementRect(iEWindowDocument.body, ele);
         elementRect.Inflate(1, 1);
         if (this._CaptureRect != elementRect)
         {
             WindowUtil.RedrawWindow(fromHandle, null, IntPtr.Zero, 0x85);
             this._CaptureRect = elementRect;
         }
         else
         {
             Graphics.FromHwnd(fromHandle).DrawRectangle(new Pen(Color.Blue, 3f), elementRect);
         }
         Marshal.ReleaseComObject(iEWindowDocument);
     }
 }
Beispiel #21
0
        //private bool GetPageClickLinkInfo(TenDayBrowser parent, mshtml.IHTMLDocument2 doc2, string linkName, string tagStr)
        //{
        //    bool flag = false;
        //    if (((this._curTenDayBrowser != null) && (this._curTenDayBrowser.Document != null)) && (doc2 != null))
        //    {
        //        IntPtr windowHwnd = GetWindowHwnd(this._curTenDayBrowser.Handle.ToInt32());
        //        int clientWidth = 0;
        //        int clientHeight = 0;
        //        int scrollWidth = 0;
        //        int scrollHeight = 0;
        //        mshtml.IHTMLElement2 element = HtmlUtil.GetWindowWidthAndHeight(windowHwnd, doc2, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight);
        //        mshtml.IHTMLElementCollection links = doc2.links;
        //        ArrayList list = new ArrayList();
        //        ElementTag iD = ElementTag.ID;
        //        if ((tagStr != string.Empty) && (tagStr != ""))
        //        {
        //            iD = (ElementTag)WindowUtil.StringToInt(tagStr);
        //        }
        //        foreach (mshtml.IHTMLElement element2 in links)
        //        {
        //            if ((((element2.getAttribute("href", 0) != null) && (element2.getAttribute("target", 0) != null)) && element2.getAttribute("target", 0).ToString().ToLower().Equals("_blank")) &&
        //                HtmlUtil.IsElementMatch(element2, iD, wangwangName, "")
        //                )
        //            {
        //                Rectangle elementRect = HtmlUtil.GetElementRect(doc2.body, element2);
        //                if ((((elementRect.Height > 0) && (elementRect.Width > 0)) && (((elementRect.X + element.scrollLeft) > 0) && ((elementRect.X + element.scrollLeft) < scrollWidth))) && (((elementRect.Y + element.scrollTop) > 0) && ((elementRect.Y + element.scrollTop) < scrollHeight)))
        //                {
        //                    list.Add(element2);
        //                }
        //            }
        //        }
        //        if (list.Count == 1)
        //        {
        //            mshtml.IHTMLElement ele = list[0] as mshtml.IHTMLElement;
        //            try
        //            {
        //                mshtml.IHTMLElement itemBoxEle = ele.parentElement.parentElement.parentElement;
        //                IHTMLElementCollection children = itemBoxEle.children as mshtml.IHTMLElementCollection;
        //                foreach (IHTMLElement div in children)
        //                {
        //                    if (div.className == "summary")
        //                    {
        //                        IHTMLElementCollection children2 = div.children as mshtml.IHTMLElementCollection;
        //                        foreach (IHTMLElement ele2 in children2)
        //                        {
        //                            if (ele2.tagName == "a")
        //                            {
        //                                ele = ele2;
        //                                break;
        //                            }
        //                        }
        //                        break;
        //                    }
        //                }
        //            }
        //            catch (System.Exception ex)
        //            {
        //                //
        //                return false;
        //            }
        //            if (!string.IsNullOrEmpty(ele.outerText) && !string.IsNullOrEmpty(ele.outerText.Trim()))
        //            {
        //                this._randomClickLink = ele.outerText;
        //                this._randomClickLinkTag = ElementTag.outerText;
        //            }
        //            else
        //            {
        //                this._randomClickLinkTag = ElementTag.href;
        //                this._randomClickLink = ele.getAttribute("href", 0).ToString();
        //            }
        //            this._randomClickLinkIndex = HtmlUtil.GetLinkElementIndex(doc2, ele, this._randomClickLink, ((int)this._randomClickLinkTag).ToString());
        //            this._status = IEStatus.IEStatus_MoveToDest;
        //            this._beforeWaitTime = this._now;
        //            list = null;
        //            flag = true;
        //            return flag;
        //        }
        //        if (doc2 != null)
        //        {
        //            this.MoveMouseToBottom(windowHwnd, doc2);
        //            if (this.MoveTimeOut() && this.WaitTimeOut())
        //            {
        //                parent.ShowTip2("不存在标签 :" + tagStr + " 的店铺:" + wangwangName);
        //                this._loop = false;
        //                flag = true;
        //            }
        //        }
        //        return flag;
        //    }
        //    if (this.WaitTimeOut())
        //    {
        //        flag = true;
        //    }
        //    return flag;
        //}
        private bool GetPageClickLinkInfo(TenDayBrowser parent, mshtml.IHTMLDocument2 doc2, int index)
        {
            bool flag = false;
            if (((this._curTenDayBrowser != null) && (this._curTenDayBrowser.Document != null)) && (doc2 != null))
            {
                IntPtr windowHwnd = GetWindowHwnd(this._curTenDayBrowser.Handle.ToInt32());
                int clientWidth = 0;
                int clientHeight = 0;
                int scrollWidth = 0;
                int scrollHeight = 0;
                mshtml.IHTMLElement2 element = HtmlUtil.GetWindowWidthAndHeight(windowHwnd, doc2, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight);
                mshtml.IHTMLElementCollection links = doc2.links;
                ArrayList list = new ArrayList();

                string outText = clickLinkItem[index];

                foreach (mshtml.IHTMLElement element2 in links)
                {
                    if (element2.innerText != null && element2.innerText.ToLower().Trim().Contains(outText))
                    {
                        Rectangle elementRect = HtmlUtil.GetElementRect(doc2.body, element2);
                        if ((((elementRect.Height > 0) && (elementRect.Width > 0)) && (((elementRect.X + element.scrollLeft) > 0) && ((elementRect.X + element.scrollLeft) < scrollWidth))) && (((elementRect.Y + element.scrollTop) > 0) && ((elementRect.Y + element.scrollTop) < scrollHeight)))
                        {
                            list.Add(element2);
                        }
                    }
                }
                if (list.Count == 1)
                {
                    mshtml.IHTMLElement ele = list[0] as mshtml.IHTMLElement;
                    if (!string.IsNullOrEmpty(ele.outerText) && !string.IsNullOrEmpty(ele.outerText.Trim()))
                    {
                        this._randomClickLink = ele.outerText;
                        this._randomClickLinkTag = ElementTag.outerText;
                    }
                    else
                    {
                        this._randomClickLinkTag = ElementTag.href;
                        this._randomClickLink = outText;
                    }
                    this._randomClickLinkIndex = HtmlUtil.GetLinkElementIndex(doc2, ele, this._randomClickLink, ((int)this._randomClickLinkTag).ToString());
                    this._status = IEStatus.IEStatus_MoveToDest;
                    this._beforeWaitTime = this._now;
                    list = null;
                    flag = true;
                    return flag;
                }
                if (doc2 != null)
                {
                    this.MoveMouseToBottom(windowHwnd, doc2);
                    if (this.MoveTimeOut() && this.WaitTimeOut())
                    {
                        parent.ShowTip2("不存在标签 :" + outText);
                        this._loop = false;
                        flag = true;
                    }
                }
                return flag;
            }
            if (this.WaitTimeOut())
            {
                flag = true;
            }
            return flag;
        }
 public override void GetPainterInfo(ref mshtml._HTML_PAINTER_INFO pInfo)
 {
     // ensure we paint above everything (including selection handles)
     pInfo.lFlags = (int)_HTML_PAINTER.HTMLPAINTER_OPAQUE;
     pInfo.lZOrder = (int)_HTML_PAINT_ZORDER.HTMLPAINT_ZORDER_WINDOW_TOP;
     pInfo.rcExpand.top = 1;
     pInfo.rcExpand.bottom = 1;
     pInfo.rcExpand.left = 1;
     pInfo.rcExpand.right = 1;
 }
Beispiel #23
0
 private bool ClickTaobaoCloseButton(IntPtr hwnd, mshtml.IHTMLDocument2 doc)
 {
     Rectangle rect = new Rectangle();
     bool isClick = false;
     int clickLinkCount = 0;
     if (!this._inputClickTaobaoCloseButton && HtmlUtil.GetLinkRect(doc, ref rect, "close", "", "3", "0"))
     {
         this.MoveMouseTo(hwnd, doc, rect.X + (rect.Width / 2), rect.Y + (rect.Height / 2), false);
         if (this.MoveTimeOut())
         {
             this.SetFakeMousePoint();
             if (HtmlUtil.ClickLinkRect(hwnd, doc, "close", "", "3", "0", ref isClick, ref this._fakeMousePoint, this._clickEvent, ref clickLinkCount) && isClick)
             {
                 this._inputClickTaobaoCloseButton = true;
             }
             if (!isClick && this.FindTimeOut())
             {
                 this._inputClickTaobaoCloseButton = true;
             }
             if (this._inputClickTaobaoCloseButton)
             {
                 this.ResetTaskTime();
             }
         }
     }
     return this._inputClickTaobaoCloseButton;
 }
Beispiel #24
0
 public static int getAttribute(string attribute, mshtml.IHTMLDocument2 myDoc, mshtml.IHTMLDocument3 doc3)
 {
     int retVal = 0;
     if(!IsDTDDocument(myDoc))
         retVal = (int)myDoc.body.getAttribute(attribute, 0);
     else
         retVal = (int)doc3.documentElement.getAttribute(attribute, 0);
     return retVal;
 }
Beispiel #25
0
 private void MoveMouseTo(IntPtr hwnd, mshtml.IHTMLDocument2 doc, int x, int y, bool shouldWait)
 {
     HtmlElementCollection elementsByTagName = this._curTenDayBrowser.Document.GetElementsByTagName("HTML");
     int count = elementsByTagName.Count;
     bool isTimeout = this.FindTimeOut();
     if ((count > 0) && (!HtmlUtil.MoveToDest(hwnd, elementsByTagName[0], doc, x, y, ref this._fakeMousePoint, shouldWait, isTimeout) || (shouldWait && !isTimeout)))
     {
         this._scrollTime = this._now;
     }
     this.SetFakeScroll();
 }
Beispiel #26
0
 public static void setAttribute(string attribute, int value, mshtml.IHTMLDocument2 myDoc, mshtml.IHTMLDocument3 doc3)
 {
     if(!IsDTDDocument(myDoc))
         myDoc.body.setAttribute(attribute, value, 0);
     else
         doc3.documentElement.setAttribute(attribute, value, 0);
 }
 public MouseMoveHandler(mshtml.IHTMLDocument2 doc)
     : base(doc)
 {
     _el = null;
 }
Beispiel #28
0
 private void HighlightTextRange(mshtml.IHTMLTxtRange range, bool isHighlighted)
 {
     GlobalSettings settings = GlobalData.Instance.Settings;
     if (settings != null)
     {
         if (isHighlighted)
         {
             RemoveHTML(settings, range);
         }
         else
         {
             string htmlToInject = BuildHTML(settings, range);
             if (!String.IsNullOrEmpty(htmlToInject))
             {
                 range.pasteHTML(htmlToInject);
             }
         }
     }
 }
Beispiel #29
0
 public HtmlTextArea(WATF.Core.Page.IPage page, mshtml.IHTMLElement elem)
     : base(page, elem)
 {
     this.m_Page = page;
     this.m_HtmlElement = elem;
 }
Beispiel #30
0
            private String BuildHTML(GlobalSettings settings,mshtml.IHTMLTxtRange range)
            {
                string background = settings.BackgroundColor.R.ToString("X2") + settings.BackgroundColor.G.ToString("X2") + settings.BackgroundColor.B.ToString("X2");
                string textColor = settings.TextColor.R.ToString("X2") + settings.TextColor.G.ToString("X2") + settings.TextColor.B.ToString("X2");
                bool isEmpty = false;
                StringBuilder builder = new StringBuilder();
                builder.Append("<span id=advanced_search style=\"background:#");
                builder.Append(background);
                builder.Append("; color:#");
                builder.Append(textColor);
                builder.Append("\">");

                if (settings.IsHightlightNonVisible)
                {
                    if (settings.IsItalic)
                    {
                        if (settings.IsBold)
                        {
                            builder.Append("<i><b>");
                            builder.Append(range.text);
                            builder.Append("</b></i></span>");
                        }
                        else
                        {
                            builder.Append("<i>");
                            builder.Append(range.text);
                            builder.Append("</i></span>");
                        }
                    }
                    else
                    {
                        if (settings.IsBold)
                        {
                            builder.Append("<b>");
                            builder.Append(range.text);
                            builder.Append("</b></span>");
                        }
                        else
                        {
                            builder.Append(range.text);
                            builder.Append("</span>");
                        }
                    }
                }
                else
                {
                    mshtml.IHTMLElement element = range.parentElement();
                    if (element.offsetTop > Const.NotFound && element.offsetLeft > Const.NotFound && element.offsetHeight > Const.Ok && element.offsetWidth > Const.Ok)
                    {
                        if (settings.IsItalic)
                        {
                            if (settings.IsBold)
                            {
                                builder.Append("<i><b>");
                                builder.Append(range.text);
                                builder.Append("</b></i></span>");
                            }
                            else
                            {
                                builder.Append("<i>");
                                builder.Append(range.text);
                                builder.Append("</i></span>");
                            }
                        }
                        else
                        {
                            if (settings.IsBold)
                            {
                                builder.Append("<b>");
                                builder.Append(range.text);
                                builder.Append("</b></span>");
                            }
                            else
                            {
                                builder.Append(range.text);
                                builder.Append("</span>");
                            }
                        }
                    }
                    else
                    {
                        isEmpty = true;
                    }
                    Marshal.ReleaseComObject(element);
                }
                if (isEmpty)
                {
                    return string.Empty;
                }
                else
                {
                    return builder.ToString();
                }
            }