Ejemplo n.º 1
0
        public static byte[] CreatePasteTextBlackMarkData(Emulation emulation, LocalizeReceipt localizeReceipt, string pasteText, bool doubleHeight, BlackMarkType type, bool utf8)
        {
            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            builder.AppendBlackMark(type);

            if (doubleHeight)
            {
                builder.AppendMultipleHeight(2);

                localizeReceipt.AppendPasteTextLabelData(builder, pasteText, utf8);

                builder.AppendMultipleHeight(1);
            }
            else
            {
                localizeReceipt.AppendPasteTextLabelData(builder, pasteText, utf8);
            }

            builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            builder.EndDocument();

            return(builder.Commands);
        }
        private void PrintReceiptViaPrinterDriverWithProgressBar()
        {
            string portName = SharedInformationManager.GetSelectedPortName();

            PrintQueue[]    printQueues     = starPrintPortJobMonitor.PrintQueues;
            LocalizeReceipt localizeReceipt = SharedInformationManager.GetSelectedLocalizeReceipt();

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                Thread thread = new Thread(
                    () =>
                {
                    foreach (PrintQueue printQueue in printQueues)
                    {
                        PrinterDriverManager.PrintViaPrinterDriver(printQueue, localizeReceipt.CreateRasterImageText(), localizeReceipt.RasterReceiptFont);
                    }
                });

                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();
            });

            progressBarWindow.ShowDialog();

            Util.FocusMainWindow();
        }
Ejemplo n.º 3
0
        public static byte[] CreateTextReceiptData(Emulation emulation, LocalizeReceipt localizeReceipt, int width, bool utf8, bool receipt, bool info, bool qrCode)
        {
            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            localizeReceipt.AppendTextReceiptData(builder, utf8);

            builder.EndDocument();

            byte[] receiptsData = builder.Commands;

            byte[] urlData = SMCSAllReceipts.UploadData(receiptsData, emulation, localizeReceipt.CharacterCode, width);

            ICommandBuilder printDataBuilder = StarIoExt.CreateCommandBuilder(emulation);

            printDataBuilder.BeginDocument();

            if (receipt)
            {
                localizeReceipt.AppendTextReceiptData(printDataBuilder, utf8);
            }

            byte[] allReceiptsData = SMCSAllReceipts.GenerateAllReceipts(urlData, emulation, info, qrCode);

            printDataBuilder.AppendRaw(allReceiptsData);

            printDataBuilder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            printDataBuilder.EndDocument();

            return(printDataBuilder.Commands);
        }
Ejemplo n.º 4
0
        public static byte[] CreateScaleRasterReceiptData(Emulation emulation, LocalizeReceipt localizeReceipt, int width, bool bothScale, bool receipt, bool info, bool qrCode)
        {
            Bitmap image = localizeReceipt.CreateScaleRasterReceiptImage();

            byte[] urlData = SMCSAllReceipts.UploadBitmap(image);

            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            if (receipt)
            {
                builder.AppendBitmap(image, false, width, bothScale);
            }

            byte[] allReceiptsData;
            if (emulation == Emulation.StarGraphic)
            {
                allReceiptsData = SMCSAllReceipts.GenerateAllReceipts(urlData, emulation, info, qrCode, width); // Support to centering in Star Graphic.
            }
            else
            {
                allReceiptsData = SMCSAllReceipts.GenerateAllReceipts(urlData, emulation, info, qrCode);// Non support to centering in Star Graphic.
            }

            builder.AppendRaw(allReceiptsData);

            builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            builder.EndDocument();

            return(builder.Commands);
        }
        public static LocalizeReceipt CreateLocalizeReceipt(ReceiptInformationManager receiptInformationManager)
        {
            LocalizeReceipt localizeReceipts = null;

            switch (receiptInformationManager.LanguageType)
            {
            case LanguageType.English:
                localizeReceipts = new EnglishReceipt();
                break;

            case LanguageType.Japanese:
                localizeReceipts = new JapaneseReceipt();
                break;

            case LanguageType.French:
                localizeReceipts = new FrenchReceipt();
                break;

            case LanguageType.Portuguese:
                localizeReceipts = new PortugueseReceipt();
                break;

            case LanguageType.Spanish:
                localizeReceipts = new SpanishReceipt();
                break;

            case LanguageType.German:
                localizeReceipts = new GermanReceipt();
                break;

            case LanguageType.Russian:
                localizeReceipts = new RussianReceipt();
                break;

            case LanguageType.SimplifiedChinese:
                localizeReceipts = new SimplifiedChineseReceipt();
                break;

            case LanguageType.TraditionalChinese:
                localizeReceipts = new TraditionalChineseReceipt();
                break;

            case LanguageType.Utf8MultiLanguage:
                localizeReceipts = new Utf8MultiLanguageReceipt();
                break;
            }

            localizeReceipts.ReceiptInformationManager = receiptInformationManager;

            return(localizeReceipts);
        }
Ejemplo n.º 6
0
        public static byte[] CreateTextReceiptData(Emulation emulation, LocalizeReceipt localizeReceipt, bool utf8)
        {
            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            localizeReceipt.AppendTextReceiptData(builder, utf8);

            builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            builder.EndDocument();

            return(builder.Commands);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public static byte[] CreateCouponData(Emulation emulation, LocalizeReceipt localizeReceipt, int width, BitmapConverterRotation rotation)
        {
            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            Bitmap rasterImage = localizeReceipt.CreateCouponImage();

            builder.AppendBitmap(rasterImage, false, width, true, rotation);

            builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            builder.EndDocument();

            return(builder.Commands);
        }
Ejemplo n.º 9
0
        public static byte[] CreateScaleRasterReceiptData(Emulation emulation, LocalizeReceipt localizeReceipt, int width, bool bothScale)
        {
            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            Bitmap rasterImage = localizeReceipt.CreateScaleRasterReceiptImage();

            builder.AppendBitmap(rasterImage, false, width, bothScale);

            builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            builder.EndDocument();

            return(builder.Commands);
        }
        /// <summary>
        /// Sample : Creating printing receipt with AllReceipts commands.
        /// </summary>
        public static byte[] CreateLocalizeReceiptWithAllReceiptsCommands(ReceiptInformationManager receiptInfo)
        {
            byte[] commands;

            // Your printer emulation.
            Emulation emulation = SharedInformationManager.SelectedEmulation;

            // print paper size
            int paperSize = receiptInfo.ActualPaperSize;

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

            // Select printing contents.
            bool printReceipt     = SharedInformationManager.AllReceiptsPrintReceipt;
            bool printInformation = SharedInformationManager.AllReceiptsPrintInformation;
            bool printQrCode      = SharedInformationManager.AllReceiptsPrintQrCode;

            switch (type)
            {
            default:
            case ReceiptInformationManager.ReceiptType.Text:
                commands = AllReceiptsFunctions.CreateTextReceiptData(emulation, localizeReceipt, paperSize, false, printReceipt, printInformation, printQrCode);
                break;

            case ReceiptInformationManager.ReceiptType.TextUTF8:
                commands = AllReceiptsFunctions.CreateTextReceiptData(emulation, localizeReceipt, paperSize, true, printReceipt, printInformation, printQrCode);
                break;

            case ReceiptInformationManager.ReceiptType.Raster:
                commands = AllReceiptsFunctions.CreateRasterReceiptData(emulation, localizeReceipt, paperSize, printReceipt, printInformation, printQrCode);
                break;

            case ReceiptInformationManager.ReceiptType.RasterBothScale:
                commands = AllReceiptsFunctions.CreateScaleRasterReceiptData(emulation, localizeReceipt, paperSize, true, printReceipt, printInformation, printQrCode);
                break;

            case ReceiptInformationManager.ReceiptType.RasterScale:
                commands = AllReceiptsFunctions.CreateScaleRasterReceiptData(emulation, localizeReceipt, paperSize, false, printReceipt, printInformation, printQrCode);
                break;
            }

            return(commands);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Sample : Creating printing receipt with page mode commands.
        /// </summary>
        public static byte[] CreateLocalizeReceiptWithPageModeCommands(ReceiptInformationManager receiptInfo)
        {
            // Your printer emulation.
            Emulation emulation = SharedInformationManager.SelectedEmulation;

            // 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.SelectedActualPaperSize;

            // 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);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Sample : Creating printing paste text with black mark commands.
        /// </summary>
        private byte[] CreatePrintBlackMarkPasteTextCommands(string pasteText)
        {
            // Your printer emulation.
            Emulation emulation = SharedInformationManager.SelectedEmulation;

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

            // Select using double height.
            bool doubleHeight = (bool)doubleHeightCheckBox.IsChecked;

            // Select black mark type.
            BlackMarkType blackMarkType = SharedInformationManager.SelectedBlackMarkType;

            byte[] commands = PrinterFunctions.CreatePasteTextBlackMarkData(emulation, localizeReceipt, pasteText, doubleHeight, blackMarkType, false);

            return(commands);
        }
Ejemplo n.º 13
0
        public static byte[] CreateTextPageModeData(Emulation emulation, LocalizeReceipt localizeReceipt, Rectangle printRegion, BitmapConverterRotation rotation, bool utf8)
        {
            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            builder.BeginPageMode(printRegion, rotation);

            localizeReceipt.AppendTextLabelData(builder, utf8);

            builder.EndPageMode();

            builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            builder.EndDocument();

            return(builder.Commands);
        }
Ejemplo n.º 14
0
        public static byte[] CreateRasterReceiptData(Emulation emulation, LocalizeReceipt localizeReceipt)
        {
            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            Bitmap rasterImage = localizeReceipt.CreateRasterReceiptImage();

            builder.AppendBitmap(rasterImage, false);

            builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            builder.AppendPeripheral(PeripheralChannel.No1);

            builder.EndDocument();

            return(builder.Commands);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Sample : Creating printing receipt with black mark commands.
        /// </summary>
        public static byte[] CreateLocalizeReceiptWithBlackMarkCommands(ReceiptInformationManager receiptInfo)
        {
            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            // Select black mark type.
            BlackMarkType blackMarkType = SharedInformationManager.GetSelectedBlackMarkType();

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

            byte[] commands;

            switch (receiptInfo.Type)
            {
            default:
            case ReceiptInformationManager.ReceiptType.Text:
                commands = PrinterFunctions.CreateTextBlackMarkData(emulation, localizeReceipt, blackMarkType, false);
                break;
            }

            return(commands);
        }