Exemple #1
0
    void Print(object sender, EventArgs args)
    {
        PrintJob pj = new PrintJob();
        PrintDialog dialog = new PrintDialog (pj, "Print diagram");
        int response = dialog.Run();

        if (response == (int) ResponseType.Cancel ||
            response == (int) ResponseType.DeleteEvent) {
            dialog.Destroy();
            return;
        }

        PrintContext ctx = pj.Context;
        Gnome.Print.Beginpage (ctx, "demo");
        Dia.Global.ExportPrint (pj, canvas);
        Gnome.Print.Showpage (ctx);
        pj.Close();

        switch (response) {
        case (int)PrintButtons.Print:
            if (pj.Config.Get ("Settings.Transport.Backend") == "file")
                pj.PrintToFile (pj.Config.Get ("Settings.Transport.Backend.FileName"));
            pj.Print();
            break;
        case (int) PrintButtons.Preview:
            new PrintJobPreview (pj, "Diagram").Show();
            break;
        }
        dialog.Destroy();
    }
        public void Print()
        {
            //		if (Html == null || Html == string.Empty) {
            //			Simple.ErrorAlert("Chyba při tisku", "Není co tisknout, prázdný dokument", parentWindow);
            //			return;
            //		}
            //
            string Caption = "Beline Printing";

            PrintJob pj = new PrintJob (PrintConfig.Default ());
            PrintDialog dialog = new PrintDialog (pj, Caption, 0);

            //		Gtk.HTML gtk_html = new Gtk.HTML (Html);
            html_panel.PrintSetMaster (pj);

            PrintContext ctx = pj.Context;
            html_panel.Print (ctx);

            pj.Close ();

            // hello user
            int response = dialog.Run ();

            if (response == (int) PrintButtons.Cancel) {
            dialog.Hide ();
            dialog.Dispose ();
            return;
            } else if (response == (int) PrintButtons.Print) {
            pj.Print ();
            } else if (response == (int) PrintButtons.Preview) {
            new PrintJobPreview (pj, Caption).Show ();
            }

            ctx.Close ();
            dialog.Hide ();
            dialog.Dispose ();
            return;
        }