protected override void OnBeginPrint(PrintEventArgs e)
{
base.OnBeginPrint(e);
// Initialize the range of pages to be printed according to the user selection.
switch (this.PrinterSettings.PrintRange)
{
case System.Drawing.Printing.PrintRange.AllPages:
this.mCurrentPage = 1;
this.mPageTo = this.mDocument.PageCount;
break;
case System.Drawing.Printing.PrintRange.SomePages:
this.mCurrentPage = this.PrinterSettings.FromPage;
this.mPageTo = this.PrinterSettings.ToPage;
break;
default:
throw new InvalidOperationException("Unsupported print range.");
}
}