2007-01-10 Jonathan Pobst <jpobst@novell.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / PrintControllerWithStatusDialog.cs
index c71672a1e28bd431c043eb73820ba083ba7153cf..65de6297d01c25df3198a5874f85a5ba05ddc652 100644 (file)
@@ -34,7 +34,6 @@ namespace System.Windows.Forms
        public class PrintControllerWithStatusDialog : PrintController {
                #region Local variables
                PrintController underlyingController;
-               string dialogTitle;
                PrintingDialog dialog;
                int currentPage;
                #endregion // Local variables
@@ -86,16 +85,22 @@ namespace System.Windows.Forms
                }
 
                public override void OnStartPrint(PrintDocument document, PrintEventArgs e) {
-                       currentPage = 0;
-                       dialog.Show();
-                       if (document.PrinterSettings.PrintToFile) {
-                               SaveFileDialog d = new SaveFileDialog ();
-                               if (d.ShowDialog () != DialogResult.OK)
-                                       // Windows throws a Win32Exception here.
-                                       throw new Exception ("The operation was canceled by the user");
-                               Set_PrinterSettings_PrintFileName (document.PrinterSettings, d.FileName);
+                       try {
+                               currentPage = 0;
+                               dialog.Show();
+                               if (document.PrinterSettings.PrintToFile) {
+                                       SaveFileDialog d = new SaveFileDialog ();
+                                       if (d.ShowDialog () != DialogResult.OK)
+                                               // Windows throws a Win32Exception here.
+                                               throw new Exception ("The operation was canceled by the user");
+                                       Set_PrinterSettings_PrintFileName (document.PrinterSettings, d.FileName);
+                               }
+                               underlyingController.OnStartPrint (document, e);
+                       }
+                       catch {
+                               dialog.Hide ();
+                               throw;
                        }
-                       underlyingController.OnStartPrint (document, e);
                }
 
                #endregion      // Protected Instance Methods