Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves DocumentViewerBase that hosts this view.
        /// </summary>
        /// <returns>DocumentViewerBase that hosts this view.</returns>
        private DocumentViewerBase GetHostViewer()
        {
            DocumentViewerBase hostViewer = null;
            Visual             visualParent;

            // First do quick check for TemplatedParent. It will cover good
            // amount of cases, because static viewers will have their
            // DocumentPageViews defined in the style.
            // If quick check does not work, do a visual tree walk.
            if (this.TemplatedParent is DocumentViewerBase)
            {
                hostViewer = (DocumentViewerBase)this.TemplatedParent;
            }
            else
            {
                // Check if hosted by DocumentViewerBase.
                visualParent = VisualTreeHelper.GetParent(this) as Visual;
                while (visualParent != null)
                {
                    if (visualParent is DocumentViewerBase)
                    {
                        hostViewer = (DocumentViewerBase)visualParent;
                        break;
                    }
                    visualParent = VisualTreeHelper.GetParent(visualParent) as Visual;
                }
            }
            return(hostViewer);
        }
Ejemplo n.º 2
0
        //------------------------------------------------------------------- 
        //
        //  Constructors
        //
        //------------------------------------------------------------------- 

        #region Constructors 
 
        /// <summary>
        /// Constructor. 
        /// </summary>
        /// <param name="viewer">Viewer associated with TextView.</param>
        /// <param name="renderScope">Render scope - root of layout structure visualizing content.</param>
        /// <param name="textContainer">TextContainer representing content.</param> 
        internal MultiPageTextView(DocumentViewerBase viewer, UIElement renderScope, ITextContainer textContainer)
        { 
            _viewer = viewer; 
            _renderScope = renderScope;
            _textContainer = textContainer; 
            _pageTextViews = new List<DocumentPageTextView>();
            OnPagesUpdatedCore();
        }
        // Token: 0x06005D93 RID: 23955 RVA: 0x001A5704 File Offset: 0x001A3904
        private bool ShouldReflowContent()
        {
            bool result = false;

            if (DocumentViewerBase.GetIsMasterPage(this))
            {
                DocumentViewerBase hostViewer = this.GetHostViewer();
                if (hostViewer != null)
                {
                    result = hostViewer.IsMasterPageView(this);
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Check whether content needs to be reflowed.
        /// </summary>
        /// <returns>True, if content needs to be reflowed.</returns>
        private bool ShouldReflowContent()
        {
            bool shouldReflow = false;
            DocumentViewerBase hostViewer;

            if (DocumentViewerBase.GetIsMasterPage(this))
            {
                hostViewer = GetHostViewer();
                if (hostViewer != null)
                {
                    shouldReflow = hostViewer.IsMasterPageView(this);
                }
            }
            return(shouldReflow);
        }
        // Token: 0x06005D94 RID: 23956 RVA: 0x001A5730 File Offset: 0x001A3930
        private DocumentViewerBase GetHostViewer()
        {
            DocumentViewerBase result = null;

            if (base.TemplatedParent is DocumentViewerBase)
            {
                result = (DocumentViewerBase)base.TemplatedParent;
            }
            else
            {
                for (Visual visual = VisualTreeHelper.GetParent(this) as Visual; visual != null; visual = (VisualTreeHelper.GetParent(visual) as Visual))
                {
                    if (visual is DocumentViewerBase)
                    {
                        result = (DocumentViewerBase)visual;
                        break;
                    }
                }
            }
            return(result);
        }
 internal BringIntoViewState(DocumentViewerBase source, ContentPosition contentPosition, DependencyObject targetObject, Rect targetRect)
 {
     this.Source = source;
     this.ContentPosition = contentPosition;
     this.TargetObject = targetObject;
     this.TargetRect = targetRect;
 }
Ejemplo n.º 7
0
        /// <summary> 
        /// Checks if all of the pages in a given range are currently visible,
        /// and if yes - returns true 
        /// </summary> 
        /// <param name="viewer">the viewer</param>
        /// <param name="startPage">first page in range to check for visibility</param> 
        /// <param name="endPage">last page in range to check for visibility</param>
        /// <returns>true all pages in the range are visible, false otherwise</returns>

        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 pageVisibility = true; 

            //if visible pages are less than selected then we have invisible pages
            // for sure
            if (viewer.PageViews.Count <= endPage - startPage) 
                return false;
 
            for (int page = startPage; page <= endPage; page++) 
            {
                if (FindView(viewer, page) == null) 
                {
                    //there is at least one invisible page
                    pageVisibility = false;
                    break; 
                }
            } 
 
            return pageVisibility;
        } 
Ejemplo n.º 8
0
        /// <summary> 
        /// Gets the DocumentPageView for a particular page if any
        /// </summary> 
        /// <param name="viewer">DocumentViewer</param>
        /// <param name="pageNb">pageNb</param>
        /// <returns>DocumentPageView; null if page is not loaded</returns>
        internal static DocumentPageView FindView(DocumentViewerBase viewer, int pageNb) 
        {
            Invariant.Assert(viewer != null, "viewer is null"); 
            Invariant.Assert(pageNb >= 0, "negative pageNb"); 

            foreach (DocumentPageView view in viewer.PageViews) 
            {
                if (view.PageNumber == pageNb)
                    return view;
            } 

            return null; 
        } 
Ejemplo n.º 9
0
        /// <summary>
        ///     Returns the AnnotationService enabled for the viewer.  If no service is
        ///     enabled for the viewer, returns null.
        /// </summary>
        /// <param name="viewer">viewer to check for an enabled AnnotationService</param>
        /// <returns>the AnnotationService instance for this viewer, null if a service
        /// is not enabled for this viewer</returns>
        /// <exception cref="ArgumentNullException">viewer is null</exception>
        public static AnnotationService GetService(DocumentViewerBase viewer)
        {
            if (viewer == null)
                throw new ArgumentNullException("viewer");

            return viewer.GetValue(AnnotationService.ServiceProperty) as AnnotationService;
        }
Ejemplo n.º 10
0
 /// <summary>
 ///    Unregister for notifications from the viewer and its DPVs for
 ///    any changes that may occur.
 /// </summary>
 private void UnregisterOnDocumentViewer(DocumentViewerBase viewer)
 {
     Invariant.Assert(viewer != null, "Parameter 'viewer' is null.");
     foreach (DocumentPageView view in _views)
     {
         view.PageConnected -= new EventHandler(OnContentChanged);
     }
     _views.Clear();
     viewer.PageViewsChanged -= new EventHandler(OnPageViewsChanged);
 }
Ejemplo n.º 11
0
 /// <summary>
 ///    Register for notifications from the viewer and its DPVs for
 ///    any changes that may occur.  As DPV content goes away we
 ///    need to unload annotations.
 /// </summary>
 private void RegisterOnDocumentViewer(DocumentViewerBase viewer)
 {
     Invariant.Assert(viewer != null, "Parameter 'viewer' is null.");
     Invariant.Assert(_views.Count == 0, "Failed to unregister on a viewer before registering on new viewer.");
     foreach (DocumentPageView view in viewer.PageViews)
     {
         view.PageConnected += new EventHandler(OnContentChanged);
         _views.Add(view);
     }
     viewer.PageViewsChanged += new EventHandler(OnPageViewsChanged);
 }
Ejemplo n.º 12
0
        /// <summary>
        ///     Creates an instance of the AnnotationService focused on a particular
        ///     DocumentViewerBase.
        /// </summary>
        /// <param name="viewer">the viewer this service will operate on</param>
        /// <exception cref="ArgumentNullException">viewer is null</exception>
        public AnnotationService(DocumentViewerBase viewer)
        {
            if (viewer == null)
                throw new ArgumentNullException("viewer");

            Initialize(viewer);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Finds the DocumentViewerBase object if root is DocumentViewerBase or FlowDocumentReader
        /// in paginated mode. If the root is FDSV or FDR in scroll mode - sets only the document;
        /// </summary>
        /// <param name="root">root the service is enabled on</param>
        /// <param name="documentViewerBase">DocumentViewerBase used by the viewer</param>
        /// <param name="document">document for the viewer</param>
        static private void GetViewerAndDocument(DependencyObject root, out DocumentViewerBase documentViewerBase, out IDocumentPaginatorSource document)
        {
            documentViewerBase = root as DocumentViewerBase;

            // Initialize out parameters
            document = null;

            if (documentViewerBase != null)
            {
                document = documentViewerBase.Document;
            }
            else
            {
                FlowDocumentReader reader = root as FlowDocumentReader;
                if (reader != null)
                {
                    documentViewerBase = AnnotationHelper.GetFdrHost(reader) as DocumentViewerBase;
                    document = reader.Document;
                }
                else
                {
                    FlowDocumentScrollViewer docScrollViewer = root as FlowDocumentScrollViewer;
                    // For backwards compatibility with internal APIs - you can enable
                    // a service on any element with internal APIs - so the root might
                    // not be neither an FDR or a FDSV
                    if (docScrollViewer != null)
                    {
                        document = docScrollViewer.Document;
                    }
                }
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="owner">Owner of the AutomationPeer.</param>
 public DocumentViewerBaseAutomationPeer(DocumentViewerBase owner)
     : base(owner)
 { }
 /// <summary>
 /// New instance
 /// </summary>
 public DocumentViewerBaseRunReader(DocumentViewerBase docViewer)
 {
     this.docViewer = docViewer;
 }