/// protected override List <AutomationPeer> GetChildrenCore() { List <AutomationPeer> children = null; ItemPeersStorage <ItemAutomationPeer> oldChildren = ItemPeers; //cache the old ones for possible reuse ItemPeers = new ItemPeersStorage <ItemAutomationPeer>(); TreeViewItem owner = Owner as TreeViewItem; if (owner != null) { iterate(this, owner, (IteratorCallback) delegate(AutomationPeer peer) { if (children == null) { children = new List <AutomationPeer>(); } children.Add(peer); return(false); }, ItemPeers, oldChildren); } return(children); }
private void ClearReusablePeers(ItemPeersStorage <ItemAutomationPeer> oldChildren) { if (_reusablePeers == oldChildren) { _reusablePeers = null; } }
/// <summary> /// Realized Columns only /// </summary> /// <returns></returns> internal List <AutomationPeer> GetCellItemPeers() { List <AutomationPeer> children = null; ItemPeersStorage <DataGridCellItemAutomationPeer> newChildren = new ItemPeersStorage <DataGridCellItemAutomationPeer>(); IList childItems = null; bool usingItemsHost = false; DataGridRow row = GetWrapper() as DataGridRow; if (row != null) { if (row.CellsPresenter != null) { Panel itemHost = row.CellsPresenter.ItemsHost; if (itemHost != null) { childItems = itemHost.Children; usingItemsHost = true; } } } if (!usingItemsHost) { childItems = OwningDataGrid.Columns; } if (childItems != null) { children = new List <AutomationPeer>(childItems.Count); foreach (object childItem in childItems) { DataGridColumn column = null; if (usingItemsHost) { column = (childItem as DataGridCell).Column; } else { column = childItem as DataGridColumn; } if (column != null) { DataGridCellItemAutomationPeer peer = GetOrCreateCellItemPeer(column, /*addParentInfo*/ false); children.Add(peer); newChildren[column] = peer; } } } // Cache children for reuse CellItemPeers = newChildren; return(children); }
/// protected override List <AutomationPeer> GetChildrenCore() { // To avoid the situation on legacy systems which may not have new unmanaged core. with this change with old unmanaged core // the behavior would be same as earlier. if (IsVirtualized) { return(base.GetChildrenCore()); } else { ItemsControl owner = (ItemsControl)Owner; ItemCollection items = owner.Items; List <AutomationPeer> children = null; ItemPeersStorage <ItemAutomationPeer> oldChildren = ItemPeers; //cache the old ones for possible reuse ItemPeers = new ItemPeersStorage <ItemAutomationPeer>(); if (items.Count > 0) { children = new List <AutomationPeer>(items.Count); for (int i = 0; i < items.Count; i++) { TreeViewItem treeViewItem = owner.ItemContainerGenerator.ContainerFromIndex(i) as TreeViewItem; if (treeViewItem != null) { ItemAutomationPeer peer = oldChildren[items[i]]; if (peer == null) { peer = CreateItemAutomationPeer(items[i]); } // perform hookup so the events sourced from wrapper peer are fired as if from the data item if (peer != null) { AutomationPeer wrapperPeer = peer.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = peer; } } // Not to add same Item again if (ItemPeers[items[i]] == null) { children.Add(peer); ItemPeers[items[i]] = peer; } } } return(children); } } return(null); }
// Token: 0x060025F4 RID: 9716 RVA: 0x000B5C6C File Offset: 0x000B3E6C internal List <AutomationPeer> GetCellItemPeers() { List <AutomationPeer> list = null; ItemPeersStorage <DataGridCellItemAutomationPeer> itemPeersStorage = new ItemPeersStorage <DataGridCellItemAutomationPeer>(); IList list2 = null; bool flag = false; DataGridRow dataGridRow = base.GetWrapper() as DataGridRow; if (dataGridRow != null && dataGridRow.CellsPresenter != null) { Panel itemsHost = dataGridRow.CellsPresenter.ItemsHost; if (itemsHost != null) { list2 = itemsHost.Children; flag = true; } } if (!flag) { list2 = this.OwningDataGrid.Columns; } if (list2 != null) { list = new List <AutomationPeer>(list2.Count); foreach (object obj in list2) { DataGridColumn dataGridColumn; if (flag) { dataGridColumn = (obj as DataGridCell).Column; } else { dataGridColumn = (obj as DataGridColumn); } if (dataGridColumn != null) { DataGridCellItemAutomationPeer orCreateCellItemPeer = this.GetOrCreateCellItemPeer(dataGridColumn, false); list.Add(orCreateCellItemPeer); itemPeersStorage[dataGridColumn] = orCreateCellItemPeer; } } } this.CellItemPeers = itemPeersStorage; return(list); }
/// <summary>Gets the collection of child elements of the <see cref="T:System.Windows.ContentElement" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.ContentElementAutomationPeer" />. Called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetChildren" />.</summary> /// <returns>A collection of <see cref="T:System.Windows.Automation.Peers.TreeViewItemAutomationPeer" /> elements, or <see langword="null" /> if the <see cref="T:System.Windows.Controls.TreeView" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.TreeViewAutomationPeer" /> is empty.</returns> // Token: 0x06002863 RID: 10339 RVA: 0x000BC40C File Offset: 0x000BA60C protected override List <AutomationPeer> GetChildrenCore() { if (this.IsVirtualized) { return(base.GetChildrenCore()); } ItemsControl itemsControl = (ItemsControl)base.Owner; ItemCollection items = itemsControl.Items; ItemPeersStorage <ItemAutomationPeer> itemPeers = base.ItemPeers; base.ItemPeers = new ItemPeersStorage <ItemAutomationPeer>(); if (items.Count > 0) { List <AutomationPeer> list = new List <AutomationPeer>(items.Count); for (int i = 0; i < items.Count; i++) { TreeViewItem treeViewItem = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as TreeViewItem; if (treeViewItem != null) { ItemAutomationPeer itemAutomationPeer = itemPeers[items[i]]; if (itemAutomationPeer == null) { itemAutomationPeer = this.CreateItemAutomationPeer(items[i]); } if (itemAutomationPeer != null) { AutomationPeer wrapperPeer = itemAutomationPeer.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = itemAutomationPeer; } } if (base.ItemPeers[items[i]] == null) { list.Add(itemAutomationPeer); base.ItemPeers[items[i]] = itemAutomationPeer; } } } return(list); } return(null); }
/// <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 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); }
/// protected override List <AutomationPeer> GetChildrenCore() { GroupItem owner = (GroupItem)Owner; ItemsControl itemsControl = ItemsControl.ItemsControlFromItemContainer(Owner); if (itemsControl != null) { ItemsControlAutomationPeer itemsControlAP = itemsControl.CreateAutomationPeer() as ItemsControlAutomationPeer; if (itemsControlAP != null) { List <AutomationPeer> children = new List <AutomationPeer>(); bool useNetFx472CompatibleAccessibilityFeatures = AccessibilitySwitches.UseNetFx472CompatibleAccessibilityFeatures; if (!useNetFx472CompatibleAccessibilityFeatures && owner.Expander != null) { _expanderPeer = UIElementAutomationPeer.CreatePeerForElement(owner.Expander); if (_expanderPeer != null) { _expanderPeer.EventsSource = this; // Call GetChildren so the Expander's toggle button updates its EventsSource as well _expanderPeer.GetChildren(); } } Panel itemsHost = owner.ItemsHost; if (itemsHost == null) { if (_expanderPeer == null) { return(null); } else { children.Add(_expanderPeer); return(children); } } IList childItems = itemsHost.Children; ItemPeersStorage <ItemAutomationPeer> addedChildren = new ItemPeersStorage <ItemAutomationPeer>(); foreach (UIElement child in childItems) { if (!((MS.Internal.Controls.IGeneratorHost)itemsControl).IsItemItsOwnContainer(child)) { UIElementAutomationPeer peer = child.CreateAutomationPeer() as UIElementAutomationPeer; if (peer != null) { children.Add(peer); if (useNetFx472CompatibleAccessibilityFeatures) { // // The AncestorsInvalid check is meant so that we do this call to invalidate the // GroupItemPeers containing the realized item peers only when we arrive here from an // UpdateSubtree call because that call does not otherwise descend into parts of the tree // that have their children invalid as an optimization. // if (itemsControlAP.RecentlyRealizedPeers.Count > 0 && this.AncestorsInvalid) { GroupItemAutomationPeer groupItemPeer = peer as GroupItemAutomationPeer; if (groupItemPeer != null) { groupItemPeer.InvalidateGroupItemPeersContainingRecentlyRealizedPeers(itemsControlAP.RecentlyRealizedPeers); } } } else { // // The AncestorsInvalid check is meant so that we do this call to invalidate the // GroupItemPeers only when we arrive here from an // UpdateSubtree call because that call does not otherwise descend into parts of the tree // that have their children invalid as an optimization. // if (this.AncestorsInvalid) { GroupItemAutomationPeer groupItemPeer = peer as GroupItemAutomationPeer; if (groupItemPeer != null) { // invalidate all GroupItemAP children, so // that the top-level ItemsControlAP's // ItemPeers collection is repopulated. groupItemPeer.AncestorsInvalid = true; groupItemPeer.ChildrenValid = true; } } } } } else { object item = itemsControl.ItemContainerGenerator.ItemFromContainer(child); // ItemFromContainer can return {UnsetValue} if we're in a re-entrant // call while the generator is in the midst of unhooking the container. // Ignore such children. if (item == DependencyProperty.UnsetValue) { continue; } // try to reuse old peer if it exists either in Current AT or in WeakRefStorage of Peers being sent to Client ItemAutomationPeer peer = useNetFx472CompatibleAccessibilityFeatures ? itemsControlAP.ItemPeers[item] : itemsControlAP.ReusablePeerFor(item); peer = itemsControlAP.ReusePeerForItem(peer, item); if (peer != null) { if (useNetFx472CompatibleAccessibilityFeatures) { // // We have now connected the realized peer to its actual parent. Hence the cache can be cleared // int realizedPeerIndex = itemsControlAP.RecentlyRealizedPeers.IndexOf(peer); if (realizedPeerIndex >= 0) { itemsControlAP.RecentlyRealizedPeers.RemoveAt(realizedPeerIndex); } } } else { peer = itemsControlAP.CreateItemAutomationPeerInternal(item); } //perform hookup so the events sourced from wrapper peer are fired as if from the data item if (peer != null) { AutomationPeer wrapperPeer = peer.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = peer; if (peer.ChildrenValid && peer.Children == null && this.AncestorsInvalid) { peer.AncestorsInvalid = true; wrapperPeer.AncestorsInvalid = true; } } } //protection from indistinguishable items - for example, 2 strings with same value //this scenario does not work in ItemsControl however is not checked for. // Our parent's ItemPeerStorage collection may not have been cleared, // this would cause us to report 0 children, if the peer is already in the collection // check its parent, if it has been set to us, we should add it to the return collection, // but only if we haven't added a peer for this item during this GetChildrenCore call. bool itemMissingPeerInGlobalStorage = itemsControlAP.ItemPeers[item] == null; if (peer != null && (itemMissingPeerInGlobalStorage || (peer.GetParent() == this && addedChildren[item] == null))) { children.Add(peer); addedChildren[item] = peer; if (itemMissingPeerInGlobalStorage) { itemsControlAP.ItemPeers[item] = peer; } } } } return(children); } } return(null); }
// Token: 0x060025DC RID: 9692 RVA: 0x000B53C8 File Offset: 0x000B35C8 protected override List <AutomationPeer> GetChildrenCore() { List <AutomationPeer> list = null; ItemPeersStorage <ItemAutomationPeer> itemPeers = base.ItemPeers; base.ItemPeers = new ItemPeersStorage <ItemAutomationPeer>(); ItemsControl itemsControl = (ItemsControl)base.Owner; DataGrid owningDataGrid = this.OwningDataGrid; if (owningDataGrid != null && owningDataGrid.Columns.Count > 0) { Panel itemsHost = itemsControl.ItemsHost; IList list2; if (this.IsVirtualized) { if (itemsHost == null) { return(null); } list2 = itemsHost.Children; } else { list2 = this.OwningDataGrid.Columns; } list = new List <AutomationPeer>(list2.Count); foreach (object obj in list2) { DataGridColumn dataGridColumn; if (obj is DataGridColumnHeader) { dataGridColumn = ((DataGridColumnHeader)obj).Column; } else { dataGridColumn = (obj as DataGridColumn); } ItemAutomationPeer itemAutomationPeer = itemPeers[dataGridColumn]; if (itemAutomationPeer == null) { itemAutomationPeer = base.GetPeerFromWeakRefStorage(dataGridColumn); if (itemAutomationPeer != null) { itemAutomationPeer.AncestorsInvalid = false; itemAutomationPeer.ChildrenValid = false; } } object o = (dataGridColumn == null) ? null : dataGridColumn.Header; if (itemAutomationPeer == null || !ItemsControl.EqualsEx(itemAutomationPeer.Item, o)) { itemAutomationPeer = this.CreateItemAutomationPeer(dataGridColumn); } if (itemAutomationPeer != null) { AutomationPeer wrapperPeer = itemAutomationPeer.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = itemAutomationPeer; } } if (itemAutomationPeer != null && base.ItemPeers[dataGridColumn] == null) { list.Add(itemAutomationPeer); base.ItemPeers[dataGridColumn] = itemAutomationPeer; } } return(list); } return(null); }
///<summary> /// If grouping is enabled then return peers corresponding to all the items in container /// otherwise sees VirtualizingStackPanel(itemsHost) and return peers corresponding to /// items which are de-virtualized. ///</summary> protected override List <AutomationPeer> GetChildrenCore() { List <AutomationPeer> children = null; ItemPeersStorage <ItemAutomationPeer> oldChildren = _dataChildren; //cache the old ones for possible reuse _dataChildren = new ItemPeersStorage <ItemAutomationPeer>(); ItemsControl owner = (ItemsControl)Owner; ItemCollection items = owner.Items; Panel itemHost = owner.ItemsHost; IList childItems = null; if (owner.IsGrouping) { if (itemHost == null) { return(null); } childItems = itemHost.Children; children = new List <AutomationPeer>(childItems.Count); foreach (UIElement child in childItems) { UIElementAutomationPeer peer = child.CreateAutomationPeer() as UIElementAutomationPeer; if (peer != null) { children.Add(peer); // // The AncestorsInvalid check is meant so that we do this call to invalidate the // GroupItemPeers containing the realized item peers only when we arrive here from an // UpdateSubtree call because that call does not otherwise descend into parts of the tree // that have their children invalid as an optimization. // if (_recentlyRealizedPeers != null && _recentlyRealizedPeers.Count > 0 && this.AncestorsInvalid) { GroupItemAutomationPeer groupItemPeer = peer as GroupItemAutomationPeer; if (groupItemPeer != null) { groupItemPeer.InvalidateGroupItemPeersContainingRecentlyRealizedPeers(_recentlyRealizedPeers); } } } } return(children); } else if (items.Count > 0) { // To avoid the situation on legacy systems which may not have new unmanaged core. this check with old unmanaged core // ensures the older behavior as ItemContainer pattern won't be available. if (IsVirtualized) { if (itemHost == null) { return(null); } childItems = itemHost.Children; } else { childItems = items; } children = new List <AutomationPeer>(childItems.Count); foreach (object item in childItems) { object dataItem = ((IsVirtualized && ((MS.Internal.Controls.IGeneratorHost)owner).IsItemItsOwnContainer(item)) ? owner.GetItemOrContainerFromContainer(item as UIElement) : item); // try to reuse old peer if it exists either in Current AT or in WeakRefStorage of Peers being sent to Client ItemAutomationPeer peer = oldChildren[dataItem]; if (peer == null) { peer = 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 = 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.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = peer; } } // protection from indistinguishable items - for example, 2 strings with same value // this scenario does not work in ItemsControl however is not checked for. if (_dataChildren[dataItem] == null) { children.Add(peer); _dataChildren[dataItem] = peer; } } return(children); } return(null); }
///<summary> /// Creates Children peers. /// /// GetChildrenCore and FindItemByProperty are almost straight copies of the /// ItemControlAutomationPeer code; however since DataGridColumHeaderPresenter /// returns the Column.Header's as the items some specialized code was needed to /// create and store peers. ///</summary> protected override List <AutomationPeer> GetChildrenCore() { List <AutomationPeer> children = null; ItemPeersStorage <ItemAutomationPeer> oldChildren = ItemPeers; //cache the old ones for possible reuse ItemPeers = new ItemPeersStorage <ItemAutomationPeer>(); ItemsControl owner = (ItemsControl)Owner; if (OwningDataGrid?.Columns.Count > 0) { IList childItems = null; Panel itemHost = owner.ItemsHost; // To avoid the situation on legacy systems which may not have new unmanaged core. this check with old unmanaged core // ensures the older behavior as ItemContainer pattern won't be available. if (IsVirtualized) { if (itemHost == null) { return(null); } childItems = itemHost.Children; } else { childItems = OwningDataGrid.Columns; } children = new List <AutomationPeer>(childItems.Count); foreach (object item in childItems) { DataGridColumn dataItem; if (item is DataGridColumnHeader) { dataItem = ((DataGridColumnHeader)item).Column; } else { dataItem = item as DataGridColumn; } // try to reuse old peer if it exists either in Current AT or in WeakRefStorage of Peers being sent to Client ItemAutomationPeer peer = oldChildren[dataItem]; if (peer == null) { peer = GetPeerFromWeakRefStorage(dataItem); // As cached peer is getting used it must be invalidated. if (peer != null) { peer.AncestorsInvalid = false; peer.ChildrenValid = false; } } // If the peer is null or dataItem.Header has changed, create a new peer. object dataItemHeader = dataItem == null ? null : dataItem.Header; if (peer == null || !ItemsControl.EqualsEx(peer.Item, dataItemHeader)) { peer = 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.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = peer; } } // protection from indistinguishable items - for example, 2 strings with same value // this scenario does not work in ItemsControl however is not checked for. if (ItemPeers[dataItem] == null) { children.Add(peer); ItemPeers[dataItem] = peer; } } return(children); } return(null); }
///<summary> /// If grouping is enabled then return peers corresponding to all the items in container /// otherwise sees VirtualizingStackPanel(itemsHost) and return peers corresponding to /// items which are de-virtualized. ///</summary> protected override List <AutomationPeer> GetChildrenCore() { List <AutomationPeer> children = null; ItemPeersStorage <ItemAutomationPeer> oldChildren = _dataChildren; //cache the old ones for possible reuse _dataChildren = new ItemPeersStorage <ItemAutomationPeer>(); ItemsControl owner = (ItemsControl)Owner; ItemCollection items = owner.Items; Panel itemHost = owner.ItemsHost; IList childItems = null; bool useNetFx472CompatibleAccessibilityFeatures = AccessibilitySwitches.UseNetFx472CompatibleAccessibilityFeatures; if (owner.IsGrouping) { if (itemHost == null) { return(null); } if (!useNetFx472CompatibleAccessibilityFeatures) { _reusablePeers = oldChildren; } childItems = itemHost.Children; children = new List <AutomationPeer>(childItems.Count); foreach (UIElement child in childItems) { UIElementAutomationPeer peer = child.CreateAutomationPeer() as UIElementAutomationPeer; if (peer != null) { children.Add(peer); if (useNetFx472CompatibleAccessibilityFeatures) { // // The AncestorsInvalid check is meant so that we do this call to invalidate the // GroupItemPeers containing the realized item peers only when we arrive here from an // UpdateSubtree call because that call does not otherwise descend into parts of the tree // that have their children invalid as an optimization. // if (_recentlyRealizedPeers != null && _recentlyRealizedPeers.Count > 0 && this.AncestorsInvalid) { GroupItemAutomationPeer groupItemPeer = peer as GroupItemAutomationPeer; if (groupItemPeer != null) { groupItemPeer.InvalidateGroupItemPeersContainingRecentlyRealizedPeers(_recentlyRealizedPeers); } } } else { // // The AncestorsInvalid check is meant so that we do this call to invalidate the // GroupItemPeers only when we arrive here from an // UpdateSubtree call because that call does not otherwise descend into parts of the tree // that have their children invalid as an optimization. // if (this.AncestorsInvalid) { GroupItemAutomationPeer groupItemPeer = peer as GroupItemAutomationPeer; if (groupItemPeer != null) { // invalidate all GroupItemAP children, so // that the top-level ItemsControlAP's // ItemPeers collection is repopulated. groupItemPeer.AncestorsInvalid = true; groupItemPeer.ChildrenValid = true; } } } } } return(children); } else if (items.Count > 0) { // To avoid the situation on legacy systems which may not have new unmanaged core. this check with old unmanaged core // ensures the older behavior as ItemContainer pattern won't be available. if (IsVirtualized) { if (itemHost == null) { return(null); } childItems = itemHost.Children; } else { childItems = items; } children = new List <AutomationPeer>(childItems.Count); foreach (object item in childItems) { object dataItem; if (IsVirtualized) { // 'item' is a container - get the corresponding data item DependencyObject d = item as DependencyObject; dataItem = (d != null) ? owner.ItemContainerGenerator.ItemFromContainer(d) : null; // ItemFromContainer can return {UnsetValue} if we're in a re-entrant // call while the generator is in the midst of unhooking the container. // Ignore such children. (DDVSO 781853) if (dataItem == DependencyProperty.UnsetValue) { dataItem = null; } } else { // 'item' is a data item dataItem = item; } // try to reuse old peer if it exists either in Current AT or in WeakRefStorage of Peers being sent to Client ItemAutomationPeer peer = oldChildren[dataItem]; peer = ReusePeerForItem(peer, dataItem); if (peer == null) { peer = 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.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = peer; } } // protection from indistinguishable items - for example, 2 strings with same value // this scenario does not work in ItemsControl however is not checked for. if (_dataChildren[dataItem] == null) { children.Add(peer); _dataChildren[dataItem] = peer; } } return(children); } return(null); }
// 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); }
/// <summary>Gets the collection of child elements of the <see cref="T:System.Windows.Controls.GroupItem" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.GroupItemAutomationPeer" />. This method is called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetChildren" />.</summary> /// <returns>The collection of child elements.</returns> // Token: 0x060026E9 RID: 9961 RVA: 0x000B8530 File Offset: 0x000B6730 protected override List <AutomationPeer> GetChildrenCore() { GroupItem groupItem = (GroupItem)base.Owner; ItemsControl itemsControl = ItemsControl.ItemsControlFromItemContainer(base.Owner); if (itemsControl != null) { ItemsControlAutomationPeer itemsControlAutomationPeer = itemsControl.CreateAutomationPeer() as ItemsControlAutomationPeer; if (itemsControlAutomationPeer != null) { Panel itemsHost = groupItem.ItemsHost; if (itemsHost == null) { return(null); } IList children = itemsHost.Children; List <AutomationPeer> list = new List <AutomationPeer>(children.Count); ItemPeersStorage <ItemAutomationPeer> itemPeersStorage = new ItemPeersStorage <ItemAutomationPeer>(); bool useNetFx472CompatibleAccessibilityFeatures = AccessibilitySwitches.UseNetFx472CompatibleAccessibilityFeatures; if (!useNetFx472CompatibleAccessibilityFeatures && groupItem.Expander != null) { this._expanderPeer = UIElementAutomationPeer.CreatePeerForElement(groupItem.Expander); if (this._expanderPeer != null) { this._expanderPeer.EventsSource = this; this._expanderPeer.GetChildren(); } } foreach (object obj in children) { UIElement uielement = (UIElement)obj; if (!((IGeneratorHost)itemsControl).IsItemItsOwnContainer(uielement)) { UIElementAutomationPeer uielementAutomationPeer = uielement.CreateAutomationPeer() as UIElementAutomationPeer; if (uielementAutomationPeer != null) { list.Add(uielementAutomationPeer); if (useNetFx472CompatibleAccessibilityFeatures) { if (itemsControlAutomationPeer.RecentlyRealizedPeers.Count > 0 && this.AncestorsInvalid) { GroupItemAutomationPeer groupItemAutomationPeer = uielementAutomationPeer as GroupItemAutomationPeer; if (groupItemAutomationPeer != null) { groupItemAutomationPeer.InvalidateGroupItemPeersContainingRecentlyRealizedPeers(itemsControlAutomationPeer.RecentlyRealizedPeers); } } } else if (this.AncestorsInvalid) { GroupItemAutomationPeer groupItemAutomationPeer2 = uielementAutomationPeer as GroupItemAutomationPeer; if (groupItemAutomationPeer2 != null) { groupItemAutomationPeer2.AncestorsInvalid = true; groupItemAutomationPeer2.ChildrenValid = true; } } } } else { object obj2 = itemsControl.ItemContainerGenerator.ItemFromContainer(uielement); if (obj2 != DependencyProperty.UnsetValue) { ItemAutomationPeer itemAutomationPeer = useNetFx472CompatibleAccessibilityFeatures ? itemsControlAutomationPeer.ItemPeers[obj2] : itemsControlAutomationPeer.ReusablePeerFor(obj2); itemAutomationPeer = itemsControlAutomationPeer.ReusePeerForItem(itemAutomationPeer, obj2); if (itemAutomationPeer != null) { if (useNetFx472CompatibleAccessibilityFeatures) { int num = itemsControlAutomationPeer.RecentlyRealizedPeers.IndexOf(itemAutomationPeer); if (num >= 0) { itemsControlAutomationPeer.RecentlyRealizedPeers.RemoveAt(num); } } } else { itemAutomationPeer = itemsControlAutomationPeer.CreateItemAutomationPeerInternal(obj2); } if (itemAutomationPeer != null) { AutomationPeer wrapperPeer = itemAutomationPeer.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = itemAutomationPeer; if (itemAutomationPeer.ChildrenValid && itemAutomationPeer.Children == null && this.AncestorsInvalid) { itemAutomationPeer.AncestorsInvalid = true; wrapperPeer.AncestorsInvalid = true; } } } bool flag = itemsControlAutomationPeer.ItemPeers[obj2] == null; if (itemAutomationPeer != null && (flag || (itemAutomationPeer.GetParent() == this && itemPeersStorage[obj2] == null))) { list.Add(itemAutomationPeer); itemPeersStorage[obj2] = itemAutomationPeer; if (flag) { itemsControlAutomationPeer.ItemPeers[obj2] = itemAutomationPeer; } } } } } return(list); } } return(null); }
/// <summary>Gets the collection of child elements of the <see cref="T:System.Windows.Controls.ItemsControl" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.ItemsControlAutomationPeer" />. This method is called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetChildren" />.</summary> /// <returns>The collection of child elements.</returns> // Token: 0x06002733 RID: 10035 RVA: 0x000B9414 File Offset: 0x000B7614 protected override List <AutomationPeer> GetChildrenCore() { List <AutomationPeer> list = null; ItemPeersStorage <ItemAutomationPeer> dataChildren = this._dataChildren; this._dataChildren = new ItemPeersStorage <ItemAutomationPeer>(); ItemsControl itemsControl = (ItemsControl)base.Owner; ItemCollection items = itemsControl.Items; Panel itemsHost = itemsControl.ItemsHost; bool useNetFx472CompatibleAccessibilityFeatures = AccessibilitySwitches.UseNetFx472CompatibleAccessibilityFeatures; if (itemsControl.IsGrouping) { if (itemsHost == null) { return(null); } if (!useNetFx472CompatibleAccessibilityFeatures) { this._reusablePeers = dataChildren; } IList list2 = itemsHost.Children; list = new List <AutomationPeer>(list2.Count); foreach (object obj in list2) { UIElement uielement = (UIElement)obj; UIElementAutomationPeer uielementAutomationPeer = uielement.CreateAutomationPeer() as UIElementAutomationPeer; if (uielementAutomationPeer != null) { list.Add(uielementAutomationPeer); if (useNetFx472CompatibleAccessibilityFeatures) { if (this._recentlyRealizedPeers != null && this._recentlyRealizedPeers.Count > 0 && this.AncestorsInvalid) { GroupItemAutomationPeer groupItemAutomationPeer = uielementAutomationPeer as GroupItemAutomationPeer; if (groupItemAutomationPeer != null) { groupItemAutomationPeer.InvalidateGroupItemPeersContainingRecentlyRealizedPeers(this._recentlyRealizedPeers); } } } else if (this.AncestorsInvalid) { GroupItemAutomationPeer groupItemAutomationPeer2 = uielementAutomationPeer as GroupItemAutomationPeer; if (groupItemAutomationPeer2 != null) { groupItemAutomationPeer2.AncestorsInvalid = true; groupItemAutomationPeer2.ChildrenValid = true; } } } } return(list); } else { if (items.Count > 0) { IList list2; if (this.IsVirtualized) { if (itemsHost == null) { return(null); } list2 = itemsHost.Children; } else { list2 = items; } list = new List <AutomationPeer>(list2.Count); foreach (object obj2 in list2) { object obj3; if (this.IsVirtualized) { DependencyObject dependencyObject = obj2 as DependencyObject; obj3 = ((dependencyObject != null) ? itemsControl.ItemContainerGenerator.ItemFromContainer(dependencyObject) : null); if (obj3 == DependencyProperty.UnsetValue) { continue; } } else { obj3 = obj2; } ItemAutomationPeer itemAutomationPeer = dataChildren[obj3]; itemAutomationPeer = this.ReusePeerForItem(itemAutomationPeer, obj3); if (itemAutomationPeer == null) { itemAutomationPeer = this.CreateItemAutomationPeer(obj3); } if (itemAutomationPeer != null) { AutomationPeer wrapperPeer = itemAutomationPeer.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = itemAutomationPeer; } } if (itemAutomationPeer != null && this._dataChildren[obj3] == null) { list.Add(itemAutomationPeer); this._dataChildren[obj3] = itemAutomationPeer; } } return(list); } return(null); } }