// Token: 0x0600629A RID: 25242 RVA: 0x001BA878 File Offset: 0x001B8A78
        private DocumentPage ComposePageWithAnnotationVisuals(int pageNumber, DocumentPage page)
        {
            Size             size             = page.Size;
            AdornerDecorator adornerDecorator = new AdornerDecorator();

            adornerDecorator.FlowDirection = this._flowDirection;
            DocumentPageView documentPageView = new DocumentPageView();

            documentPageView.UseAsynchronousGetPage = false;
            documentPageView.DocumentPaginator      = this._originalPaginator;
            documentPageView.PageNumber             = pageNumber;
            adornerDecorator.Child = documentPageView;
            adornerDecorator.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            adornerDecorator.Arrange(new Rect(adornerDecorator.DesiredSize));
            adornerDecorator.UpdateLayout();
            AnnotationComponentManager annotationComponentManager = new AnnotationComponentManager(null);

            if (this._isFixedContent)
            {
                AnnotationService.SetSubTreeProcessorId(adornerDecorator, FixedPageProcessor.Id);
                this._locatorManager.RegisterSelectionProcessor(new FixedTextSelectionProcessor(), typeof(TextRange));
            }
            else
            {
                AnnotationService.SetDataId(adornerDecorator, "FlowDocument");
                this._locatorManager.RegisterSelectionProcessor(new TextViewSelectionProcessor(), typeof(DocumentPageView));
                TextSelectionProcessor textSelectionProcessor = new TextSelectionProcessor();
                textSelectionProcessor.SetTargetDocumentPageView(documentPageView);
                this._locatorManager.RegisterSelectionProcessor(textSelectionProcessor, typeof(TextRange));
            }
            IList <IAttachedAnnotation> list = this.ProcessAnnotations(documentPageView);

            foreach (IAttachedAnnotation attachedAnnotation in list)
            {
                if (attachedAnnotation.AttachmentLevel != AttachmentLevel.Unresolved && attachedAnnotation.AttachmentLevel != AttachmentLevel.Incomplete)
                {
                    annotationComponentManager.AddAttachedAnnotation(attachedAnnotation, false);
                }
            }
            adornerDecorator.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            adornerDecorator.Arrange(new Rect(adornerDecorator.DesiredSize));
            adornerDecorator.UpdateLayout();
            return(new AnnotationDocumentPaginator.AnnotatedDocumentPage(page, adornerDecorator, size, new Rect(size), new Rect(size)));
        }
コード例 #2
0
        ///<summary>
        /// For a given page # and a page, returns a page that include the original
        /// page along with any annotations that are displayed on that page.
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pageNumber"></param>
        private DocumentPage ComposePageWithAnnotationVisuals(int pageNumber, DocumentPage page)
        {
            // Need to store these because our current highlight mechanism
            // causes the page to be disposed
            Size tempSize = page.Size;

            AdornerDecorator decorator = new AdornerDecorator();

            decorator.FlowDirection = _flowDirection;
            DocumentPageView dpv = new DocumentPageView();

            dpv.UseAsynchronousGetPage = false;
            dpv.DocumentPaginator      = _originalPaginator;
            dpv.PageNumber             = pageNumber;
            decorator.Child            = dpv;

            // Arrange the first time to get the DPV setup right
            decorator.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            decorator.Arrange(new Rect(decorator.DesiredSize));
            decorator.UpdateLayout();

            // Create a new one for each page because it keeps a cache of annotation components
            // and we don't want to be holding them in memory once the page is no longer used
            AnnotationComponentManager manager = new MS.Internal.Annotations.Component.AnnotationComponentManager(null);

            // Setup DPs and processors for annotation handling.  If the service isn't already
            // enabled the processors will be registered by the service when it is enabled.
            if (_isFixedContent)
            {
                // Setup service to look for FixedPages in the content
                AnnotationService.SetSubTreeProcessorId(decorator, FixedPageProcessor.Id);
                // If the service is already registered, set it up for fixed content
                _locatorManager.RegisterSelectionProcessor(new FixedTextSelectionProcessor(), typeof(TextRange));
            }
            else
            {
                // Setup up an initial DataId used to identify the document
                AnnotationService.SetDataId(decorator, "FlowDocument");
                _locatorManager.RegisterSelectionProcessor(new TextViewSelectionProcessor(), typeof(DocumentPageView));
                // Setup the selection processor, pre-targeting it at a specific DocumentPageView
                TextSelectionProcessor textSelectionProcessor = new TextSelectionProcessor();
                textSelectionProcessor.SetTargetDocumentPageView(dpv);
                _locatorManager.RegisterSelectionProcessor(textSelectionProcessor, typeof(TextRange));
            }

            // Get attached annotations for the page
            IList <IAttachedAnnotation> attachedAnnotations = ProcessAnnotations(dpv);

            // Now make sure they have a visual component added to the DPV via the component manager
            foreach (IAttachedAnnotation attachedAnnotation in attachedAnnotations)
            {
                if (attachedAnnotation.AttachmentLevel != AttachmentLevel.Unresolved && attachedAnnotation.AttachmentLevel != AttachmentLevel.Incomplete)
                {
                    manager.AddAttachedAnnotation(attachedAnnotation, false);
                }
            }

            // Update layout a second time to get the annotations layed out correctly
            decorator.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            decorator.Arrange(new Rect(decorator.DesiredSize));
            decorator.UpdateLayout();

/*          Look into using the VisualBrush in order to get a dead page instead of a live one...
 *          VisualBrush visualBrush = new VisualBrush(decorator);
 *          Rectangle rectangle = new Rectangle();
 *          rectangle.Fill = visualBrush;
 *          rectangle.Margin = new Thickness(0);
 */

            return(new AnnotatedDocumentPage(page, decorator, tempSize, new Rect(tempSize), new Rect(tempSize)));
        }