From c858e3e9c4ed8901d5c9354bee2195d4f0e5dfd6 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 28 Feb 2022 13:44:47 +0100 Subject: [PATCH] added qrcode --- Controllers/PrinterController.cs | 4 ++++ Instructions/QRCode.cs | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 Instructions/QRCode.cs diff --git a/Controllers/PrinterController.cs b/Controllers/PrinterController.cs index f9d0ed7..9707488 100644 --- a/Controllers/PrinterController.cs +++ b/Controllers/PrinterController.cs @@ -53,6 +53,10 @@ public class PrinterController : Controller case "barcode2d": parsedInstruction = instruction.Deserialize(); break; + case "qrcode": + parsedInstruction = instruction.Deserialize(); + break; + default: return BadRequest(); } diff --git a/Instructions/QRCode.cs b/Instructions/QRCode.cs new file mode 100644 index 0000000..2a6d194 --- /dev/null +++ b/Instructions/QRCode.cs @@ -0,0 +1,26 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using ESCPOS_NET.Emitters; + +public class QRCode : BaseInstruction +{ + [DataMember(IsRequired = true)] + public string? data { get; set; } + + [JsonConverter(typeof(JsonStringEnumConverter))] + public TwoDimensionCodeType barcodeType {get; set; } = TwoDimensionCodeType.QRCODE_MODEL2; + + [JsonConverter(typeof(JsonStringEnumConverter))] + public Size2DCode size {get; set; } = Size2DCode.NORMAL; + + [JsonConverter(typeof(JsonStringEnumConverter))] + public CorrectionLevel2DCode correctionLevel {get; set; } = CorrectionLevel2DCode.PERCENT_7; + public override List GetInstructions() + { + var commands = new List(); + + commands.Add(e.PrintQRCode(data,barcodeType,size,correctionLevel)); + + return commands; + } +} \ No newline at end of file