Esempio n. 1
0
        private async Task PrintAsync(PpsCommandContext ctx)
        {
            var pdf = pdfViewer.Document;

            using (var doc = pdf.GetPrintDocument())
            {
                var printDialog = new PrintDialog
                {
                    MinPage              = 1,
                    MaxPage              = (uint)pdf.PageCount,
                    PageRange            = new PageRange(1, pdf.PageCount),
                    CurrentPageEnabled   = true,
                    UserPageRangeEnabled = true
                };

                using (var bar = this.DisableUI("Drucken..."))
                {
                    if (this.ShowModalDialog(printDialog.ShowDialog))
                    {
                        inPrint = true;
                        try
                        {
                            if (printDialog.PageRangeSelection == PageRangeSelection.CurrentPage)
                            {
                                printDialog.PageRange          = new PageRange(pdfViewer.CurrentPageNumber + 1);
                                printDialog.PageRangeSelection = PageRangeSelection.UserPages;
                            }
                            printDialog.SetPrintDocument(doc, bar);

                            await Task.Run(new Action(doc.Print));
                        }
                        finally
                        {
                            inPrint = false;
                        }
                    }
                }
            }
        }         // proc PrintAsync