Author: toshok
Date: 2006-11-17 12:38:51 -0500 (Fri, 17 Nov 2006)
New Revision: 68068
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CommonDialog.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PageSetupDialog.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintDialog.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewControl.cs
Log:
2006-11-17 Chris Toshok <[EMAIL PROTECTED]>
[ fixes the exit/crashes associated with #79835. it's clearly
suboptimal though, we need to figure out a better way to solve
this. ]
* PrintPreviewControl.cs: deal with the new invalid printer
exceptions.
* PageSetupDialog.cs: if the printer is invalid, pop up a dialog
and return false (so CommonDialog.ShowDialog doesn't actually show
the form.)
* PrintDialog.cs: enable/disable the Ok button depending on
whether or not the printer is valid.
* CommonDialog.cs (ShowDialog): only actually show the form if
RunDialog returns true.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-11-17 17:06:42 UTC (rev 68067)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-11-17 17:38:51 UTC (rev 68068)
@@ -1,3 +1,22 @@
+2006-11-17 Chris Toshok <[EMAIL PROTECTED]>
+
+ [ fixes the exit/crashes associated with #79835. it's clearly
+ suboptimal though, we need to figure out a better way to solve
+ this. ]
+
+ * PrintPreviewControl.cs: deal with the new invalid printer
+ exceptions.
+
+ * PageSetupDialog.cs: if the printer is invalid, pop up a dialog
+ and return false (so CommonDialog.ShowDialog doesn't actually show
+ the form.)
+
+ * PrintDialog.cs: enable/disable the Ok button depending on
+ whether or not the printer is valid.
+
+ * CommonDialog.cs (ShowDialog): only actually show the form if
+ RunDialog returns true.
+
2006-11-17 Jackson Harper <[EMAIL PROTECTED]>
* TextControl.cs: When soft splitting a line, mark it as a soft
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CommonDialog.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CommonDialog.cs
2006-11-17 17:06:42 UTC (rev 68067)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CommonDialog.cs
2006-11-17 17:38:51 UTC (rev 68068)
@@ -104,11 +104,11 @@
public DialogResult ShowDialog(IWin32Window ownerWin32) {
// Prep the dialog
- RunDialog(form.Handle);
+ if (RunDialog(form.Handle)) {
+ // Run
+ form.ShowDialog(ownerWin32);
+ }
- // Run
- form.ShowDialog(ownerWin32);
-
return form.DialogResult;
}
#endregion // Public Instance Methods
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PageSetupDialog.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PageSetupDialog.cs
2006-11-17 17:06:42 UTC (rev 68067)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PageSetupDialog.cs
2006-11-17 17:38:51 UTC (rev 68068)
@@ -191,8 +191,14 @@
#region Protected Instance Methods
protected override bool RunDialog (IntPtr hwnd)
{
- SetPrinterDetails ();
- return true;
+ try {
+ SetPrinterDetails ();
+ return true;
+ }
+ catch (Exception e) {
+ MessageBox.Show (e.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
}
#endregion // Protected Instance Methods
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintDialog.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintDialog.cs
2006-11-17 17:06:42 UTC (rev 68067)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintDialog.cs
2006-11-17 17:38:51 UTC (rev 68068)
@@ -591,8 +591,10 @@
label_where.Text = port;
label_comment.Text = comment;
+ accept_button.Enabled = true;
}
catch {
+ accept_button.Enabled = false;
}
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewControl.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewControl.cs
2006-11-17 17:06:42 UTC (rev 68067)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewControl.cs
2006-11-17 17:38:51 UTC (rev 68068)
@@ -179,33 +179,39 @@
#region Public Instance Methods
internal void GeneratePreview ()
{
- if (document == null)
- return;
+ try {
+ if (document == null)
+ return;
- if (page_infos == null) {
- document.Print ();
- page_infos = controller.GetPreviewPageInfo ();
- }
+ if (page_infos == null) {
+ document.Print ();
+ page_infos =
controller.GetPreviewPageInfo ();
+ }
+
+ if (image_cache == null) {
+ image_cache = new
Image[page_infos.Length];
- if (image_cache == null) {
- image_cache = new Image[page_infos.Length];
+ if (page_infos.Length > 0) {
+ image_size =
ThemeEngine.Current.PrintPreviewControlGetPageSize (this);
+ if (image_size.Width >= 0 &&
image_size.Width < page_infos[0].Image.Width
+ && image_size.Height >= 0
&& image_size.Height < page_infos[0].Image.Height) {
- if (page_infos.Length > 0) {
- image_size =
ThemeEngine.Current.PrintPreviewControlGetPageSize (this);
- if (image_size.Width >= 0 &&
image_size.Width < page_infos[0].Image.Width
- && image_size.Height >= 0 &&
image_size.Height < page_infos[0].Image.Height) {
-
- for (int i = 0; i <
page_infos.Length; i ++) {
- image_cache[i] = new
Bitmap (image_size.Width, image_size.Height);
- Graphics g =
Graphics.FromImage (image_cache[i]);
- g.DrawImage
(page_infos[i].Image, new Rectangle (new Point (0, 0), image_size), 0, 0,
page_infos[i].Image.Width, page_infos[i].Image.Height, GraphicsUnit.Pixel);
- g.Dispose ();
+ for (int i = 0; i <
page_infos.Length; i ++) {
+ image_cache[i]
= new Bitmap (image_size.Width, image_size.Height);
+ Graphics g =
Graphics.FromImage (image_cache[i]);
+ g.DrawImage
(page_infos[i].Image, new Rectangle (new Point (0, 0), image_size), 0, 0,
page_infos[i].Image.Width, page_infos[i].Image.Height, GraphicsUnit.Pixel);
+ g.Dispose ();
+ }
}
}
}
+ UpdateScrollBars();
}
-
- UpdateScrollBars();
+ catch (Exception e) {
+ page_infos = new PreviewPageInfo[0];
+ image_cache = new Image[0];
+ MessageBox.Show (e.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
}
public void InvalidatePreview()
@@ -249,7 +255,7 @@
{
base.OnResize (e);
if (AutoZoom) {
- if (page_infos != null) {
+ if (page_infos != null && page_infos.Length >
0) {
Size new_size =
ThemeEngine.Current.PrintPreviewControlGetPageSize (this);
if (new_size.Width != image_size.Width
&& new_size.Height != image_size.Height)
image_cache = null;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches