// Token: 0x06006332 RID: 25394 RVA: 0x001BE260 File Offset: 0x001BC460 private string GetOverlapQueryFragment(XmlNamespaceManager namespaceManager) { string text = namespaceManager.LookupPrefix("http://schemas.microsoft.com/windows/annotations/2003/11/core"); string text2 = namespaceManager.LookupPrefix(this.PartType.Namespace); string text3 = (text2 == null) ? "" : (text2 + ":"); text3 = string.Concat(new string[] { text3, TextSelectionProcessor.CharacterRangeElementName.Name, "/", text, ":Item" }); int num; int num2; TextSelectionProcessor.GetMaxMinLocatorPartValues(this, out num, out num2); string text4 = num.ToString(NumberFormatInfo.InvariantInfo); string text5 = num2.ToString(NumberFormatInfo.InvariantInfo); return(string.Concat(new string[] { text3, "[starts-with(@Name, \"Segment\") and ((substring-before(@Value,\",\") >= ", text4, " and substring-before(@Value,\",\") <= ", text5, ") or (substring-before(@Value,\",\") < ", text4, " and substring-after(@Value,\",\") >= ", text4, "))]" })); }
// Token: 0x0600632D RID: 25389 RVA: 0x001BE15C File Offset: 0x001BC35C internal bool Matches(ContentLocatorPart part) { bool flag = false; string value; this._nameValues.TryGetValue("IncludeOverlaps", out value); if (!bool.TryParse(value, out flag) || !flag) { return(this.Equals(part)); } if (part == this) { return(true); } if (!this._type.Equals(part.PartType)) { return(false); } int num; int num2; TextSelectionProcessor.GetMaxMinLocatorPartValues(this, out num, out num2); int num3; int num4; TextSelectionProcessor.GetMaxMinLocatorPartValues(part, out num3, out num4); return((num == num3 && num2 == num4) || (num != int.MinValue && ((num3 >= num && num3 <= num2) || (num3 < num && num4 >= num)))); }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods /// <summary> /// Determines if a locator part matches this locator part. Matches is /// different from equals because a locator part may be defined to match /// a range of locator parts, not just exact replicas. /// </summary> internal bool Matches(ContentLocatorPart part) { bool overlaps = false; string overlapsString; _nameValues.TryGetValue(TextSelectionProcessor.IncludeOverlaps, out overlapsString); // If IncludeOverlaps is true, a match is any locator part // whose range overlaps with ours if (Boolean.TryParse(overlapsString, out overlaps) && overlaps) { // We match ourselves if (part == this) { return(true); } // Have different type names if (!_type.Equals(part.PartType)) { return(false); } int desiredStartOffset; int desiredEndOffset; TextSelectionProcessor.GetMaxMinLocatorPartValues(this, out desiredStartOffset, out desiredEndOffset); int startOffset; int endOffset; TextSelectionProcessor.GetMaxMinLocatorPartValues(part, out startOffset, out endOffset); // Take care of an exact match to us (which may include offset==MinValue // which we don't want to handle with the formula below. if (desiredStartOffset == startOffset && desiredEndOffset == endOffset) { return(true); } // Take care of the special case of no content to match to if (desiredStartOffset == int.MinValue) { return(false); } if ((startOffset >= desiredStartOffset && startOffset <= desiredEndOffset) || (startOffset < desiredStartOffset && endOffset >= desiredStartOffset)) { return(true); } return(false); } return(this.Equals(part)); }
// 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))); }
// Token: 0x060062D3 RID: 25299 RVA: 0x001BB8C4 File Offset: 0x001B9AC4 private static IList <IAttachedAnnotation> GetSpannedAnnotationsForFlow(AnnotationService service, ITextSelection selection) { Invariant.Assert(service != null); ITextPointer textPointer = selection.Start.CreatePointer(); ITextPointer textPointer2 = selection.End.CreatePointer(); textPointer.MoveToNextInsertionPosition(LogicalDirection.Backward); textPointer2.MoveToNextInsertionPosition(LogicalDirection.Forward); ITextRange selection2 = new TextRange(textPointer, textPointer2); IList <ContentLocatorBase> list = service.LocatorManager.GenerateLocators(selection2); Invariant.Assert(list != null && list.Count > 0); 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."); IList <IAttachedAnnotation> result = null; try { textSelectionProcessor.Clamping = false; textSelectionProcessor2.Clamping = false; ContentLocator contentLocator = list[0] as ContentLocator; Invariant.Assert(contentLocator != null, "Locators for selection in Flow should always be ContentLocators. ContentLocatorSets not supported."); contentLocator.Parts[contentLocator.Parts.Count - 1].NameValuePairs.Add("IncludeOverlaps", bool.TrueString); IList <Annotation> annotations = service.Store.GetAnnotations(contentLocator); result = AnnotationHelper.ResolveAnnotations(service, annotations); } finally { textSelectionProcessor.Clamping = true; textSelectionProcessor2.Clamping = true; } return(result); }
/// <summary> /// Produces an XPath fragment that selects for ContentLocatorParts with an anchor that /// intersects with the range specified by this ContentLocatorPart. /// </summary> /// <param name="namespaceManager">namespace manager used to look up prefixes</param> private string GetOverlapQueryFragment(XmlNamespaceManager namespaceManager) { string corePrefix = namespaceManager.LookupPrefix(AnnotationXmlConstants.Namespaces.CoreSchemaNamespace); string prefix = namespaceManager.LookupPrefix(this.PartType.Namespace); string res = prefix == null ? "" : (prefix + ":"); res += TextSelectionProcessor.CharacterRangeElementName.Name + "/" + corePrefix + ":" + AnnotationXmlConstants.Elements.Item; int startOffset; int endOffset; TextSelectionProcessor.GetMaxMinLocatorPartValues(this, out startOffset, out endOffset); string startStr = startOffset.ToString(NumberFormatInfo.InvariantInfo); string endStr = endOffset.ToString(NumberFormatInfo.InvariantInfo); // Note: this will never match if offsetStr == 0. Which makes sense - there // is no content to get anchors for. res += "[starts-with(@" + AnnotationXmlConstants.Attributes.ItemName + ", \"" + TextSelectionProcessor.SegmentAttribute + "\") and " + " ((substring-before(@" + AnnotationXmlConstants.Attributes.ItemValue + ",\",\") >= " + startStr + " and substring-before(@" + AnnotationXmlConstants.Attributes.ItemValue + ",\",\") <= " + endStr + ") or " + " (substring-before(@" + AnnotationXmlConstants.Attributes.ItemValue + ",\",\") < " + startStr + " and substring-after(@" + AnnotationXmlConstants.Attributes.ItemValue + ",\",\") >= " + startStr + "))]"; return(res); }
/// <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); }
///<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))); }