Revision: 35
http://nplot.svn.sourceforge.net/nplot/?rev=35&view=rev
Author: jamcquay
Date: 2010-06-08 21:17:24 +0000 (Tue, 08 Jun 2010)
Log Message:
-----------
Improved the Print/PrintPreview exception handling
Modified Paths:
--------------
trunk/src/Windows.PlotSurface2D.cs
Modified: trunk/src/Windows.PlotSurface2D.cs
===================================================================
--- trunk/src/Windows.PlotSurface2D.cs 2009-12-28 15:29:51 UTC (rev 34)
+++ trunk/src/Windows.PlotSurface2D.cs 2010-06-08 21:17:24 UTC (rev 35)
@@ -1019,29 +1019,36 @@
printDocument.DefaultPageSettings.Landscape = true;
DialogResult result;
- if (!preview)
- {
- PrintDialog dlg = new PrintDialog();
- dlg.Document = printDocument;
- result = dlg.ShowDialog();
- }
- else
- {
- PrintPreviewDialog dlg = new PrintPreviewDialog();
- dlg.Document = printDocument;
- result = dlg.ShowDialog();
- }
- if (result == DialogResult.OK)
- {
- try
- {
- printDocument.Print();
- }
- catch
- {
- Console.WriteLine( "caught\n" );
- }
- }
+ try
+ {
+ if (!preview)
+ {
+ PrintDialog dlg = new PrintDialog();
+ dlg.Document = printDocument;
+ result = dlg.ShowDialog();
+ }
+ else
+ {
+ PrintPreviewDialog dlg = new PrintPreviewDialog();
+ dlg.Document = printDocument;
+ result = dlg.ShowDialog();
+ }
+ if (result == DialogResult.OK)
+ {
+ try
+ {
+ printDocument.Print();
+ }
+ catch
+ {
+ Console.WriteLine("caught\n");
+ }
+ }
+ }
+ catch (InvalidPrinterException)
+ {
+ Console.WriteLine("caught\n");
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|