Inheritance: System.Windows.Automation.Peers.ItemsControlAutomationPeer, IExpandCollapseProvider, ISelectionItemProvider, IScrollItemProvider
        ///
        override public object GetPattern(PatternInterface patternInterface)
        {
            if (patternInterface == PatternInterface.ExpandCollapse)
            {
                return(this);
            }
            else if (patternInterface == PatternInterface.SelectionItem)
            {
                return(this);
            }
            else if (patternInterface == PatternInterface.ScrollItem)
            {
                return(this);
            }
            else if ((patternInterface == PatternInterface.ItemContainer) || (patternInterface == PatternInterface.SynchronizedInput))
            {
                TreeViewItemAutomationPeer treeViewItemAutomationPeer = GetWrapperPeer() as TreeViewItemAutomationPeer;
                if (treeViewItemAutomationPeer != null)
                {
                    if (patternInterface == PatternInterface.SynchronizedInput)
                    {
                        return(treeViewItemAutomationPeer.GetPattern(patternInterface));
                    }
                    else
                    {
                        return(treeViewItemAutomationPeer);
                    }
                }
            }

            return(base.GetPattern(patternInterface));
        }
Exemple #2
0
        // Token: 0x0600287D RID: 10365 RVA: 0x000BC834 File Offset: 0x000BAA34
        private void RecursiveScrollIntoView()
        {
            ItemsControlAutomationPeer itemsControlAutomationPeer = base.ItemsControlAutomationPeer;

            if (this.ParentDataItemAutomationPeer != null && itemsControlAutomationPeer == null)
            {
                this.ParentDataItemAutomationPeer.RecursiveScrollIntoView();
                itemsControlAutomationPeer = base.ItemsControlAutomationPeer;
            }
            if (itemsControlAutomationPeer != null)
            {
                TreeViewItemAutomationPeer treeViewItemAutomationPeer = itemsControlAutomationPeer as TreeViewItemAutomationPeer;
                if (treeViewItemAutomationPeer != null && ((IExpandCollapseProvider)treeViewItemAutomationPeer).ExpandCollapseState == ExpandCollapseState.Collapsed)
                {
                    ((IExpandCollapseProvider)treeViewItemAutomationPeer).Expand();
                }
                ItemsControl itemsControl = itemsControlAutomationPeer.Owner as ItemsControl;
                if (itemsControl != null)
                {
                    if (itemsControl.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
                    {
                        itemsControl.OnBringItemIntoView(base.Item);
                        return;
                    }
                    base.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(itemsControl.OnBringItemIntoView), base.Item);
                }
            }
        }
Exemple #3
0
        // Token: 0x0600286C RID: 10348 RVA: 0x000BC648 File Offset: 0x000BA848
        internal override AutomationPeer GetWrapperPeer()
        {
            AutomationPeer             wrapperPeer = base.GetWrapperPeer();
            TreeViewItemAutomationPeer treeViewItemAutomationPeer = wrapperPeer as TreeViewItemAutomationPeer;

            if (treeViewItemAutomationPeer != null)
            {
                treeViewItemAutomationPeer.AddDataPeerInfo(this);
            }
            return(wrapperPeer);
        }
Exemple #4
0
        /// <summary>Scrolls the content area of a container object in order to display the control within the visible region (viewport) of the container.</summary>
        // Token: 0x0600287B RID: 10363 RVA: 0x000BC808 File Offset: 0x000BAA08
        void IScrollItemProvider.ScrollIntoView()
        {
            TreeViewItemAutomationPeer treeViewItemAutomationPeer = this.GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (treeViewItemAutomationPeer != null)
            {
                IScrollItemProvider scrollItemProvider = treeViewItemAutomationPeer;
                scrollItemProvider.ScrollIntoView();
                return;
            }
            this.RecursiveScrollIntoView();
        }
Exemple #5
0
        /// <summary>Removes the current element from the collection of selected items.</summary>
        /// <exception cref="T:System.Windows.Automation.ElementNotAvailableException">UI Automation element is no longer available.</exception>
        // Token: 0x06002878 RID: 10360 RVA: 0x000BC788 File Offset: 0x000BA988
        void ISelectionItemProvider.RemoveFromSelection()
        {
            TreeViewItemAutomationPeer treeViewItemAutomationPeer = this.GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (treeViewItemAutomationPeer != null)
            {
                ISelectionItemProvider selectionItemProvider = treeViewItemAutomationPeer;
                selectionItemProvider.RemoveFromSelection();
                return;
            }
            base.ThrowElementNotAvailableException();
        }
Exemple #6
0
        /// <summary>Hides all nodes, controls, or content that are descendants of the control.</summary>
        // Token: 0x06002873 RID: 10355 RVA: 0x000BC6D8 File Offset: 0x000BA8D8
        void IExpandCollapseProvider.Collapse()
        {
            TreeViewItemAutomationPeer treeViewItemAutomationPeer = this.GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (treeViewItemAutomationPeer != null)
            {
                IExpandCollapseProvider expandCollapseProvider = treeViewItemAutomationPeer;
                expandCollapseProvider.Collapse();
                return;
            }
            base.ThrowElementNotAvailableException();
        }
        void IScrollItemProvider.ScrollIntoView()
        {
            TreeViewItemAutomationPeer wrapperPeer = GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (wrapperPeer != null)
            {
                IScrollItemProvider iScrollItemProvider = wrapperPeer as IScrollItemProvider;
                iScrollItemProvider.ScrollIntoView();
            }
            else
            {
                RecursiveScrollIntoView();
            }
        }
        /// <summary>
        ///     Unselects this item.
        /// </summary>
        void ISelectionItemProvider.RemoveFromSelection()
        {
            TreeViewItemAutomationPeer wrapperPeer = GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (wrapperPeer != null)
            {
                ISelectionItemProvider iSelectionItemProvider = wrapperPeer as ISelectionItemProvider;
                iSelectionItemProvider.RemoveFromSelection();
            }
            else
            {
                ThrowElementNotAvailableException();
            }
        }
        ///
        void IExpandCollapseProvider.Collapse()
        {
            TreeViewItemAutomationPeer wrapperPeer = GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (wrapperPeer != null)
            {
                IExpandCollapseProvider iExpandCollapseProvider = wrapperPeer as IExpandCollapseProvider;
                iExpandCollapseProvider.Collapse();
            }
            else
            {
                ThrowElementNotAvailableException();
            }
        }
        /// <summary>Gets the collection of child elements of the <see cref="T:System.Windows.Controls.TreeViewItem" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.TreeViewItemAutomationPeer" />. This method is called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetChildren" />.</summary>
        /// <returns>The collection of child elements.</returns>
        // Token: 0x06002884 RID: 10372 RVA: 0x000BC8F8 File Offset: 0x000BAAF8
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> children = null;
            ItemPeersStorage <ItemAutomationPeer> itemPeers = base.ItemPeers;

            base.ItemPeers = new ItemPeersStorage <ItemAutomationPeer>();
            TreeViewItem treeViewItem = base.Owner as TreeViewItem;

            if (treeViewItem != null)
            {
                TreeViewItemAutomationPeer.iterate(this, treeViewItem, delegate(AutomationPeer peer)
                {
                    if (children == null)
                    {
                        children = new List <AutomationPeer>();
                    }
                    children.Add(peer);
                    return(false);
                }, base.ItemPeers, itemPeers);
            }
            return(children);
        }
        private void RecursiveScrollIntoView()
        {
            ItemsControlAutomationPeer itemsControlAutomationPeer = ItemsControlAutomationPeer;

            // to check if the parent of this item is TreeViewItem.
            if (ParentDataItemAutomationPeer != null)
            {
                // there might be a possibility that it's parent item is itself virtualized so we have to realize it and make a second attempt
                if (itemsControlAutomationPeer == null)
                {
                    ParentDataItemAutomationPeer.RecursiveScrollIntoView();
                    itemsControlAutomationPeer = ItemsControlAutomationPeer;
                }
            }

            if (itemsControlAutomationPeer != null)
            {
                TreeViewItemAutomationPeer treeViewItemAutomationPeer = itemsControlAutomationPeer as TreeViewItemAutomationPeer;
                if (treeViewItemAutomationPeer != null && (treeViewItemAutomationPeer as IExpandCollapseProvider).ExpandCollapseState == ExpandCollapseState.Collapsed)
                {
                    (treeViewItemAutomationPeer as IExpandCollapseProvider).Expand();
                }

                ItemsControl parent = itemsControlAutomationPeer.Owner as ItemsControl;
                if (parent != null)
                {
                    if (parent.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
                    {
                        parent.OnBringItemIntoView(Item);
                    }
                    else
                    {
                        // The items aren't generated, try at a later time
                        Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(parent.OnBringItemIntoView), Item);
                    }
                }
            }
        }
        //
        private static bool iterate(TreeViewItemAutomationPeer logicalParentAp, DependencyObject parent, IteratorCallback callback, ItemPeersStorage <ItemAutomationPeer> dataChildren, ItemPeersStorage <ItemAutomationPeer> oldChildren)
        {
            bool done = false;

            if (parent != null)
            {
                AutomationPeer peer  = null;
                int            count = VisualTreeHelper.GetChildrenCount(parent);
                for (int i = 0; i < count && !done; i++)
                {
                    DependencyObject child = VisualTreeHelper.GetChild(parent, i);

                    if (child != null &&
                        child is UIElement)
                    {
                        if (child is TreeViewItem)
                        {
                            object dataItem = (child as UIElement) != null ? (logicalParentAp.Owner as ItemsControl).GetItemOrContainerFromContainer(child as UIElement) : child;
                            peer = oldChildren[dataItem];

                            if (peer == null)
                            {
                                peer = logicalParentAp.GetPeerFromWeakRefStorage(dataItem);
                                if (peer != null)
                                {
                                    // As cached peer is getting used it must be invalidated.
                                    peer.AncestorsInvalid = false;
                                    peer.ChildrenValid    = false;
                                }
                            }

                            if (peer == null)
                            {
                                peer = logicalParentAp.CreateItemAutomationPeer(dataItem);
                            }

                            //perform hookup so the events sourced from wrapper peer are fired as if from the data item
                            if (peer != null)
                            {
                                AutomationPeer wrapperPeer = (peer as ItemAutomationPeer).GetWrapperPeer();
                                if (wrapperPeer != null)
                                {
                                    wrapperPeer.EventsSource = peer;
                                }

                                if (dataChildren[dataItem] == null && peer is ItemAutomationPeer)
                                {
                                    callback(peer);
                                    dataChildren[dataItem] = peer as ItemAutomationPeer;
                                }
                            }
                        }
                        else
                        {
                            peer = CreatePeerForElement((UIElement)child);

                            if (peer != null)
                            {
                                done = callback(peer);
                            }
                        }

                        if (peer == null)
                        {
                            done = iterate(logicalParentAp, child, callback, dataChildren, oldChildren);
                        }
                    }
                    else
                    {
                        done = iterate(logicalParentAp, child, callback, dataChildren, oldChildren);
                    }
                }
            }

            return(done);
        }
        //
        private static bool iterate(TreeViewItemAutomationPeer logicalParentAp, DependencyObject parent, IteratorCallback callback, ItemPeersStorage<ItemAutomationPeer> dataChildren, ItemPeersStorage<ItemAutomationPeer> oldChildren)
        { 
            bool done = false;
 
            if (parent != null) 
            {
                AutomationPeer peer = null; 
                int count = VisualTreeHelper.GetChildrenCount(parent);
                for (int i = 0; i < count && !done; i++)
                {
                    DependencyObject child = VisualTreeHelper.GetChild(parent, i); 

                    if (child != null 
                        && child is UIElement) 
                    {
                        if (child is TreeViewItem) 
                        {
                            object dataItem = (child as UIElement) != null ? (logicalParentAp.Owner as ItemsControl).GetItemOrContainerFromContainer(child as UIElement) : child;
                            peer = oldChildren[dataItem];
 
                            if (peer == null)
                            { 
                                peer = logicalParentAp.GetPeerFromWeakRefStorage(dataItem); 
                                if (peer != null)
                                { 
                                    // As cached peer is getting used it must be invalidated.
                                    peer.AncestorsInvalid = false;
                                    peer.ChildrenValid = false;
                                } 
                            }
 
                            if (peer == null) 
                            {
                                peer = logicalParentAp.CreateItemAutomationPeer(dataItem); 
                            }

                            //perform hookup so the events sourced from wrapper peer are fired as if from the data item
                            if (peer != null) 
                            {
                                AutomationPeer wrapperPeer = (peer as ItemAutomationPeer).GetWrapperPeer(); 
                                if (wrapperPeer != null) 
                                {
                                    wrapperPeer.EventsSource = peer; 
                                }

                                if (dataChildren[dataItem] == null && peer is ItemAutomationPeer)
                                { 
                                    callback(peer);
                                    dataChildren[dataItem] = peer as ItemAutomationPeer; 
                                } 
                            }
                        } 
                        else
                        {
                            peer = CreatePeerForElement((UIElement)child);
 
                            if (peer != null)
                                done = callback(peer); 
                        } 

                        if(peer == null) 
                            done = iterate(logicalParentAp, child, callback, dataChildren, oldChildren);
                    }
                    else
                    { 
                        done = iterate(logicalParentAp, child, callback, dataChildren, oldChildren);
                    } 
                } 
            }
 
            return done;
        }
        // Token: 0x06002885 RID: 10373 RVA: 0x000BC954 File Offset: 0x000BAB54
        private static bool iterate(TreeViewItemAutomationPeer logicalParentAp, DependencyObject parent, TreeViewItemAutomationPeer.IteratorCallback callback, ItemPeersStorage <ItemAutomationPeer> dataChildren, ItemPeersStorage <ItemAutomationPeer> oldChildren)
        {
            bool flag = false;

            if (parent != null)
            {
                int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
                int num           = 0;
                while (num < childrenCount && !flag)
                {
                    DependencyObject child = VisualTreeHelper.GetChild(parent, num);
                    if (child != null && child is UIElement)
                    {
                        AutomationPeer automationPeer;
                        if (child is TreeViewItem)
                        {
                            object item = (child is UIElement) ? (logicalParentAp.Owner as ItemsControl).GetItemOrContainerFromContainer(child as UIElement) : child;
                            automationPeer = oldChildren[item];
                            if (automationPeer == null)
                            {
                                automationPeer = logicalParentAp.GetPeerFromWeakRefStorage(item);
                                if (automationPeer != null)
                                {
                                    automationPeer.AncestorsInvalid = false;
                                    automationPeer.ChildrenValid    = false;
                                }
                            }
                            if (automationPeer == null)
                            {
                                automationPeer = logicalParentAp.CreateItemAutomationPeer(item);
                            }
                            if (automationPeer != null)
                            {
                                AutomationPeer wrapperPeer = (automationPeer as ItemAutomationPeer).GetWrapperPeer();
                                if (wrapperPeer != null)
                                {
                                    wrapperPeer.EventsSource = automationPeer;
                                }
                                if (dataChildren[item] == null && automationPeer is ItemAutomationPeer)
                                {
                                    callback(automationPeer);
                                    dataChildren[item] = (automationPeer as ItemAutomationPeer);
                                }
                            }
                        }
                        else
                        {
                            automationPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)child);
                            if (automationPeer != null)
                            {
                                flag = callback(automationPeer);
                            }
                        }
                        if (automationPeer == null)
                        {
                            flag = TreeViewItemAutomationPeer.iterate(logicalParentAp, child, callback, dataChildren, oldChildren);
                        }
                    }
                    else
                    {
                        flag = TreeViewItemAutomationPeer.iterate(logicalParentAp, child, callback, dataChildren, oldChildren);
                    }
                    num++;
                }
            }
            return(flag);
        }