67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using Inspectron.Epson.PrintServer.Printers.Utils;
|
|
using Inspectron.Epson.PrintServer.PrintServices;
|
|
using System.Reflection;
|
|
|
|
namespace Inspectron.Epson.PrintServer.Printers;
|
|
|
|
public class TM_U220IITranslated:IPrinter
|
|
{
|
|
private readonly EpsonPrinter _printer;
|
|
|
|
public TM_U220IITranslated(EpsonPrinter printer)
|
|
{
|
|
_printer = printer;
|
|
}
|
|
|
|
public async Task InitAsync()
|
|
{
|
|
await _printer.InitAsync();
|
|
await Task.Delay(200);
|
|
}
|
|
|
|
public Task PrintImageAsync(string path)
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public async Task SetFontSizeAsync(int fontSize)
|
|
{
|
|
//await _printer.SetBiggerFontTM220(fontSize == 2);
|
|
//await Task.Delay(200);
|
|
//await _printer.SelectFont(EpsonCommands.PrinterFont.A);
|
|
//await Task.Delay(200);
|
|
}
|
|
|
|
public async Task PrintTextAsync(string text)
|
|
{
|
|
ReceiptTranslator translator = new ReceiptTranslator();
|
|
var ast = translator.ParseReceipt(text);
|
|
KitchenReceiptPrinter printer = new KitchenReceiptPrinter(lineWidth:33,21);
|
|
var commands = printer.ConvertToCommands((KitchenReceipt)ast);
|
|
foreach (KitchenPrintCommand command in commands)
|
|
{
|
|
await _printer.SetBiggerFontTM220(command.IsBig);
|
|
await Task.Delay(200);
|
|
await _printer.SetRedColor(command.IsRed);
|
|
await Task.Delay(200);
|
|
await _printer.SetEmphasized(command.IsBold);
|
|
await Task.Delay(200);
|
|
await _printer.PrintTextAsync(command.Text + "\n");
|
|
await Task.Delay(200);
|
|
}
|
|
//await _printer.PrintTextAsync(text);
|
|
//var lines = text.Split('\n').Length;
|
|
//for (int i = 0; i < lines; i++)
|
|
//{
|
|
// await Task.Delay(200);
|
|
//}
|
|
await _printer.FeedLinesAsync(10);
|
|
await Task.Delay(1000);
|
|
}
|
|
|
|
public async Task Cut()
|
|
{
|
|
await _printer.CutAsync();
|
|
await Task.Delay(200);
|
|
}
|
|
} |