Ejemplo n.º 1
0
        void printButton_Click(object sender, RoutedEventArgs e)
        {
            if (_vm.SelectedProtocol == null)
            {
                MessageBox.Show("Please select an analysis protocol first", "No Protocol Selected", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var reportService = new ReportPdf();
            var reportData    = CreateReportData();

            System.Windows.Forms.PrintDialog printDlg = new System.Windows.Forms.PrintDialog();
            MigraDocPrintDocument            printDoc = new MigraDocPrintDocument();

            printDoc.Renderer = new MigraDoc.Rendering.DocumentRenderer(reportService.CreateReport(reportData));
            printDoc.Renderer.PrepareDocument();

            printDoc.DocumentName = Window.GetWindow(this).Title;
            //printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
            printDlg.Document       = printDoc;
            printDlg.AllowSelection = true;
            printDlg.AllowSomePages = true;
            //Call ShowDialog
            if (printDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                printDoc.Print();
            }
        }