private ISelectionItemProvider ChildItemAtIndex(int i)
        {
            Adapter parentAdapter = AutomationBridge.GetAdapterForProviderSemiLazy(ChildrenHolder);

            if (parentAdapter == null)
            {
                Log.Error("Can't get adapter for Selection ChildrenHolder");
                return(null);
            }
            Adapter adapter = parentAdapter.RefAccessibleChild(i) as Adapter;

            if (adapter == null || adapter.Provider == null)
            {
                return(null);
            }
            ISelectionItemProvider ret = (ISelectionItemProvider)adapter.Provider.GetPatternProvider
                                             (SelectionItemPatternIdentifiers.Pattern.Id);

            if (ret != null)
            {
                return(ret);
            }
            IRawElementProviderFragment fragment = adapter.Provider as IRawElementProviderFragment;

            if (fragment != null)
            {
                fragment = fragment.Navigate(NavigateDirection.Parent);
            }
            if (fragment != null && (int)fragment.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id) == ControlType.DataItem.Id)
            {
                ret = (ISelectionItemProvider)fragment.GetPatternProvider
                          (SelectionItemPatternIdentifiers.Pattern.Id);
            }
            return(ret);
        }
Exemple #2
0
        public Atk.Object RefAt(int row, int column)
        {
            if (!AreRowColInBounds(row, column))
            {
                return(null);
            }

            IRawElementProviderSimple[] headers = null;
            if (tableProvider != null)
            {
                headers = tableProvider.GetColumnHeaders();
            }

            // Some controls will have column headers that need to
            // be mapped to row 0
            if (row == 0 && headers != null)
            {
                if (column >= headers.Length)
                {
                    return(null);
                }

                return(AutomationBridge.GetAdapterForProviderSemiLazy(
                           headers [column]));
            }

            // GetItem indexes through only items, not headers, so
            // we need to remap the row number
            if (headers != null)
            {
                row -= 1;
            }

            IRawElementProviderSimple item;

            try {
                item = GridProvider.GetItem(row, column);
            } catch (ArgumentOutOfRangeException e) {
                Log.Debug(e);
                return(null);
            }

            if (item == null)
            {
                return(null);
            }

            return(AutomationBridge.GetAdapterForProviderSemiLazy(item));
        }
Exemple #3
0
        //this kind of search will work regardless of the technique used for the hierarchy layout used for
        //the children (mono-level or multi-level), because in the provider side it's multi-level always
        private Adapter RefProviderChildByDepthSearch(int pos)
        {
            Adapter adapter = null;
            var     frag    = resource.Provider as IRawElementProviderFragment;
            var     parent  = frag;

            while (pos >= 0)
            {
                if (frag == null)
                {
                    return(null);
                }
                frag = frag.Navigate(NavigateDirection.FirstChild);
                if (frag == null)
                {
                    frag = parent.Navigate(NavigateDirection.NextSibling);
                }

                if (frag != null)
                {
                    parent = frag;
                }
                else
                {
                    if (parent != resource.Provider)
                    {
                        parent = parent.Navigate(NavigateDirection.Parent);
                        frag   = parent.Navigate(NavigateDirection.NextSibling);
                    }
                    else
                    {
                        return(null);
                    }
                }

                adapter = AutomationBridge.GetAdapterForProviderSemiLazy(frag);
                //we need this check because there are some children providers that don't have an Adapter
                if (adapter != null)
                {
                    pos--;
                }
            }
            return(adapter);
        }
        public Atk.Object RefSelection(int i)
        {
            IRawElementProviderSimple[] selectedElements =
                GetSelection();
            if (selectedElements.Length == 0 || (i < 0 || i >= selectedElements.Length))
            {
                return(null);
            }
            IRawElementProviderSimple provider = selectedElements [i];

            if (provider == null)
            {
                return(null);
            }
            if (provider is IRawElementProviderFragment && (int)provider.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id) == ControlType.DataItem.Id)
            {
                provider = ((IRawElementProviderFragment)provider).Navigate(NavigateDirection.FirstChild);
            }
            return(AutomationBridge.GetAdapterForProviderSemiLazy(provider));
        }