Esempio n. 1
0
        /// <summary>
        /// Creates an MsHtmlElement
        /// </summary>
        /// <param name="msElement">The IE DOM element</param>
        /// <returns>the created instance</returns>
        private MsHtmlElement Create(IHTMLElement msElement)
        {
            if (msElement == null)
            {
                throw new ArgumentNullException("msElement");
            }

            int id       = this.GetId(msElement);
            int?parentId = this.GetParentId(msElement);

            int[]  childrenIds = this.GetChildrenIds(msElement);
            string tagName     = msElement.tagName;
            string innerHtml   = this.GetInnerHtml(msElement);
            string outerHtml   = this.GetOuterHtml(msElement);
            string outerText   = this.GetOuterText(msElement);

            int?      offsetParentId  = this.GetOffsetParentId(msElement);
            Rectangle offsetRectangle = this.GetOffsetRectangle(msElement);

            Dictionary <string, string> attributes      = this.GetAttributes(msElement);
            Dictionary <string, string> styles          = this.GetStyles(tagName, msElement);
            IEnumerable <string>        classifications = new List <string>();

            var msHtmlElement = new MsHtmlElement(id, id, parentId, childrenIds, classifications, tagName, outerHtml, innerHtml, outerText, attributes, styles, _defaultStyleLookup, offsetParentId, offsetRectangle);

            return(msHtmlElement);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the tree links
        /// </summary>
        /// <param name="lookup">The tree node lookup</param>
        public override void Link(IDictionary <int, TreeNode> lookup)
        {
            base.Link(lookup);

            if (_offsetParentId.HasValue)
            {
                _offsetParent = (MsHtmlElement)lookup[_offsetParentId.Value];
            }

            this.ComputeBoundingBox();
        }
Esempio n. 3
0
        /// <summary>
        /// Computes the bounding box
        /// from the offset parent and offset rectangle
        /// </summary>
        private void ComputeBoundingBox()
        {
            Rectangle     boundingBox  = _offsetRectangle;
            MsHtmlElement offsetParent = _offsetParent;

            while (offsetParent != null)
            {
                boundingBox.X += offsetParent._offsetRectangle.X;
                boundingBox.Y += offsetParent._offsetRectangle.Y;
                offsetParent   = offsetParent._offsetParent;
            }

            this.BoundingBox = boundingBox;
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MsHtmlDocument" /> class
 /// </summary>
 /// <param name="root">The root element</param>
 /// <param name="info">The Html Document information</param>
 /// <param name="defaultStyleLookup">The default style lookup</param>
 public MsHtmlDocument(MsHtmlElement root, HtmlDocumentInfo info, DefaultStyleLookup defaultStyleLookup)
     : base(root, info, defaultStyleLookup)
 {
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MsHtmlDocument" /> class
 /// </summary>
 /// <param name="root">The root element</param>
 /// <param name="info">The Html Document information</param>
 /// <param name="defaultStyleLookup">The default style lookup</param>
 /// <param name="displayHtml">The display HTML</param>
 public MsHtmlDocument(MsHtmlElement root, HtmlDocumentInfo info, DefaultStyleLookup defaultStyleLookup, string displayHtml)
     : base(root, info, defaultStyleLookup)
 {
     this.DisplayHtml = displayHtml;
 }