Exemplo n.º 1
0
        /// <summary>
        /// Obtain the IRawElementProviderSimple at an absolute position
        /// </summary>
        IRawElementProviderSimple IGridProvider.GetItem(int row, int column)
        {
            if (row < 0 || row >= ((IGridProvider)this).RowCount)
            {
                throw new ArgumentOutOfRangeException("row");
            }
            if (column < 0 || column >= ((IGridProvider)this).ColumnCount)
            {
                throw new ArgumentOutOfRangeException("column");
            }

            ListViewItem lvi = _listview.ItemContainerGenerator.ContainerFromIndex(row) as ListViewItem;

            //If item is virtualized, try to de-virtualize it
            if (lvi == null)
            {
                VirtualizingPanel itemsHost = _listview.ItemsHost as VirtualizingPanel;
                if (itemsHost != null)
                {
                    itemsHost.BringIndexIntoView(row);
                }

                lvi = _listview.ItemContainerGenerator.ContainerFromIndex(row) as ListViewItem;

                if (lvi != null)
                {
                    //Must call Invoke here to force run the render process
                    _listview.Dispatcher.Invoke(
                        System.Windows.Threading.DispatcherPriority.Loaded,
                        (System.Windows.Threading.DispatcherOperationCallback) delegate(object arg)
                    {
                        return(null);
                    },
                        null);
                }
            }

            //lvi is null, it is virtualized, so we can't return its cell
            if (lvi != null)
            {
                AutomationPeer lvpeer = UIElementAutomationPeer.FromElement(_listview);
                if (lvpeer != null)
                {
                    List <AutomationPeer> rows = lvpeer.GetChildren();
                    //Headers is the first child of GridView, so we need to skip it here
                    if (rows.Count - 1 > row)
                    {
                        AutomationPeer        peer    = rows[row + 1];
                        List <AutomationPeer> columns = peer.GetChildren();
                        if (columns.Count > column)
                        {
                            return(ElementProxy.StaticWrap(columns[column], lvpeer));
                        }
                    }
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>Returns the UI Automation provider for the specified cell.</summary>
        /// <param name="row">The ordinal number of the row of interest.</param>
        /// <param name="column">The ordinal number of the column of interest.</param>
        /// <returns>The UI Automation provider for the specified cell.</returns>
        // Token: 0x060026B4 RID: 9908 RVA: 0x000B7CA0 File Offset: 0x000B5EA0
        IRawElementProviderSimple IGridProvider.GetItem(int row, int column)
        {
            if (row < 0 || row >= ((IGridProvider)this).RowCount)
            {
                throw new ArgumentOutOfRangeException("row");
            }
            if (column < 0 || column >= ((IGridProvider)this).ColumnCount)
            {
                throw new ArgumentOutOfRangeException("column");
            }
            ListViewItem listViewItem = this._listview.ItemContainerGenerator.ContainerFromIndex(row) as ListViewItem;

            if (listViewItem == null)
            {
                VirtualizingPanel virtualizingPanel = this._listview.ItemsHost as VirtualizingPanel;
                if (virtualizingPanel != null)
                {
                    virtualizingPanel.BringIndexIntoView(row);
                }
                listViewItem = (this._listview.ItemContainerGenerator.ContainerFromIndex(row) as ListViewItem);
                if (listViewItem != null)
                {
                    this._listview.Dispatcher.Invoke(DispatcherPriority.Loaded, new DispatcherOperationCallback((object arg) => null), null);
                }
            }
            if (listViewItem != null)
            {
                AutomationPeer automationPeer = UIElementAutomationPeer.FromElement(this._listview);
                if (automationPeer != null)
                {
                    AutomationPeer automationPeer2 = UIElementAutomationPeer.FromElement(listViewItem);
                    if (automationPeer2 != null)
                    {
                        AutomationPeer eventsSource = automationPeer2.EventsSource;
                        if (eventsSource != null)
                        {
                            automationPeer2 = eventsSource;
                        }
                        List <AutomationPeer> children = automationPeer2.GetChildren();
                        if (children.Count > column)
                        {
                            return(ElementProxy.StaticWrap(children[column], automationPeer));
                        }
                    }
                }
            }
            return(null);
        }