Пример #1
0
        public void PrintForm(Form form, PrintSettings printSettings = null, MarginsI margins = null)
        {
            try {
                GtkFormPrintDocument doc = new GtkFormPrintDocument(form);
                if (margins != null)
                {
                    doc.SetDefaultMargins(margins.Top, margins.Bottom, margins.Left, margins.Right, margins.UnitType);
                }

                string printerName = null;
                if (printSettings != null)
                {
                    doc.PrintSettings = printSettings.Copy();
                    if (!string.IsNullOrWhiteSpace(printSettings.Printer))
                    {
                        printerName = printSettings.Printer;
                    }

                    doc.DefaultPageSetup.Orientation = printSettings.Orientation;
                    if (printSettings.PaperSize != null &&
                        printSettings.PaperSize.IsCustom)
                    {
                        doc.DefaultPageSetup.PaperSize = printSettings.PaperSize;
                    }
                }

                doc.SetPrinterSettings(printerName);

                doc.Run(PrintOperationAction.Print, ComponentHelper.TopWindow);
            } catch (Exception ex) {
                ErrorHandling.LogException(ex, ErrorSeverity.FatalError);
            }
        }
Пример #2
0
        private static void ExportDocument(IList <Form> forms, string name, string fileName, bool portrait, string type, Type sourceObjectType = null, bool recalculateForm = true, PrintSettings printSettings = null, MarginsI margins = null)
        {
            IDocumentExporter exporter;
            string            filename;
            bool?  toFile;
            string email;
            string subject;

            using (ExportDocuments dialog = new ExportDocuments(sourceObjectType ?? forms [0].SourceObject.GetType(), fileName)) {
                if (dialog.Run() != ResponseType.Ok)
                {
                    return;
                }

                exporter = dialog.DocumentExporter;
                filename = dialog.FileName;
                toFile   = dialog.ToFile;
                email    = dialog.Email;
                subject  = dialog.EmailSubject;
            }

            BusinessDomain.FeedbackProvider.TrackEvent("Export document", type);

            try {
                exporter.Export(filename, toFile, email, subject, name, forms, portrait, recalculateForm, printSettings, margins);
            } catch (LicenseLimitationException ex) {
                MessageError.ShowDialog(ex.Message, ErrorSeverity.Warning, ex);
            } catch (IOException ex) {
                MessageError.ShowDialog(string.Format(Translator.GetString("Error occurred while saving export to \"{0}\". Please check if you have write permissions to that location."), filename), ErrorSeverity.Warning, ex);
            } catch (Exception ex) {
                MessageError.ShowDialog(Translator.GetString("Error occurred while performing export."), ErrorSeverity.Warning, ex);
            }
        }
Пример #3
0
        public static void ExportBarcodes(Form form, bool portrait, PrintSettings printSettings, MarginsI margins)
        {
            DateTime date = DateTime.Today;

            ExportDocument(new List <Form> {
                form
            }, "Barcodes", string.Format("Barcodes-{0}_{1}_{2}", date.Day, date.Month, date.Year), portrait, "Barcodes", typeof(Item), false, printSettings, margins);
        }
Пример #4
0
 public static void PrintForm(Form form, PrintSettings printSettings = null, MarginsI margins = null)
 {
     resProvider.PrintForm(form, printSettings, margins);
 }