Exemplo n.º 1
0
        /// <summary>
        /// Creates a <see cref="PrtRequest"/> configured to notificate the thermal printer
        /// that all items have been sent, and the printer can already beging to print.
        /// </summary>
        /// <returns>The finish printing request.</returns>
        private PrtRequest CreateRequestToFinishPrinting()
        {
            PrtRequest finishPrintingRequest = new PrtRequest();

            // Setup request to finish pinting:
            finishPrintingRequest.PRT_Action.Value = IngenicoPrinterAction.End;

            return(finishPrintingRequest);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a <see cref="PrtRequest"/> configured to notificate the thermal printer
        /// that a printing operation is about to begin.
        /// </summary>
        /// <returns>The printing request.</returns>
        private PrtRequest CreateRequestToStartPrinting()
        {
            PrtRequest startRequest = new PrtRequest();

            // Setup request to start printing:
            startRequest.PRT_Action.Value = IngenicoPrinterAction.Start;

            return(startRequest);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a <see cref="PrtRequest"/> configured with skip lines.
        /// </summary>
        /// <param name="item">Item with skip configuration.</param>
        /// <returns>The skip line request.</returns>
        private PrtRequest CreateRequestToSkipLine(PrinterItem item)
        {
            PrtRequest skipLineRequest = new PrtRequest();

            // Setup request to skip line:
            skipLineRequest.PRT_Action.Value = IngenicoPrinterAction.SkipLine;
            skipLineRequest.PRT_Steps.Value  = item.StepsToSkip;

            return(skipLineRequest);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a <see cref="PrtRequest"/> configured with Stone logotype to print.
        /// </summary>
        /// <returns>The image printing request.</returns>
        private PrtRequest CreateRequestToPrintLogo()
        {
            PrtRequest printImageRequest = new PrtRequest();

            // Setup request to print an image:
            printImageRequest.PRT_Action.Value     = IngenicoPrinterAction.PrintImage;
            printImageRequest.PRT_Horizontal.Value = 1;
            printImageRequest.PRT_DATA.Value       = PrinterLogo.FileName;

            return(printImageRequest);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a <see cref="PrtRequest"/> configured with a text to print.
        /// </summary>
        /// <param name="item">Item with text to print information.</param>
        /// <returns>The text printing request.</returns>
        private PrtRequest CreateRequestToPrintText(PrinterItem item)
        {
            PrtRequest printTextRequest = new PrtRequest();

            // Setup request to print text:
            printTextRequest.PRT_Action.Value    = IngenicoPrinterAction.PrintText;
            printTextRequest.PRT_Alignment.Value = item.Alignment;
            printTextRequest.PRT_Size.Value      = item.FontSize;
            printTextRequest.PRT_DATA.Value      = item.Text;

            return(printTextRequest);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Print all content in printer buffer.
        /// </summary>
        /// <returns>
        /// Whether the printing was successful or not. Also, returns false
        /// if the pinpad has no printer or the printer is not supported by this
        /// application.
        /// </returns>
        public bool Print()
        {
            // If pinpad has no printer, or is not supported by this application,
            // this method must return false.
            if (this.IsSupported == false)
            {
                return(false);
            }

            // Add command to begin printing:
            this.ItemsToPrint.Insert(0, new PrinterItem {
                Type = IngenicoPrinterAction.Start
            });

            // Add command to skip line at the end of the receipt:
            this.ItemsToPrint.Add(new PrinterItem
            {
                Type        = IngenicoPrinterAction.SkipLine,
                StepsToSkip = 8
            });

            // Add command to finish printing:
            this.ItemsToPrint.Add(new PrinterItem {
                Type = IngenicoPrinterAction.End
            });

            foreach (PrinterItem item in this.ItemsToPrint)
            {
                // Get request based on the configured item:
                PrtRequest request = this.GetRequestByType(item);

                if (request == null)
                {
                    return(false);
                }

                // Send the print request to the pinpad and verify whether it was
                // accepted or not:
                bool status = this.Communication.SendRequestAndVerifyResponseCode(request);

                if (status == false)
                {
                    return(false);
                }
            }

            // Clear list of items to print:
            this.ItemsToPrint.Clear();

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a <see cref="PrtRequest"/> configured with a QR code to print.
        /// </summary>
        /// <param name="item">Item with QR code information.</param>
        /// <returns>The QR code printing request.</returns>
        private PrtRequest CreateRequestToPrintQrCode(PrinterItem item)
        {
            PrtRequest printQrCodeRequest = new PrtRequest();

            // Setup request to print a QR code:
            printQrCodeRequest.PRT_Action.Value     = IngenicoPrinterAction.PrintQrCode;
            printQrCodeRequest.PRT_Size.Value       = item.FontSize;
            printQrCodeRequest.PRT_Alignment.Value  = item.Alignment;
            printQrCodeRequest.PRT_Horizontal.Value = 1;
            printQrCodeRequest.PRT_DATA.Value       = item.Text;
            printQrCodeRequest.PRT_DATA.Value       = printQrCodeRequest
                                                      .PRT_DATA.Value;

            return(printQrCodeRequest);
        }