Monday, August 19, 2013

Printing pages with different settings

It is possible to print various pages in C# WinForms application (to printer or to file) using QueryPageSettings event of PrintDocument. In PrintPage handler it is not already possible to set page settings, if you want to change settings for a page you should do this in QueryPageSettings handler.

For example, here we set different orientations for pages depending on condition:
printDocument = new PrintDocument();
printDocument.QueryPageSettings += printDocument_QueryPageSettings;

void printDocument_QueryPageSettings(object sender, QueryPageSettingsEventArgs e)
{  
    e.PageSettings.Landscape = true;
    if (some_condition_here)
    {
       e.PageSettings.Landscape = false;
    }
}
Generally, you should handle PrintPage event also, for instance, to specify whether you have more pages to print or not.

Tuesday, August 13, 2013

Visual Studio 2013 and .NET Framework 4.5.1

Microsoft released Visual Studio 2013 Preview and official release is expected by the end of the year. You can find more details, for example, here:

http://blogs.msdn.com/b/somasegar/archive/2013/06/26/visual-studio-2013-preview.aspx

Visual Studio 2013 can be installed on:
  • Windows 7 SP1
  • Windows 8 or Windows 8.1
  • Windows Server 2008 R2 SP1 or Windows Server 2012

Visual Studio 2013 can be installed on the machine together with the previous versions of Visual Studio like VS 2012 or VS 2010.

Along with Visual Studio 2013 Microsoft announced .NET 4.5.1. This is a compatible update for .NET 4.5 and it will be the part of Windows 8.1. While we have to wait for .NET 5.0 for some revolutionary features, .NET 4.5.1 includes mostly enhancements targeted in developer productivity and application performance.