2022-02-17 15:45:42 +00:00
|
|
|
using System.Runtime.Serialization;
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
using ESCPOS_NET.Emitters;
|
|
|
|
|
2022-02-17 17:29:32 +00:00
|
|
|
public class TextInstruction : BaseInstruction
|
2022-02-17 15:45:42 +00:00
|
|
|
{
|
|
|
|
[DataMember(IsRequired = true)]
|
|
|
|
public string? text { get; set; }
|
|
|
|
|
2022-02-17 17:29:32 +00:00
|
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
|
|
|
public Alignment alignment {get; set; } = Alignment.Left;
|
|
|
|
|
2022-02-18 17:48:03 +00:00
|
|
|
public bool underline {get; set; } = false;
|
|
|
|
|
2022-02-17 15:45:42 +00:00
|
|
|
public bool newLine { get; set; } = true;
|
|
|
|
public override List<byte[]> GetInstructions()
|
|
|
|
{
|
|
|
|
var e = new EPSON();
|
|
|
|
var commands = new List<byte[]>();
|
2022-02-17 17:29:32 +00:00
|
|
|
|
|
|
|
commands.Add(alignmentCommand(alignment));
|
2022-02-17 15:45:42 +00:00
|
|
|
|
2022-02-18 17:48:03 +00:00
|
|
|
if (underline){
|
|
|
|
commands.Add(e.SetStyles(PrintStyle.Underline));
|
|
|
|
}
|
|
|
|
|
2022-02-17 15:45:42 +00:00
|
|
|
if (newLine)
|
|
|
|
{
|
|
|
|
commands.Add(e.PrintLine(text));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
commands.Add(e.Print(text));
|
|
|
|
}
|
|
|
|
|
2022-02-18 17:48:03 +00:00
|
|
|
if (underline){
|
|
|
|
commands.Add(e.SetStyles(PrintStyle.None));
|
|
|
|
}
|
|
|
|
|
2022-02-17 15:45:42 +00:00
|
|
|
return commands;
|
|
|
|
}
|
|
|
|
}
|