// Token: 0x06007C49 RID: 31817 RVA: 0x0022F5F8 File Offset: 0x0022D7F8 internal static void GetMaxMinLocatorPartValues(ContentLocatorPart locatorPart, out int startOffset, out int endOffset) { if (locatorPart == null) { throw new ArgumentNullException("locatorPart"); } string text = locatorPart.NameValuePairs["Count"]; if (text == null) { throw new ArgumentException(SR.Get("InvalidLocatorPart", new object[] { "Count" })); } int num = int.Parse(text, NumberFormatInfo.InvariantInfo); startOffset = int.MaxValue; endOffset = 0; for (int i = 0; i < num; i++) { int num2; int num3; TextSelectionProcessor.GetLocatorPartSegmentValues(locatorPart, i, out num2, out num3); if (num2 < startOffset) { startOffset = num2; } if (num3 > endOffset) { endOffset = num3; } } }
// Token: 0x06007BFD RID: 31741 RVA: 0x0022D8D4 File Offset: 0x0022BAD4 public LocatorManager(AnnotationStore store) { this._locatorPartHandlers = new Hashtable(); this._subtreeProcessors = new Hashtable(); this._selectionProcessors = new Hashtable(); this.RegisterSubTreeProcessor(new DataIdProcessor(this), "Id"); this.RegisterSubTreeProcessor(new FixedPageProcessor(this), FixedPageProcessor.Id); TreeNodeSelectionProcessor processor = new TreeNodeSelectionProcessor(); this.RegisterSelectionProcessor(processor, typeof(FrameworkElement)); this.RegisterSelectionProcessor(processor, typeof(FrameworkContentElement)); TextSelectionProcessor processor2 = new TextSelectionProcessor(); this.RegisterSelectionProcessor(processor2, typeof(TextRange)); this.RegisterSelectionProcessor(processor2, typeof(TextAnchor)); this._internalStore = store; }
/// <summary> /// Create an instance of LocatorManager with an optional specific store. /// It manages the processors that are used to create and resolve locators. /// If a store is passed in, its used to query for annotations. Otherwise /// the service is looked for and the service's store is used. /// </summary> /// <param name="store">optional, store to use for query of annotations</param> public LocatorManager(AnnotationStore store) { _locatorPartHandlers = new Hashtable(); _subtreeProcessors = new Hashtable(); _selectionProcessors = new Hashtable(); RegisterSubTreeProcessor(new DataIdProcessor(this), DataIdProcessor.Id); RegisterSubTreeProcessor(new FixedPageProcessor(this), FixedPageProcessor.Id); TreeNodeSelectionProcessor nodeProcessor = new TreeNodeSelectionProcessor(); RegisterSelectionProcessor(nodeProcessor, typeof(FrameworkElement)); RegisterSelectionProcessor(nodeProcessor, typeof(FrameworkContentElement)); TextSelectionProcessor textProcessor = new TextSelectionProcessor(); RegisterSelectionProcessor(textProcessor, typeof(TextRange)); RegisterSelectionProcessor(textProcessor, typeof(TextAnchor)); _internalStore = store; }
///<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)); }
// Token: 0x06007C46 RID: 31814 RVA: 0x0022F3A8 File Offset: 0x0022D5A8 public override object ResolveLocatorPart(ContentLocatorPart locatorPart, DependencyObject startNode, out AttachmentLevel attachmentLevel) { if (startNode == null) { throw new ArgumentNullException("startNode"); } if (locatorPart == null) { throw new ArgumentNullException("locatorPart"); } if (TextSelectionProcessor.CharacterRangeElementName != locatorPart.PartType) { throw new ArgumentException(SR.Get("IncorrectLocatorPartType", new object[] { locatorPart.PartType.Namespace + ":" + locatorPart.PartType.Name }), "locatorPart"); } int num = 0; int num2 = 0; string text = locatorPart.NameValuePairs["Count"]; if (text == null) { throw new ArgumentException(SR.Get("InvalidLocatorPart", new object[] { "Count" })); } int num3 = int.Parse(text, NumberFormatInfo.InvariantInfo); TextAnchor textAnchor = new TextAnchor(); attachmentLevel = AttachmentLevel.Unresolved; for (int i = 0; i < num3; i++) { TextSelectionProcessor.GetLocatorPartSegmentValues(locatorPart, i, out num, out num2); ITextPointer textPointer; ITextPointer textPointer2; if (!this.GetNodesStartAndEnd(startNode, out textPointer, out textPointer2)) { return(null); } int offsetToPosition = textPointer.GetOffsetToPosition(textPointer2); if (num > offsetToPosition) { return(null); } ITextPointer textPointer3 = textPointer.CreatePointer(num); ITextPointer textPointer4 = (offsetToPosition <= num2) ? textPointer2.CreatePointer() : textPointer.CreatePointer(num2); if (textPointer3.CompareTo(textPointer4) >= 0) { return(null); } textAnchor.AddTextSegment(textPointer3, textPointer4); } if (textAnchor.IsEmpty) { throw new ArgumentException(SR.Get("IncorrectAnchorLength"), "locatorPart"); } attachmentLevel = AttachmentLevel.Full; if (this._clamping) { ITextPointer start = textAnchor.Start; ITextPointer end = textAnchor.End; IServiceProvider serviceProvider; if (this._targetPage != null) { serviceProvider = this._targetPage; } else { FlowDocument node = start.TextContainer.Parent as FlowDocument; serviceProvider = (PathNode.GetParent(node) as IServiceProvider); } Invariant.Assert(serviceProvider != null, "No ServiceProvider found to get TextView from."); ITextView textView = serviceProvider.GetService(typeof(ITextView)) as ITextView; Invariant.Assert(textView != null, "Null TextView provided by ServiceProvider."); textAnchor = TextAnchor.TrimToIntersectionWith(textAnchor, textView.TextSegments); if (textAnchor == null) { attachmentLevel = AttachmentLevel.Unresolved; } else { if (textAnchor.Start.CompareTo(start) != 0) { attachmentLevel &= ~AttachmentLevel.StartPortion; } if (textAnchor.End.CompareTo(end) != 0) { attachmentLevel &= ~AttachmentLevel.EndPortion; } } } return(textAnchor); }