コード例 #1
0
        private void btnPrint_Clicked(object o, EventArgs args)
        {
            if (!ValidateFilters())
            {
                return;
            }

            DisplayReport();

            if (string.IsNullOrEmpty(txvPreview.Buffer.Text))
            {
                using (MessageError dlgMsg = new MessageError(
                           Translator.GetString("No matches."), "Icons.Report16.png",
                           ErrorSeverity.Information, null)) {
                    dlgMsg.Run();
                }
            }
            else
            {
                try {
                    exportProgress = new MessageProgress(Translator.GetString("Printing report..."), null, null);
                    exportProgress.Show();

                    FormHelper.TryReceiptPrinterCommand(delegate
                    {
                        DeviceManagerBase devMan = BusinessDomain.DeviceManager;
                        ICashReceiptPrinterController printer = devMan.CustomerOrderPrinter as ICashReceiptPrinterController;
                        if (printer != null)
                        {
                            PrintNonFiscal(devMan, printer);
                        }
                        else
                        {
                            IKitchenPrinterController kitchenPrinter = devMan.CustomerOrderPrinter as IKitchenPrinterController;
                            if (kitchenPrinter != null)
                            {
                                PrintKitchen(devMan, kitchenPrinter);
                            }
                        }
                    }, false);
                } finally {
                    exportProgress.Dispose();
                    exportProgress = null;
                }
            }
        }
コード例 #2
0
        private void PrintKitchen(DeviceManagerBase devMan, IKitchenPrinterController kitchenPrinter)
        {
            if (!kitchenPrinter.SupportedCommands.Contains(DeviceCommands.PrintFreeText))
            {
                return;
            }

            KeyValuePair <string, string> [] lines = receiptReport.GetReportLines();
            txvPreview.Buffer.Text = receiptReport.Display(lines);

            devMan.TryDeviceCommand(delegate
            {
                kitchenPrinter.PrintFreeText(receiptReport.Title.AlignCenter(kitchenPrinter.TextCharsPerLine));
                kitchenPrinter.PrintFreeText(DriverBase.SEPARATOR);

                if (kitchenPrinter.SupportedCommands.Contains(DeviceCommands.PaperFeed))
                {
                    kitchenPrinter.PaperFeed();
                }
            });

            for (int i = 0; i < lines.Length; i++)
            {
                if (i % 5 == 0)
                {
                    ShowProgress(((double)i * 100) / lines.Length);
                }

                string key = lines [i].Key;
                string val = lines [i].Value;
                devMan.TryDeviceCommand(() => kitchenPrinter.PrintFreeText(ReceiptReport.GetReportLine(key, val, kitchenPrinter.TextCharsPerLine)));
            }

            if (kitchenPrinter.SupportedCommands.Contains(DeviceCommands.PaperCut))
            {
                devMan.TryDeviceCommand(kitchenPrinter.PaperCut);
            }
        }