[Mono-bugs] [Bug 61656][Nor] New - Cannot call PrintPageEventArgs.Graphics.DrawString twice
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 16 Jul 2004 05:46:54 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by michael.haider@hofstaedtler.com.
http://bugzilla.ximian.com/show_bug.cgi?id=61656
--- shadow/61656 2004-07-16 05:46:54.000000000 -0400
+++ shadow/61656.tmp.10758 2004-07-16 05:46:54.000000000 -0400
@@ -0,0 +1,118 @@
+Bug#: 61656
+Product: Mono: Runtime
+Version: unspecified
+OS: other
+OS Details: Debian
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: michael.haider@hofstaedtler.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Cannot call PrintPageEventArgs.Graphics.DrawString twice
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+Cannot call PrintPageEventArgs.Graphics.DrawString twice!
+As you can see, the following example calls the DrawString function twice,
+with the result that the 2 call produces an Unhandeld Exeption error!
+
+If I just call the function once it works all fine!
+
+On Windows the problem does not exists!
+
+I have gtk-sharp.dll 1.0.0.0 and System.Drawing 1.0.5000.0 on Windows and
+Debian installed!
+
+Steps to reproduce the problem:
+
+using System;
+using Gtk;
+using GtkSharp;
+using System.Drawing.Printing;
+using System.Drawing;
+
+class PrintSample
+{
+ TextView tv;
+ Font printFont;
+
+static void Main ()
+ {
+ new PrintSample ();
+ }
+
+ PrintSample ()
+ {
+
+ Application.Init ();
+ Gtk.Window win = new Gtk.Window ("Print sample");
+ win.SetDefaultSize (400, 300);
+ win.DeleteEvent += new DeleteEventHandler (OnWinDelete);
+ VBox vbox = new VBox (false, 0);
+ win.Add (vbox);
+ tv = new TextView ();
+ tv.Buffer.Text = "Hello World";
+ vbox.PackStart (tv, true, true, 0);
+ Button print = new Button (Gtk.Stock.Print);
+ print.Clicked += new EventHandler (OnPrintClicked);
+ vbox.PackStart (print, false, true, 0);
+ win.ShowAll ();
+ Application.Run ();
+ }
+
+
+ void OnPrintClicked (object o, EventArgs args)
+ {
+
+ PrintDocument pd = new PrintDocument();
+ pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
+ pd.Print();
+ }
+ public void pd_PrintPage(object sender, PrintPageEventArgs ev)
+ {
+ printFont = new Font("Arial", 20);
+ ev.Graphics.DrawString("foo",printFont,Brushes.Black,10,10);
+ printFont = new Font("Arial", 10);
+ ev.Graphics.DrawString("bar",printFont,Brushes.Black,100,10);
+
+ Pen pen = new Pen(Color.Red);
+ Rectangle rectangle = new Rectangle();
+ rectangle.X = 100;
+ rectangle.Y = 100;
+ rectangle.Width = 100;
+ rectangle.Height = 100;
+ ev.Graphics.DrawRectangle(pen,rectangle);
+
+ rectangle.X = 200;
+ rectangle.Y = 200;
+ rectangle.Width = 400;
+ rectangle.Height = 500;
+ ev.Graphics.DrawRectangle(pen,rectangle);
+
+ }
+ void OnWinDelete (object o, DeleteEventArgs args)
+ {
+ Application.Quit ();
+ }
+}
+
+Actual Results:
+Unhandeld Exeption: System.NullReferenceExeption
+
+to see the full message go to http://www.hofstaedtler.com/edv/monoerror.gif
+
+Expected Results:
+no error
+
+How often does this happen?
+everytime
+
+Additional Information: