// Token: 0x060062DD RID: 25309 RVA: 0x001BC160 File Offset: 0x001BA360 private static ITextSelection GetTextSelection(FrameworkElement viewer) { FlowDocumentReader flowDocumentReader = viewer as FlowDocumentReader; if (flowDocumentReader != null) { viewer = (AnnotationHelper.GetFdrHost(flowDocumentReader) as FrameworkElement); } if (viewer != null) { return(TextEditor.GetTextSelection(viewer)); } return(null); }
// Token: 0x060062D1 RID: 25297 RVA: 0x001BB730 File Offset: 0x001B9930 private static IList <IAttachedAnnotation> GetSpannedAnnotations(AnnotationService service) { AnnotationHelper.CheckInputs(service); bool flag = true; DocumentViewerBase documentViewerBase = service.Root as DocumentViewerBase; if (documentViewerBase == null) { FlowDocumentReader flowDocumentReader = service.Root as FlowDocumentReader; if (flowDocumentReader != null) { documentViewerBase = (AnnotationHelper.GetFdrHost(flowDocumentReader) as DocumentViewerBase); } } else { flag = (documentViewerBase.Document is FlowDocument); } bool flag2 = true; ITextSelection textSelection = AnnotationHelper.GetTextSelection((FrameworkElement)service.Root); Invariant.Assert(textSelection != null, "TextSelection is null"); int num = 0; int num2 = 0; if (documentViewerBase != null) { TextSelectionHelper.GetPointerPage(textSelection.Start, out num); TextSelectionHelper.GetPointerPage(textSelection.End, out num2); if (num == -1 || num2 == -1) { throw new ArgumentException(SR.Get("InvalidSelectionPages")); } flag2 = AnnotationHelper.AreAllPagesVisible(documentViewerBase, num, num2); } IList <IAttachedAnnotation> list; if (flag2) { list = service.GetAttachedAnnotations(); } else if (flag) { list = AnnotationHelper.GetSpannedAnnotationsForFlow(service, textSelection); } else { list = AnnotationHelper.GetSpannedAnnotationsForFixed(service, num, num2); } IList <TextSegment> textSegments = textSelection.TextSegments; if (list != null && list.Count > 0 && (flag2 || !flag)) { for (int i = list.Count - 1; i >= 0; i--) { TextAnchor textAnchor = list[i].AttachedAnchor as TextAnchor; if (textAnchor == null || !textAnchor.IsOverlapping(textSegments)) { list.RemoveAt(i); } } } return(list); }
/// <summary>Returns an <see cref="T:System.Windows.Annotations.IAnchorInfo" /> object that provides anchoring information, such as the anchor location, about the specified annotation.</summary> /// <param name="service">The annotation service to use for this operation.</param> /// <param name="annotation">The annotation to get anchoring information for.</param> /// <returns>An <see cref="T:System.Windows.Annotations.IAnchorInfo" /> object that provides anchoring information about the specified annotation, or <see langword="null" /> if it cannot be resolved.</returns> // Token: 0x060062C1 RID: 25281 RVA: 0x001BB2D0 File Offset: 0x001B94D0 public static IAnchorInfo GetAnchorInfo(AnnotationService service, Annotation annotation) { AnnotationHelper.CheckInputs(service); if (annotation == null) { throw new ArgumentNullException("annotation"); } bool flag = true; DocumentViewerBase documentViewerBase = service.Root as DocumentViewerBase; if (documentViewerBase == null) { FlowDocumentReader flowDocumentReader = service.Root as FlowDocumentReader; if (flowDocumentReader != null) { documentViewerBase = (AnnotationHelper.GetFdrHost(flowDocumentReader) as DocumentViewerBase); } } else { flag = (documentViewerBase.Document is FlowDocument); } IList <IAttachedAnnotation> list = null; if (flag) { TextSelectionProcessor textSelectionProcessor = service.LocatorManager.GetSelectionProcessor(typeof(TextRange)) as TextSelectionProcessor; TextSelectionProcessor textSelectionProcessor2 = service.LocatorManager.GetSelectionProcessor(typeof(TextAnchor)) as TextSelectionProcessor; Invariant.Assert(textSelectionProcessor != null, "TextSelectionProcessor should be available for TextRange if we are processing flow content."); Invariant.Assert(textSelectionProcessor2 != null, "TextSelectionProcessor should be available for TextAnchor if we are processing flow content."); try { textSelectionProcessor.Clamping = false; textSelectionProcessor2.Clamping = false; list = AnnotationHelper.ResolveAnnotations(service, new Annotation[] { annotation }); goto IL_12E; } finally { textSelectionProcessor.Clamping = true; textSelectionProcessor2.Clamping = true; } } FixedPageProcessor fixedPageProcessor = service.LocatorManager.GetSubTreeProcessorForLocatorPart(FixedPageProcessor.CreateLocatorPart(0)) as FixedPageProcessor; Invariant.Assert(fixedPageProcessor != null, "FixedPageProcessor should be available if we are processing fixed content."); try { fixedPageProcessor.UseLogicalTree = true; list = AnnotationHelper.ResolveAnnotations(service, new Annotation[] { annotation }); } finally { fixedPageProcessor.UseLogicalTree = false; } IL_12E: Invariant.Assert(list != null); if (list.Count > 0) { return(list[0]); } return(null); }