2022-02-17 15:45:42 +00:00
|
|
|
using System.Runtime.Serialization;
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
using ESCPOS_NET.Emitters;
|
|
|
|
|
|
|
|
public class BarcodeInstruction : BaseInstruction
|
|
|
|
{
|
|
|
|
|
|
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
|
|
|
public BarcodeType barcodeType { get; set; } = BarcodeType.CODE128;
|
|
|
|
|
|
|
|
[DataMember(IsRequired = true)]
|
|
|
|
public string? barcode { get; set; }
|
|
|
|
|
|
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
|
|
|
public BarcodeCode barcodeCode { get; set; } = BarcodeCode.CODE_B;
|
|
|
|
|
2022-02-17 17:29:41 +00:00
|
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
|
|
|
public Alignment alignment {get; set; } = Alignment.Left;
|
|
|
|
|
2022-02-18 18:03:09 +00:00
|
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
2022-02-28 00:31:08 +00:00
|
|
|
public BarLabelPrintPosition labelPos {get; set; } = BarLabelPrintPosition.Below;
|
2022-02-18 18:03:09 +00:00
|
|
|
|
2022-02-17 16:20:57 +00:00
|
|
|
// [JsonConverter(typeof(JsonStringEnumConverter))]
|
|
|
|
// public BarWidth width { get; set; } = BarWidth.Default;
|
2022-02-17 15:45:42 +00:00
|
|
|
|
|
|
|
public int height { get; set; } = 0;
|
|
|
|
|
|
|
|
public override List<byte[]> GetInstructions()
|
|
|
|
{
|
|
|
|
var commands = new List<byte[]>();
|
|
|
|
|
2022-02-17 16:20:57 +00:00
|
|
|
// if (width != BarWidth.Default)
|
|
|
|
// {
|
|
|
|
// commands.Add(e.SetBarWidth(width));
|
|
|
|
// }
|
2022-02-17 15:45:42 +00:00
|
|
|
|
2022-02-17 17:29:41 +00:00
|
|
|
commands.Add(alignmentCommand(alignment));
|
|
|
|
|
2022-02-28 00:31:08 +00:00
|
|
|
if (labelPos != BarLabelPrintPosition.Below){
|
|
|
|
commands.Add(e.SetBarLabelPosition(labelPos));
|
2022-02-18 18:03:09 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 15:45:42 +00:00
|
|
|
if (height > 0)
|
|
|
|
{
|
|
|
|
commands.Add(e.SetBarcodeHeightInDots(height));
|
|
|
|
}
|
|
|
|
|
|
|
|
commands.Add(e.PrintBarcode(barcodeType, barcode, barcodeCode));
|
|
|
|
|
|
|
|
return commands;
|
|
|
|
}
|
|
|
|
}
|