示例#1
0
        public void Click()
        {
            object         refObj   = null;
            IHTMLDocument4 document = node.document as IHTMLDocument4;
            IHTMLElement3  element  = (IHTMLElement3)node;

            IHTMLEventObj eventObject = document.CreateEventObject(ref refObj);
            object        eventRef    = eventObject;

            element.FireEvent("onMouseDown", ref eventRef);
            element.FireEvent("onMouseUp", ref eventRef);
            node.click();
            parent.WaitForLoadToComplete();
        }
示例#2
0
        private void Type(string value)
        {
            object         refObj   = null;
            IHTMLDocument4 document = node.document as IHTMLDocument4;
            IHTMLElement3  element  = (IHTMLElement3)node;

            string val = "";

            foreach (char c in value)
            {
                IHTMLEventObj eventObject = document.CreateEventObject(ref refObj);
                eventObject.keyCode = c;
                object eventRef = eventObject;
                val += c;
                element.FireEvent("onKeyDown", ref eventRef);
                element.FireEvent("onKeyPress", ref eventRef);
                node.setAttribute("value", val, 0);
                element.FireEvent("onKeyUp", ref eventRef);
            }
        }
示例#3
0
        /// <summary>
        /// Pushes the values from the specified line in the item array to the selected line in
        /// the browser
        /// </summary>
        public static void PushToSelectedLine(int rowIndex, string[] items, IHTMLDocument3 doc3, DataGridView dgvText)
        {
            // Iterate over all of the INPUT elements to find those wanting the project hours
            IHTMLElementCollection allInputs = doc3.getElementsByTagName("input");

            for (int i = 0; i < allInputs.length; i++)
            {
                // We're looking for an INPUT whose id contains "reg_value" and not "IsDirty"
                // this is enough to get the INPUTS for the hours
                IHTMLElement e   = allInputs.item(i);
                int          pos = e.id.IndexOf("reg_value");
                if (pos > -1 && !e.id.Contains("IsDirty"))
                {
                    // Get the single digit index of this current INPUT - this matches to our column index
                    string id = e.id.Substring(pos + 9);
                    if (char.IsDigit(id[0]))
                    {
                        int   index          = int.Parse(id.Substring(0, 1)) + 1;
                        Color originalColour = dgvText.Rows[rowIndex].Cells[index].Style.BackColor;
                        dgvText.Rows[rowIndex].Cells[index].Style.BackColor = Color.Gold;
                        e.click();
                        System.Threading.Thread.Sleep(100);

                        var stringToInsert = items[index];
                        try
                        {
                            // Try to use agresso culture setting
                            decimal value = decimal.Parse(items[index], System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
                            stringToInsert = value.ToString(AgressoCulture.NumberFormat);
                        }
                        catch (Exception)
                        {
                            // Revert to old behaviour
                        }

                        e.innerText = stringToInsert;
                        IHTMLElement3 e3 = e as IHTMLElement3;
                        if (e3 != null)
                        {
                            e3.FireEvent("onchange");
                            Marshal.ReleaseComObject(e3);
                        }
                        dgvText.Rows[rowIndex].Cells[index].Style.BackColor = originalColour;
                    }
                }
                Marshal.ReleaseComObject(e);
            }
            Marshal.ReleaseComObject(allInputs);
        }
        private void fireKeyEvents(IHTMLElement3 elem)
        {
            object dummy = null;
            object eventObj = _doc.CreateEventObject(ref dummy);

            ((IHTMLEventObj)eventObj).keyCode = _keyCode;

            KeyEventStatus thisKeyStatus = new KeyEventStatus();
            thisKeyStatus.keyDownFired = elem.FireEvent("onkeydown", ref eventObj);
            thisKeyStatus.keyPressFired = elem.FireEvent("onkeypress", ref eventObj);
            thisKeyStatus.keyUpFired = elem.FireEvent("onkeyup", ref eventObj);
            _keyEvents.Add(thisKeyStatus);
        }