예제 #1
0
        /// <summary>
        ///     Selects the menu item.
        /// </summary>
        /// <param name = "menuItems">The menu items.</param>
        /// <param name = "itemPath">The 'path' to the menu item.</param>
        private static void SelectMenuItemStatic(AutomationElementCollection menuItems, Collection <string> itemPath)
        {
            foreach (AutomationElement item in menuItems)
            {
                /* Expand top menu */
                try
                {
                    string name = item.Current.Name;
                    if (string.Compare(name, itemPath[0], true, CultureInfo.CurrentCulture) != 0)
                    {
                        continue;
                    }

                    ExpandCollapseHelper.Expand(item);
                    FindItemStatic(item, itemPath);
                }
                catch (InvalidOperationException err)
                {
                    throw new ProdOperationException(err.Message, err);
                }
                catch (ElementNotAvailableException err)
                {
                    throw new ProdOperationException(err.Message, err);
                }
            }
        }
예제 #2
0
 /// <summary>
 ///     Finds an AutomationElement in a list.
 /// </summary>
 /// <param name = "item">The item to search for.</param>
 /// <param name = "itemPath">The 'path' to the menu item.</param>
 private static void FindItemStatic(AutomationElement item, Collection <string> itemPath)
 {
     /* Loop through supplied menu path */
     for (int i = 1; i < itemPath.Count; i++)
     {
         try
         {
             /* Get next item */
             AutomationElement ael = item.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, itemPath[i], PropertyConditionFlags.IgnoreCase));
             /* Expand next item */
             ExpandCollapseHelper.Expand(ael);
             ael.SetFocus();
             InvokePatternHelper.Invoke(ael);
         }
         catch (InvalidOperationException err)
         {
             throw new ProdOperationException(err.Message, err);
         }
         catch (ElementNotAvailableException err)
         {
             throw new ProdOperationException(err.Message, err);
         }
     }
     return;
 }
예제 #3
0
        public void ExpandNode(string itemText)
        {
            LogText = "Item: " + itemText;

            try
            {
                RegisterEvent(ExpandCollapsePattern.ExpandCollapseStateProperty);
                SelectNode(itemText);
                AutomationElement retVal = GetSelectedNode();
                ExpandCollapseHelper.Expand(retVal);
            }
            catch (ProdOperationException err)
            {
                throw;
            }
        }
예제 #4
0
        /// <summary>
        /// Expands the menu item.
        /// </summary>
        /// <param name="menuItems">The menu items.</param>
        /// <param name="itemPath">The item path.</param>
        private static void ExpandMenuItem(AutomationElementCollection menuItems, string[] itemPath)
        {
            foreach (AutomationElement item in menuItems)
            {
                /* Expand top menu */
                try
                {
                    string name = item.Current.Name;
                    if (string.Compare(name, itemPath[_ctr], true, CultureInfo.CurrentCulture) != 0)
                    {
                        continue;
                    }

                    if (CommonUIAPatternHelpers.CheckPatternSupport(ExpandCollapsePattern.Pattern, item) != null)
                    {
                        ExpandCollapseHelper.Expand(item);

                        AutomationElementCollection items = GetChildMenuItems(item);
                        _ctr++;
                        ExpandMenuItem(items, itemPath);
                    }

                    if (CommonUIAPatternHelpers.CheckPatternSupport(InvokePattern.Pattern, item) == null)
                    {
                        return;
                    }
                    InvokePatternHelper.Invoke(item);
                }
                catch (InvalidOperationException err)
                {
                    throw new ProdOperationException(err.Message, err);
                }
                catch (ElementNotAvailableException err)
                {
                    throw new ProdOperationException(err.Message, err);
                }
            }
        }
예제 #5
0
        /// <summary>
        ///     Enumerates all nodes ion the TreeView and adds to a collection
        /// </summary>
        /// <param name = "aeRoot">The root tree node.</param>
        private void EnumControlElements(AutomationElement aeRoot)
        {
            while (aeRoot != null)
            {
                AllNodes.Add(aeRoot);
                _chk++;
                int ret = ExpandCollapseHelper.Expand(aeRoot);
                if (ret == -1)
                {
                    ExpandCollapseHelper.Collapse(AllNodes[_treeIndex]);
                    aeRoot     = TreeWalker.ControlViewWalker.GetNextSibling(AllNodes[_treeIndex]);
                    _treeIndex = _chk;
                }
                else
                {
                    aeRoot = TreeWalker.ControlViewWalker.GetFirstChild(aeRoot);
                }
                EnumControlElements(aeRoot);
                aeRoot = null;
            }

            return;
        }
 private static void UiaExpand(BaseProdControl control)
 {
     ExpandCollapseHelper.Expand(control.UIAElement);
 }