// 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); }
// 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); }
// 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); }
/// <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: 0x06008E5B RID: 36443 RVA: 0x0025BE9C File Offset: 0x0025A09C private void GetContent() { this._contentSegments.Clear(); ITextPointer textPointer = this._segment.Start.CreatePointer(); ITextPointer textPointer2 = null; while (textPointer.CompareTo(this._segment.End) < 0) { TextPointerContext pointerContext = textPointer.GetPointerContext(LogicalDirection.Forward); if (pointerContext == TextPointerContext.ElementStart) { Type elementType = textPointer.GetElementType(LogicalDirection.Forward); if (typeof(Run).IsAssignableFrom(elementType) || typeof(BlockUIContainer).IsAssignableFrom(elementType)) { this.OpenSegment(ref textPointer2, textPointer); } else if (typeof(Table).IsAssignableFrom(elementType) || typeof(Floater).IsAssignableFrom(elementType) || typeof(Figure).IsAssignableFrom(elementType)) { this.CloseSegment(ref textPointer2, textPointer, this._segment.End); } textPointer.MoveToNextContextPosition(LogicalDirection.Forward); if (typeof(Run).IsAssignableFrom(elementType) || typeof(BlockUIContainer).IsAssignableFrom(elementType)) { textPointer.MoveToElementEdge(ElementEdge.AfterEnd); } } else if (pointerContext == TextPointerContext.ElementEnd) { Type parentType = textPointer.ParentType; if (typeof(TableCell).IsAssignableFrom(parentType) || typeof(Floater).IsAssignableFrom(parentType) || typeof(Figure).IsAssignableFrom(parentType)) { this.CloseSegment(ref textPointer2, textPointer, this._segment.End); } textPointer.MoveToNextContextPosition(LogicalDirection.Forward); } else if (pointerContext == TextPointerContext.Text || pointerContext == TextPointerContext.EmbeddedElement) { this.OpenSegment(ref textPointer2, textPointer); textPointer.MoveToNextContextPosition(LogicalDirection.Forward); } else { Invariant.Assert(false, "unexpected TextPointerContext"); } } this.CloseSegment(ref textPointer2, textPointer, this._segment.End); }
// Part of plain text converter: called from GetTextInternal when processing ElementEnd for Paragraph elements. // Outputs \n - for regular paragraphs and TableRow ends or \t for TableCell ends. private static void PlainConvertParagraphEnd(StringBuilder textBuffer, ITextPointer navigator) { // Check for a special case for a single paragraph within a TableCell // which must be serialized as "\t" character. navigator.MoveToElementEdge(ElementEdge.BeforeStart); bool theParagraphIsTheFirstInCollection = navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart; navigator.MoveToNextContextPosition(LogicalDirection.Forward); navigator.MoveToElementEdge(ElementEdge.AfterEnd); TextPointerContext symbolType = navigator.GetPointerContext(LogicalDirection.Forward); if (theParagraphIsTheFirstInCollection && symbolType == TextPointerContext.ElementEnd && typeof(TableCell).IsAssignableFrom(navigator.ParentType)) { // This is an end of a table cell navigator.MoveToNextContextPosition(LogicalDirection.Forward); symbolType = navigator.GetPointerContext(LogicalDirection.Forward); if (symbolType == TextPointerContext.ElementStart) { // Next table cell starts after this one. Use '\t' as a cell separator textBuffer.Append('\t'); } else { // This was the last cell in a row. Use '\r\n' as a line separator textBuffer.Append(Environment.NewLine); } } else { // Ordinary paragraph end textBuffer.Append(Environment.NewLine); } }
/// <summary> /// Retrieves the range of a child object. /// </summary> /// <param name="childElementProvider">The child element. A provider should check that the /// passed element is a child of the text container, and should throw an /// InvalidOperationException if it is not.</param> /// <returns>A range that spans the child element.</returns> ITextRangeProvider ITextProvider.RangeFromChild(IRawElementProviderSimple childElementProvider) { if (childElementProvider == null) { throw new ArgumentNullException("childElementProvider"); } // Retrieve DependencyObject from AutomationElement DependencyObject childElement; if (_textPeer is TextAutomationPeer) { childElement = ((TextAutomationPeer)_textPeer).ElementFromProvider(childElementProvider); } else { childElement = ((ContentTextAutomationPeer)_textPeer).ElementFromProvider(childElementProvider); } TextRangeAdaptor range = null; if (childElement != null) { ITextPointer rangeStart = null; ITextPointer rangeEnd = null; // Retrieve start and end positions for given element. // If element is TextElement, retrieve its Element Start and End positions. // If element is UIElement hosted by UIContainer (Inlien of Block), // retrieve content Start and End positions of the container. // Otherwise scan ITextContainer to find a range for given element. if (childElement is TextElement) { rangeStart = ((TextElement)childElement).ElementStart; rangeEnd = ((TextElement)childElement).ElementEnd; } else { DependencyObject parent = LogicalTreeHelper.GetParent(childElement); if (parent is InlineUIContainer || parent is BlockUIContainer) { rangeStart = ((TextElement)parent).ContentStart; rangeEnd = ((TextElement)parent).ContentEnd; } else { ITextPointer position = _textContainer.Start.CreatePointer(); while (position.CompareTo(_textContainer.End) < 0) { TextPointerContext context = position.GetPointerContext(LogicalDirection.Forward); if (context == TextPointerContext.ElementStart) { if (childElement == position.GetAdjacentElement(LogicalDirection.Forward)) { rangeStart = position.CreatePointer(LogicalDirection.Forward); position.MoveToElementEdge(ElementEdge.AfterEnd); rangeEnd = position.CreatePointer(LogicalDirection.Backward); break; } } else if (context == TextPointerContext.EmbeddedElement) { if (childElement == position.GetAdjacentElement(LogicalDirection.Forward)) { rangeStart = position.CreatePointer(LogicalDirection.Forward); position.MoveToNextContextPosition(LogicalDirection.Forward); rangeEnd = position.CreatePointer(LogicalDirection.Backward); break; } } position.MoveToNextContextPosition(LogicalDirection.Forward); } } } // Create range if (rangeStart != null && rangeEnd != null) { range = new TextRangeAdaptor(this, rangeStart, rangeEnd, _textPeer); } } if (range == null) { throw new InvalidOperationException(SR.Get(SRID.TextProvider_InvalidChildElement)); } return(range); }
/// <summary> /// This helper method is used by TextRangeAdaptor to bring the range into view /// through multiple nested scroll providers. /// </summary> internal void ScrollIntoView(ITextPointer start, ITextPointer end, bool alignToTop) { // Calculate the bounding rectangle for the range Rect rangeBounds = Rect.Empty; Rect[] lineBounds = GetBoundingRectangles(start, end, false, false); foreach (Rect rect in lineBounds) { rangeBounds.Union(rect); } ITextView textView = GetUpdatedTextView(); if (textView != null && !rangeBounds.IsEmpty) { // Find out the visible portion of the range. Rect visibleRect = GetVisibleRectangle(textView); Rect rangeVisibleBounds = Rect.Intersect(rangeBounds, visibleRect); if (rangeVisibleBounds == rangeBounds) { // The range is already in the view. It's probably not aligned as requested, // but who cares since it's entirely visible anyway. return; } // Ensure the visibility of the range. // BringIntoView will do most of the magic except the very first scroll // in order to satisfy the requested alignment. UIElement renderScope = textView.RenderScope; Visual visual = renderScope; while (visual != null) { IScrollInfo isi = visual as IScrollInfo; if (isi != null) { // Transform the bounding rectangle into the IScrollInfo coordinates. if (visual != renderScope) { GeneralTransform childToParent = renderScope.TransformToAncestor(visual); rangeBounds = childToParent.TransformBounds(rangeBounds); } if (isi.CanHorizontallyScroll) { isi.SetHorizontalOffset(alignToTop ? rangeBounds.Left : (rangeBounds.Right - isi.ViewportWidth)); } if (isi.CanVerticallyScroll) { isi.SetVerticalOffset(alignToTop ? rangeBounds.Top : (rangeBounds.Bottom - isi.ViewportHeight)); } break; } visual = VisualTreeHelper.GetParent(visual) as Visual; } FrameworkElement fe = renderScope as FrameworkElement; if (fe != null) { fe.BringIntoView(rangeVisibleBounds); } } else { // If failed to retrive range bounds, try to Bring into view closes element. ITextPointer pointer = alignToTop ? start.CreatePointer() : end.CreatePointer(); pointer.MoveToElementEdge(alignToTop ? ElementEdge.AfterStart : ElementEdge.AfterEnd); FrameworkContentElement element = pointer.GetAdjacentElement(LogicalDirection.Backward) as FrameworkContentElement; if (element != null) { element.BringIntoView(); } } }
//------------------------------------------------------------------- // // 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; }
internal object BuildObjectTree() { IAddChild root; switch (_type) { case ElementType.Table: root = new Table(); break; case ElementType.TableRowGroup: root = new TableRowGroup(); break; case ElementType.TableRow: root = new TableRow(); break; case ElementType.TableCell: root = new TableCell(); break; case ElementType.Paragraph: root = new Paragraph(); break; case ElementType.Hyperlink: Hyperlink link = new Hyperlink(); link.NavigateUri = GetValue(NavigateUriProperty) as Uri; link.RequestNavigate += new RequestNavigateEventHandler(ClickHyperlink); AutomationProperties.SetHelpText(link, (String)this.GetValue(HelpTextProperty)); AutomationProperties.SetName(link, (String)this.GetValue(NameProperty)); root = link; break; default: Debug.Assert(false); root = null; break; } ITextPointer pos = ((ITextPointer)_start).CreatePointer(); while (pos.CompareTo((ITextPointer)_end) < 0) { TextPointerContext tpc = pos.GetPointerContext(LogicalDirection.Forward); if (tpc == TextPointerContext.Text) { root.AddText(pos.GetTextInRun(LogicalDirection.Forward)); } else if (tpc == TextPointerContext.EmbeddedElement) { root.AddChild(pos.GetAdjacentElement(LogicalDirection.Forward)); } else if (tpc == TextPointerContext.ElementStart) { object obj = pos.GetAdjacentElement(LogicalDirection.Forward); if (obj != null) { root.AddChild(obj); pos.MoveToNextContextPosition(LogicalDirection.Forward); pos.MoveToElementEdge(ElementEdge.BeforeEnd); } } pos.MoveToNextContextPosition(LogicalDirection.Forward); } return(root); }
// Token: 0x06002D1F RID: 11551 RVA: 0x000CBAC0 File Offset: 0x000C9CC0 internal object BuildObjectTree() { FixedElement.ElementType type = this._type; IAddChild addChild; if (type != FixedElement.ElementType.Paragraph) { switch (type) { case FixedElement.ElementType.Table: addChild = new Table(); goto IL_C7; case FixedElement.ElementType.TableRowGroup: addChild = new TableRowGroup(); goto IL_C7; case FixedElement.ElementType.TableRow: addChild = new TableRow(); goto IL_C7; case FixedElement.ElementType.TableCell: addChild = new TableCell(); goto IL_C7; case FixedElement.ElementType.Hyperlink: { Hyperlink hyperlink = new Hyperlink(); hyperlink.NavigateUri = (base.GetValue(FixedElement.NavigateUriProperty) as Uri); hyperlink.RequestNavigate += this.ClickHyperlink; AutomationProperties.SetHelpText(hyperlink, (string)base.GetValue(FixedElement.HelpTextProperty)); AutomationProperties.SetName(hyperlink, (string)base.GetValue(FixedElement.NameProperty)); addChild = hyperlink; goto IL_C7; } } addChild = null; } else { addChild = new Paragraph(); } IL_C7: ITextPointer textPointer = ((ITextPointer)this._start).CreatePointer(); while (textPointer.CompareTo(this._end) < 0) { TextPointerContext pointerContext = textPointer.GetPointerContext(LogicalDirection.Forward); if (pointerContext == TextPointerContext.Text) { addChild.AddText(textPointer.GetTextInRun(LogicalDirection.Forward)); } else if (pointerContext == TextPointerContext.EmbeddedElement) { addChild.AddChild(textPointer.GetAdjacentElement(LogicalDirection.Forward)); } else if (pointerContext == TextPointerContext.ElementStart) { object adjacentElement = textPointer.GetAdjacentElement(LogicalDirection.Forward); if (adjacentElement != null) { addChild.AddChild(adjacentElement); textPointer.MoveToNextContextPosition(LogicalDirection.Forward); textPointer.MoveToElementEdge(ElementEdge.BeforeEnd); } } textPointer.MoveToNextContextPosition(LogicalDirection.Forward); } return(addChild); }
// Token: 0x060065D1 RID: 26065 RVA: 0x001C8918 File Offset: 0x001C6B18 ITextRangeProvider ITextProvider.RangeFromChild(IRawElementProviderSimple childElementProvider) { if (childElementProvider == null) { throw new ArgumentNullException("childElementProvider"); } DependencyObject dependencyObject; if (this._textPeer is TextAutomationPeer) { dependencyObject = ((TextAutomationPeer)this._textPeer).ElementFromProvider(childElementProvider); } else { dependencyObject = ((ContentTextAutomationPeer)this._textPeer).ElementFromProvider(childElementProvider); } TextRangeAdaptor textRangeAdaptor = null; if (dependencyObject != null) { ITextPointer textPointer = null; ITextPointer textPointer2 = null; if (dependencyObject is TextElement) { textPointer = ((TextElement)dependencyObject).ElementStart; textPointer2 = ((TextElement)dependencyObject).ElementEnd; } else { DependencyObject parent = LogicalTreeHelper.GetParent(dependencyObject); if (parent is InlineUIContainer || parent is BlockUIContainer) { textPointer = ((TextElement)parent).ContentStart; textPointer2 = ((TextElement)parent).ContentEnd; } else { ITextPointer textPointer3 = this._textContainer.Start.CreatePointer(); while (textPointer3.CompareTo(this._textContainer.End) < 0) { TextPointerContext pointerContext = textPointer3.GetPointerContext(LogicalDirection.Forward); if (pointerContext == TextPointerContext.ElementStart) { if (dependencyObject == textPointer3.GetAdjacentElement(LogicalDirection.Forward)) { textPointer = textPointer3.CreatePointer(LogicalDirection.Forward); textPointer3.MoveToElementEdge(ElementEdge.AfterEnd); textPointer2 = textPointer3.CreatePointer(LogicalDirection.Backward); break; } } else if (pointerContext == TextPointerContext.EmbeddedElement && dependencyObject == textPointer3.GetAdjacentElement(LogicalDirection.Forward)) { textPointer = textPointer3.CreatePointer(LogicalDirection.Forward); textPointer3.MoveToNextContextPosition(LogicalDirection.Forward); textPointer2 = textPointer3.CreatePointer(LogicalDirection.Backward); break; } textPointer3.MoveToNextContextPosition(LogicalDirection.Forward); } } } if (textPointer != null && textPointer2 != null) { textRangeAdaptor = new TextRangeAdaptor(this, textPointer, textPointer2, this._textPeer); } } if (textRangeAdaptor == null) { throw new InvalidOperationException(SR.Get("TextProvider_InvalidChildElement")); } return(textRangeAdaptor); }
// Token: 0x060065C7 RID: 26055 RVA: 0x001C84A0 File Offset: 0x001C66A0 internal void ScrollIntoView(ITextPointer start, ITextPointer end, bool alignToTop) { Rect rect = Rect.Empty; Rect[] boundingRectangles = this.GetBoundingRectangles(start, end, false, false); foreach (Rect rect2 in boundingRectangles) { rect.Union(rect2); } ITextView updatedTextView = this.GetUpdatedTextView(); if (updatedTextView != null && !rect.IsEmpty) { Rect visibleRectangle = this.GetVisibleRectangle(updatedTextView); Rect rect3 = Rect.Intersect(rect, visibleRectangle); if (rect3 == rect) { return; } UIElement renderScope = updatedTextView.RenderScope; Visual visual = renderScope; while (visual != null) { IScrollInfo scrollInfo = visual as IScrollInfo; if (scrollInfo != null) { if (visual != renderScope) { GeneralTransform generalTransform = renderScope.TransformToAncestor(visual); rect = generalTransform.TransformBounds(rect); } if (scrollInfo.CanHorizontallyScroll) { scrollInfo.SetHorizontalOffset(alignToTop ? rect.Left : (rect.Right - scrollInfo.ViewportWidth)); } if (scrollInfo.CanVerticallyScroll) { scrollInfo.SetVerticalOffset(alignToTop ? rect.Top : (rect.Bottom - scrollInfo.ViewportHeight)); break; } break; } else { visual = (VisualTreeHelper.GetParent(visual) as Visual); } } FrameworkElement frameworkElement = renderScope as FrameworkElement; if (frameworkElement != null) { frameworkElement.BringIntoView(rect3); return; } } else { ITextPointer textPointer = alignToTop ? start.CreatePointer() : end.CreatePointer(); textPointer.MoveToElementEdge(alignToTop ? ElementEdge.AfterStart : ElementEdge.AfterEnd); FrameworkContentElement frameworkContentElement = textPointer.GetAdjacentElement(LogicalDirection.Backward) as FrameworkContentElement; if (frameworkContentElement != null) { frameworkContentElement.BringIntoView(); } } }
//------------------------------------------------------------------- // // 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); }