/// <summary>Initializes a new instance of the <see cref="T:System.Windows.Documents.Hyperlink" /> class, taking two <see cref="T:System.Windows.Documents.TextPointer" /> objects that indicate the beginning and end of a selection of content to be contained by the new <see cref="T:System.Windows.Documents.Hyperlink" />.</summary> /// <param name="start">A <see cref="T:System.Windows.Documents.TextPointer" /> indicating the beginning of a selection of content to be contained by the new <see cref="T:System.Windows.Documents.Hyperlink" />.</param> /// <param name="end">A <see cref="T:System.Windows.Documents.TextPointer" /> indicating the end of a selection of content to be contained by the new <see cref="T:System.Windows.Documents.Hyperlink" />.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="start" /> or <paramref name="end" /> is <see langword="null" />.</exception> /// <exception cref="T:System.ArgumentException"> /// <paramref name="start" /> and <paramref name="end" /> do not resolve to a range of content suitable for enclosure by a <see cref="T:System.Windows.Documents.Span" /> element; for example, if <paramref name="start" /> and <paramref name="end" /> indicate positions in different paragraphs.</exception> // Token: 0x0600301F RID: 12319 RVA: 0x000D8A18 File Offset: 0x000D6C18 public Hyperlink(TextPointer start, TextPointer end) : base(start, end) { TextPointer textPointer = base.ContentStart.CreatePointer(); TextPointer contentEnd = base.ContentEnd; while (textPointer.CompareTo(contentEnd) < 0) { Hyperlink hyperlink = textPointer.GetAdjacentElement(LogicalDirection.Forward) as Hyperlink; if (hyperlink != null) { hyperlink.Reposition(null, null); } else { textPointer.MoveToNextContextPosition(LogicalDirection.Forward); } } }
/// <summary> /// Creates a new Hyperlink instance covering existing content. /// </summary> /// <param name="start"> /// Start position of the new Hyperlink. /// </param> /// <param name="end"> /// End position of the new Hyperlink. /// </param> /// <remarks> /// start and end must both be parented by the same Paragraph, otherwise /// the method will raise an ArgumentException. /// </remarks> public Hyperlink(TextPointer start, TextPointer end) : base(start, end) { // After inserting this Hyperlink, we need to extract any child Hyperlinks. TextPointer navigator = this.ContentStart.CreatePointer(); TextPointer stop = this.ContentEnd; while (navigator.CompareTo(stop) < 0) { Hyperlink hyperlink = navigator.GetAdjacentElement(LogicalDirection.Forward) as Hyperlink; if (hyperlink != null) { hyperlink.Reposition(null, null); } else { navigator.MoveToNextContextPosition(LogicalDirection.Forward); } } }