// Token: 0x060062CF RID: 25295 RVA: 0x001BB61C File Offset: 0x001B981C private static Annotation CreateStickyNoteForSelection(AnnotationService service, XmlQualifiedName noteType, string author) { AnnotationHelper.CheckInputs(service); ITextSelection textSelection = AnnotationHelper.GetTextSelection((FrameworkElement)service.Root); Invariant.Assert(textSelection != null, "TextSelection is null"); if (textSelection.IsEmpty) { throw new InvalidOperationException(SR.Get("EmptySelectionNotSupported")); } Annotation annotation = null; EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.CreateStickyNoteBegin); try { annotation = AnnotationHelper.CreateAnnotationForSelection(service, textSelection, noteType, author); Invariant.Assert(annotation != null, "CreateAnnotationForSelection returned null."); service.Store.AddAnnotation(annotation); textSelection.SetCaretToPosition(textSelection.MovingPosition, textSelection.MovingPosition.LogicalDirection, true, true); } finally { EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.CreateStickyNoteEnd); } return(annotation); }
// Token: 0x060062C7 RID: 25287 RVA: 0x001BB534 File Offset: 0x001B9734 internal static void OnDeleteAnnotationsCommand(object sender, ExecutedRoutedEventArgs e) { FrameworkElement frameworkElement = sender as FrameworkElement; if (frameworkElement != null) { ITextSelection textSelection = AnnotationHelper.GetTextSelection(frameworkElement); if (textSelection != null) { AnnotationService service = AnnotationService.GetService(frameworkElement); AnnotationHelper.DeleteTextStickyNotesForSelection(service); AnnotationHelper.DeleteInkStickyNotesForSelection(service); if (!textSelection.IsEmpty) { AnnotationHelper.ClearHighlightsForSelection(service); } } } }
// Token: 0x060062E0 RID: 25312 RVA: 0x001BC2C0 File Offset: 0x001BA4C0 private static bool IsCommandEnabled(object sender, bool checkForEmpty) { Invariant.Assert(sender != null, "Parameter 'sender' is null."); FrameworkElement frameworkElement = sender as FrameworkElement; if (frameworkElement != null) { FrameworkElement frameworkElement2 = frameworkElement.Parent as FrameworkElement; AnnotationService service = AnnotationService.GetService(frameworkElement); if (service != null && service.IsEnabled && (service.Root == frameworkElement || (frameworkElement2 != null && service.Root == frameworkElement2.TemplatedParent))) { ITextSelection textSelection = AnnotationHelper.GetTextSelection(frameworkElement); if (textSelection != null) { return(!checkForEmpty || !textSelection.IsEmpty); } } } return(false); }
// Token: 0x060062D7 RID: 25303 RVA: 0x001BBC34 File Offset: 0x001B9E34 private static void DeleteSpannedAnnotations(AnnotationService service, XmlQualifiedName annotationType) { AnnotationHelper.CheckInputs(service); Invariant.Assert(annotationType != null && (annotationType == HighlightComponent.TypeName || annotationType == StickyNoteControl.TextSchemaName || annotationType == StickyNoteControl.InkSchemaName), "Invalid Annotation Type"); ITextSelection textSelection = AnnotationHelper.GetTextSelection((FrameworkElement)service.Root); Invariant.Assert(textSelection != null, "TextSelection is null"); IList <IAttachedAnnotation> spannedAnnotations = AnnotationHelper.GetSpannedAnnotations(service); foreach (IAttachedAnnotation attachedAnnotation in spannedAnnotations) { if (annotationType.Equals(attachedAnnotation.Annotation.AnnotationType)) { TextAnchor textAnchor = attachedAnnotation.AttachedAnchor as TextAnchor; if (textAnchor != null && ((textSelection.Start.CompareTo(textAnchor.Start) > 0 && textSelection.Start.CompareTo(textAnchor.End) < 0) || (textSelection.End.CompareTo(textAnchor.Start) > 0 && textSelection.End.CompareTo(textAnchor.End) < 0) || (textSelection.Start.CompareTo(textAnchor.Start) <= 0 && textSelection.End.CompareTo(textAnchor.End) >= 0) || AnnotationHelper.CheckCaret(textSelection, textAnchor, annotationType))) { service.Store.DeleteAnnotation(attachedAnnotation.Annotation.Id); } } } }
// Token: 0x060062DA RID: 25306 RVA: 0x001BBE8C File Offset: 0x001BA08C private static Annotation Highlight(AnnotationService service, string author, Brush highlightBrush, bool create) { AnnotationHelper.CheckInputs(service); ITextSelection textSelection = AnnotationHelper.GetTextSelection((FrameworkElement)service.Root); Invariant.Assert(textSelection != null, "TextSelection is null"); if (textSelection.IsEmpty) { throw new InvalidOperationException(SR.Get("EmptySelectionNotSupported")); } Color?color = null; if (highlightBrush != null) { SolidColorBrush solidColorBrush = highlightBrush as SolidColorBrush; if (solidColorBrush == null) { throw new ArgumentException(SR.Get("InvalidHighlightColor"), "highlightBrush"); } byte a; if (solidColorBrush.Opacity <= 0.0) { a = 0; } else if (solidColorBrush.Opacity >= 1.0) { a = solidColorBrush.Color.A; } else { a = (byte)(solidColorBrush.Opacity * (double)solidColorBrush.Color.A); } color = new Color?(Color.FromArgb(a, solidColorBrush.Color.R, solidColorBrush.Color.G, solidColorBrush.Color.B)); } ITextRange textRange = new TextRange(textSelection.Start, textSelection.End); Annotation result = AnnotationHelper.ProcessHighlights(service, textRange, author, color, create); textSelection.SetCaretToPosition(textSelection.MovingPosition, textSelection.MovingPosition.LogicalDirection, true, true); return(result); }
// 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); }