Beispiel #1
0
        /// <summary>
        /// Sample : Creating printing receipt and open cash drawer commands.
        /// </summary>
        private byte[] CreateLocalizeReceiptAndOpenCashDrawerCommands(ReceiptInformationManager receiptInfo)
        {
            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            // print paper size
            int paperSize = SharedInformationManager.GetSelectedActualPaperSize();

            // Creating localize receipt commands sample is in "LocalizeReceipts/'Language'Receipt.cs"
            ReceiptInformationManager.ReceiptType type = receiptInfo.Type;
            LocalizeReceipt localizeReceipt            = receiptInfo.LocalizeReceipt;

            byte[] commands;

            switch (type)
            {
            default:
            case ReceiptInformationManager.ReceiptType.Text:
                commands = CombinationFunctions.CreateTextReceiptData(emulation, localizeReceipt, false);
                break;

            case ReceiptInformationManager.ReceiptType.TextUTF8:
                commands = CombinationFunctions.CreateTextReceiptData(emulation, localizeReceipt, true);
                break;

            case ReceiptInformationManager.ReceiptType.Raster:
                commands = CombinationFunctions.CreateRasterReceiptData(emulation, localizeReceipt);
                break;

            case ReceiptInformationManager.ReceiptType.RasterBothScale:
                commands = CombinationFunctions.CreateScaleRasterReceiptData(emulation, localizeReceipt, paperSize, true);
                break;

            case ReceiptInformationManager.ReceiptType.RasterScale:
                commands = CombinationFunctions.CreateScaleRasterReceiptData(emulation, localizeReceipt, paperSize, false);
                break;

            case ReceiptInformationManager.ReceiptType.RasterCoupon:
                commands = CombinationFunctions.CreateCouponData(emulation, localizeReceipt, paperSize, BitmapConverterRotation.Normal);
                break;

            case ReceiptInformationManager.ReceiptType.RasterCouponRotation90:
                commands = CombinationFunctions.CreateCouponData(emulation, localizeReceipt, paperSize, BitmapConverterRotation.Right90);
                break;
            }

            return(commands);
        }
Beispiel #2
0
        /// <summary>
        /// Sample : Creating printing receipt with page mode commands.
        /// </summary>
        public static byte[] CreateLocalizeReceiptWithPageModeCommands(ReceiptInformationManager receiptInfo)
        {
            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            // Creating localize receipt commands sample is in "LocalizeReceipts/'Language'Receipt.cs"
            LocalizeReceipt localizeReceipt = receiptInfo.LocalizeReceipt;

            // Image height.
            int height = 30 * 8;

            // Image width.
            int width = SharedInformationManager.GetSelectedActualPaperSize();

            // Image rotation.
            BitmapConverterRotation rotation = receiptInfo.Rotation;

            // Print region.
            Rectangle printRegion;

            switch (rotation)
            {
            default:
            case BitmapConverterRotation.Normal:
                printRegion = new Rectangle(0, 0, width, height);
                break;

            case BitmapConverterRotation.Right90:
                printRegion = new Rectangle(0, 0, width, width);
                break;

            case BitmapConverterRotation.Rotate180:
                printRegion = new Rectangle(0, 0, width, height);
                rotation    = BitmapConverterRotation.Rotate180;
                break;

            case BitmapConverterRotation.Left90:
                printRegion = new Rectangle(0, 0, height, width);
                break;
            }

            byte[] commands = PrinterFunctions.CreateTextPageModeData(emulation, localizeReceipt, printRegion, rotation, false);

            return(commands);
        }
        /// <summary>
        /// Sample : Printing photo from image file.
        /// </summary>
        public static void PrintPhotoFromLibrary()
        {
            // Get printing file path.
            string filePath = ShowSelectImageFileDialog();

            if (filePath == null)
            {
                return;
            }

            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            // print paper size
            int paperSize = SharedInformationManager.GetSelectedActualPaperSize();

            byte[] commands = PrinterFunctions.CreateFileOpenData(emulation, filePath, paperSize);

            Print(commands);
        }
        /// <summary>
        /// Sample : Creating API commands.
        /// </summary>
        private static byte[] CreateAPICommands(APIManager.APIType type)
        {
            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            // Your printer paper size.
            int paperSize = SharedInformationManager.GetSelectedActualPaperSize();

            byte[] commands;

            switch (type)
            {
            default:
            case APIManager.APIType.Generic:
                commands = APIFunctions.CreateGenericData(emulation);
                break;

            case APIManager.APIType.FontStyle:
                commands = APIFunctions.CreateFontStyleData(emulation);
                break;

            case APIManager.APIType.Initialization:
                commands = APIFunctions.CreateInitializationData(emulation);
                break;

            case APIManager.APIType.CodePage:
                commands = APIFunctions.CreateCodePageData(emulation);
                break;

            case APIManager.APIType.International:
                commands = APIFunctions.CreateInternationalData(emulation);
                break;

            case APIManager.APIType.Feed:
                commands = APIFunctions.CreateFeedData(emulation);
                break;

            case APIManager.APIType.CharacterSpace:
                commands = APIFunctions.CreateCharacterSpaceData(emulation);
                break;

            case APIManager.APIType.LineSpace:
                commands = APIFunctions.CreateLineSpaceData(emulation);
                break;

            case APIManager.APIType.Emphasis:
                commands = APIFunctions.CreateEmphasisData(emulation);
                break;

            case APIManager.APIType.Invert:
                commands = APIFunctions.CreateInvertData(emulation);
                break;

            case APIManager.APIType.UnderLine:
                commands = APIFunctions.CreateUnderLineData(emulation);
                break;

            case APIManager.APIType.Multiple:
                commands = APIFunctions.CreateMultipleData(emulation);
                break;

            case APIManager.APIType.AbsolutePosition:
                commands = APIFunctions.CreateAbsolutePositionData(emulation);
                break;

            case APIManager.APIType.Alignment:
                commands = APIFunctions.CreateAlignmentData(emulation);
                break;

            case APIManager.APIType.Logo:
                commands = APIFunctions.CreateLogoData(emulation);
                break;

            case APIManager.APIType.CutPaper:
                commands = APIFunctions.CreateCutPaperData(emulation);
                break;

            case APIManager.APIType.Peripheral:
                commands = APIFunctions.CreatePeripheralData(emulation);
                break;

            case APIManager.APIType.Sound:
                commands = APIFunctions.CreateSoundData(emulation);
                break;

            case APIManager.APIType.Bitmap:
                commands = APIFunctions.CreateBitmapData(emulation, paperSize);
                break;

            case APIManager.APIType.Barcode:
                commands = APIFunctions.CreateBarcodeData(emulation);
                break;

            case APIManager.APIType.Pdf417:
                commands = APIFunctions.CreatePdf417Data(emulation);
                break;

            case APIManager.APIType.QrCode:
                commands = APIFunctions.CreateQrCodeData(emulation);
                break;

            case APIManager.APIType.BlackMark:
                // Select black mark type.
                BlackMarkType?blackmarkType = ShowSelectBlackMarkTypeWindow();

                if (blackmarkType == null)
                {
                    return(null);
                }

                commands = APIFunctions.CreateBlackMarkData(emulation, (BlackMarkType)blackmarkType);
                break;

            case APIManager.APIType.PageMode:
                commands = APIFunctions.CreatePageModeData(emulation, paperSize);
                break;
            }

            return(commands);
        }