renamed printInstruction

This commit is contained in:
Djeeberjr 2022-02-17 18:29:32 +01:00
parent 486459a107
commit 2e9909129b
2 changed files with 8 additions and 6 deletions

View File

@ -41,8 +41,8 @@ public class PrinterController : Controller
switch (instruction.GetProperty("type").GetString())
{
case "print":
parsedInstruction = instruction.Deserialize<PrintInstruction>();
case "text":
parsedInstruction = instruction.Deserialize<TextInstruction>();
break;
case "barcode":
parsedInstruction = instruction.Deserialize<BarcodeInstruction>();

View File

@ -1,21 +1,23 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using ESCPOS_NET.Emitters;
using ESCPOS_NET.Utilities;
public class PrintInstruction : BaseInstruction
public class TextInstruction : BaseInstruction
{
[DataMember(IsRequired = true)]
public string? text { get; set; }
[JsonConverter(typeof(JsonStringEnumConverter))]
public Alignment alignment {get; set; } = Alignment.Left;
public bool newLine { get; set; } = true;
public override List<byte[]> GetInstructions()
{
var e = new EPSON();
var commands = new List<byte[]>();
commands.Add(alignmentCommand(alignment));
if (newLine)
{
commands.Add(e.PrintLine(text));