// Token: 0x06007245 RID: 29253 RVA: 0x0020AA54 File Offset: 0x00208C54 internal static List <AutomationPeer> GetAutomationPeersFromRange(ITextPointer start, ITextPointer end, ITextPointer ownerContentStart) { List <AutomationPeer> list = new List <AutomationPeer>(); start = start.CreatePointer(); while (start.CompareTo(end) < 0) { bool flag = false; if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart) { object adjacentElement = start.GetAdjacentElement(LogicalDirection.Forward); if (adjacentElement is ContentElement) { AutomationPeer automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)adjacentElement); if (automationPeer != null) { if (ownerContentStart == null || TextContainerHelper.IsImmediateAutomationChild(start, ownerContentStart)) { list.Add(automationPeer); } start.MoveToNextContextPosition(LogicalDirection.Forward); start.MoveToElementEdge(ElementEdge.AfterEnd); flag = true; } } } else if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement) { object adjacentElement = start.GetAdjacentElement(LogicalDirection.Forward); if (adjacentElement is UIElement) { if (ownerContentStart == null || TextContainerHelper.IsImmediateAutomationChild(start, ownerContentStart)) { AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)adjacentElement); if (automationPeer != null) { list.Add(automationPeer); } else { TextContainerHelper.iterate((Visual)adjacentElement, list); } } } else if (adjacentElement is ContentElement) { AutomationPeer automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)adjacentElement); if (automationPeer != null && (ownerContentStart == null || TextContainerHelper.IsImmediateAutomationChild(start, ownerContentStart))) { list.Add(automationPeer); } } } if (!flag && !start.MoveToNextContextPosition(LogicalDirection.Forward)) { break; } } return(list); }
// Token: 0x06007246 RID: 29254 RVA: 0x0020AB60 File Offset: 0x00208D60 internal static bool IsImmediateAutomationChild(ITextPointer elementStart, ITextPointer ownerContentStart) { Invariant.Assert(elementStart.CompareTo(ownerContentStart) >= 0); bool result = true; ITextPointer textPointer = elementStart.CreatePointer(); while (typeof(TextElement).IsAssignableFrom(textPointer.ParentType)) { textPointer.MoveToElementEdge(ElementEdge.BeforeStart); if (textPointer.CompareTo(ownerContentStart) <= 0) { break; } AutomationPeer automationPeer = null; object adjacentElement = textPointer.GetAdjacentElement(LogicalDirection.Forward); if (adjacentElement is UIElement) { automationPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)adjacentElement); } else if (adjacentElement is ContentElement) { automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)adjacentElement); } if (automationPeer != null) { result = false; break; } } return(result); }
/// <summary> /// Is AutometionPeer represented by 'elementStart' is immediate child of AutomationPeer /// represented by 'ownerContentStart'. /// </summary> internal static bool IsImmediateAutomationChild(ITextPointer elementStart, ITextPointer ownerContentStart) { Invariant.Assert(elementStart.CompareTo(ownerContentStart) >= 0); bool immediateChild = true; // Walk element tree up looking for AutomationPeers. ITextPointer position = elementStart.CreatePointer(); while (typeof(TextElement).IsAssignableFrom(position.ParentType)) { position.MoveToElementEdge(ElementEdge.BeforeStart); if (position.CompareTo(ownerContentStart) <= 0) { break; } AutomationPeer peer = null; object element = position.GetAdjacentElement(LogicalDirection.Forward); if (element is UIElement) { peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)element); } else if (element is ContentElement) { peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element); } if (peer != null) { immediateChild = false; break; } } return(immediateChild); }
// Token: 0x06007247 RID: 29255 RVA: 0x0020ABF0 File Offset: 0x00208DF0 internal static AutomationPeer GetEnclosingAutomationPeer(ITextPointer start, ITextPointer end, out ITextPointer elementStart, out ITextPointer elementEnd) { List <object> list = new List <object>(); List <ITextPointer> list2 = new List <ITextPointer>(); ITextPointer textPointer = start.CreatePointer(); while (typeof(TextElement).IsAssignableFrom(textPointer.ParentType)) { textPointer.MoveToElementEdge(ElementEdge.BeforeStart); object obj = textPointer.GetAdjacentElement(LogicalDirection.Forward); if (obj != null) { list.Insert(0, obj); list2.Insert(0, textPointer.CreatePointer(LogicalDirection.Forward)); } } List <object> list3 = new List <object>(); List <ITextPointer> list4 = new List <ITextPointer>(); textPointer = end.CreatePointer(); while (typeof(TextElement).IsAssignableFrom(textPointer.ParentType)) { textPointer.MoveToElementEdge(ElementEdge.AfterEnd); object obj = textPointer.GetAdjacentElement(LogicalDirection.Backward); if (obj != null) { list3.Insert(0, obj); list4.Insert(0, textPointer.CreatePointer(LogicalDirection.Backward)); } } AutomationPeer automationPeer = null; ITextPointer textPointer2; elementEnd = (textPointer2 = null); elementStart = textPointer2; for (int i = Math.Min(list.Count, list3.Count); i > 0; i--) { if (list[i - 1] == list3[i - 1]) { object obj = list[i - 1]; if (obj is UIElement) { automationPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)obj); } else if (obj is ContentElement) { automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)obj); } if (automationPeer != null) { elementStart = list2[i - 1]; elementEnd = list4[i - 1]; break; } } } return(automationPeer); }
/// <summary>Handles the <see cref="E:System.Windows.Documents.Hyperlink.Click" /> routed event.</summary> // Token: 0x06003041 RID: 12353 RVA: 0x000D8E2C File Offset: 0x000D702C protected virtual void OnClick() { if (AutomationPeer.ListenerExists(AutomationEvents.InvokePatternOnInvoked)) { AutomationPeer automationPeer = ContentElementAutomationPeer.CreatePeerForElement(this); if (automationPeer != null) { automationPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked); } } Hyperlink.DoNavigation(this); base.RaiseEvent(new RoutedEventArgs(Hyperlink.ClickEvent, this)); CommandHelpers.ExecuteCommandSource(this); }
/// <summary> /// Returns the common ancestor of two positions. This ancestor needs to have /// AutomationPeer associated with it. /// </summary> internal static AutomationPeer GetEnclosingAutomationPeer(ITextPointer start, ITextPointer end, out ITextPointer elementStart, out ITextPointer elementEnd) { object element; AutomationPeer peer; ITextPointer position; List <object> ancestorsStart, ancestorsEnd; List <ITextPointer> positionsStart, positionsEnd; // Get instances of parent objects for start position. The only valid type for // scoping elements inside ITextContainer is TextElement. ancestorsStart = new List <object>(); positionsStart = new List <ITextPointer>(); position = start.CreatePointer(); while (typeof(TextElement).IsAssignableFrom(position.ParentType)) { position.MoveToElementEdge(ElementEdge.BeforeStart); element = position.GetAdjacentElement(LogicalDirection.Forward); if (element != null) { ancestorsStart.Insert(0, element); positionsStart.Insert(0, position.CreatePointer(LogicalDirection.Forward)); } } // Get instances of parent objects for end position. The only valid type for // scoping elements inside ITextContainer is TextElement. ancestorsEnd = new List <object>(); positionsEnd = new List <ITextPointer>(); position = end.CreatePointer(); while (typeof(TextElement).IsAssignableFrom(position.ParentType)) { position.MoveToElementEdge(ElementEdge.AfterEnd); element = position.GetAdjacentElement(LogicalDirection.Backward); if (element != null) { ancestorsEnd.Insert(0, element); positionsEnd.Insert(0, position.CreatePointer(LogicalDirection.Backward)); } } // Find common ancestor. If any of ancestors collection is empty, there // is no common ancestor. peer = null; elementStart = elementEnd = null; int depth = Math.Min(ancestorsStart.Count, ancestorsEnd.Count); while (depth > 0) { if (ancestorsStart[depth - 1] == ancestorsEnd[depth - 1]) { element = ancestorsStart[depth - 1]; if (element is UIElement) { peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)element); } else if (element is ContentElement) { peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element); } if (peer != null) { elementStart = positionsStart[depth - 1]; elementEnd = positionsEnd[depth - 1]; break; } } depth--; } return(peer); }
//------------------------------------------------------------------- // // Internal Methods // //------------------------------------------------------------------- #region Internal Methods /// <summary> /// Retrieves a collection of AutomationPeers that fall within the range. /// Children that overlap with the range but are not entirely enclosed by /// it will also be included in the collection. /// </summary> internal static List <AutomationPeer> GetAutomationPeersFromRange(ITextPointer start, ITextPointer end, ITextPointer ownerContentStart) { bool positionMoved; AutomationPeer peer = null; object element; List <AutomationPeer> peers = new List <AutomationPeer>(); start = start.CreatePointer(); while (start.CompareTo(end) < 0) { // Indicate that 'start' position is not moved yet. positionMoved = false; if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart) { // Get adjacent element and try to retrive AutomationPeer for it. element = start.GetAdjacentElement(LogicalDirection.Forward); if (element is ContentElement) { peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element); // If AutomationPeer has been retrieved, add it to the collection. // And skip entire element. if (peer != null) { if (ownerContentStart == null || IsImmediateAutomationChild(start, ownerContentStart)) { peers.Add(peer); } start.MoveToNextContextPosition(LogicalDirection.Forward); start.MoveToElementEdge(ElementEdge.AfterEnd); positionMoved = true; } } } else if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement) { // Get adjacent element and try to retrive AutomationPeer for it. element = start.GetAdjacentElement(LogicalDirection.Forward); if (element is UIElement) { if (ownerContentStart == null || IsImmediateAutomationChild(start, ownerContentStart)) { peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)element); // If AutomationPeer has been retrieved, add it to the collection. if (peer != null) { peers.Add(peer); } else { iterate((Visual)element, peers); } } } else if (element is ContentElement) { peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element); // If AutomationPeer has been retrieved, add it to the collection. if (peer != null) { if (ownerContentStart == null || IsImmediateAutomationChild(start, ownerContentStart)) { peers.Add(peer); } } } } // Move to the next content position, if position has not been moved already. if (!positionMoved) { if (!start.MoveToNextContextPosition(LogicalDirection.Forward)) { break; } } } return(peers); }