Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 16
0
 public SUIHtmlAnchor(SUIHtmlControlBase ctrl)
     : base(ctrl)
 { }
Exemplo n.º 17
0
 public SUIHtmlInputButton(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     buttonElement = (IHTMLInputButtonElement)ctrl.HtmlElement;
 }
Exemplo n.º 18
0
 public SUIHtmlAnchor(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
 }
Exemplo n.º 19
0
 public SUIHtmlSelect(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     selectElement = (IHTMLSelectElement)ctrl.HtmlElement;
 }
Exemplo n.º 20
0
 public SUIHtmlImage(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     imageElement = (IHTMLImgElement)ctrl.HtmlElement;
 }
Exemplo n.º 21
0
 public SUIHtmlSpan(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     spanElement = (IHTMLSpanElement)ctrl.HtmlElement;
 }
Exemplo n.º 22
0
 public SUIHtmlSelect(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     selectElement = (IHTMLSelectElement)ctrl.HtmlElement;
 }
Exemplo n.º 23
0
 public SUIHtmlInputText(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     textElement = (IHTMLInputTextElement)ctrl.HtmlElement;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 26
0
 public void Add(SUIHtmlControlBase ctl)
 {
     this.InnerList.Add(ctl);
 }
Exemplo n.º 27
0
 public SUIHtmlControlBase(SUIHtmlControlBase ctrl)
 {
     doc = ctrl.HtmlDocument;
     element = ctrl.HtmlElement;
 }
Exemplo n.º 28
0
 public SUIHtmlImage(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     imageElement = (IHTMLImgElement)ctrl.HtmlElement;
 }
Exemplo n.º 29
0
 public SUIHtmlDiv(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     divElement = (IHTMLDivElement)ctrl.HtmlElement;
 }
Exemplo n.º 30
0
 public SUIHtmlInputButton(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     buttonElement = (IHTMLInputButtonElement)ctrl.HtmlElement;
 }
Exemplo n.º 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;
        }
Exemplo n.º 32
0
 public SUIHtmlSpan(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     spanElement = (IHTMLSpanElement)ctrl.HtmlElement;
 }
Exemplo n.º 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;
        }
Exemplo n.º 34
0
 public void Add(SUIHtmlControlBase ctl)
 {
     this.InnerList.Add(ctl);
 }
Exemplo n.º 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;
        }
Exemplo n.º 36
0
 public SUIHtmlControlBase(SUIHtmlControlBase ctrl)
 {
     doc     = ctrl.HtmlDocument;
     element = ctrl.HtmlElement;
 }
Exemplo n.º 37
0
 public SUIHtmlDiv(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     divElement = (IHTMLDivElement)ctrl.HtmlElement;
 }
Exemplo n.º 38
0
 public SUIHtmlInputText(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     textElement = (IHTMLInputTextElement)ctrl.HtmlElement;
 }