Пример #1
0
        public static void SelectContinueWith(this ITreeViewUiaMarker uiaTreeView, string item)
        {
            var lastSelected = ((ITreeViewControl)uiaTreeView).LastElement.AutomationElement;
            var treeItems    = uiaTreeView.AutomationElement.FindAll(TreeScope.Descendants, new PropertyCondition(
                                                                         AutomationElement.
                                                                         ControlTypeProperty,

                                                                         ControlType.TreeItem));
            var bFound = false;

            for (int i = 0; i < treeItems.Count; i++)
            {
                if ((treeItems[i] == lastSelected))
                {
                    bFound = true;
                    continue;
                }
                else
                {
                    if (!bFound)
                    {
                        continue;
                    }
                }

                if (bFound && treeItems[i].Current.Name.Equals(item))
                {
                    var uiaElement = new UiaElementWrapper(treeItems[i]);
                    ((ITreeViewControl)uiaTreeView).LastElement = uiaElement;
                    uiaElement.GetSelectionItemPattern().Select();
                    break;
                }
            }
        }
Пример #2
0
        public static void SelectItem(this IMenuControlUiaMarker uiaTreeView, string item)
        {
            var treeItem = uiaTreeView.AutomationElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, item));

            if (treeItem != null)
            {
                var uiaElement = new UiaElementWrapper(treeItem);
                ((IMenuControl)uiaTreeView).LastElement = uiaElement;
            }
        }
Пример #3
0
        public static string GetSelectedItem(this ITreeViewUiaMarker uiaListBox)
        {
            var list     = new List <string>();
            var treeItem = uiaListBox.AutomationElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TreeItem));

            if (treeItem != null)
            {
                var uiaElement        = new UiaElementWrapper(treeItem);
                var selectItemPattern = uiaElement.GetSelectionItemPattern();
                var selectionPattern  = selectItemPattern.Current.SelectionContainer.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern;
                list.AddRange(selectionPattern.Current.GetSelection().Select(ae => ae.Current.Name));
            }
            return(list.Count == 0 ? string.Empty : list[0]);
        }