Exemple #1
0
        /// <summary>
        /// Fire ColumnCount changed event for GridPattern
        /// </summary>
        private void OnColumnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (_oldColumnsCount != _owner.Columns.Count)
            {
                ListViewAutomationPeer peer = UIElementAutomationPeer.FromElement(_listview) as ListViewAutomationPeer;
                Invariant.Assert(peer != null);
                if (peer != null)
                {
                    peer.RaisePropertyChangedEvent(GridPatternIdentifiers.ColumnCountProperty, _oldColumnsCount, _owner.Columns.Count);
                }
            }

            _oldColumnsCount = _owner.Columns.Count;

            AutomationPeer lvPeer = UIElementAutomationPeer.FromElement(_listview);

            if (lvPeer != null)
            {
                List <AutomationPeer> list = lvPeer.GetChildren();
                if (list != null)
                {
                    foreach (AutomationPeer peer in list)
                    {
                        peer.InvalidatePeer();
                    }
                }
            }
        }
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> children = new List <AutomationPeer>();
            AutoCompleteBox       owner    = OwnerAutoCompleteBox;

            // TextBox part.
            TextBox textBox = owner.TextBox;

            if (textBox != null)
            {
                AutomationPeer peer = CreatePeerForElement(textBox);
                if (peer != null)
                {
                    children.Insert(0, peer);
                }
            }

            // Include SelectionAdapter's children.
            AutomationPeer        selectionAdapterPeer = owner.SelectionAdapter?.CreateAutomationPeer();
            List <AutomationPeer> listChildren         = selectionAdapterPeer?.GetChildren();

            if (listChildren != null)
            {
                children.AddRange(listChildren);
            }

            return(children);
        }
Exemple #3
0
        // Token: 0x060026B5 RID: 9909 RVA: 0x000B7DAC File Offset: 0x000B5FAC
        private void OnColumnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (this._oldColumnsCount != this._owner.Columns.Count)
            {
                ListViewAutomationPeer listViewAutomationPeer = UIElementAutomationPeer.FromElement(this._listview) as ListViewAutomationPeer;
                Invariant.Assert(listViewAutomationPeer != null);
                if (listViewAutomationPeer != null)
                {
                    listViewAutomationPeer.RaisePropertyChangedEvent(GridPatternIdentifiers.ColumnCountProperty, this._oldColumnsCount, this._owner.Columns.Count);
                }
            }
            this._oldColumnsCount = this._owner.Columns.Count;
            AutomationPeer automationPeer = UIElementAutomationPeer.FromElement(this._listview);

            if (automationPeer != null)
            {
                List <AutomationPeer> children = automationPeer.GetChildren();
                if (children != null)
                {
                    foreach (AutomationPeer automationPeer2 in children)
                    {
                        automationPeer2.InvalidatePeer();
                    }
                }
            }
        }
Exemple #4
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);
        }
        // Token: 0x060025E5 RID: 9701 RVA: 0x000B5780 File Offset: 0x000B3980
        protected override List <AutomationPeer> GetChildrenCore()
        {
            AutomationPeer wrapperPeer = this.GetWrapperPeer();

            if (wrapperPeer != null)
            {
                wrapperPeer.ForceEnsureChildren();
                return(wrapperPeer.GetChildren());
            }
            return(this.GetCellItemPeers());
        }
Exemple #6
0
        // Token: 0x0600262D RID: 9773 RVA: 0x000B6340 File Offset: 0x000B4540
        protected override List <AutomationPeer> GetChildrenCore()
        {
            AutomationPeer wrapperPeer = this.WrapperPeer;

            if (wrapperPeer != null)
            {
                return(wrapperPeer.GetChildren());
            }
            this.ThrowElementNotAvailableException();
            return(null);
        }
        // Token: 0x06002587 RID: 9607 RVA: 0x000B47A0 File Offset: 0x000B29A0
        protected override List <AutomationPeer> GetChildrenCore()
        {
            AutomationPeer owningCellPeer = this.OwningCellPeer;

            if (owningCellPeer != null)
            {
                owningCellPeer.ForceEnsureChildren();
                return(owningCellPeer.GetChildren());
            }
            return(null);
        }
        ///
        protected override List <AutomationPeer> GetChildrenCore()
        {
            AutomationPeer wrapperPeer = GetWrapperPeer();

            if (wrapperPeer != null)
            {
                // The children needs to be updated before GetChildren call as ChildrenValid flag would already be true and GetChildren call won't update the children list.
                wrapperPeer.ForceEnsureChildren();
                List <AutomationPeer> children = wrapperPeer.GetChildren();
                return(children);
            }

            return(null);
        }
Exemple #9
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);
        }
        ///
        protected override List <AutomationPeer> GetChildrenCore()
        {
            AutomationPeer wrapperPeer = GetWrapperPeer();

            if (wrapperPeer != null)
            {
                // We need to update children manually since wrapperPeer is not in the Automation Tree
                // When containers are recycled the visual (DataGridRow) will point to a new item. ForceEnsureChildren will just refresh children of this peer,
                // unlike UpdateSubtree which would raise property change events and recursively updates entire subtree.
                // WrapperPeer's children are the peers for DataGridRowHeader, DataGridCells and DataGridRowDetails.
                wrapperPeer.ForceEnsureChildren();
                List <AutomationPeer> children = wrapperPeer.GetChildren();
                return(children);
            }

            return(GetCellItemPeers());
        }
        ///
        protected override List <AutomationPeer> GetChildrenCore()
        {
            AutomationPeer wrapperPeer = OwningCellPeer;

            if (wrapperPeer != null)
            {
                // We need to manually update children here since the wrapperPeer is not in the automation tree.
                // When containers are recycled the visual (DataGridCell) will point to a new item. ForceEnsureChildren will just refresh children of this peer,
                // unlike UpdateSubtree which would raise property change events and recursively updates entire subtree.
                // WrapperPeer's children need to be updated when switching from Editing mode to Non-editing mode and back.
                wrapperPeer.ForceEnsureChildren();
                List <AutomationPeer> children = wrapperPeer.GetChildren();
                return(children);
            }

            return(null);
        }
        private bool isDescendantOf(AutomationPeer parent)
        {
            if(parent == null)
                throw new ArgumentNullException("parent");

            List<AutomationPeer> children  = parent.GetChildren();

            if(children == null)
                return false;

            int cnt = children.Count;
            for(int i = 0; i < cnt; ++i)
            {
                AutomationPeer child = children[i];

                //depth first
                if(child == this || this.isDescendantOf(child))
                    return true;
            }

            return false;
        }