Example #1
0
        public List <PageContent> PrintPage()
        {
            List <PageContent> Pages = new List <PageContent>();

            PrintDialog printDialog = new PrintDialog();

            PageContent pageContent = new PageContent();
            FixedPage   fixedPage   = new FixedPage();

            BitmapSource displayAreaSource = RenderVisaulToBitmap(m_FormHost, (int)m_FormHost.ActualWidth, (int)m_FormHost.ActualHeight);

            bool rotate = false;

            double width  = printDialog.PrintableAreaWidth;
            double height = printDialog.PrintableAreaHeight;

            if (displayAreaSource.Width > displayAreaSource.Height)
            {
                width  = printDialog.PrintableAreaHeight;
                height = printDialog.PrintableAreaWidth;
                rotate = true;
            }

            PrintPreview printPreview = new PrintPreview(m_CaseObject, width, height);

            printPreview.SetImage(displayAreaSource);

            fixedPage.Children.Add((UIElement)printPreview);

            if (rotate)
            {
                double pageWidth  = printDialog.PrintableAreaWidth;
                double pageHeight = printDialog.PrintableAreaHeight;

                TranslateTransform tt = new TranslateTransform((pageWidth - pageHeight) / 2, (pageHeight - pageWidth) / 2);
                printPreview.RenderTransform = tt;

                RotateTransform rotateTransform = new RotateTransform(-90D, pageWidth / 2D, pageHeight / 2D);
                fixedPage.RenderTransform = rotateTransform;
            }

            ((IAddChild)pageContent).AddChild(fixedPage);

            Pages.Add(pageContent);

            return(Pages);
        }
Example #2
0
        public List<PageContent> PrintPage()
        {
            List<PageContent> Pages = new List<PageContent>();

            PrintDialog printDialog = new PrintDialog();

            PageContent pageContent = new PageContent();
            FixedPage fixedPage = new FixedPage();

            BitmapSource displayAreaSource = RenderVisaulToBitmap(m_FormHost, (int)m_FormHost.ActualWidth, (int)m_FormHost.ActualHeight);

            bool rotate = false;

            double width = printDialog.PrintableAreaWidth;
            double height = printDialog.PrintableAreaHeight;

            if (displayAreaSource.Width > displayAreaSource.Height)
            {
                width = printDialog.PrintableAreaHeight;
                height = printDialog.PrintableAreaWidth;
                rotate = true;
            }

            PrintPreview printPreview = new PrintPreview(m_CaseObject, width, height);
            printPreview.SetImage(displayAreaSource);

            fixedPage.Children.Add((UIElement)printPreview);

            if (rotate)
            {
                double pageWidth = printDialog.PrintableAreaWidth;
                double pageHeight = printDialog.PrintableAreaHeight;

                TranslateTransform tt = new TranslateTransform((pageWidth - pageHeight) / 2, (pageHeight - pageWidth) / 2);
                printPreview.RenderTransform = tt;

                RotateTransform rotateTransform = new RotateTransform(-90D, pageWidth / 2D, pageHeight / 2D);
                fixedPage.RenderTransform = rotateTransform;
            }

            ((IAddChild)pageContent).AddChild(fixedPage);

            Pages.Add(pageContent);

            return Pages;
        }