} // class PpsProgressPrintController #endregion /// <summary>Copy print-dialog setting to a System.Drawing.</summary> /// <param name="printDialog"></param> /// <param name="printDocument"></param> /// <param name="progress"></param> public static void SetPrintDocument(this PrintDialog printDialog, PrintDocument printDocument, IPpsProgress progress = null) { var printerSettings = printDocument.PrinterSettings; printDocument.PrintController = progress != null ? (PrintController) new PpsProgressPrintController(new StandardPrintController(), progress) : (PrintController) new StandardPrintController(); // update device settings printerSettings.SetPrintTicket(printDialog.PrintQueue, printDialog.PrintTicket); switch (printDialog.PageRangeSelection) { case PageRangeSelection.AllPages: printerSettings.PrintRange = PrintRange.AllPages; break; case PageRangeSelection.UserPages: printerSettings.PrintRange = PrintRange.SomePages; printerSettings.FromPage = printDialog.PageRange.PageFrom; printerSettings.ToPage = printDialog.PageRange.PageTo; break; //case PageRangeSelection.CurrentPage: //case PageRangeSelection.SelectedPages: default: throw new NotSupportedException(nameof(PrintDialog.PageRangeSelection)); } } // proc SetPrintDocument
public PpsProgressPrintController(PrintController controller, IPpsProgress progress) { this.controller = controller; this.progress = progress; } // ctor