コード例 #1
0
        /// <summary>
        /// Retrieve the html eleme from document by x,y position in the doc.
        /// Create a Watin Element and by finding the control type and index create the WatingControl.
        /// </summary>
        /// <param name="x">X positing of the control relative to the document (body, upper left it 0,0)</param>
        /// <param name="y">Y positing of the control relative to the document (body, upper left it 0,0)</param>
        /// <returns>Watin control with known groupe type and index inside the group</returns>
        public WatinControl GetElementFromPoint(int x, int y)
        {
            WatinControl wat;
            //  Point er = new Point(x,y);
            //Thread th = new System.Threading.Thread(new ParameterizedThreadStart(ControlFromPointWorker));
            // th.Start(er);
            // th.Join();

            INativeElement htmlElem = browser.NativeDocument.ElementFromPoint(x, y);

            if (htmlElem.TagName.Contains("FRAME"))
            {
                int sourceIdx = htmlElem.GetElementSourceIndex();
                WatinBaseControl watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Frames);

                IEnumerator <Frame> frmEnum = browser.Frames.GetEnumerator();

                while (frmEnum.MoveNext())
                {
                    INativeElement htmlElem2 = frmEnum.Current.NativeDocument.ContainingFrameElement;
                    if (sourceIdx == htmlElem2.GetElementSourceIndex())
                    {
                        WatFrame frameParent = new WatFrame(new WatinBaseControl(this, WatinBaseTypes.Frames), frmEnum.Current, sourceIdx);

                        //htmlElem = frmEnum.Current.NativeDocument.ElementFromPoint(x - htmlElem2.GetAbsElementBounds().Left, y - htmlElem2.GetAbsElementBounds().Top);
                        //wat = CreateWatinControl(htmlElem);
                        return(frameParent.GetControlFromPoint(x, y));
                    }
                }
            }

            wat = CreateWatinControl(htmlElem);
            return(wat);
        }
コード例 #2
0
 public WatinBaseControl(WatFrame frameWithChilds, WatinBaseTypes type)
 {
     _parent   = frameWithChilds;
     this.type = type;
 }