Beispiel #1
0
        private void mnuItmPrint_Click(object sender, System.EventArgs e)
        {
            _bPagesPrinted = false;
            _bPrintPreview = false;

            MiCo.MiForms.LoadedForm xlform = miFormsComponent1.ActiveForm;
            _printDoc.DocumentName                = xlform.Form.Name + " (" + xlform.Form.GetSessionDescriptor() + ")";
            _printDialog.AllowSomePages           = true;
            _printDialog.PrintToFile              = true;
            _printDialog.PrinterSettings.FromPage = 1;
            _printDialog.PrinterSettings.ToPage   = xlform.Form.Pages.Count;
            _printDialog.PrintToFile              = false;
            try
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    MiCo.MiForms.RenderType xType = MiCo.MiForms.RenderType.FieldValues;

                    // call SignalFormPrint() in case the client script wants to cancel the
                    // print
                    if (miFormsComponent1.SignalFormPrint(xlform, _printDialog.PrinterSettings.FromPage, _printDialog.PrinterSettings.ToPage, xType))
                    {
                        _nPageToPrint             = _printDoc.PrinterSettings.FromPage;
                        _printDoc.PrintController = new System.Drawing.Printing.StandardPrintController();
                        _printDoc.Print();
                    }
                }
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(this, String.Format("Print failed: {0}", ex.Message));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Handles the PrintRequested event; we handle this so that form scripts are able
        /// to request prints.
        /// </summary>
        private void mfc_PrintRequested(object sender, MiCo.MiForms.MiFormsComponent.PrintRequestedEventArgs e)
        {
            _bPagesPrinted = false;
            if (e.Form == null)
            {
                return;
            }
            if (e.Page < 1 || e.Page > e.Form.Form.Pages.Count)
            {
                return;
            }

            // we'll override the default render type so that the script author can
            // specify the desired render type
            _bOverrideRenderType = true;
            _xRenderType         = e.RenderType;

            MiCo.MiForms.LoadedForm xlform = miFormsComponent1.ActiveForm;

            // fire off the print job
            _printDoc.DocumentName             = xlform.Form.Name + " (" + xlform.Form.GetSessionDescriptor() + ")";
            _printDoc.PrintController          = new System.Drawing.Printing.StandardPrintController();
            _printDoc.PrinterSettings.FromPage = e.Page;
            _printDoc.PrinterSettings.ToPage   = e.Page;
            _nPageToPrint = _printDoc.PrinterSettings.FromPage;
            _printDoc.Print();

            e.Success = true;
        }