Esempio n. 1
0
        /// <summary>
        /// <see cref="AutomationPeer.GetAutomationIdCore()"/>
        /// </summary>
        /// <returns>A string representing the current DocumentPageView.</returns>
        protected override string GetAutomationIdCore()
        {
            // Initialize the result to Empty, so that if Name is not set on the
            // DocumentPageView, and there is no valid PageNumber set, then the
            // AutomationId will remain blank to avoid duplicate entries.
            string           result = string.Empty;
            DocumentPageView owner  = (DocumentPageView)Owner;

            // Check if a Name is already set on the DocumentPageView, otherwise attempt
            // to construct one.
            if (!string.IsNullOrEmpty(owner.Name))
            {
                result = owner.Name;
            }
            else if ((owner.PageNumber >= 0) && (owner.PageNumber < int.MaxValue))
            {
                // This will set the AutomationId to a string that represents the current
                // page number, i.e. "DocumentPage1" will represent the first page.  These numbers
                // will be kept in a 1-indexed format.  InvariantCulture is used to ensure
                // that these AutomationIds will not change with the language, so that they
                // can be trusted to always work in automation.
                result = String.Format(CultureInfo.InvariantCulture, "DocumentPage{0}", owner.PageNumber + 1);
            }

            return(result);
        }
Esempio n. 2
0
        // Token: 0x06007BC7 RID: 31687 RVA: 0x0022C590 File Offset: 0x0022A790
        public override ContentLocator GenerateLocator(PathNode node, out bool continueGenerating)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            continueGenerating = true;
            ContentLocator   contentLocator   = null;
            DocumentPageView documentPageView = node.Node as DocumentPageView;
            int num = -1;

            if (documentPageView != null)
            {
                if (documentPageView.DocumentPage is FixedDocumentPage || documentPageView.DocumentPage is FixedDocumentSequenceDocumentPage)
                {
                    num = documentPageView.PageNumber;
                }
            }
            else
            {
                FixedTextSelectionProcessor.FixedPageProxy fixedPageProxy = node.Node as FixedTextSelectionProcessor.FixedPageProxy;
                if (fixedPageProxy != null)
                {
                    num = fixedPageProxy.Page;
                }
            }
            if (num >= 0)
            {
                contentLocator = new ContentLocator();
                ContentLocatorPart item = FixedPageProcessor.CreateLocatorPart(num);
                contentLocator.Parts.Add(item);
            }
            return(contentLocator);
        }
        public static FixedDocument FlowToFixed(FlowDocument flowDoc)
        {
            DocumentPaginator paginator = (flowDoc as IDocumentPaginatorSource).DocumentPaginator;

            paginator.PageSize = new Size(Page.ExtentWidth, Page.ExtentHeight);     // A3
            if (!paginator.IsPageCountValid)
            {
                paginator.ComputePageCount();
            }

            FixedDocument fixedDoc = new FixedDocument();

            for (int i = 0; i < paginator.PageCount; i++)
            {
                Canvas pageCanvas = new Canvas();
                pageCanvas.Margin = new Thickness(Page.Bleed);
                DocumentPageView dpv = new DocumentPageView {
                    DocumentPaginator = paginator, PageNumber = i
                };
                pageCanvas.Children.Add(dpv);

                FixedPage fp = new FixedPage {
                    Width = Page.MediaWidth, Height = Page.MediaHeight
                };
                fp.Children.Add(pageCanvas);
                PageContent pc = new PageContent();
                (pc as IAddChild).AddChild(fp);
                fixedDoc.Pages.Add(pc);
            }
            return(fixedDoc);
        }
Esempio n. 4
0
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// Creates the static members of DocumentGridPage's Visual Tree.
        /// </summary>
        private void Init()
        {
            //Create the DocumentPageView, which will display our
            //content.
            _documentPageView = new DocumentPageView();
            _documentPageView.ClipToBounds     = true;
            _documentPageView.StretchDirection = StretchDirection.Both;
            _documentPageView.PageNumber       = int.MaxValue;

            //Create the border that goes around the page content.
            _pageBorder             = new Border();
            _pageBorder.BorderBrush = Brushes.Black;
            _pageBorder.Child       = _documentPageView;

            //Create the drop shadow that goes behind the page, made
            //of two rectangles in an "L" shape.
            _dropShadowRight         = new Rectangle();
            _dropShadowRight.Fill    = Brushes.Black;
            _dropShadowRight.Opacity = _dropShadowOpacity;

            _dropShadowBottom         = new Rectangle();
            _dropShadowBottom.Fill    = Brushes.Black;
            _dropShadowBottom.Opacity = _dropShadowOpacity;

            _loaded = false;
        }
Esempio n. 5
0
        // Token: 0x0600650A RID: 25866 RVA: 0x001C5A2C File Offset: 0x001C3C2C
        private static bool DumpDocumentPageView(XmlTextWriter writer, UIElement element, bool uiElementsOnly)
        {
            DocumentPageView documentPageView = element as DocumentPageView;

            if (documentPageView.DocumentPage != null)
            {
                LayoutDump.DumpDocumentPage(writer, documentPageView.DocumentPage, element);
            }
            return(false);
        }
Esempio n. 6
0
        /// <summary>
        /// Adds a page body.
        /// </summary>
        /// <param name="sourceFlowDocPaginator">The source flow document paginator.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageCanvas">The page canvas.</param>
        /// <param name="margins">The margins.</param>
        private void AddPageBody(DocumentPaginator sourceFlowDocPaginator, int pageNumber, Canvas pageCanvas, Thickness margins)
        {
            var dpv = new DocumentPageView {
                DocumentPaginator = sourceFlowDocPaginator, PageNumber = pageNumber
            };

            Canvas.SetTop(dpv, margins.Top);
            Canvas.SetLeft(dpv, margins.Left);
            pageCanvas.Children.Add(dpv);
        }
Esempio n. 7
0
 /// <summary>
 /// The add page body.
 /// </summary>
 /// <param name="sourceFlowDocPaginator">
 /// The source flow doc paginator.
 /// </param>
 /// <param name="pageNo">
 /// The page no.
 /// </param>
 /// <param name="pageCanvas">
 /// The page canvas.
 /// </param>
 /// <param name="margins">
 /// The margins.
 /// </param>
 private void AddPageBody(
     DocumentPaginator sourceFlowDocPaginator, int pageNo, Canvas pageCanvas, Thickness margins)
 {
     using (var dpv = new DocumentPageView())
     {
         dpv.DocumentPaginator = sourceFlowDocPaginator;
         dpv.PageNumber        = pageNo;
         Canvas.SetTop(dpv, margins.Top);
         Canvas.SetLeft(dpv, margins.Left);
         pageCanvas.Children.Add(dpv);
     }
 }
Esempio n. 8
0
        private IList <IAttachedAnnotation> ProcessAnnotations(DocumentPageView dpv)
        {
            if (dpv == null)
            {
                throw new ArgumentNullException("dpv");
            }

            IList <IAttachedAnnotation> attachedAnnotations = new List <IAttachedAnnotation>();
            IList <ContentLocatorBase>  locators            = _locatorManager.GenerateLocators(dpv);

            if (locators.Count > 0)
            {
                // LocatorBases for a single node should always be Locators
                ContentLocator[] lists = new ContentLocator[locators.Count];
                locators.CopyTo(lists, 0);

                IList <Annotation> annotations = _annotationStore.GetAnnotations(lists[0]);

                foreach (ContentLocator locator in locators)
                {
                    if (locator.Parts[locator.Parts.Count - 1].NameValuePairs.ContainsKey(TextSelectionProcessor.IncludeOverlaps))
                    {
                        locator.Parts.RemoveAt(locator.Parts.Count - 1);
                    }
                }

                foreach (Annotation annotation in annotations)
                {
                    foreach (AnnotationResource anchor in annotation.Anchors)
                    {
                        foreach (ContentLocatorBase locator in anchor.ContentLocators)
                        {
                            AttachmentLevel attachmentLevel;
                            object          attachedAnchor = _locatorManager.FindAttachedAnchor(dpv, lists, locator, out attachmentLevel);

                            if (attachmentLevel != AttachmentLevel.Unresolved)
                            {
                                Invariant.Assert(VisualTreeHelper.GetChildrenCount(dpv) == 1, "DocumentPageView has no visual children.");
                                DependencyObject firstElement = VisualTreeHelper.GetChild(dpv, 0);

                                attachedAnnotations.Add(new AttachedAnnotation(_locatorManager, annotation, anchor, attachedAnchor, attachmentLevel, firstElement as DocumentPageHost));

                                // Only process one locator per resource
                                break;
                            }
                        }
                    }
                }
            }

            return(attachedAnnotations);
        }
Esempio n. 9
0
        // ------------------------------------------------------------------
        // Dump DocumentPageView specific data.
        // ------------------------------------------------------------------
        private static bool DumpDocumentPageView(XmlTextWriter writer, UIElement element, bool uiElementsOnly)
        {
            DocumentPageView dpv = element as DocumentPageView;

            Debug.Assert(dpv != null, "Dump function has to match element type.");

            // Dump text range
            if (dpv.DocumentPage != null)
            {
                DumpDocumentPage(writer, dpv.DocumentPage, element);
            }
            return(false);
        }
Esempio n. 10
0
        public async Task <DocumentPageView> GetPageList(DocumentParm parm)
        {
            return(await WithConnection(async c =>
            {
                StringBuilder sql = new StringBuilder();
                sql.Append($@"  SELECT 
                id,
                doc_name,
                doc_version,
                doc_num,
                doc_type,
                doc_type2,
                eqp_type_id,
                active_time,
                dead_time,
                created_time,
                created_by,
                updated_time,
                updated_by,is_del FROM document
                 ");
                StringBuilder whereSql = new StringBuilder();
                //whereSql.Append(" WHERE ai.ProcessInstanceID = '" + parm.ProcessInstanceID + "'");

                //if (parm.AppName != null)
                //{
                //    whereSql.Append(" and ai.AppName like '%" + parm.AppName.Trim() + "%'");
                //}

                sql.Append(whereSql);
                //验证是否有参与到流程中
                //string sqlcheck = sql.ToString();
                //sqlcheck += ("AND ai.CreatedByUserID = '" + parm.UserID + "'");
                //var checkdata = await c.QueryFirstOrDefaultAsync<TaskViewModel>(sqlcheck);
                //if (checkdata == null)
                //{
                //    return null;
                //}

                var data = await c.QueryAsync <Document>(sql.ToString());
                var total = data.ToList().Count;
                sql.Append(" order by " + parm.sort + " " + parm.order)
                .Append(" limit " + (parm.page - 1) * parm.rows + "," + parm.rows);
                var ets = await c.QueryAsync <Document>(sql.ToString());

                DocumentPageView ret = new DocumentPageView();
                ret.rows = ets.ToList();
                ret.total = total;
                return ret;
            }));
        }
Esempio n. 11
0
 // Token: 0x06006FA1 RID: 28577 RVA: 0x00201684 File Offset: 0x001FF884
 internal DocumentPageTextView(DocumentPageView owner, ITextContainer textContainer)
 {
     Invariant.Assert(owner != null && textContainer != null);
     this._owner         = owner;
     this._page          = owner.DocumentPageInternal;
     this._textContainer = textContainer;
     if (this._page is IServiceProvider)
     {
         this._pageTextView = (((IServiceProvider)this._page).GetService(typeof(ITextView)) as ITextView);
     }
     if (this._pageTextView != null)
     {
         this._pageTextView.Updated += this.HandlePageTextViewUpdated;
     }
 }
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// Creates the static members of DocumentGridPage's Visual Tree.
        /// </summary>
        private void Init()
        {
            //Create the DocumentPageView, which will display our
            //content.
            _documentPageView = new DocumentPageView();
            _documentPageView.ClipToBounds     = true;
            _documentPageView.StretchDirection = StretchDirection.Both;
            _documentPageView.PageNumber       = int.MaxValue;

            //Create the content control that contains the page content.
            _documentContainer         = new ContentControl();
            _documentContainer.Content = _documentPageView;

            _loaded = false;
        }
Esempio n. 13
0
        //-------------------------------------------------------------------
        //
        //  Constructors
        //
        //-------------------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="owner">
        /// Root of layout structure visualizing content of a page.
        /// </param>
        /// <param name="textContainer">
        /// TextContainer representing content.
        /// </param>
        internal DocumentPageTextView(DocumentPageView owner, ITextContainer textContainer)
        {
            Invariant.Assert(owner != null && textContainer != null);
            _owner         = owner;
            _page          = owner.DocumentPageInternal;
            _textContainer = textContainer;
            // Retrive inner TextView
            if (_page is IServiceProvider)
            {
                _pageTextView = ((IServiceProvider)_page).GetService(typeof(ITextView)) as ITextView;
            }
            if (_pageTextView != null)
            {
                _pageTextView.Updated += new EventHandler(HandlePageTextViewUpdated);
            }
        }
Esempio n. 14
0
        // ------------------------------------------------------------------
        // Dump DocumentPageView specific data.
        // ------------------------------------------------------------------
        private static void DumpDocumentPageView(XmlNode writer, UIElement element)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            DocumentPageView dpv = (DocumentPageView)element;

            DumpDocumentPage(writer, dpv.DocumentPage, element);
        }
Esempio n. 15
0
        // Token: 0x06007BC6 RID: 31686 RVA: 0x0022C53C File Offset: 0x0022A73C
        public override IList <IAttachedAnnotation> PreProcessNode(DependencyObject node, out bool calledProcessAnnotations)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            DocumentPageView documentPageView = node as DocumentPageView;

            if (documentPageView != null && (documentPageView.DocumentPage is FixedDocumentPage || documentPageView.DocumentPage is FixedDocumentSequenceDocumentPage))
            {
                calledProcessAnnotations = true;
                return(base.Manager.ProcessAnnotations(documentPageView));
            }
            calledProcessAnnotations = false;
            return(null);
        }
Esempio n. 16
0
        private void documentViewer1_PageViewsChanged(object sender, EventArgs e)
        {
            // Get the page number from the PageViews currently visible.
            ReadOnlyCollection <DocumentPageView> oP = documentViewer1.PageViews;

            if ((doc != null) && (oP.Count > 0))
            {
                DocumentPageView pv = oP[oP.Count - 1];     // Take last page.
                //pv.SizeChanged += new SizeChangedEventHandler(pv_SizeChanged);
                int iPageNum = pv.PageNumber + 1;           // 1-based.
                //BlockEvent = true;                          // For txtBoxPageNum_TextChanged().
                txtPageNumber.Text = iPageNum.ToString();
                //BlockEvent = false;
                // Show total number of pages.
                lblTotalPages.Content = "of " + documentViewer1.PageCount.ToString();
            }
        }
        /// <summary>Gets the string that uniquely identifies the <see cref="T:System.Windows.Controls.Primitives.DocumentPageView" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.DocumentPageViewAutomationPeer" />. This method is called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetAutomationId" />.</summary>
        /// <returns>A string that contains the automation identifier.</returns>
        // Token: 0x06002666 RID: 9830 RVA: 0x000B6F9C File Offset: 0x000B519C
        protected override string GetAutomationIdCore()
        {
            string           result           = string.Empty;
            DocumentPageView documentPageView = (DocumentPageView)base.Owner;

            if (!string.IsNullOrEmpty(documentPageView.Name))
            {
                result = documentPageView.Name;
            }
            else if (documentPageView.PageNumber >= 0 && documentPageView.PageNumber < 2147483647)
            {
                result = string.Format(CultureInfo.InvariantCulture, "DocumentPage{0}", new object[]
                {
                    documentPageView.PageNumber + 1
                });
            }
            return(result);
        }
        // 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)));
        }
Esempio n. 19
0
        /// <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: 0x0600629B RID: 25243 RVA: 0x001BAA28 File Offset: 0x001B8C28
        private IList <IAttachedAnnotation> ProcessAnnotations(DocumentPageView dpv)
        {
            if (dpv == null)
            {
                throw new ArgumentNullException("dpv");
            }
            IList <IAttachedAnnotation> list  = new List <IAttachedAnnotation>();
            IList <ContentLocatorBase>  list2 = this._locatorManager.GenerateLocators(dpv);

            if (list2.Count > 0)
            {
                ContentLocator[] array = new ContentLocator[list2.Count];
                list2.CopyTo(array, 0);
                IList <Annotation> annotations = this._annotationStore.GetAnnotations(array[0]);
                foreach (ContentLocatorBase contentLocatorBase in list2)
                {
                    ContentLocator contentLocator = (ContentLocator)contentLocatorBase;
                    if (contentLocator.Parts[contentLocator.Parts.Count - 1].NameValuePairs.ContainsKey("IncludeOverlaps"))
                    {
                        contentLocator.Parts.RemoveAt(contentLocator.Parts.Count - 1);
                    }
                }
                foreach (Annotation annotation in annotations)
                {
                    foreach (AnnotationResource annotationResource in annotation.Anchors)
                    {
                        foreach (ContentLocatorBase locator in annotationResource.ContentLocators)
                        {
                            AttachmentLevel attachmentLevel;
                            object          attachedAnchor = this._locatorManager.FindAttachedAnchor(dpv, array, locator, out attachmentLevel);
                            if (attachmentLevel != AttachmentLevel.Unresolved)
                            {
                                Invariant.Assert(VisualTreeHelper.GetChildrenCount(dpv) == 1, "DocumentPageView has no visual children.");
                                DependencyObject child = VisualTreeHelper.GetChild(dpv, 0);
                                list.Add(new AttachedAnnotation(this._locatorManager, annotation, annotationResource, attachedAnchor, attachmentLevel, child as DocumentPageHost));
                                break;
                            }
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 21
0
        public ActionResult Index(string id)
        {
            DocumentPageView documentPageView = new DocumentPageView();

            documentPageView.EmployeeView = GetEmployee();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("Document_Read");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(View(documentPageView));
            }
            #endregion

            documentPageView.CustomerView = GetCustomer(id);


            return(View(documentPageView));
        }
Esempio n. 22
0
        /// <summary>
        ///     Generates locators identifying 'chunks'.  If node is a chunk,
        ///     generates a locator with a single locator part containing a
        ///     fingerprint of the chunk.  Otherwise null is returned.
        /// </summary>
        /// <param name="node">the node to generate a locator for</param>
        /// <param name="continueGenerating">return flag indicating whether the search
        /// should continue (presumably because the search was not exhaustive).
        /// This processor will always return true because it is possible to locate
        /// parts of the node (if it is FixedPage or FixedPageProxy)</param>
        /// <returns>if node is a FixedPage or FixedPageProxy, a ContentLocator
        /// with  a single locator part containing the page number; null if node is not
        /// FixedPage or FixedPageProxy </returns>
        /// <exception cref="ArgumentNullException">node is null</exception>
        /// <exception cref="ArgumentException">node points to a Document Page View which
        /// doesn't contain a FixedDocumentPage</exception>
        public override ContentLocator GenerateLocator(PathNode node, out bool continueGenerating)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            // Initial value
            continueGenerating = true;

            ContentLocator   locator = null;
            DocumentPageView dpv     = node.Node as DocumentPageView;

            int pageNb = -1;

            if (dpv != null)
            {
                // Only produce locator parts for FixedDocumentPages
                if (dpv.DocumentPage is FixedDocumentPage || dpv.DocumentPage is FixedDocumentSequenceDocumentPage)
                {
                    pageNb = dpv.PageNumber;
                }
            }
            else
            {
                FixedTextSelectionProcessor.FixedPageProxy fPage = node.Node as FixedTextSelectionProcessor.FixedPageProxy;
                if (fPage != null)
                {
                    pageNb = fPage.Page;
                }
            }

            if (pageNb >= 0)
            {
                locator = new ContentLocator();
                ContentLocatorPart locatorPart = CreateLocatorPart(pageNb);
                locator.Parts.Add(locatorPart);
            }

            return(locator);
        }
Esempio n. 23
0
        // 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);
        }
Esempio n. 24
0
 public static IObservable <EventPattern <MouseButtonEventArgs> > MouseUpObserver(this DocumentPageView This)
 {
     return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.MouseUp += h, h => This.MouseUp -= h));
 }
        /// <summary>
        ///     Creates a TextRange object spanning the portion of 'startNode'
        ///     specified by 'locatorPart'.
        /// </summary>
        /// <param name="locatorPart">FixedTextRange locator part specifying start and end point of
        /// the TextRange</param>
        /// <param name="startNode">the FixedPage containing this locator part</param>
        /// <param name="attachmentLevel">set to AttachmentLevel.Full if the FixedPage for the locator
        /// part was found, AttachmentLevel.Unresolved otherwise</param>
        /// <returns>a TextRange spanning the text between start end end point in the FixedTextRange
        /// locator part
        /// , null if selection described by locator part could not be
        /// recreated</returns>
        /// <exception cref="ArgumentNullException">locatorPart or startNode are
        /// null</exception>
        /// <exception cref="ArgumentException">locatorPart is of the incorrect type</exception>
        /// <exception cref="ArgumentException">startNode is not a FixedPage</exception>
        /// <exception cref="ArgumentException">startNode does not belong to the DocumentViewer</exception>
        public override Object ResolveLocatorPart(ContentLocatorPart locatorPart, DependencyObject startNode, out AttachmentLevel attachmentLevel)
        {
            if (startNode == null)
            {
                throw new ArgumentNullException("startNode");
            }

            DocumentPage docPage = null;
            FixedPage    page    = startNode as FixedPage;

            if (page != null)
            {
                docPage = GetDocumentPage(page);
            }
            else
            {
                // If we were passed a DPV because we are walking the visual tree,
                // extract the DocumentPage from it;  its TextView will be used to
                // turn coordinates into text positions
                DocumentPageView dpv = startNode as DocumentPageView;
                if (dpv != null)
                {
                    docPage = dpv.DocumentPage as FixedDocumentPage;
                    if (docPage == null)
                    {
                        docPage = dpv.DocumentPage as FixedDocumentSequenceDocumentPage;
                    }
                }
            }

            if (docPage == null)
            {
                throw new ArgumentException(SR.Get(SRID.StartNodeMustBeDocumentPageViewOrFixedPage), "startNode");
            }

            if (locatorPart == null)
            {
                throw new ArgumentNullException("locatorPart");
            }

            attachmentLevel = AttachmentLevel.Unresolved;

            ITextView tv = (ITextView)((IServiceProvider)docPage).GetService(typeof(ITextView));

            Debug.Assert(tv != null);

            ReadOnlyCollection <TextSegment> ts = tv.TextSegments;

            //check first if a TextRange can be generated
            if (ts == null || ts.Count <= 0)
            {
                return(null);
            }

            TextAnchor resolvedAnchor = new TextAnchor();

            if (docPage != null)
            {
                string stringCount = locatorPart.NameValuePairs["Count"];
                if (stringCount == null)
                {
                    throw new ArgumentException(SR.Get(SRID.InvalidLocatorPart, TextSelectionProcessor.CountAttribute));
                }
                int count = Int32.Parse(stringCount, NumberFormatInfo.InvariantInfo);

                for (int i = 0; i < count; i++)
                {
                    // First we extract the start and end Point from the locator part.
                    Point start;
                    Point end;
                    GetLocatorPartSegmentValues(locatorPart, i, out start, out end);

                    //calulate start ITextPointer
                    ITextPointer segStart;
                    if (double.IsNaN(start.X) || double.IsNaN(start.Y))
                    {
                        //get start of the page
                        segStart = FindStartVisibleTextPointer(docPage);
                    }
                    else
                    {
                        //convert Point to TextPointer
                        segStart = tv.GetTextPositionFromPoint(start, true);
                    }

                    if (segStart == null)
                    {
                        //selStart can be null if there are no insertion points on this page
                        continue;
                    }

                    //calulate end ITextPointer
                    ITextPointer segEnd;
                    if (double.IsNaN(end.X) || double.IsNaN(end.Y))
                    {
                        segEnd = FindEndVisibleTextPointer(docPage);
                    }
                    else
                    {
                        //convert Point to TextPointer
                        segEnd = tv.GetTextPositionFromPoint(end, true);
                    }

                    //end TP can not be null when start is not
                    Invariant.Assert(segEnd != null, "end TP is null when start TP is not");

                    attachmentLevel = AttachmentLevel.Full;  // Not always true right?
                    resolvedAnchor.AddTextSegment(segStart, segEnd);
                }
            }

            if (resolvedAnchor.TextSegments.Count > 0)
            {
                return(resolvedAnchor);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 26
0
 /// <summary>
 ///     Set the DocumentPageView this selection processor should use
 ///     when clamping text anchors. If this target is not set then
 ///     the set of DPVs held by the viewer are used.
 /// </summary>
 internal void SetTargetDocumentPageView(DocumentPageView target)
 {
     Debug.Assert(target != null);
     _targetPage = target;
 }
Esempio n. 27
0
 public static IObservable <EventPattern <ContextMenuEventArgs> > ContextMenuClosingObserver(this DocumentPageView This)
 {
     return(Observable.FromEventPattern <ContextMenuEventHandler, ContextMenuEventArgs>(h => This.ContextMenuClosing += h, h => This.ContextMenuClosing -= h));
 }
Esempio n. 28
0
        /// <summary>
        ///     Searches the logical tree for a node matching the values of
        ///     locatorPart.  A match must be a chunk which produces the same
        ///     fingerprint as in the locator part.
        /// </summary>
        /// <param name="locatorPart">locator part to be matched, must be of the type
        /// handled by this processor</param>
        /// <param name="startNode">logical tree node to start search at</param>
        /// <param name="continueResolving">return flag indicating whether the search
        /// should continue (presumably because the search was not exhaustive). This
        /// processor will return false if the startNode is a FixedPage
        /// with a different page number than the locator part's page number.
        /// Otherwise the return value will be true.
        /// inside the FixedPage(like TextSelection) </param>
        /// <returns>returns a node that matches the locator part; null if no such
        /// node is found</returns>
        /// <exception cref="ArgumentNullException">locatorPart or startNode are
        /// null</exception>
        /// <exception cref="ArgumentException">locatorPart is of the incorrect
        /// type</exception>
        public override DependencyObject ResolveLocatorPart(ContentLocatorPart locatorPart, DependencyObject startNode, out bool continueResolving)
        {
            if (locatorPart == null)
            {
                throw new ArgumentNullException("locatorPart");
            }

            if (startNode == null)
            {
                throw new ArgumentNullException("startNode");
            }

            if (PageNumberElementName != locatorPart.PartType)
            {
                throw new ArgumentException(SR.Get(SRID.IncorrectLocatorPartType, locatorPart.PartType.Namespace + ":" + locatorPart.PartType.Name), "locatorPart");
            }

            // Initial value
            continueResolving = true;

            int    pageNumber       = 0;
            string pageNumberString = locatorPart.NameValuePairs[ValueAttributeName];

            if (pageNumberString != null)
            {
                pageNumber = Int32.Parse(pageNumberString, NumberFormatInfo.InvariantInfo);
            }
            else
            {
                throw new ArgumentException(SR.Get(SRID.IncorrectLocatorPartType, locatorPart.PartType.Namespace + ":" + locatorPart.PartType.Name), "locatorPart");
            }


            // Get the actual FixedPage for the page number specified in the LocatorPart.  We need
            // the actual FixedPage cause its what exists in the visual tree and what we'll use to
            // anchor the annotations to.
            FixedDocumentPage        page     = null;
            IDocumentPaginatorSource document = null;
            DocumentPageView         dpv      = null;

            if (_useLogicalTree)
            {
                document = startNode as FixedDocument;
                if (document != null)
                {
                    page = document.DocumentPaginator.GetPage(pageNumber) as FixedDocumentPage;
                }
                else
                {
                    document = startNode as FixedDocumentSequence;
                    if (document != null)
                    {
                        FixedDocumentSequenceDocumentPage sequencePage = document.DocumentPaginator.GetPage(pageNumber) as FixedDocumentSequenceDocumentPage;
                        if (sequencePage != null)
                        {
                            page = sequencePage.ChildDocumentPage as FixedDocumentPage;
                        }
                    }
                }
            }
            else
            {
                dpv = startNode as DocumentPageView;
                if (dpv != null)
                {
                    page = dpv.DocumentPage as FixedDocumentPage;
                    if (page == null)
                    {
                        FixedDocumentSequenceDocumentPage sequencePage = dpv.DocumentPage as FixedDocumentSequenceDocumentPage;
                        if (sequencePage != null)
                        {
                            page = sequencePage.ChildDocumentPage as FixedDocumentPage;
                        }
                    }

                    // If this was the wrong fixed page we want to stop searching this subtree
                    if (page != null && dpv.PageNumber != pageNumber)
                    {
                        continueResolving = false;
                        page = null;
                    }
                }
            }

            if (page != null)
            {
                return(page.FixedPage);
            }

            return(null);
        }
Esempio n. 29
0
 public static IObservable <EventPattern <MouseButtonEventArgs> > PreviewMouseDownObserver(this DocumentPageView This)
 {
     return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.PreviewMouseDown += h, h => This.PreviewMouseDown -= h));
 }
Esempio n. 30
0
        ///<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)));
        }