Last active
August 29, 2015 14:25
-
-
Save bjoerntx/b71397ad942d36758ee7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*------------------------------------------------------ | |
** OnBeginPrint | |
** description: This method overrides the standard | |
** OnBeginPrint method and sets the from | |
** and to page values | |
** | |
** parameters: standard PrintEventArgs | |
**----------------------------------------------------*/ | |
protected override void OnBeginPrint(PrintEventArgs e) | |
{ | |
base.OnBeginPrint(e); | |
// if PrinterSettings have been specified, check the print ranges | |
switch (PrinterSettings.PrintRange) | |
{ | |
case PrintRange.AllPages: | |
m_currentPage = 0; | |
m_toPage = m_textControl.Pages - 1; | |
break; | |
case PrintRange.SomePages: | |
m_currentPage = PrinterSettings.FromPage - 1; | |
m_toPage = PrinterSettings.ToPage - 1; | |
break; | |
default: | |
throw new InvalidOperationException("This print range is not valid."); | |
} | |
// switch the page size values based on the page orientation | |
m_paperSize = (PrinterSettings.DefaultPageSettings.Landscape) ? | |
new Size( | |
PrinterSettings.DefaultPageSettings.PaperSize.Height, | |
PrinterSettings.DefaultPageSettings.PaperSize.Width) : | |
new Size( | |
PrinterSettings.DefaultPageSettings.PaperSize.Width, | |
PrinterSettings.DefaultPageSettings.PaperSize.Height); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment