示例#1
0
        public SUIHtmlDocument GetFrame(SUIHtmlControlBase frameControl)
        {
            SUIHtmlDocument frame = null;

            if (frameControl.TagName != null && frameControl.TagName.Equals("FRAME"))
            {
                int index = 0;
                List <SUIHtmlControlBase> frameTags = GetElementsByTagName("Frame");
                if (frameTags.Count != 0)
                {
                    foreach (SUIHtmlControlBase ctrl in frameTags)
                    {
                        if (frameControl.Name.Equals(ctrl.Name))
                        {
                            break;
                        }
                        index++;
                    }
                    List <SUIHtmlDocument> frames = Frames;
                    if (index != frameTags.Count && index < frames.Count)
                    {
                        frame = frames[index];
                    }
                }
            }

            return(frame);
        }
示例#2
0
        public SUIHtmlControlBase SearchHtmlElementByID(string tagName, string id, int index)
        {
            List <SUIHtmlControlBase> list = GetElementsByTagName(tagName);
            int    i      = 0;
            Regex  regex  = new Regex("[0-9]+");
            string ctrlID = null;

            foreach (SUIHtmlControlBase ctrl in list)
            {
                if (ctrl.ID != null)
                {
                    ctrlID = regex.Replace(ctrl.ID, "*");
                }
                if ((ctrl.ID != null && ctrlID.Equals(id)) ||
                    (ctrl.ID == null && id == null))
                {
                    if (i == index)
                    {
                        SUIHtmlControlBase newCtrl = new SUIHtmlControlBase(ctrl);
                        return(newCtrl);
                    }
                    i++;
                }
            }
            return(null);
        }
示例#3
0
 public static bool IsDivElement(SUIHtmlControlBase ctrl)
 {
     bool itis = false;
     try
     {
         IHTMLDivElement span = ctrl.HtmlElement as mshtml.IHTMLDivElement;
         itis = true;
     }
     catch
     {
         itis = false;
     }
     return itis;
 }
示例#4
0
 public static bool IsSelectElement(SUIHtmlControlBase ctrl)
 {
     bool itis = false;
     try
     {
         IHTMLSelectElement select = ctrl.HtmlElement as IHTMLSelectElement;
         int size = select.size;
         itis = true;
     }
     catch
     {
         itis = false;
     }
     return itis;
 }
示例#5
0
        public static bool IsSpanElement(SUIHtmlControlBase ctrl)
        {
            bool itis = false;

            try
            {
                IHTMLSpanElement span = ctrl.HtmlElement as mshtml.IHTMLSpanElement;
                itis = true;
            }
            catch
            {
                itis = false;
            }
            return(itis);
        }
示例#6
0
 public static bool IsAnchorElement(SUIHtmlControlBase ctrl)
 {
     bool itis = false;
     try
     {
         IHTMLAnchorElement anchor = ctrl.HtmlElement as IHTMLAnchorElement;
         string href = anchor.href;
         itis = true;
     }
     catch
     {
         itis = false;
     }
     return itis;
 }
示例#7
0
 public static bool IsInputButtonElement(SUIHtmlControlBase ctrl)
 {
     bool itis = false;
     try
     {
         IHTMLInputButtonElement input = ctrl.HtmlElement as IHTMLInputButtonElement;
         string value = input.value;
         itis = true;
     }
     catch
     {
         itis = false;
     }
     return itis;
 }
示例#8
0
 public static bool IsInputTextElement(SUIHtmlControlBase ctrl)
 {
     bool itis = false;
     try
     {
         IHTMLInputElement input = ctrl.HtmlElement as IHTMLInputElement;
         if (input.type.ToLower() == "text" || input.type.ToLower() == "password")
             itis = true;
     }
     catch
     {
         itis = false;
     }
     return itis;
 }
示例#9
0
        public static bool IsInputButtonElement(SUIHtmlControlBase ctrl)
        {
            bool itis = false;

            try
            {
                IHTMLInputButtonElement input = ctrl.HtmlElement as IHTMLInputButtonElement;
                string value = input.value;
                itis = true;
            }
            catch
            {
                itis = false;
            }
            return(itis);
        }
示例#10
0
        public static bool IsAnchorElement(SUIHtmlControlBase ctrl)
        {
            bool itis = false;

            try
            {
                IHTMLAnchorElement anchor = ctrl.HtmlElement as IHTMLAnchorElement;
                string             href   = anchor.href;
                itis = true;
            }
            catch
            {
                itis = false;
            }
            return(itis);
        }
示例#11
0
        public static bool IsSelectElement(SUIHtmlControlBase ctrl)
        {
            bool itis = false;

            try
            {
                IHTMLSelectElement select = ctrl.HtmlElement as IHTMLSelectElement;
                int size = select.size;
                itis = true;
            }
            catch
            {
                itis = false;
            }
            return(itis);
        }
示例#12
0
        public SUIHtmlControlBase SearchHtmlElementByText(string tagName, string text, int index)
        {
            if (text == "null")
            {
                text = null;
            }
            List <SUIHtmlControlBase> list = GetElementsByTagName(tagName);
            int    i   = 0;
            string str = null;

            foreach (SUIHtmlControlBase ctrl in list)
            {
                if (ctrl.InnerText != null)
                {
                    if (ctrl.InnerText.Length > 50)
                    {
                        str = ctrl.InnerText.Substring(0, 50);//Only use the first 50 chars.
                    }
                    else
                    {
                        str = ctrl.InnerText;
                    }
                    if (str.IndexOf("\r\n") > -1)
                    {
                        str = str.Substring(0, str.IndexOf("\r\n"));
                    }
                }
                else
                {
                    str = null;
                }

                if ((str != null && str.Equals(text)) ||
                    (str == null && text == null))
                {
                    if (i == index)
                    {
                        SUIHtmlControlBase newCtrl = new SUIHtmlControlBase(ctrl);
                        return(newCtrl);
                    }
                    i++;
                }
            }
            return(null);
        }
示例#13
0
        public static bool IsInputTextElement(SUIHtmlControlBase ctrl)
        {
            bool itis = false;

            try
            {
                IHTMLInputElement input = ctrl.HtmlElement as IHTMLInputElement;
                if (input.type.ToLower() == "text" || input.type.ToLower() == "password")
                {
                    itis = true;
                }
            }
            catch
            {
                itis = false;
            }
            return(itis);
        }
示例#14
0
        public SUIHtmlControlBase ElementFromPoint(int x, int y)
        {
            SUIHtmlControlBase ctrl    = null;
            IHTMLElement       element = this.IHTMLDocument2.elementFromPoint(x, y);

            if (element != null)
            {
                ctrl = new SUIHtmlControlBase(this, element);
            }

            if (ctrl.TagName != null && ctrl.TagName.Equals("FRAME"))
            {
                SUIHtmlDocument frame = GetFrame(ctrl);
                //TODO: implement the logic for embedding frames.
                //ctrl = frame.ElementFromPoint(x, y);
            }

            return(ctrl);
        }
示例#15
0
        public List <SUIHtmlControlBase> GetElementsByTagName(string tagName)
        {
            List <SUIHtmlControlBase> list = new List <SUIHtmlControlBase>();

            foreach (IHTMLElement e in IHTMLDocument3.getElementsByTagName(tagName))
            {
                SUIHtmlControlBase ctrl = new SUIHtmlControlBase(this, e);
                list.Add(ctrl);
            }
            //Get elements in frames.
            foreach (SUIHtmlDocument frame in Frames)
            {
                foreach (IHTMLElement eInFrame in frame.IHTMLDocument3.getElementsByTagName(tagName))
                {
                    SUIHtmlControlBase ctrl = new SUIHtmlControlBase(this, eInFrame);
                    list.Add(ctrl);
                }
            }
            return(list);
        }
示例#16
0
 public SUIHtmlAnchor(SUIHtmlControlBase ctrl)
     : base(ctrl)
 { }
示例#17
0
 public SUIHtmlInputButton(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     buttonElement = (IHTMLInputButtonElement)ctrl.HtmlElement;
 }
示例#18
0
 public SUIHtmlAnchor(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
 }
示例#19
0
 public SUIHtmlSelect(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     selectElement = (IHTMLSelectElement)ctrl.HtmlElement;
 }
示例#20
0
 public SUIHtmlImage(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     imageElement = (IHTMLImgElement)ctrl.HtmlElement;
 }
示例#21
0
 public SUIHtmlSpan(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     spanElement = (IHTMLSpanElement)ctrl.HtmlElement;
 }
示例#22
0
 public SUIHtmlSelect(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     selectElement = (IHTMLSelectElement)ctrl.HtmlElement;
 }
示例#23
0
 public SUIHtmlInputText(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     textElement = (IHTMLInputTextElement)ctrl.HtmlElement;
 }
示例#24
0
 public SUIHtmlControlBase SearchHtmlElementByID(string tagName, string id, int index)
 {
     List<SUIHtmlControlBase> list = GetElementsByTagName(tagName);
     int i = 0;
     Regex regex = new Regex("[0-9]+");
     string ctrlID = null;
     foreach (SUIHtmlControlBase ctrl in list)
     {
         if (ctrl.ID != null)
             ctrlID = regex.Replace(ctrl.ID, "*");
         if ((ctrl.ID != null && ctrlID.Equals(id)) ||
             (ctrl.ID == null && id == null))
         {
             if (i == index)
             {
                 SUIHtmlControlBase newCtrl = new SUIHtmlControlBase(ctrl);
                 return newCtrl;
             }
             i++;
         }
     }
     return null;
 }
示例#25
0
 public List<SUIHtmlControlBase> GetElementsByTagName(string tagName)
 {
     List<SUIHtmlControlBase> list = new List<SUIHtmlControlBase>();
     foreach (IHTMLElement e in IHTMLDocument3.getElementsByTagName(tagName))
     {
         SUIHtmlControlBase ctrl = new SUIHtmlControlBase(this, e);
         list.Add(ctrl);
     }
     //Get elements in frames.
     foreach (SUIHtmlDocument frame in Frames)
     {
         foreach (IHTMLElement eInFrame in frame.IHTMLDocument3.getElementsByTagName(tagName))
         {
             SUIHtmlControlBase ctrl = new SUIHtmlControlBase(this, eInFrame);
             list.Add(ctrl);
         }
     }
     return list;
 }
示例#26
0
 public void Add(SUIHtmlControlBase ctl)
 {
     this.InnerList.Add(ctl);
 }
示例#27
0
 public SUIHtmlControlBase(SUIHtmlControlBase ctrl)
 {
     doc = ctrl.HtmlDocument;
     element = ctrl.HtmlElement;
 }
示例#28
0
 public SUIHtmlImage(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     imageElement = (IHTMLImgElement)ctrl.HtmlElement;
 }
示例#29
0
 public SUIHtmlDiv(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     divElement = (IHTMLDivElement)ctrl.HtmlElement;
 }
示例#30
0
 public SUIHtmlInputButton(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     buttonElement = (IHTMLInputButtonElement)ctrl.HtmlElement;
 }
示例#31
0
        public SUIHtmlControlBase ElementFromPoint(int x, int y)
        {
            SUIHtmlControlBase ctrl = null;
            IHTMLElement element = this.IHTMLDocument2.elementFromPoint(x, y);
            if (element != null)
                ctrl = new SUIHtmlControlBase(this, element);

            if (ctrl.TagName != null && ctrl.TagName.Equals("FRAME"))
            {
                SUIHtmlDocument frame = GetFrame(ctrl);
                //TODO: implement the logic for embedding frames.
                //ctrl = frame.ElementFromPoint(x, y);
            }

            return ctrl;
        }
示例#32
0
 public SUIHtmlSpan(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     spanElement = (IHTMLSpanElement)ctrl.HtmlElement;
 }
示例#33
0
        public SUIHtmlDocument GetFrame(SUIHtmlControlBase frameControl)
        {
            SUIHtmlDocument frame = null;
            if (frameControl.TagName != null && frameControl.TagName.Equals("FRAME"))
            {
                int index = 0;
                List<SUIHtmlControlBase> frameTags = GetElementsByTagName("Frame");
                if (frameTags.Count != 0)
                {
                    foreach (SUIHtmlControlBase ctrl in frameTags)
                    {
                        if (frameControl.Name.Equals(ctrl.Name))
                            break;
                        index++;
                    }
                    List<SUIHtmlDocument> frames = Frames;
                    if (index != frameTags.Count && index < frames.Count)
                    {
                        frame = frames[index];
                    }
                }
            }

            return frame;
        }
示例#34
0
 public void Add(SUIHtmlControlBase ctl)
 {
     this.InnerList.Add(ctl);
 }
示例#35
0
        public SUIHtmlControlBase SearchHtmlElementByText(string tagName, string text, int index)
        {
            if (text == "null")
                text = null;
            List<SUIHtmlControlBase> list = GetElementsByTagName(tagName);
            int i = 0;
            string str = null;
            foreach (SUIHtmlControlBase ctrl in list)
            {
                if (ctrl.InnerText != null)
                {
                    if (ctrl.InnerText.Length > 50)
                        str = ctrl.InnerText.Substring(0, 50);//Only use the first 50 chars.
                    else
                        str = ctrl.InnerText;
                    if (str.IndexOf("\r\n") > -1)
                        str = str.Substring(0, str.IndexOf("\r\n"));
                }
                else
                    str = null;

                if ((str != null && str.Equals(text)) ||
                    (str == null && text == null))
                {
                    if (i == index)
                    {
                        SUIHtmlControlBase newCtrl = new SUIHtmlControlBase(ctrl);
                        return newCtrl;
                    }
                    i++;
                }
            }
            return null;
        }
示例#36
0
 public SUIHtmlControlBase(SUIHtmlControlBase ctrl)
 {
     doc     = ctrl.HtmlDocument;
     element = ctrl.HtmlElement;
 }
示例#37
0
 public SUIHtmlDiv(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     divElement = (IHTMLDivElement)ctrl.HtmlElement;
 }
示例#38
0
 public SUIHtmlInputText(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     textElement = (IHTMLInputTextElement)ctrl.HtmlElement;
 }