Provides a base class for DOM nodes.
コード例 #1
0
        public GeckoNode ImportNode(GeckoNode node, bool deep)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            return(GeckoNode.Create(DomDocument.ImportNode((nsIDOMNode)node.DomObject, deep)));
        }
コード例 #2
0
ファイル: GeckoDom.cs プロジェクト: Porfoore/DirtyGecko
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            nsIDOMNode node;

            while ((node = xpathResult.IterateNext()) != null)
            {
                yield return(GeckoNode.Create(node));
            }
        }
コード例 #3
0
        public GeckoNode RemoveChild(GeckoNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            _DomObject.RemoveChild(node._DomObject);
            return(node);
        }
コード例 #4
0
ファイル: GeckoHelpers.cs プロジェクト: alexcepoi/ShareTabWin
 /// <summary>
 /// Gets the DOM id of a node relative to this node, as defined by us.
 /// </summary>
 /// 
 /// <remarks>The DOM id is the index of the given node in a depht-first search
 /// of the DOM tree. It is designed to give a good enough reference to a node
 /// that does not have an id attribute. This fails more or less depending on
 /// the amout of dynamic content inside the page.</remarks>
 /// <param name="root">Root element where to begin the search</param>
 /// <param name="node">Node to search for.</param>
 /// <returns>The DOM id of the node, or 0 if not found</returns>
 public static int GetDomId(this GeckoNode root, GeckoNode node)
 {
     int i = 0;
     foreach (var iter in root.TraverseDom ())
     {
         i++;
         if (node.Equals (iter))
             return i;
     }
     return 0;
 }
コード例 #5
0
        public GeckoNode InsertBefore(GeckoNode newChild, GeckoNode before)
        {
            if (newChild == null)
            {
                throw new ArgumentNullException("newChild");
            }
            if (before == null)
            {
                throw new ArgumentNullException("before");
            }

            _DomObject.InsertBefore(newChild._DomObject, before._DomObject);
            return(newChild);
        }
コード例 #6
0
        public GeckoNode ReplaceChild(GeckoNode newChild, GeckoNode oldChild)
        {
            if (newChild == null)
            {
                throw new ArgumentNullException("newChild");
            }
            if (oldChild == null)
            {
                throw new ArgumentNullException("oldChild");
            }

            _DomObject.ReplaceChild(newChild._DomObject, oldChild._DomObject);
            return(newChild);
        }
コード例 #7
0
 public void SetEndBefore(GeckoNode node)
 {
     Range.SetEndBefore((nsIDOMNode)node.DomObject);
 }
コード例 #8
0
 /// <summary>
 /// Adds all children of the specified node to the selection.
 /// </summary>
 /// <param name="parentNode"></param>
 public void SelectAllChildren(GeckoNode parentNode)
 {
     Selection.SelectAllChildren((nsIDOMNode)parentNode.DomObject);
 }
コード例 #9
0
 /// <summary>
 /// Extends the selection by moving the selection end to the specified node and offset, preserving the selection begin position. The new selection end result will always be from the anchorNode to the new focusNode, regardless of direction.
 /// </summary>
 /// <param name="parentNode">The node where the selection will be extended to.</param>
 /// <param name="offset">Where in node to place the offset in the new selection end.</param>
 public void Extend(GeckoNode parentNode, int offset)
 {
     Selection.Extend((nsIDOMNode)parentNode.DomObject, offset);
 }
コード例 #10
0
 public void SelectNodeContents(GeckoNode node)
 {
     DomRange.SelectNodeContents((nsIDOMNode)node.DomObject);
 }
コード例 #11
0
		public GeckoNode ReplaceChild(GeckoNode newChild, GeckoNode oldChild)
		{
			if (newChild == null)
				throw new ArgumentNullException("newChild");
			if (oldChild == null)
				throw new ArgumentNullException("oldChild");

			_DomObject.ReplaceChild(newChild._DomObject, oldChild._DomObject);
			return newChild;
		}
コード例 #12
0
 public void InsertNode(GeckoNode newNode)
 {
     Range.InsertNode((nsIDOMNode)newNode.DomObject);
 }
コード例 #13
0
 public void SelectNode(GeckoNode node)
 {
     Range.SelectNode((nsIDOMNode)node);
 }
コード例 #14
0
 /// <summary>
 ///Scrolls to a given DOM content node.
 ///	</summary>
 public void ScrollToNode(GeckoNode node)
 {
     m_markupDocumentViewer.ScrollToNode(node.DomObject);
 }
コード例 #15
0
        void Browser_DocumentCompleted_xiangxi(object sender, EventArgs e)
        {
            GeckoWebBrowser br = sender as GeckoWebBrowser;

            if (br.Url.ToString() == "about:blank")
            {
                GetOneUrlandnagative(); return;
            }
            System.GC.Collect();
            try
            {
                ShowClickMsg("开始加载每个楼盘的数据 " + br.Url.ToString());

                foreach (Skybound.Gecko.GeckoElement a in br.Document.Links)
                {
                    if (
                        a.Parent != null &&
                        a.Parent.TagName != null &&
                        a.Parent.TagName.ToLower() == "li" &&
                        a.Parent.Parent != null &&
                        a.Parent.Parent.TagName != null &&
                        a.Parent.Parent.TagName.ToLower() == "ul" &&
                        a.Parent.Parent.Parent != null &&
                        a.Parent.Parent.Parent.ClassName != null &&
                        a.Parent.Parent.Parent.ClassName == "blockLA" &&
                        a.Parent.Parent.Parent.Parent != null &&
                        a.Parent.Parent.Parent.Parent.ClassName != null &&
                        a.Parent.Parent.Parent.Parent.ClassName == "l"
                        &&
                        a.Parent.Parent.Parent.Parent.Parent != null &&
                        a.Parent.Parent.Parent.Parent.Parent.ClassName != null &&
                        a.Parent.Parent.Parent.Parent.Parent.ClassName == "area"
                        &&
                        a.Parent.Parent.Parent.Parent.Parent.Id == "contentB"
                        )
                    {
                        House house = CItyhouseList.Where(item => item.urll == br.Url.ToString()).ToList()[0];
                        if (house != null)
                        {
                            house.IsSearch = true;
                        }
                        else
                        {
                            GetOneUrlandnagative(); return;
                        }
                        if (house != null)
                        {
                            Skybound.Gecko.GeckoElement divinfoo = (Skybound.Gecko.GeckoElement)a.Parent.Parent.Parent.Parent.Parent;

                            Skybound.Gecko.GeckoNode divclass111 = (Skybound.Gecko.GeckoNode)divinfoo.ChildNodes[1];
                            Skybound.Gecko.GeckoNode divblockaaa = (Skybound.Gecko.GeckoNode)divclass111.ChildNodes[1];
                            Skybound.Gecko.GeckoNode ulll1       = (Skybound.Gecko.GeckoNode)divblockaaa.ChildNodes[1];
                            house.updateTime = ((Skybound.Gecko.GeckoNode)ulll1.ChildNodes[1]).ChildNodes[1].TextContent;
                            house.AlongArea  = ((Skybound.Gecko.GeckoNode)ulll1.ChildNodes[5]).TextContent.Replace("所属片区:", "");

                            Skybound.Gecko.GeckoNode divblockBBBB = (Skybound.Gecko.GeckoNode)divclass111.ChildNodes[3];
                            Skybound.Gecko.GeckoNode ulllBBBB     = (Skybound.Gecko.GeckoNode)divblockBBBB.ChildNodes[1];
                            house.Jiaotong   = ((Skybound.Gecko.GeckoNode)ulllBBBB.ChildNodes[1]).TextContent.Replace("周围交通:", "");
                            house.opentime   = ((Skybound.Gecko.GeckoNode)ulllBBBB.ChildNodes[3]).TextContent.Replace("开盘时间:", "");
                            house.LiveIntime = ((Skybound.Gecko.GeckoNode)ulllBBBB.ChildNodes[5]).TextContent.Replace("入住时间:", "");
                        }



                        string name = ListCItyUrl.SingleOrDefault(item => item.Value == GetUrl()).Key;
                        Log.Datalogger(house.ID + "," + GetRightString(house.Name.Replace(",", "、")) + "," + GetRightString(house.HouseType.Replace(",", "、")) + "," + house.Price + "," + GetRightString(house.Danwei) + "," + GetRightString(house.phones.Replace(",", "、")) + "," + GetRightString(house.AlongArea.Replace(",", "、")) + "," +
                                       house.address.Replace(",", "、").Replace("查看地图", "") + "," + GetRightString(house.Kaifangshang.Replace(",", "、")) + "," + GetRightString(house.Jiaotong.Replace(",", "、")) + "," +
                                       GetRightString(house.opentime.Replace(",", "、")) + "," + GetRightString(house.LiveIntime.Replace(",", "、")) + "," + GetRightString(house.updateTime.Replace(",", "、")) + "," + GetRightString(house.wuyeleixing.Replace(",", "、")), name);
                        break;
                    }
                }
                GetOneUrlandnagative();
            }
            catch (Exception ex)
            {
                Log.logger(ex.Message + ex.StackTrace);
                GetOneUrlandnagative();
            }
        }
コード例 #16
0
        void Browser_DocumentCompleted(object sender, EventArgs e)
        {
            GeckoWebBrowser br = sender as GeckoWebBrowser;

            //加载成功开始分析。
            if (br.Url.ToString() == "about:blank")
            {
                return;
            }
            ShowClickMsg("加载成功开始分析" + br.Url.ToString());
            Log.logger("加载成功开始分析" + br.Url.ToString());

            int CountLoupan = 0;

            foreach (Skybound.Gecko.GeckoElement a in br.Document.Links)
            {
                if (a.Parent != null &&
                    a.Parent.Parent != null &&
                    a.Parent.Parent.ClassName != null &&
                    a.Parent.Parent.ClassName == "t"
                    &&
                    a.Parent.Parent.Parent != null &&
                    a.Parent.Parent.Parent.ClassName != null &&
                    a.Parent.Parent.Parent.ClassName == "h3 clear" &&
                    a.Parent.Parent.Parent.Parent != null &&
                    a.Parent.Parent.Parent.Parent.ClassName != null &&
                    a.Parent.Parent.Parent.Parent.ClassName == "rinfo"
                    )
                {
                    CountLoupan++;
                    if (a.TextContent == null)
                    {
                        continue;
                    }

                    House  hous  = new House();
                    string price = a.Parent.Parent.Parent.ChildNodes[3].TextContent.Replace("\n\n\t\t\t    \n\t\t\t    ", "");
                    //		price.Replace("元/平米", "").Replace("均价:", "").Replace(",", "").Trim()	"起价:75万元/套"	string
                    if (price == "        ")
                    {
                        hous.Price = 0;
                    }
                    else
                    {
                        //最高价:8,016万元/套
                        int    priceint  = 0;
                        string trimprice = price.Replace(",", "");
                        if (price.IndexOf("元/平米") >= 0)
                        {
                            trimprice = price.Replace("元/平米", "").Replace("均价:", "").Replace(",", "").Replace("起价:", "").Replace("二手房参考价:", "");
                            int.TryParse(trimprice, out priceint);
                            hous.Price  = priceint;
                            hous.Danwei = "元/平米";
                        }
                        if (price.IndexOf("万元/套") >= 0)
                        {
                            trimprice = price.Replace("万元/套", "").Replace("最高价:", "").Replace(",", "").Replace("起价:", "");
                            int.TryParse(trimprice, out priceint);
                            hous.Price  = priceint;
                            hous.Danwei = "万元/套";
                        }
                    }

                    hous.Name = a.Parent.Parent.Parent.ChildNodes[1].ChildNodes[0].TextContent;

                    Skybound.Gecko.GeckoElement isnew = (Skybound.Gecko.GeckoElement)a.Parent.Parent.ChildNodes[1];

                    hous.HouseType = isnew.TextContent;


                    string[] sArray = Regex.Split(GetUrl(), "housemarket", RegexOptions.IgnoreCase);

                    // 均价:12,800元/平米
                    hous.urll = sArray[0] + a.GetAttribute("href").TrimStart('/');

                    Skybound.Gecko.GeckoElement divadd = (Skybound.Gecko.GeckoElement)a.Parent.Parent.Parent.Parent;
                    Skybound.Gecko.GeckoElement wuye   = (Skybound.Gecko.GeckoElement)divadd.ChildNodes[3];
                    string wuyename = wuye.ChildNodes[1].TextContent;                        //物业类型:普通住宅 别墅 花园洋房

                    string phone = wuye.ChildNodes[3].TextContent.Replace("\n\t\t\t\t", ""); //电话:400-888-2200 转 13923

                    Skybound.Gecko.GeckoNode kaifangshang = (Skybound.Gecko.GeckoNode)divadd.ChildNodes[5];
                    string address = kaifangshang.TextContent;
                    if (wuyename != null)
                    {
                        hous.wuyeleixing = wuyename.Replace("物业类型:", "");
                    }
                    else
                    {
                        hous.wuyeleixing = "无";
                    }
                    if (phone != null)
                    {
                        hous.phones = phone.Replace("电话:", "");
                    }
                    else
                    {
                        hous.phones = "无";
                    }
                    string[] kaifang_address = address.Split(new string[] { "查看地图" }, StringSplitOptions.RemoveEmptyEntries);
                    if (kaifang_address.Length >= 2)
                    {
                        hous.Kaifangshang = kaifang_address[1].Replace("开 发 商:", "");
                        hous.address      = kaifang_address[0].Replace("物业地址:", "");
                    }
                    else
                    {
                        hous.Kaifangshang = address;//物业地址:大兴京开高速庞各庄出口南1000米查看地图\r\n开 发 商:北京富源盛达房地产开发有限公司
                        hous.address      = "无法识别地址";
                    }
                    if (hous.Danwei == null)
                    {
                        hous.Danwei = "";
                    }
                    if (hous.wuyeleixing == null)
                    {
                        hous.wuyeleixing = "";
                    }
                    if (hous.phones == null)
                    {
                        hous.phones = "";
                    }
                    if (hous.Kaifangshang == null)
                    {
                        hous.Kaifangshang = "";
                    }

                    ShowClickMsg(i + "_" + "楼盘:" + hous.Name.Trim() + ";" + hous.Price + " " + hous.Danwei.Trim() + ";" + hous.wuyeleixing.Trim() + ";" + hous.phones.Trim() + ";" + hous.Kaifangshang.Trim());
                    House house = CItyhouseList.SingleOrDefault(item => item.urll == hous.urll);
                    if (house == null)
                    {
                        hous.ID = AllCItyCount;
                        ShowLoadddingMsg(AllCItyCount.ToString());
                        CItyhouseList.Add(hous);
                        AllCItyCount++;
                    }
                }
            }
            i++;
            count++;
            string urll = GetUrl() + "index.php?page=" + i;// "http://sh.focus.cn/housemarket/house_search/index.php?page=" + i;

            ShowClickMsg(urll);
            string page = GetPage();

            if (page == "")
            {
                page = "300";
            }

            System.GC.Collect();
            if (i < int.Parse(page) && CountLoupan > 0)
            {
                this.Browser.Navigate(urll);
            }
            else // if (CountLoupan == 0) //没有查找到新页面了。就可以查找二级页面了。
            {
                this.Browser.DocumentCompleted -= new  EventHandler(Browser_DocumentCompleted);
                this.Browser.DocumentCompleted += new EventHandler(Browser_DocumentCompleted_xiangxi);
                GetOneUrlandnagative();
            }
        }
コード例 #17
0
 /// <summary>
 ///Scrolls to a given DOM content node.
 ///	</summary>
 public void ScrollToNode(GeckoNode node)
 {
     m_markupDocumentViewer.ScrollToNode(node.DomObject);
 }
コード例 #18
0
 public bool IsPointInRange(GeckoNode node, int offset)
 {
     return(DomNsRange.IsPointInRange(node.DomObject, offset));
 }
コード例 #19
0
 public void SelectNode(GeckoNode node)
 {
     Range.SelectNode((nsIDOMNode)node);
 }
コード例 #20
0
 public GeckoNode ExtractContents()
 {
     return(GeckoNode.Create(Range.ExtractContents()));
 }
コード例 #21
0
 public void SelectNodeContents(GeckoNode node)
 {
     Range.SelectNodeContents((nsIDOMNode)node);
 }
コード例 #22
0
		public GeckoNode InsertBefore(GeckoNode newChild, GeckoNode before)
		{
			if (newChild == null)
				throw new ArgumentNullException("newChild");
			if (before == null)
				throw new ArgumentNullException("before");

			_DomObject.InsertBefore(newChild._DomObject, before._DomObject);
			return newChild;
		}
コード例 #23
0
 public void SetEnd(GeckoNode node, int offset)
 {
     Range.SetEnd((nsIDOMNode)node.DomObject, offset);
 }
コード例 #24
0
 public void SetEndAfter(GeckoNode node)
 {
     Range.SetEndAfter((nsIDOMNode)node.DomObject);
 }
コード例 #25
0
 public void SetEndBefore(GeckoNode node)
 {
     Range.SetEndBefore((nsIDOMNode)node.DomObject);
 }
コード例 #26
0
 /// <summary>Creates a new instance of a <see cref="GeckoContextMenuEventArgs"/> object.</summary>
 public GeckoContextMenuEventArgs(Point location, ContextMenu contextMenu, string associatedLink, Uri backgroundImageSrc, Uri imageSrc, GeckoNode targetNode)
 {
     this._Location = location;
     this._ContextMenu = contextMenu;
     this._AssociatedLink = associatedLink;
     this._BackgroundImageSrc = backgroundImageSrc;
     this._ImageSrc = ImageSrc;
     this._TargetNode = targetNode;
 }
コード例 #27
0
 public void InsertNode(GeckoNode newNode)
 {
     DomRange.InsertNode((nsIDOMNode)newNode.DomObject);
 }
コード例 #28
0
 /// <summary>
 /// Collapses the selection to a single point, at the specified offset in the given DOM node. When the selection is collapsed, and the content is focused and editable, the caret will blink there.
 /// </summary>
 /// <param name="parentNode"></param>
 /// <param name="offset"></param>
 public void Collapse(GeckoNode parentNode, int offset)
 {
     Selection.Collapse((nsIDOMNode)parentNode.DomObject, offset);
 }
コード例 #29
0
 public bool IsPointInRange(GeckoNode node, int offset)
 {
     return DomNsRange.IsPointInRange(node.DomObject, offset);
 }
コード例 #30
0
 /// <summary>
 /// Returns whether the specified node is part of the selection.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="partlyContained">True if the function should return true when some part of the node is contained with the selection; when false, the function only returns true when the entire node is contained within the selection.</param>
 /// <returns></returns>
 public bool ContainsNode(GeckoNode node, bool partlyContained)
 {
     return(Selection.ContainsNode((nsIDOMNode)node.DomObject, partlyContained));
 }
コード例 #31
0
 public void SelectNodeContents(GeckoNode node)
 {
     DomRange.SelectNodeContents((nsIDOMNode)node.DomObject);
 }
コード例 #32
0
 public void SetEnd(GeckoNode node, int offset)
 {
     Range.SetEnd((nsIDOMNode)node.DomObject, offset);
 }
コード例 #33
0
 public void SetStart(GeckoNode node, int offset)
 {
     DomRange.SetStart((nsIDOMNode)node.DomObject, offset);
 }
コード例 #34
0
 public void SetEndAfter(GeckoNode node)
 {
     Range.SetEndAfter((nsIDOMNode)node.DomObject);
 }
コード例 #35
0
 public void SetStartAfter(GeckoNode node)
 {
     DomRange.SetStartAfter((nsIDOMNode)node.DomObject);
 }
コード例 #36
0
 public void SelectNodeContents(GeckoNode node)
 {
     Range.SelectNodeContents((nsIDOMNode)node);
 }
コード例 #37
0
 public void SetStartBefore(GeckoNode node)
 {
     DomRange.SetStartBefore((nsIDOMNode)node.DomObject);
 }
コード例 #38
0
 public GeckoNode CloneContents()
 {
     return(GeckoNode.Create(Range.CloneContents()));
 }
コード例 #39
0
 public void SurroundContents(GeckoNode newParent)
 {
     DomRange.SurroundContents((nsIDOMNode)newParent.DomObject);
 }
コード例 #40
0
 public void SurroundContents(GeckoNode newParent)
 {
     Range.SurroundContents((nsIDOMNode)newParent.DomObject);
 }
コード例 #41
0
 /// <summary>
 /// Collapses the selection to a single point, at the specified offset in the given DOM node. When the selection is collapsed, and the content is focused and editable, the caret will blink there.
 /// </summary>
 /// <param name="parentNode"></param>
 /// <param name="offset"></param>
 public void Collapse(GeckoNode parentNode, int offset)
 {
     Selection.Collapse((nsIDOMNode)parentNode.DomObject, offset);
 }
コード例 #42
0
		public GeckoNode RemoveChild(GeckoNode node)
		{
			if (node == null)
				throw new ArgumentNullException("node");

			_DomObject.RemoveChild(node._DomObject);
			return node;
		}
コード例 #43
0
 /// <summary>
 /// Returns whether the specified node is part of the selection.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="partlyContained">True if the function should return true when some part of the node is contained with the selection; when false, the function only returns true when the entire node is contained within the selection.</param>
 /// <returns></returns>
 public bool ContainsNode(GeckoNode node, bool partlyContained)
 {
     return Selection.ContainsNode((nsIDOMNode)node.DomObject, partlyContained);
 }
コード例 #44
0
 public GeckoNode CloneNode(bool deep)
 {
     return(GeckoNode.Create(_DomObject.CloneNode(deep)));
 }
コード例 #45
0
ファイル: GeckoDom.cs プロジェクト: Porfoore/DirtyGecko
 public GeckoNode CreateTextNode(string data)
 {
     return(GeckoNode.Create(DomDocument.CreateTextNode(new nsAString(data))));
 }
コード例 #46
0
 public void SetStartBefore(GeckoNode node)
 {
     DomRange.SetStartBefore((nsIDOMNode)node.DomObject);
 }
コード例 #47
0
 /// <summary>
 /// Adds all children of the specified node to the selection.
 /// </summary>
 /// <param name="parentNode"></param>
 public void SelectAllChildren(GeckoNode parentNode)
 {
     Selection.SelectAllChildren((nsIDOMNode)parentNode.DomObject);
 }
コード例 #48
0
 public void SetStart(GeckoNode node, int offset)
 {
     DomRange.SetStart((nsIDOMNode)node.DomObject, offset);
 }
コード例 #49
0
ファイル: PublicTab.cs プロジェクト: alexcepoi/ShareTabWin
        /// <summary>
        /// When the user moves his mouse over the renderer, if the DOM element under the cursor
        /// changes, notifies the server of the identity of the new element under the mouse
        /// so that the clients can scroll there.
        /// </summary>
        protected override void renderer_DomMouseMove(object sender, GeckoDomMouseEventArgs e)
        {
            base.renderer_DomMouseMove (sender, e);
            if (!e.Target.Equals (currentNode))
            {
                currentNode = e.Target;
                if (currentNode != null)
                {
                    CurrentNodeChangedEventArgs args = null;
                    string tagId = null;

                    if (currentNode is GeckoElement)
                        tagId = (currentNode as GeckoElement).Id;

                    if (string.IsNullOrEmpty (tagId))
                    {
                        int domId = renderer.Document.DocumentElement.GetDomId (currentNode);
                        if (domId != 0) //throw new InvalidOperationException ("GetDomId returned a 0, this should never happen!");
                            args = new CurrentNodeChangedEventArgs (TabData, domId);
                    }
                    else
                    {
                        args = new CurrentNodeChangedEventArgs (TabData, tagId);
                    }

                    if (args != null)
                        RaiseEvent (args);
                }
            }
        }
コード例 #50
0
 /// <summary>
 /// Extends the selection by moving the selection end to the specified node and offset, preserving the selection begin position. The new selection end result will always be from the anchorNode to the new focusNode, regardless of direction.
 /// </summary>
 /// <param name="parentNode">The node where the selection will be extended to.</param>
 /// <param name="offset">Where in node to place the offset in the new selection end.</param>
 public void Extend(GeckoNode parentNode, int offset)
 {
     Selection.Extend((nsIDOMNode)parentNode.DomObject, offset);
 }
コード例 #51
0
 public void SetStartAfter(GeckoNode node)
 {
     DomRange.SetStartAfter((nsIDOMNode)node.DomObject);
 }