Hello folks,

I installed the mono-1.2.5.1 installer for windows xp. It has gtk-sharp 2.10 and gnome 2.16 included. I also found *PrintSample.cs* in the samples directory. This PrintSample.cs uses the Gnome namespace to print.

I am having problems on how to compile it using mono on windows. I don't know what library to include so the Gnome namespace can be accessible. But when I compile it on mono(linux), it runs fine.

Also, when I tried copying the PrintSample.exe which is produced by a mono(linux) compilation. It won't run on my mono(windows). It outputs a System.DllNotFoundException.

    Attached is the *PrintSample.cs *file.

    Does anyone know how to compile it correctly on a windows machine?

Desperate already,
Marc Glenn


using System;
using Gtk;
using Gnome;

class PrintSample
{
        TextView tv;
        
        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 MyPrint (Gnome.PrintContext gpc)
        {
                gpc.BeginPage ("demo");
                gpc.MoveTo (1, 700);
                gpc.Show (tv.Buffer.Text);
                gpc.ShowPage ();
        }
        
        void OnPrintClicked (object o, EventArgs args)
        {
                Gnome.PrintJob pj = new Gnome.PrintJob 
(Gnome.PrintConfig.Default ());
                Gnome.PrintDialog dialog = new Gnome.PrintDialog (pj, "Print 
Test", 0);
                int response = dialog.Run ();
                Console.WriteLine ("response: " + response);
                
                if (response == (int) PrintButtons.Cancel) {
                        Console.WriteLine ("Canceled");
                        dialog.Hide ();
                        dialog.Dispose ();
                        return;
                }

                Gnome.PrintContext ctx = pj.Context;
                MyPrint (ctx); 

                pj.Close ();
                
                switch (response) {
                case (int) PrintButtons.Print: 
                        pj.Print (); 
                        break;
                case (int) PrintButtons.Preview:
                        new PrintJobPreview (pj, "Print Test").Show ();
                        break;
                }

                dialog.Hide ();
                dialog.Dispose ();
        }
        
        void OnWinDelete (object o, DeleteEventArgs args)
        {
                Application.Quit ();
        }
}
_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to