private void DocPrinterInit()
        {
            MultiDocPrinter = new MultipleDocumentPrinter
            {
                PrintableDocuments = new GenericObservableList <SelectablePrintDocument>(DocumentsToPrint)
            };

            MultiDocPrinter.DocumentsPrinted += (o, args) => DocumentsPrinted?.Invoke(o, args);
            MultiDocPrinter.PrintingCanceled += (o, args) => PrintingCanceled?.Invoke(o, args);
        }
        public void PrintSelectedDocuments()
        {
            var prnbleDocs = PrintableDocuments.Where(d => d.Selected);

            if (!prnbleDocs.Any())
            {
                return;
            }

            List <IPrintableDocument> rdlToPrinter = new List <IPrintableDocument>();
            List <IPrintableDocument> odtToPrinter = new List <IPrintableDocument>();
            List <IPrintableDocument> imgToPrinter = new List <IPrintableDocument>();

            foreach (var document in prnbleDocs)
            {
                document.Document.CopiesToPrint = document.Copies;
                switch (document.Document.PrintType)
                {
                case PrinterType.ODT:
                    document.Document.CopiesToPrint = document.Copies;
                    odtToPrinter.Add(document.Document);
                    break;

                case PrinterType.RDL:
                    for (int i = 0; i < document.Copies; i++)
                    {
                        rdlToPrinter.Add(document.Document);
                    }
                    break;

                case PrinterType.Image:
                    for (int i = 0; i < document.Copies; i++)
                    {
                        imgToPrinter.Add(document.Document);
                    }
                    break;

                default:
                    throw new NotImplementedException("Печать документа не поддерживается");
                }
            }
            var printer = new DocumentPrinter(PrinterSettings);

            printer.DocumentsPrinted += (sender, e) => DocumentsPrinted?.Invoke(sender, e);
            printer.PrintingCanceled += (sender, e) => PrintingCanceled?.Invoke(sender, e);
            if (rdlToPrinter.Count > 0)
            {
                printer.PrintAll(rdlToPrinter);
            }
            DocumentPrinters.ImagePrinter?.Print(imgToPrinter.ToArray(), printer.PrintSettings);
            DocumentPrinters.OdtDocPrinter?.Print(odtToPrinter.ToArray(), printer.PrintSettings);
            PrinterSettings = printer.PrintSettings;
        }
예제 #3
0
        void Configure()
        {
            ytreeviewDocuments.ColumnsConfig = ColumnsConfigFactory.Create <SelectablePrintDocument>()
                                               .AddColumn("✓").AddToggleRenderer(x => x.Selected)
                                               .AddColumn("Документ").AddTextRenderer(x => x.Document.Name)
                                               .AddColumn("Копий").AddNumericRenderer(x => x.Copies).Editing()
                                               .Adjustment(new Adjustment(0, 0, 10000, 1, 100, 0))
                                               .RowCells()
                                               .Finish();

            ytreeviewDocuments.ItemsDataSource = _entityDocumentsPrinter.MultiDocPrinterPrintableDocuments;

            DefaultPreviewDocument();
            _entityDocumentsPrinter.DocumentsPrinted += (o, args) => DocumentsPrinted?.Invoke(o, args);
        }
예제 #4
0
        public void PrintAll(IEnumerable <IPrintableDocument> documents)
        {
            PrintSettings = null;
            if (Environment.OSVersion.Platform != PlatformID.MacOSX && Environment.OSVersion.Platform != PlatformID.Unix)
            {
                PrintSettings = PrintAll_Win_Workaround(documents);
                return;
            }

            PrintOperation printOp;

            printOp              = new PrintOperation();
            printOp.Unit         = Unit.Points;
            printOp.UseFullPage  = true;
            printOp.ShowProgress = true;
            var documentsRDL          = documents.Where(doc => doc.PrintType == PrinterType.RDL).ToList();
            BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL);

            var result = LongOperationDlg.StartOperation(
                renderer.PrepareDocuments,
                "Подготовка к печати...",
                documentsRDL.Count()
                );

            if (result == LongOperationResult.Canceled)
            {
                PrintSettings = new PrintSettings();
                return;
            }

            printOp.NPages = renderer.PageCount;
            if (documentsRDL.Any(x => x.Orientation == DocumentOrientation.Landscape))
            {
                printOp.RequestPageSetup += renderer.RequestPageSetup;
            }

            printOp.DrawPage += renderer.DrawPage;
            printOp.EndPrint += (o, args) => {
                args.Args = documentsRDL.ToArray();
                DocumentsPrinted?.Invoke(o, args);
            };
            printOp.Run(PrintOperationAction.PrintDialog, null);
            PrintSettings = printOp.PrintSettings;
        }
예제 #5
0
 void DocPrinterInit()
 {
     MultiDocPrinter = new MultipleDocumentPrinter {
         PrintableDocuments = new GenericObservableList <SelectablePrintDocument>(DocumentsToPrint)
     };
     MultiDocPrinter.DocumentsPrinted += (o, args) => {
         //если среди распечатанных документов есть МЛ, то выставляем его соответствующий признак в true
         if (args is EndPrintArgs endPrintArgs && endPrintArgs.Args.Cast <IPrintableDocument>().Any(d => d.Name == RouteListPrintableDocuments.RouteList.GetEnumTitle()))
         {
             using (IUnitOfWork uow = UnitOfWorkFactory.CreateWithoutRoot()) {
                 var rl = uow.GetById <RouteList>(currentRouteList.Id);
                 rl.Printed = true;
                 uow.Save(rl);
                 uow.Commit();
             }
             uow?.Session?.Refresh(currentRouteList);
         }
         DocumentsPrinted?.Invoke(o, args);
     };
     MultiDocPrinter.PrintingCanceled += (o, args) => PrintingCanceled?.Invoke(o, args);
 }
예제 #6
0
 void Reportviewer_ReportPrinted(object sender, EventArgs e) => DocumentsPrinted?.Invoke(this, new EndPrintArgs {
     Args = new[] { _selectedDocument.Document }
 });
예제 #7
0
 void MultipleDocumentPrinter_DocumentsPrinted(object o, EventArgs args)
 {
     DocumentsPrinted?.Invoke(o, args);
 }
예제 #8
0
        /// <summary>
        /// Альтернативная релализация печати, специально для обхода бага в кайро при поворачивании(со старой реализацией печати пол Linux)
        /// https://bugzilla.mozilla.org/show_bug.cgi?id=1205854#c16
        /// В новой при установке ориентации для каждой странице на большенстве принтеров обрезается часть выходящая за поворот. Хотя ориентация правильная.
        /// На некоторых принтерах например в водовозе, табличка рисуется за вертикалью листа а текст нет.
        /// используется только на винде, в линуксе такой проблемы нет.
        /// </summary>
        private PrintSettings PrintAll_Win_Workaround(IEnumerable <IPrintableDocument> documents)
        {
            PrintOperation printOp       = null;
            PrintSettings  printSettings = null;

            var documentsRDL_Portrait  = documents.Where(doc => doc.PrintType == PrinterType.RDL && doc.Orientation == DocumentOrientation.Portrait).ToList();
            var documentsRDL_Landscape = documents.Where(doc => doc.PrintType == PrinterType.RDL && doc.Orientation == DocumentOrientation.Landscape).ToList();

            if (!documents.Any())
            {
                printOp = new PrintOperation();
                printOp.Run(PrintOperationAction.PrintDialog, null);
                return(printOp.PrintSettings);
            }

            if (documentsRDL_Portrait.Any())
            {
                printOp                              = new PrintOperation();
                printOp.Unit                         = Unit.Points;
                printOp.UseFullPage                  = true;
                printOp.ShowProgress                 = true;
                printOp.DefaultPageSetup             = new PageSetup();
                printOp.DefaultPageSetup.Orientation = PageOrientation.Portrait;

                BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL_Portrait);

                var result = LongOperationDlg.StartOperation(
                    renderer.PrepareDocuments,
                    "Подготовка к печати портретных страниц...",
                    documentsRDL_Portrait.Count()
                    );
                if (result == LongOperationResult.Canceled)
                {
                    return(new PrintSettings());
                }

                printOp.NPages = renderer.PageCount;

                printOp.DrawPage += renderer.DrawPage;
                printOp.EndPrint += (o, args) => {
                    args.Args = documentsRDL_Portrait.Concat(documentsRDL_Landscape).ToArray();
                    DocumentsPrinted?.Invoke(o, args);
                };
                printOp.Run(PrintOperationAction.PrintDialog, null);
                printSettings = printOp.PrintSettings;
            }

            if (documentsRDL_Landscape.Any())
            {
                printOp                  = new PrintOperation();
                printOp.Unit             = Unit.Points;
                printOp.UseFullPage      = true;
                printOp.ShowProgress     = true;
                printOp.DefaultPageSetup = new PageSetup();

                //если printSettings == null, то значит, до этого не печатались RDL формата
                //PageOrientation.Portrait и, соответственно, не показывался PrintDialog и
                //нужно показать его сейчас.
                PrintOperationAction printOperationAction = PrintOperationAction.PrintDialog;
                if (printSettings != null)
                {
                    printOp.PrintSettings             = printSettings;
                    printOp.PrintSettings.Orientation = PageOrientation.Landscape;
                    printOperationAction = PrintOperationAction.Print;
                }
                printOp.DefaultPageSetup.Orientation = PageOrientation.Landscape;

                BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL_Landscape);

                var result = LongOperationDlg.StartOperation(
                    renderer.PrepareDocuments,
                    "Подготовка к печати альбомных страниц...",
                    documentsRDL_Landscape.Count()
                    );
                if (result == LongOperationResult.Canceled)
                {
                    return(new PrintSettings());
                }

                printOp.NPages    = renderer.PageCount;
                printOp.DrawPage += renderer.DrawPage;
                printOp.EndPrint += (o, args) => {
                    args.Args = documentsRDL_Portrait.Concat(documentsRDL_Landscape).ToArray();
                    DocumentsPrinted?.Invoke(o, args);
                };
                printOp.Run(printOperationAction, null);
            }
            return(printOp.PrintSettings);
        }
예제 #9
0
 private void Configure()
 {
     EntityDocumentsPrinter.DocumentsPrinted += (o, args) => DocumentsPrinted?.Invoke(o, args);
 }
예제 #10
0
 public void ReportViewerOnReportPrinted(object o, EventArgs args) => DocumentsPrinted?.Invoke(o, args);