///
        protected override List <AutomationPeer> GetChildrenCore()
        {
            ListView listview = _listviewAP.Owner as ListView;

            Invariant.Assert(listview != null);
            object item = Item;

            ListViewItem lvi = listview.ItemContainerGenerator.ContainerFromItem(item) as ListViewItem;

            if (lvi != null)
            {
                GridViewRowPresenter rowPresenter = GridViewAutomationPeer.FindVisualByType(lvi, typeof(GridViewRowPresenter)) as GridViewRowPresenter;
                if (rowPresenter != null)
                {
                    Hashtable oldChildren = _dataChildren; //cache the old ones for possible reuse
                    _dataChildren = new Hashtable(rowPresenter.ActualCells.Count);

                    List <AutomationPeer> list = new List <AutomationPeer>();
                    int row    = listview.Items.IndexOf(item);
                    int column = 0;

                    foreach (UIElement ele in rowPresenter.ActualCells)
                    {
                        GridViewCellAutomationPeer peer = (oldChildren == null ? null : (GridViewCellAutomationPeer)oldChildren[ele]);
                        if (peer == null)
                        {
                            if (ele is ContentPresenter)
                            {
                                peer = new GridViewCellAutomationPeer((ContentPresenter)ele, _listviewAP);
                            }
                            else if (ele is TextBlock)
                            {
                                peer = new GridViewCellAutomationPeer((TextBlock)ele, _listviewAP);
                            }
                            else
                            {
                                Invariant.Assert(false, "Children of GridViewRowPresenter should be ContentPresenter or TextBlock");
                            }
                        }

                        //protection from indistinguishable UIElement - for example, 2 UIElement wiht same value
                        if (_dataChildren[ele] == null)
                        {
                            //Set Cell's row and column
                            peer.Column = column;
                            peer.Row    = row;
                            list.Add(peer);
                            _dataChildren.Add(ele, peer);
                            column++;
                        }
                    }
                    return(list);
                }
            }

            return(null);
        }
        /// 
        protected override List<AutomationPeer> GetChildrenCore()
        {
            ListView listview = _listviewAP.Owner as ListView;
            Invariant.Assert(listview != null);

            ListViewItem lvi = listview.ItemContainerGenerator.ContainerFromItem(_item) as ListViewItem;
            if (lvi != null)
            {
                GridViewRowPresenter rowPresenter = GridViewAutomationPeer.FindVisualByType(lvi, typeof(GridViewRowPresenter)) as GridViewRowPresenter;
                if (rowPresenter != null)
                {
                    Hashtable oldChildren = _dataChildren; //cache the old ones for possible reuse
                    _dataChildren = new Hashtable(rowPresenter.ActualCells.Count);

                    List<AutomationPeer> list = new List<AutomationPeer>();
                    int row = listview.Items.IndexOf(_item);
                    int column = 0;

                    foreach (UIElement ele in rowPresenter.ActualCells)
                    {
                        GridViewCellAutomationPeer peer = (oldChildren == null ? null : (GridViewCellAutomationPeer)oldChildren[ele]);
                        if (peer == null)
                        {
                            if (ele is ContentPresenter)
                            {
                                peer = new GridViewCellAutomationPeer((ContentPresenter)ele, _listviewAP);
                            }
                            else if (ele is TextBlock)
                            {
                                peer = new GridViewCellAutomationPeer((TextBlock)ele, _listviewAP);
                            }
                            else
                            {
                                Invariant.Assert(false, "Children of GridViewRowPresenter should be ContentPresenter or TextBlock");
                            }
                        }

                        //protection from indistinguishable UIElement - for example, 2 UIElement wiht same value
                        if (_dataChildren[ele] == null)
                        {
                            //Set Cell's row and column
                            peer.Column = column;
                            peer.Row = row;
                            list.Add(peer);
                            _dataChildren.Add(ele, peer);
                            column++;
                        }
                    }
                    return list;
                }
            }

            return null;
        }
Esempio n. 3
0
        /// <summary>Gets the collection of child elements of the <see cref="P:System.Windows.Controls.ItemsControl.Items" /> collection that is associated with this <see cref="T:System.Windows.Automation.Peers.GridViewItemAutomationPeer" />. Called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetChildren" />.</summary>
        /// <returns>The collection of child elements.</returns>
        // Token: 0x060026DE RID: 9950 RVA: 0x000B8264 File Offset: 0x000B6464
        protected override List <AutomationPeer> GetChildrenCore()
        {
            ListView listView = this._listviewAP.Owner as ListView;

            Invariant.Assert(listView != null);
            object       item         = base.Item;
            ListViewItem listViewItem = listView.ItemContainerGenerator.ContainerFromItem(item) as ListViewItem;

            if (listViewItem != null)
            {
                GridViewRowPresenter gridViewRowPresenter = GridViewAutomationPeer.FindVisualByType(listViewItem, typeof(GridViewRowPresenter)) as GridViewRowPresenter;
                if (gridViewRowPresenter != null)
                {
                    Hashtable dataChildren = this._dataChildren;
                    this._dataChildren = new Hashtable(gridViewRowPresenter.ActualCells.Count);
                    List <AutomationPeer> list = new List <AutomationPeer>();
                    int row = listView.Items.IndexOf(item);
                    int num = 0;
                    foreach (UIElement uielement in gridViewRowPresenter.ActualCells)
                    {
                        GridViewCellAutomationPeer gridViewCellAutomationPeer = (dataChildren == null) ? null : ((GridViewCellAutomationPeer)dataChildren[uielement]);
                        if (gridViewCellAutomationPeer == null)
                        {
                            if (uielement is ContentPresenter)
                            {
                                gridViewCellAutomationPeer = new GridViewCellAutomationPeer((ContentPresenter)uielement, this._listviewAP);
                            }
                            else if (uielement is TextBlock)
                            {
                                gridViewCellAutomationPeer = new GridViewCellAutomationPeer((TextBlock)uielement, this._listviewAP);
                            }
                            else
                            {
                                Invariant.Assert(false, "Children of GridViewRowPresenter should be ContentPresenter or TextBlock");
                            }
                        }
                        if (this._dataChildren[uielement] == null)
                        {
                            gridViewCellAutomationPeer.Column = num;
                            gridViewCellAutomationPeer.Row    = row;
                            list.Add(gridViewCellAutomationPeer);
                            this._dataChildren.Add(uielement, gridViewCellAutomationPeer);
                            num++;
                        }
                    }
                    return(list);
                }
            }
            return(null);
        }
        // Token: 0x060026D9 RID: 9945 RVA: 0x000B818C File Offset: 0x000B638C
        private List <AutomationPeer> GetChildrenAutomationPeer(Visual parent, bool includeInvisibleItems)
        {
            Invariant.Assert(parent != null);
            List <AutomationPeer> children = null;

            GridViewCellAutomationPeer.iterate(parent, includeInvisibleItems, delegate(AutomationPeer peer)
            {
                if (children == null)
                {
                    children = new List <AutomationPeer>();
                }
                children.Add(peer);
                return(false);
            });
            return(children);
        }
        // Token: 0x060026DA RID: 9946 RVA: 0x000B81CC File Offset: 0x000B63CC
        private static bool iterate(Visual parent, bool includeInvisibleItems, GridViewCellAutomationPeer.IteratorCallback callback)
        {
            bool flag = false;
            int  internalVisualChildrenCount = parent.InternalVisualChildrenCount;
            int  num = 0;

            while (num < internalVisualChildrenCount && !flag)
            {
                Visual         visual = parent.InternalGetVisualChild(num);
                AutomationPeer peer;
                if (visual != null && visual.CheckFlagsAnd(VisualFlags.IsUIElement) && (includeInvisibleItems || ((UIElement)visual).IsVisible) && (peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)visual)) != null)
                {
                    flag = callback(peer);
                }
                else
                {
                    flag = GridViewCellAutomationPeer.iterate(visual, includeInvisibleItems, callback);
                }
                num++;
            }
            return(flag);
        }