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

            PrintDialog printDialog = new PrintDialog();

            foreach (ImageInfo imageInfo in OCRImages_ListBox.SelectedItems)
            {
                PageContent pageContent = new PageContent();
                FixedPage   fixedPage   = new FixedPage();

                bool rotate = false;

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

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

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

                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);
        }
Exemple #2
0
        public List<PageContent> PrintPage()
        {
            List<PageContent> Pages = new List<PageContent>();

            PrintDialog printDialog = new PrintDialog();

            foreach (ImageInfo imageInfo in OCRImages_ListBox.SelectedItems)
            {
                PageContent pageContent = new PageContent();
                FixedPage fixedPage = new FixedPage();

                bool rotate = false;

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

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

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

                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;
        }