public virtual void Dispose(bool isDisplsed)
        {
            if (isDisplsed)
            {
                return;
            }

            if (DocumentPrint != null)
            {
                DocumentPrint.Dispose();
            }

            if (PrintBitmap != null)
            {
                PrintBitmap.Dispose();
            }

            MemoryHepler.FlushMemory();
        }
Ejemplo n.º 2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var      obj = JObject.Load(reader);
            ICommand command;

            switch (obj["Name"].Value <string>())
            {
            case nameof(Barcode):
                command = new Barcode();
                break;

            case nameof(Bitmap):
                command = new Bitmap();
                break;

            case nameof(FeedAndPaperCut):
                command = new FeedAndPaperCut();
                break;

            case nameof(FeedCutAndStamp):
                command = new FeedCutAndStamp();
                break;

            case nameof(FeedLines):
                command = new FeedLines();
                break;

            case nameof(FeedReverse):
                command = new FeedReverse();
                break;

            case nameof(FeedUnits):
                command = new FeedUnits();
                break;

            case nameof(FireStamp):
                command = new FireStamp();
                break;

            case nameof(Line):
                command = new Line();
                break;

            case nameof(PaperCut):
                command = new PaperCut();
                break;

            case nameof(PrintBitmap):
                command = new PrintBitmap();
                break;

            case nameof(PrintBottomLogo):
                command = new PrintBottomLogo();
                break;

            case nameof(PrintTopLogo):
                command = new PrintTopLogo();
                break;

            default:
                throw new NotImplementedException();
            }

            serializer.Populate(obj.CreateReader(), command);
            return(command);
        }
Ejemplo n.º 3
0
        public void Print(FrameworkElement receipt, string transactionId)
        {
            RenderTargetBitmap rtb;
            Bitmap orgBmp;

            Console.WriteLine("{0}: Zebra Print() called.", DateTime.Now.ToString("HH:mm:ss:ffff"));

            string receiptImagePath = string.Empty;
            Mod_XAMLToBitmap_08 converter = new Mod_XAMLToBitmap_08();
            rtb = converter.XAMLToBitmap(receipt, 203.0);
            Console.WriteLine("{0}: Mod_XAMLToBitmap_08 completed.", DateTime.Now.ToString("HH:mm:ss:ffff"));

            // Write to memory stream.
            using (MemoryStream ms = new MemoryStream())
            {
                BmpBitmapEncoder enc = new BmpBitmapEncoder();
                enc.Frames.Add(BitmapFrame.Create(rtb));
                enc.Save(ms);
                orgBmp = new Bitmap(ms);
            }

            Console.WriteLine("{0}: Converting to 1bpp bitmap...", DateTime.Now.ToString("HH:mm:ss:ffff"));
            Bitmap newbmp = BitmapConverter.CopyToBpp(orgBmp, 1);
            Console.WriteLine("{0}: Conversion to 1bpp bitmap completed.", DateTime.Now.ToString("HH:mm:ss:ffff"));
            PrintBitmap printAsync = new PrintBitmap(this.SendToPrinter);
            printAsync.BeginInvoke(newbmp, transactionId, null, null);
        }