Пример #1
0
        private ReceiptPrintJob GetCustomerFooter(ClaimedPosPrinter printer)
        {
            ReceiptPrintJob customerFooter = printer.Receipt.CreateJob();

            customerFooter.PrintLine();
            customerFooter.PrintLine("______________________");
            customerFooter.PrintLine("Tip");
            customerFooter.PrintLine();
            customerFooter.PrintLine("Customer Copy");
            LineFeedAndCutPaper(customerFooter);

            return(customerFooter);
        }
        private async Task <bool> PrintLine(string message, ClaimedPosPrinter claimedPrinter)
        {
            if (claimedPrinter == null)
            {
                rootPage.NotifyUser("Claimed printer object is null. Cannot print.", NotifyType.ErrorMessage);
                return(false);
            }

            if (claimedPrinter.Receipt == null)
            {
                rootPage.NotifyUser("No receipt printer object in claimed printer.", NotifyType.ErrorMessage);
                return(false);
            }

            ReceiptPrintJob job = claimedPrinter.Receipt.CreateJob();

            job.PrintLine(message);
            if (await job.ExecuteAsync())
            {
                rootPage.NotifyUser("Printed line", NotifyType.StatusMessage);
                return(true);
            }
            rootPage.NotifyUser("Was not able to print line", NotifyType.StatusMessage);
            return(false);
        }
Пример #3
0
        /// <summary>
        /// Prints the line that is in the textbox.
        /// </summary>
        async void PrintLine_Click()
        {
            if (!IsPrinterClaimed())
            {
                return;
            }

            ReceiptPrintJob job = rootPage.ClaimedPrinter.Receipt.CreateJob();

            job.PrintLine(PrintLineTextBox.Text);
            await ExecuteJobAndReportResultAsync(job);
        }
Пример #4
0
        private ReceiptPrintJob GetMerchantFooter(ClaimedPosPrinter printer)
        {
            ReceiptPrintJob merchantFooter = printer.Receipt.CreateJob();

            merchantFooter.PrintLine();
            merchantFooter.PrintLine("______________________");
            merchantFooter.PrintLine("Tip");
            merchantFooter.PrintLine();
            merchantFooter.PrintLine("______________________");
            merchantFooter.PrintLine("Signature");
            merchantFooter.PrintLine();
            merchantFooter.PrintLine("Merchant Copy");
            LineFeedAndCutPaper(merchantFooter);

            return(merchantFooter);
        }
Пример #5
0
        // Cut the paper after printing enough blank lines to clear the paper cutter.
        private void LineFeedAndCutPaper(ReceiptPrintJob job)
        {
            if (IsPrinterClaimed())
            {
                for (uint n = 0; n < claimedPrinter.Receipt.LinesToPaperCut; n++)
                {
                    job.PrintLine();
                }

                if (printer.Capabilities.Receipt.CanCutPaper)
                {
                    job.CutPaper();
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Prints a sample receipt.
        /// </summary>
        private async Task <bool> PrintReceipt(Dictionary <string, double> receiptItems)
        {
            if (!IsPrinterClaimed())
            {
                return(false);
            }

            ReceiptPrintJob job = claimedPrinter.Receipt.CreateJob();

            job.PrintLine("======================");
            job.PrintLine("|   Sample Header    |");
            job.PrintLine("======================");

            job.PrintLine("Item             Price");
            job.PrintLine("----------------------");
            double total = 0.0;

            foreach (KeyValuePair <string, double> item in receiptItems)
            {
                job.PrintLine(string.Format("{0,-15} {1,6:##0.00}", item.Key, item.Value));
                total += item.Value;
            }
            job.PrintLine("----------------------");
            job.PrintLine(string.Format("Total-----------{0,6:##0.00}", total));

            ReceiptPrintJob merchantFooter = GetMerchantFooter(claimedPrinter);
            ReceiptPrintJob customerFooter = GetCustomerFooter(claimedPrinter);

            // execute print jobs
            // Note that we actually execute "job" twice in order to print
            // the statement for both the customer as well as the merchant.

            if (!await job.ExecuteAsync() ||
                !await customerFooter.ExecuteAsync() ||
                !await job.ExecuteAsync() ||
                !await merchantFooter.ExecuteAsync())
            {
                rootPage.NotifyUser("Failed to print receipts.", NotifyType.ErrorMessage);
                return(false);
            }
            rootPage.NotifyUser("Printed receipts.", NotifyType.StatusMessage);
            return(true);
        }
        private async Task <bool> PrintLine()
        {
            if (!IsPrinterClaimed())
            {
                return(false);
            }
            ReceiptPrintJob job = claimedPrinter.Receipt.CreateJob();

            job.PrintLine(txtPrintLine.Text);

            if (await job.ExecuteAsync())
            {
                rootPage.NotifyUser("Printed line", NotifyType.StatusMessage);
                return(true);
            }
            rootPage.NotifyUser("Was not able to print line", NotifyType.StatusMessage);
            return(false);
        }
        /// <summary>
        /// Prints the line that is in the textbox. Then checks for any error conditions and reports the same to user.
        /// </summary>
        private async Task <bool> PrintLineAndCheckForErrors()
        {
            if (!IsPrinterClaimed())
            {
                return(false);
            }
            ReceiptPrintJob job = claimedPrinter.Receipt.CreateJob();

            job.PrintLine(txtPrintLine.Text);

            if (await job.ExecuteAsync())
            {
                rootPage.NotifyUser("Printed line", NotifyType.StatusMessage);
                return(true);
            }
            else
            {
                if (claimedPrinter.Receipt.IsCartridgeEmpty)
                {
                    rootPage.NotifyUser("Printer is out of ink. Please replace cartridge.", NotifyType.StatusMessage);
                }
                else if (claimedPrinter.Receipt.IsCartridgeRemoved)
                {
                    rootPage.NotifyUser("Printer cartridge is missing. Please replace cartridge.", NotifyType.StatusMessage);
                }
                else if (claimedPrinter.Receipt.IsCoverOpen)
                {
                    rootPage.NotifyUser("Printer cover is open. Please close it.", NotifyType.StatusMessage);
                }
                else if (claimedPrinter.Receipt.IsHeadCleaning)
                {
                    rootPage.NotifyUser("Printer is currently cleaning the cartridge. Please wait until cleaning has completed.", NotifyType.StatusMessage);
                }
                else if (claimedPrinter.Receipt.IsPaperEmpty)
                {
                    rootPage.NotifyUser("Printer is out of paper. Please insert a new roll.", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Was not able to print line", NotifyType.StatusMessage);
                }
            }
            return(false);
        }