Esempio n. 1
0
        /// <summary>
        /// Selects the specified item in the combobox by clicking on it
        /// </summary>
        /// <param name="itemText">The item to select</param>
        /// <param name="caseSensitivity">Whether to include the case of the item in the comparison</param>
        /// <param name="checkSelected">Whether to check the item selected is the current item after selecting</param>
        public void SingleClickItem(string itemText, CaseSensitivity caseSensitivity, bool checkSelected)
        {
            Stopwatch timer;

            //Check if its already selected
            switch (caseSensitivity)
            {
            case CaseSensitivity.Sensitive:
                if (CurrentItemText() == itemText)
                {
                    GUI.Log("Ensure " + Identity.Description + " is set to " + itemText, LogItemType.Action);
                    return;
                }
                break;

            case CaseSensitivity.Insensitive:
                if (CurrentItemText().ToLower() == itemText.ToLower())
                {
                    GUI.Log("Ensure " + Identity.Description + " is set to " + itemText, LogItemType.Action);
                    return;
                }
                break;

            default:
                throw GUI.ApeException("Unsupported CaseSensitivity value: " + caseSensitivity.ToString());
            }

            GUI.Log("Select [" + itemText + "] from " + Identity.Description, LogItemType.Action);

            //Get the style
            Input.WaitForInputIdle(Identity.Handle, GUI.m_APE.TimeOut);
            string style = GetComboBoxStyle(out dynamic droppedDown);

            IntPtr listBox = IntPtr.Zero;

            NM.COMBOBOXINFO cbi = new NM.COMBOBOXINFO();
            cbi.cbSize = Marshal.SizeOf(cbi);

            Input.Block();
            try
            {
                GUIComboBox actualComboBox;
                if ((Identity.TechnologyType == "Windows ActiveX" && Identity.TypeName == "ImageCombo") || (Identity.TechnologyType == "Windows Native" && Identity.TypeName.StartsWith("ImageCombo")))
                {
                    IntPtr sendResult;
                    IntPtr messageResult;
                    sendResult = NM.SendMessageTimeout(Identity.Handle, NM.CBEM_GETCOMBOCONTROL, IntPtr.Zero, IntPtr.Zero, NM.SendMessageTimeoutFlags.SMTO_NORMAL, GUI.m_APE.TimeOut, out messageResult);
                    if (sendResult == IntPtr.Zero)
                    {
                        throw GUI.ApeException("Failed to access the " + Description);
                    }

                    if (messageResult == IntPtr.Zero)
                    {
                        throw GUI.ApeException("Failed to find the " + Description + " actual combobox");
                    }

                    actualComboBox = new GUIComboBox(this.ParentForm, Description + " actual combobox", new Identifier(Identifiers.Handle, messageResult));
                }
                else
                {
                    actualComboBox = this;
                }

                if (style == "Simple")
                {
                    //get the Simple mode listbox child window
                    NM.GetComboBoxInfo(actualComboBox.Handle, ref cbi);
                    listBox = cbi.hwndList;
                }
                else
                {
                    if (droppedDown == null)
                    {
                        Thread.Sleep(250);
                        style = GetComboBoxStyle(out droppedDown);
                        if (droppedDown == null)
                        {
                            throw GUI.ApeException("Failed to determine the dropdown state of the " + Description);
                        }
                    }

                    if (!droppedDown)
                    {
                        actualComboBox.SingleClickInternal(Width - 5, -1, MouseButton.Left, MouseKeyModifier.None);
                    }

                    //find the dropdown
                    Input.WaitForInputIdle(actualComboBox.Handle, GUI.m_APE.TimeOut);

                    NM.GetComboBoxInfo(actualComboBox.Handle, ref cbi);
                    listBox = cbi.hwndList;
                    if (listBox == IntPtr.Zero)
                    {
                        throw GUI.ApeException("Failed to find the " + Description + " dropdown");
                    }
                }

                //locate the item
                timer = Stopwatch.StartNew();
                int index;
                while (true)
                {
                    index = ItemIndex(itemText, caseSensitivity);
                    if (index != NM.CB_ERR)
                    {
                        break;
                    }

                    if (timer.ElapsedMilliseconds > GUI.m_APE.TimeOut)
                    {
                        throw GUI.ApeException("Failed to find the " + Description + " item");
                    }

                    Thread.Sleep(50);
                }

                NM.tagRect ClientRect;
                NM.GetClientRect(listBox, out ClientRect);

                //Locate the rectangle of the item
                Rectangle itemRectangle = GetItemRectangle(listBox, index);

                //scroll the item into view if needed and then locate the rectangle
                if ((itemRectangle.Height / 2) + itemRectangle.Top > ClientRect.bottom || (itemRectangle.Height / 2) + itemRectangle.Top < ClientRect.top)
                {
                    SetTopIndex(listBox, index);
                    itemRectangle = GetItemRectangle(listBox, index);
                }

                //click the item
                GUIForm comboBoxDropdown = new GUIForm(ParentForm, Description + " dropdown", new Identifier(Identifiers.Handle, listBox), new Identifier(Identifiers.TechnologyType, "Windows Native"));
                //WaitForAnimation(comboBoxDropdown.Handle, false, AnimationUtils.WaitForAnimationSource.ComboBoxDropdown);

                comboBoxDropdown.SingleClickInternal(-1, (itemRectangle.Height / 2) + itemRectangle.Top, MouseButton.Left, MouseKeyModifier.None);

                if (checkSelected)
                {
                    //wait for CurrentItemText() to == text
                    bool selected = false;
                    timer = Stopwatch.StartNew();

                    while (true)
                    {
                        switch (caseSensitivity)
                        {
                        case CaseSensitivity.Sensitive:
                            if (CurrentItemText() == itemText)
                            {
                                selected = true;
                            }
                            break;

                        case CaseSensitivity.Insensitive:
                            if (CurrentItemText().ToLower() == itemText.ToLower())
                            {
                                selected = true;
                            }
                            break;

                        default:
                            throw GUI.ApeException("Unsupported CaseSensitivity value: " + caseSensitivity.ToString());
                        }

                        if (selected)
                        {
                            break;
                        }

                        if (timer.ElapsedMilliseconds > GUI.m_APE.TimeOut)
                        {
                            throw GUI.ApeException("Failed to select the item in the " + Description);
                        }

                        Thread.Sleep(15);
                    }
                }
            }
            catch when(Input.ResetInputFilter())
            {
                // Will never be reached as ResetInputFilter always returns false
            }
            finally
            {
                Input.Unblock();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Constructor used for non-form controls
 /// </summary>
 /// <param name="parentForm">The top level form the control belongs to</param>
 /// <param name="descriptionOfControl">A description of the control which would make sense to a human.
 /// <para/>This text is used in the logging method.  For example: OK button</param>
 /// <param name="identParams">One or more identifier object(s) used to locate the control.
 /// <para/>Normally you would just use the name identifier</param>
 public GUIComboBox(GUIForm parentForm, string descriptionOfControl, params Identifier[] identParams)
     : base(parentForm, descriptionOfControl, identParams)
 {
 }
Esempio n. 3
0
 /// <summary>
 /// Constructor used for non-form controls
 /// </summary>
 /// <param name="parentForm">The top level form the control belongs to</param>
 /// <param name="descriptionOfControl">A description of the control which would make sense to a human.
 /// <para/>This text is used in the logging method.  For example: OK button</param>
 /// <param name="identParams">One or more identifier object(s) used to locate the control.
 /// <para/>Normally you would just use the name identifier</param>
 public GUIProgressBar(GUIForm parentForm, string descriptionOfControl, params Identifier[] identParams)
     : base(parentForm, descriptionOfControl, identParams)
 {
 }
Esempio n. 4
0
 /// <summary>
 /// Constructor used for non-form controls
 /// </summary>
 /// <param name="parentForm">The top level form the control belongs to</param>
 /// <param name="descriptionOfControl">A description of the control which would make sense to a human.
 /// <para/>This text is used in the logging method.  For example: OK button</param>
 /// <param name="identParams">One or more identifier object(s) used to locate the control.
 /// <para/>Normally you would just use the name identifier</param>
 public GUIRadioButton(GUIForm parentForm, string descriptionOfControl, params Identifier[] identParams)
     : base(parentForm, descriptionOfControl, identParams)
 {
 }
Esempio n. 5
0
 /// <summary>
 /// Constructor used for non-form controls
 /// </summary>
 /// <param name="parentForm">The top level form the control belongs to</param>
 /// <param name="descriptionOfControl">A description of the control which would make sense to a human.
 /// <para/>This text is used in the logging method.  For example: OK button</param>
 /// <param name="identParams">One or more identifier object(s) used to locate the control.
 /// <para/>Normally you would just use the name identifier</param>
 public GUIFocusableObject(GUIForm parentForm, string descriptionOfControl, params Identifier[] identParams)
     : base(parentForm, descriptionOfControl, identParams)
 {
 }
Esempio n. 6
0
 /// <summary>
 /// Initialises a new instance of the GUIForm class for a child form
 /// </summary>
 /// <param name="parentForm">The top level form the control belongs to</param>
 /// <param name="descriptionOfControl">A description of the control which would make sense to a human.
 /// <para/>This text is used in the logging method.  For example: OK button</param>
 /// <param name="identParams">One or more identifier object(s) used to locate the control.
 /// <para/>Normally you would just use the name identifier</param>
 public GUIForm(GUIForm parentForm, string descriptionOfControl, params Identifier[] identParams)
     : base(parentForm, descriptionOfControl, identParams)
 {
     //When a form is opened it is animated, so wait for it to finish
     WaitForAnimation(Identity.Handle, true, AnimationUtils.WaitForAnimationSource.Form);
 }
Esempio n. 7
0
        internal static ControlIdentifier BuildIdentity(GUIForm parentForm, string descriptionOfControl, params Identifier[] identParams)
        {
            ControlIdentifier Identity = new ControlIdentifier();

            Identity.Description = descriptionOfControl;
            if (parentForm != null)
            {
                Identity.ParentHandle = parentForm.Handle;
            }

            foreach (Identifier i in identParams)
            {
                switch (i.IdentifierType)
                {
                case Identifiers.Handle:
                    Identity.Handle = i.IdentifierValue;
                    break;

                case Identifiers.Name:
                    Identity.Name = i.IdentifierValue;
                    break;

                case Identifiers.TechnologyType:
                    Identity.TechnologyType = i.IdentifierValue;
                    break;

                case Identifiers.TypeNameSpace:
                    Identity.TypeNameSpace = i.IdentifierValue;
                    break;

                case Identifiers.TypeName:
                    Identity.TypeName = i.IdentifierValue;
                    break;

                case Identifiers.ModuleName:
                    Identity.ModuleName = i.IdentifierValue;
                    break;

                case Identifiers.AssemblyName:
                    Identity.AssemblyName = i.IdentifierValue;
                    break;

                case Identifiers.Index:
                    Identity.Index = i.IdentifierValue;
                    break;

                case Identifiers.Text:
                    Identity.Text = i.IdentifierValue;
                    break;

                case Identifiers.ChildOf:
                    Identity.ChildOf = i.IdentifierValue.Handle;
                    break;

                case Identifiers.SiblingOf:
                    Identity.SiblingOf = i.IdentifierValue.Handle;
                    break;

                case Identifiers.ParentOf:
                    Identity.ParentOf = i.IdentifierValue.Handle;
                    break;

                case Identifiers.AccessibilityObjectName:
                    Identity.AccessibilityObjectName = i.IdentifierValue;
                    break;

                case Identifiers.UniqueId:
                    Identity.UniqueId = i.IdentifierValue;
                    break;

                default:
                    throw GUI.ApeException("Unsupported identifier: " + i.ToString());
                }
            }

            return(Identity);
        }
Esempio n. 8
0
 /// <summary>
 /// Constructor used for non-form controls
 /// </summary>
 /// <param name="parentForm">The top level form the control belongs to</param>
 /// <param name="descriptionOfControl">A description of the control which would make sense to a human.
 /// <para/>This text is used in the logging method.  For example: OK button</param>
 /// <param name="identParams">One or more identifier object(s) used to locate the control.
 /// <para/>Normally you would just use the name identifier</param>
 public GUIDocumentContainer(GUIForm parentForm, string descriptionOfControl, params Identifier[] identParams)
     : base(parentForm, descriptionOfControl, identParams)
 {
 }
Esempio n. 9
0
 /// <summary>
 /// Constructor used for non-form controls
 /// </summary>
 /// <param name="parentForm">The top level form the control belongs to</param>
 /// <param name="descriptionOfControl">A description of the control which would make sense to a human.
 /// <para/>This text is used in the logging method.  For example: OK button</param>
 /// <param name="identParams">One or more identifier object(s) used to locate the control.
 /// <para/>Normally you would just use the name identifier</param>
 public GUILzNavBarGridControl(GUIForm parentForm, string descriptionOfControl, params Identifier[] identParams)
     : base(parentForm, descriptionOfControl, identParams)
 {
 }
Esempio n. 10
0
 /// <summary>
 /// Constructor used for non-form controls
 /// </summary>
 /// <param name="parentForm">The top level form the control belongs to</param>
 /// <param name="descriptionOfControl">A description of the control which would make sense to a human.
 /// <para/>This text is used in the logging method.  For example: OK button</param>
 /// <param name="identParams">One or more identifier object(s) used to locate the control.
 /// <para/>Normally you would just use the name identifier</param>
 public GUIVScrollBar(GUIForm parentForm, string descriptionOfControl, params Identifier[] identParams)
     : base(parentForm, descriptionOfControl, identParams)
 {
     this.DisableMouseEvents = true; //TODO work out what is going on here
 }
Esempio n. 11
0
 /// <summary>
 /// Constructor used for non-form controls
 /// </summary>
 /// <param name="parentForm">The top level form the control belongs to</param>
 /// <param name="descriptionOfControl">A description of the control which would make sense to a human.
 /// <para/>This text is used in the logging method.  For example: OK button</param>
 /// <param name="identParams">One or more identifier object(s) used to locate the control.
 /// <para/>Normally you would just use the name identifier</param>
 public GUIGenericWalker(GUIForm parentForm, string descriptionOfControl, params Identifier[] identParams)
     : base(parentForm, descriptionOfControl, identParams)
 {
 }