Esempio n. 1
0
        private void PrintNonFiscal(DeviceManagerBase devMan, ICashReceiptPrinterController printer)
        {
            if (!printer.SupportedCommands.Contains(DeviceCommands.OpenNonFiscal) ||
                (!printer.SupportedCommands.Contains(DeviceCommands.PrintTextNonFiscal) &&
                 !printer.SupportedCommands.Contains(DeviceCommands.PrintKeyValueNonFiscal)) ||
                !printer.SupportedCommands.Contains(DeviceCommands.CloseNonFiscal))
            {
                return;
            }

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

            devMan.TryDeviceCommand(delegate
            {
                printer.OpenNonFiscal(false);

                if (printer.SupportedCommands.Contains(DeviceCommands.PrintTitleNonFiscal))
                {
                    printer.PrintTitleNonFiscal(receiptReport.Title);
                }
                else
                {
                    printer.PrintTextNonFiscal(receiptReport.Title.AlignCenter(printer.NonFiscalTextCharsPerLine));
                }

                printer.PrintTextNonFiscal(DriverBase.SEPARATOR);
            });

            if (printer.SupportedCommands.Contains(DeviceCommands.PrintKeyValueNonFiscal))
            {
                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(() => printer.PrintKeyValueNonFiscal(key, val, " "));
                }
            }
            else
            {
                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(() => printer.PrintTextNonFiscal(ReceiptReport.GetReportLine(key, val, printer.NonFiscalTextCharsPerLine)));
                }
            }

            devMan.TryDeviceCommand(printer.CloseNonFiscal);
        }
Esempio n. 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);
            }
        }