// private static bool iterate(DependencyObject parent, IteratorCallback callback) { 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 && (peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)child)) != null) { done = callback(peer); } else if (child != null && child is UIElement3D && (peer = CreatePeerForElement(((UIElement3D)child))) != null) { done = callback(peer); } else { done = iterate(child, callback); } } } return(done); }
// private static bool iterate(Visual parent, IteratorCallback callback) { bool done = false; AutomationPeer peer = null; int count = parent.InternalVisualChildrenCount; for (int i = 0; i < count && !done; i++) { Visual child = parent.InternalGetVisualChild(i); if (child != null && child.CheckFlagsAnd(VisualFlags.IsUIElement) && (peer = CreatePeerForElement((UIElement)child)) != null) { done = callback(peer); } else { done = iterate(child, callback); } } 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); }
// private static bool iterate(DependencyObject parent, IteratorCallback callback) { 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 && (peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)child)) != null ) { done = callback(peer); } else if ( child != null && child is UIElement3D && (peer = CreatePeerForElement(((UIElement3D)child))) != null ) { done = callback(peer); } else { done = iterate(child, callback); } } } 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; }
// private static bool iterate(Visual parent, IteratorCallback callback) { bool done = false; AutomationPeer peer = null; int count = parent.InternalVisualChildrenCount; for (int i = 0; i < count && !done; i++) { Visual child = parent.InternalGetVisualChild(i); if (child != null && child.CheckFlagsAnd(VisualFlags.IsUIElement) && (peer = CreatePeerForElement((UIElement)child)) != null) { done = callback(peer); } else { done = iterate(child, callback); } } return (done); }