// Token: 0x060062CE RID: 25294 RVA: 0x001BB5A4 File Offset: 0x001B97A4 internal static DocumentPageView FindView(DocumentViewerBase viewer, int pageNb) { Invariant.Assert(viewer != null, "viewer is null"); Invariant.Assert(pageNb >= 0, "negative pageNb"); foreach (DocumentPageView documentPageView in viewer.PageViews) { if (documentPageView.PageNumber == pageNb) { return(documentPageView); } } return(null); }
/// <summary> /// Gets the parent element of ITextPointer. /// </summary> /// <param name="pointer">the pointer to examine</param> /// <returns>the parent element of this pointer; can be null</returns> /// <exception cref="ArgumentNullException">pointer is null</exception> public static UIElement GetParent(ITextPointer pointer) { if (pointer == null) { throw new ArgumentNullException("pointer"); } DependencyObject document = pointer.TextContainer.Parent; DependencyObject parent = PathNode.GetParent(document); FlowDocumentScrollViewer scrollViewer = parent as FlowDocumentScrollViewer; if (scrollViewer != null) { return((UIElement)scrollViewer.ScrollViewer.Content); } // Special case - for paginated content we want the DocumentPageHost for the // specific page instead of the viewer. DocumentViewerBase documentViewerBase = parent as DocumentViewerBase; if (documentViewerBase != null) { int pageNumber; // We get the content again here GetPointerPage handles // special cases like FixedDocumentSequences IDocumentPaginatorSource content = GetPointerPage(pointer.CreatePointer(LogicalDirection.Forward), out pageNumber); if (pageNumber >= 0) { foreach (DocumentPageView dpv in documentViewerBase.PageViews) { if (dpv.PageNumber == pageNumber) { // DPVs always have one child - the DocumentPageHost int count = VisualTreeHelper.GetChildrenCount(dpv); Invariant.Assert(count == 1); return(VisualTreeHelper.GetChild(dpv, 0) as DocumentPageHost); } } // Page must not be visible. return(null); } } return(parent as UIElement); }
/// <summary> /// Gets existing views for pages from start to end. Scans only existing view to /// avoid loading of unloaded pages. /// </summary> /// <param name="idp">IDocumentPaginatorSource</param> /// <param name="startPageNumber">start page number</param> /// <param name="endPageNumber">end page number</param> /// <returns>returns a list of text views</returns> private static List <ITextView> ProcessMultiplePages(IDocumentPaginatorSource idp, int startPageNumber, int endPageNumber) { Invariant.Assert(idp != null, "IDocumentPaginatorSource is null"); //now get available views DocumentViewerBase viewer = PathNode.GetParent(idp as DependencyObject) as DocumentViewerBase; Invariant.Assert(viewer != null, "DocumentViewer not found"); // If the pages for the text segment are reversed (possibly a floater where the floater // reflow on to a page that comes after its anchor) we just swap them if (endPageNumber < startPageNumber) { int temp = endPageNumber; endPageNumber = startPageNumber; startPageNumber = temp; } List <ITextView> res = null; if (idp != null && startPageNumber >= 0 && endPageNumber >= startPageNumber) { res = new List <ITextView>(endPageNumber - startPageNumber + 1); for (int pageNb = startPageNumber; pageNb <= endPageNumber; pageNb++) { DocumentPageView view = AnnotationHelper.FindView(viewer, pageNb); if (view != null) { IServiceProvider serviceProvider = view.DocumentPage as IServiceProvider; if (serviceProvider != null) { ITextView textView = serviceProvider.GetService(typeof(ITextView)) as ITextView; if (textView != null) { res.Add(textView); } } } } } return(res); }
// Token: 0x060062D0 RID: 25296 RVA: 0x001BB6D4 File Offset: 0x001B98D4 private static bool AreAllPagesVisible(DocumentViewerBase viewer, int startPage, int endPage) { Invariant.Assert(viewer != null, "viewer is null."); Invariant.Assert(endPage >= startPage, "EndPage is less than StartPage"); bool result = true; if (viewer.PageViews.Count <= endPage - startPage) { return(false); } for (int i = startPage; i <= endPage; i++) { if (AnnotationHelper.FindView(viewer, i) == null) { result = false; break; } } return(result); }
// Token: 0x06007C3F RID: 31807 RVA: 0x0022F168 File Offset: 0x0022D368 private static List <ITextView> ProcessMultiplePages(IDocumentPaginatorSource idp, int startPageNumber, int endPageNumber) { Invariant.Assert(idp != null, "IDocumentPaginatorSource is null"); DocumentViewerBase documentViewerBase = PathNode.GetParent(idp as DependencyObject) as DocumentViewerBase; Invariant.Assert(documentViewerBase != null, "DocumentViewer not found"); if (endPageNumber < startPageNumber) { int num = endPageNumber; endPageNumber = startPageNumber; startPageNumber = num; } List <ITextView> list = null; if (idp != null && startPageNumber >= 0 && endPageNumber >= startPageNumber) { list = new List <ITextView>(endPageNumber - startPageNumber + 1); for (int i = startPageNumber; i <= endPageNumber; i++) { DocumentPageView documentPageView = AnnotationHelper.FindView(documentViewerBase, i); if (documentPageView != null) { IServiceProvider serviceProvider = documentPageView.DocumentPage as IServiceProvider; if (serviceProvider != null) { ITextView textView = serviceProvider.GetService(typeof(ITextView)) as ITextView; if (textView != null) { list.Add(textView); } } } } } return(list); }
// Token: 0x06007C35 RID: 31797 RVA: 0x0022EBE4 File Offset: 0x0022CDE4 public static UIElement GetParent(ITextPointer pointer) { if (pointer == null) { throw new ArgumentNullException("pointer"); } DependencyObject parent = pointer.TextContainer.Parent; DependencyObject parent2 = PathNode.GetParent(parent); FlowDocumentScrollViewer flowDocumentScrollViewer = parent2 as FlowDocumentScrollViewer; if (flowDocumentScrollViewer != null) { return((UIElement)flowDocumentScrollViewer.ScrollViewer.Content); } DocumentViewerBase documentViewerBase = parent2 as DocumentViewerBase; if (documentViewerBase != null) { int num; IDocumentPaginatorSource pointerPage = TextSelectionHelper.GetPointerPage(pointer.CreatePointer(LogicalDirection.Forward), out num); if (num >= 0) { foreach (DocumentPageView documentPageView in documentViewerBase.PageViews) { if (documentPageView.PageNumber == num) { int childrenCount = VisualTreeHelper.GetChildrenCount(documentPageView); Invariant.Assert(childrenCount == 1); return(VisualTreeHelper.GetChild(documentPageView, 0) as DocumentPageHost); } } return(null); } } return(parent2 as UIElement); }
// Token: 0x060062DF RID: 25311 RVA: 0x001BC234 File Offset: 0x001BA434 private static void CheckInputs(AnnotationService service) { if (service == null) { throw new ArgumentNullException("service"); } if (!service.IsEnabled) { throw new ArgumentException(SR.Get("AnnotationServiceNotEnabled"), "service"); } DocumentViewerBase documentViewerBase = service.Root as DocumentViewerBase; if (documentViewerBase == null) { FlowDocumentScrollViewer flowDocumentScrollViewer = service.Root as FlowDocumentScrollViewer; FlowDocumentReader flowDocumentReader = service.Root as FlowDocumentReader; Invariant.Assert(flowDocumentScrollViewer != null || flowDocumentReader != null, "Service's Root must be either a FlowDocumentReader, DocumentViewerBase or a FlowDocumentScrollViewer."); return; } if (documentViewerBase.Document == null) { throw new InvalidOperationException(SR.Get("OnlyFlowFixedSupported")); } }
public static IObservable <EventPattern <ContextMenuEventArgs> > ContextMenuClosingObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <ContextMenuEventHandler, ContextMenuEventArgs>(h => This.ContextMenuClosing += h, h => This.ContextMenuClosing -= h)); }
public static IObservable <EventPattern <ToolTipEventArgs> > ToolTipClosingObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <ToolTipEventHandler, ToolTipEventArgs>(h => This.ToolTipClosing += h, h => This.ToolTipClosing -= h)); }
public static IObservable <EventPattern <DragEventArgs> > DropObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.Drop += h, h => This.Drop -= h)); }
public static IObservable <EventPattern <TextCompositionEventArgs> > TextInputObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <TextCompositionEventHandler, TextCompositionEventArgs>(h => This.TextInput += h, h => This.TextInput -= h)); }
public static IObservable <EventPattern <QueryContinueDragEventArgs> > QueryContinueDragObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <QueryContinueDragEventHandler, QueryContinueDragEventArgs>(h => This.QueryContinueDrag += h, h => This.QueryContinueDrag -= h)); }
/// <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); }
public static IObservable <EventPattern <EventArgs> > InitializedObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <EventHandler, EventArgs>(h => This.Initialized += h, h => This.Initialized -= h)); }
public static IObservable <EventPattern <RoutedEventArgs> > LostFocusObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.LostFocus += h, h => This.LostFocus -= h)); }
public static IObservable <EventPattern <SizeChangedEventArgs> > SizeChangedObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <SizeChangedEventHandler, SizeChangedEventArgs>(h => This.SizeChanged += h, h => This.SizeChanged -= h)); }
public static IObservable <EventPattern <TouchEventArgs> > TouchLeaveObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.TouchLeave += h, h => This.TouchLeave -= h)); }
public static IObservable <EventPattern <TouchEventArgs> > PreviewTouchUpObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.PreviewTouchUp += h, h => This.PreviewTouchUp -= h)); }
public static IObservable <EventPattern <RequestBringIntoViewEventArgs> > RequestBringIntoViewObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <RequestBringIntoViewEventHandler, RequestBringIntoViewEventArgs>(h => This.RequestBringIntoView += h, h => This.RequestBringIntoView -= h)); }
public static IObservable <EventPattern <MouseButtonEventArgs> > MouseDownObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.MouseDown += h, h => This.MouseDown -= h)); }
public static IObservable <EventPattern <MouseButtonEventArgs> > PreviewMouseUpObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.PreviewMouseUp += h, h => This.PreviewMouseUp -= h)); }
public static IObservable <EventPattern <DependencyPropertyChangedEventArgs> > FocusableChangedObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <DependencyPropertyChangedEventHandler, DependencyPropertyChangedEventArgs>(h => This.FocusableChanged += h, h => This.FocusableChanged -= h)); }
public static IObservable <EventPattern <GiveFeedbackEventArgs> > GiveFeedbackObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <GiveFeedbackEventHandler, GiveFeedbackEventArgs>(h => This.GiveFeedback += h, h => This.GiveFeedback -= h)); }
public static IObservable <EventPattern <ManipulationInertiaStartingEventArgs> > ManipulationInertiaStartingObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <EventHandler <ManipulationInertiaStartingEventArgs>, ManipulationInertiaStartingEventArgs>(h => This.ManipulationInertiaStarting += h, h => This.ManipulationInertiaStarting -= h)); }
// 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); }
public static IObservable <EventPattern <ManipulationCompletedEventArgs> > ManipulationCompletedObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <EventHandler <ManipulationCompletedEventArgs>, ManipulationCompletedEventArgs>(h => This.ManipulationCompleted += h, h => This.ManipulationCompleted -= h)); }
/// <summary> /// Constructor. /// </summary> /// <param name="owner">Owner of the AutomationPeer.</param> public DocumentViewerBaseAutomationPeer(DocumentViewerBase owner) : base(owner) { }
public static IObservable <EventPattern <RoutedEventArgs> > UnloadedObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.Unloaded += h, h => This.Unloaded -= h)); }
public static IObservable <EventPattern <ManipulationBoundaryFeedbackEventArgs> > ManipulationBoundaryFeedbackObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <EventHandler <ManipulationBoundaryFeedbackEventArgs>, ManipulationBoundaryFeedbackEventArgs>(h => This.ManipulationBoundaryFeedback += h, h => This.ManipulationBoundaryFeedback -= h)); }
public static IObservable <EventPattern <DragEventArgs> > PreviewDragLeaveObserver(this DocumentViewerBase This) { return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.PreviewDragLeave += h, h => This.PreviewDragLeave -= h)); }