Beispiel #1
0
        // ----------------------- CreateFixedDocument ------------------------
        /// <summary>
        ///   Creates a FixedDocument with two (2) FixedPages.</summary>
        /// <returns>
        ///   The FixedDocument.</returns>
        static private FixedDocument CreateFixedDocument()
        {
            FixedDocument fixedDocument = new FixedDocument();

            //Create Pages
            PageContent pageContent1 = new PageContent();
            FixedPage   fixedPage1   = new FixedPage();

            Canvas canvas1 = new Canvas();

            FillCanvas(canvas1);
            SetUpPage(fixedPage1, canvas1);

            pageContent1.BeginInit();
            ((IAddChild)pageContent1).AddChild(fixedPage1);
            pageContent1.EndInit();

            PageContent pageContent2 = new PageContent();
            FixedPage   fixedPage2   = new FixedPage();

            Canvas canvas2 = new Canvas();

            FillCanvas(canvas2);
            SetUpPage(fixedPage2, canvas2);

            pageContent2.BeginInit();
            ((IAddChild)pageContent2).AddChild(fixedPage2);
            pageContent2.EndInit();

            //Attach Pages
            ((IAddChild)fixedDocument).AddChild(pageContent1);
            ((IAddChild)fixedDocument).AddChild(pageContent2);
            return(fixedDocument);
        }
Beispiel #2
0
        internal PageContent BuildPageContent(ClassicReportPage page)
        {
            PageContent content = new PageContent();

            content.BeginInit();
            (content as IAddChild).AddChild(BuildPage(page));
            content.EndInit();
            return(content);
        }
Beispiel #3
0
        /// <summary>
        /// Attaches a FixedPage to a FixedDocument.
        /// </summary>
        /// <param name="page">The page to attach.</param>
        /// <param name="document">The document to attach to.</param>
        private static void AttachPageToDocument(FixedPage page, FixedDocument document)
        {
            PageContent content = new PageContent();

            content.BeginInit();
            ((IAddChild)content).AddChild(page);
            content.EndInit();

            ((IAddChild)document).AddChild(content);
        }
    /// <summary>
    /// encapsulater for a UIElement in an DocumentReference
    /// DocumentReference(FixedDocument(PageContent(FixedPage(UIElement))))
    /// to simplify the print of multiple pages
    /// </summary>
    /// <param name="uiElement">the UIElement which</param>
    /// <returns>creates a DocumentReference</returns>
    private DocumentReference toDocumentReference(UIElement uiElement)
    {
        if (uiElement == null)
        {
            throw new NullReferenceException("the UIElement has to be not null");
        }

        FixedPage         fixedPage   = new FixedPage();
        PageContent       pageContent = new PageContent();
        FixedDocument     fixedDoc    = new FixedDocument();
        DocumentReference docRef      = new DocumentReference();

        #region Step1

        // add the UIElement object the FixedPage
        fixedPage.Children.Add(uiElement);

        #endregion

        #region Step2

        // add the FixedPage to the PageContent collection
        pageContent.BeginInit();
        ((IAddChild)pageContent).AddChild(fixedPage);
        pageContent.EndInit();

        #endregion

        #region Step 3

        //// add the PageContent to the FixedDocument collection
        ((IAddChild)fixedDoc).AddChild(pageContent);

        #endregion

        #region Step 4

        //// add the FixedDocument to the document reference collection
        docRef.BeginInit();
        docRef.SetDocument(fixedDoc);
        docRef.EndInit();

        #endregion

        return(docRef);
    }