Files
Print_server/Inspectron.Epson/PrintServer/Printers/TM-T30IIITranslated.cs
EugeneTes 5ee95c8109 1.0.12
2026-04-03 08:38:32 +02:00

85 lines
2.4 KiB
C#

using Inspectron.Epson.PrintServer.Printers.Utils;
using Inspectron.Epson.PrintServer.PrintServices;
namespace Inspectron.Epson.PrintServer.Printers;
public class TM_T30IIITranslated : IPrinter
{
private readonly IEpsonPrinter _printer;
public bool SkipDelays { get; set; }
public TM_T30IIITranslated(IEpsonPrinter printer)
{
_printer = printer;
}
public Task InitAsync()
{
return _printer.InitAsync();
}
public async Task PrintImageAsync(string path)
{
await _printer.FeedLinesAsync(1);
await _printer.SetAbsolutePrintPosition(100);
await _printer.LoadImageAsync(path, 384);
if (!SkipDelays) await Task.Delay(100);
if (_printer is HtmlPrinter)
{
await _printer.PrintLoadedImage();
}
await _printer.FeedLinesAsync(1);
await _printer.SetAbsolutePrintPosition(0);
}
public async Task SetFontSizeAsync(int fontSize)
{
//await _printer.SetFontSizeAsync(fontSize, fontSize);
}
public async Task PrintAsync(List<PrintCommand> commands)
{
await _printer.SetCustomLineSpacing(22);
foreach (var command in commands)
{
if (command.IsCut)
{
await _printer.FeedLinesAsync(10);
await _printer.CutAsync(false);
continue;
}
if(command.SetLineSpacing.HasValue)
{
Console.WriteLine($"Setting line spacing to {command.SetLineSpacing.Value}");
await _printer.SetCustomLineSpacing(command.SetLineSpacing.Value);
Console.WriteLine($"------------------------------------------------------");
continue;
}
await _printer.SetFontSizeAsync(command.IsBig?2:1, command.IsTall?2:1);
//if (command.IsBig)
//{
// await _printer.SetFontSizeAsync(2, 1);
//}
//else
//{
// await _printer.SetFontSizeAsync(1, 1);
//}
await _printer.SetEmphasized(command.IsBold);
await _printer.PrintTextAsync(command.Text + "\n");
}
await _printer.SetDefaultLineSpacing();
await _printer.FeedLinesAsync(10);
if (!SkipDelays) await Task.Delay(200);
}
public async Task Cut()
{
await _printer.CutAsync();
if (!SkipDelays) await Task.Delay(200);
}
}