public override void DoPrint(string[] lines)
        {
            var document = new FormattedDocument(lines, Printer.CharsPerLine).GetFormattedDocument().ToArray();

            foreach (var line in document)
            {
                var data = line.Contains("<") ? line.Split('<').Where(x => !string.IsNullOrEmpty(x)).Select(x => '<' + x) : line.Split('#');
                foreach (var s in data)
                {
                    if (s.Trim().ToLower() == "<w>")
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                    if (s.ToLower().StartsWith("<lb"))
                    {
                        SerialPortService.WritePort(Printer.ShareName, RemoveTag(s) + "\n\r");
                    }
                    else if (s.ToLower().StartsWith("<xct"))
                    {
                        var lineData = s.ToLower().Replace("<xct", "").Trim(new[] { ' ', '<', '>' });
                        SerialPortService.WriteCommand(Printer.ShareName, lineData, Printer.CodePage);
                    }
                    else
                    {
                        SerialPortService.WritePort(Printer.ShareName, RemoveTag(s), Printer.CodePage);
                    }
                }
            }
            SerialPortService.ResetCache();
        }
示例#2
0
        public override void DoPrint(string[] lines)
        {
            var q    = PrinterInfo.GetPrinter(Printer.ShareName);
            var text = new FormattedDocument(lines, Printer.CharsPerLine).GetFormattedText();

            PrintFlowDocument(q, new FlowDocument(new Paragraph(new Run(text))));
        }
示例#3
0
        public override void DoPrint(string[] lines)
        {
            var q             = PrinterInfo.GetPrinter(Printer.ShareName);
            var text          = new FormattedDocument(lines, Printer.CharsPerLine).GetFormattedText();
            var customPrinter = _printerService.GetCustomPrinter(Printer.CustomPrinterName);

            customPrinter.Process(Printer, text);
        }
示例#4
0
        public string GetPrintingContent(Ticket ticket, string format, int width)
        {
            var lines = _ticketFormatter.GetFormattedTicket(ticket, ticket.Orders, new PrinterTemplate {
                Template = format
            });
            var result = new FormattedDocument(lines, width).GetFormattedText();

            return(result);
        }
        public override void DoPrint(string[] lines)
        {
            Debug.Assert(!string.IsNullOrEmpty(Printer.ShareName));
            var text = new FormattedDocument(lines, Printer.CharsPerLine).GetFormattedText();

            if (!Utility.IsValidFile(Printer.ShareName) || !SaveToFile(Printer.ShareName, text))
            {
                SendToNotepad(Printer, text);
            }
        }
        public override void DoPrint(string[] lines)
        {
            var q    = PrinterInfo.GetPrinter(Printer.ShareName);
            var text = new FormattedDocument(lines, Printer.CharsPerLine).GetFormattedText();
            var run  = new Run(text)
            {
                Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255))
            };

            PrintFlowDocument(q, new FlowDocument(new Paragraph(run)));
        }
示例#7
0
        public override void DoPrint(string[] lines)
        {
            var printer = new LinePrinter(Printer.ShareName, Printer.CharsPerLine, Printer.CodePage);

            printer.StartDocument();

            var formatters = new FormattedDocument(lines, Printer.CharsPerLine).GetFormatters();

            foreach (var formatter in formatters)
            {
                SendToPrinter(printer, formatter);
            }

            printer.Cut();
            printer.EndDocument();
        }
示例#8
0
        public override void DoPrint(string[] lines)
        {
            var text = new FormattedDocument(lines, Printer.CharsPerLine).GetFormattedText();

            DoPrint(new FlowDocument(new Paragraph(new Run(text))));
        }
示例#9
0
        string RenderDocumentBody(FormattedDocument doc)
        {
            var formatter = formatters.Find(doc.BodyFormatterId);

            return(formatter.RenderHtml(doc.Body));
        }