Esempio n. 1
0
        /// <summary>
        /// Call to print
        /// </summary>
        public virtual void Print(object sender, System.EventArgs e)
        {
            if (!this.printInProgress)
            {
                this.printDialog1.Document = this.document;
                DialogResult result = this.printDialog1.ShowDialog();
                if (result == DialogResult.OK)
                {
                    PrintController printController;
                    printController = new StandardPrintController();

                    if (this.ShowStatusDialog)
                    {
                        this.document.PrintController = new PrintControllerWithStatusDialog(
                            printController, "Please wait...");
                    }
                    else
                    {
                        this.document.PrintController = printController;
                    }

                    onPrinting();
                    if (this.PrintInBackground)
                    {
                        // disable buttons or else the user could get into trouble!
                        PrintInBackgroundDelegate d = new PrintInBackgroundDelegate(
                            BeginBackgroundPrint);
                        d.BeginInvoke(new AsyncCallback(PrintInBackgroundComplete), null);
                    }
                    else
                    {
                        this.printInProgress = true;
                        this.document.Print();
                        this.printInProgress = false;
                        onPrinted();
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Call to print
        /// </summary>
        public virtual void Print(object sender, System.EventArgs e)
        {
            if (!this.printInProgress)
            {
                this.printDialog1.Document = this.document;

                if (this.PrintWithoutDialogBox)
                {
                    this.printDialog1.PrinterSettings.PrinterName = DEFS.DefPrinter;
                    //MessageBox.Show(DEFS.DefPrinter);
                    PrintController printController;
                    printController = new StandardPrintController();

                    if (this.ShowStatusDialog)
                    {
                        this.document.PrintController = new PrintControllerWithStatusDialog(
                            printController, "Please wait...");
                    }
                    else
                    {
                        this.document.PrintController = printController;
                    }

                    onPrinting();
                    if (this.PrintInBackground)
                    {
                        // disable buttons or else the user could get into trouble!
                        PrintInBackgroundDelegate d = new PrintInBackgroundDelegate(
                            BeginBackgroundPrint);
                        d.BeginInvoke(new AsyncCallback(PrintInBackgroundComplete), null);
                    }
                    else
                    {
                        this.printInProgress = true;
                        this.document.Print();
                        this.printInProgress = false;
                        onPrinted();
                    }

                }
                else
                {

                    DialogResult result = this.printDialog1.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        PrintController printController;
                        printController = new StandardPrintController();

                        if (this.ShowStatusDialog)
                        {
                            this.document.PrintController = new PrintControllerWithStatusDialog(
                                printController, "Please wait...");
                        }
                        else
                        {
                            this.document.PrintController = printController;
                        }

                        onPrinting();
                        if (this.PrintInBackground)
                        {
                            // disable buttons or else the user could get into trouble!
                            PrintInBackgroundDelegate d = new PrintInBackgroundDelegate(
                                BeginBackgroundPrint);
                            d.BeginInvoke(new AsyncCallback(PrintInBackgroundComplete), null);
                        }
                        else
                        {
                            this.printInProgress = true;
                            this.document.Print();
                            this.printInProgress = false;
                            onPrinted();
                        }

                    }
                }
            }
        }