コード例 #1
0
        // 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);
        }