From fc5cb17a798093bbf8e1a376e35051f1fc1a9ff7 Mon Sep 17 00:00:00 2001 From: ignotion Date: Fri, 28 May 2021 10:40:54 +0200 Subject: [PATCH 1/2] Added optional bar code charset to allow diferent charsets instead of 'C' only --- ESC-POS-USB-NET/Enums/BarCodeCharSet.cs | 14 ++++++++++++++ ESC-POS-USB-NET/Epson Commands/BarCode.cs | 4 ++-- ESC-POS-USB-NET/Interfaces/Command/IBarCode.cs | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 ESC-POS-USB-NET/Enums/BarCodeCharSet.cs diff --git a/ESC-POS-USB-NET/Enums/BarCodeCharSet.cs b/ESC-POS-USB-NET/Enums/BarCodeCharSet.cs new file mode 100644 index 0000000..c55c07e --- /dev/null +++ b/ESC-POS-USB-NET/Enums/BarCodeCharSet.cs @@ -0,0 +1,14 @@ +namespace ESC_POS_USB_NET.Enums +{ + /// + /// This enum is used to set postion of barcode label + /// + + public enum BarCodeCharSet + { + A= 'A', + B= 'B', + C= 'C' + } +} + diff --git a/ESC-POS-USB-NET/Epson Commands/BarCode.cs b/ESC-POS-USB-NET/Epson Commands/BarCode.cs index 80bfb2d..8392c93 100644 --- a/ESC-POS-USB-NET/Epson Commands/BarCode.cs +++ b/ESC-POS-USB-NET/Epson Commands/BarCode.cs @@ -6,7 +6,7 @@ namespace ESC_POS_USB_NET.EpsonCommands { public class BarCode : IBarCode { - public byte[] Code128(string code,Positions printString=Positions.NotPrint) + public byte[] Code128(string code,Positions printString=Positions.NotPrint, BarCodeCharSet codeSet = BarCodeCharSet.C) { return new byte[] { 29, 119, 2 } // Width .AddBytes(new byte[] { 29, 104, 50 }) // Height @@ -14,7 +14,7 @@ public byte[] Code128(string code,Positions printString=Positions.NotPrint) .AddBytes(new byte[] { 29, 72, printString.ToByte() }) // If print code informed .AddBytes(new byte[] { 29, 107, 73 }) // printCode .AddBytes(new[] { (byte)(code.Length + 2) }) - .AddBytes(new[] { '{'.ToByte(), 'C'.ToByte() }) + .AddBytes(new[] { '{'.ToByte(), codeSet.ToByte() }) .AddBytes(code) .AddLF(); } diff --git a/ESC-POS-USB-NET/Interfaces/Command/IBarCode.cs b/ESC-POS-USB-NET/Interfaces/Command/IBarCode.cs index 89a7fd4..52a7198 100644 --- a/ESC-POS-USB-NET/Interfaces/Command/IBarCode.cs +++ b/ESC-POS-USB-NET/Interfaces/Command/IBarCode.cs @@ -4,7 +4,7 @@ namespace ESC_POS_USB_NET.Interfaces.Command { interface IBarCode { - byte[] Code128(string code,Positions printString); + byte[] Code128(string code,Positions printString, BarCodeCharSet codeSet); byte[] Code39(string code, Positions printString); byte[] Ean13(string code, Positions printString); } From 2f5a51285cd28b30ab1af6d29d3c8e96593ecf75 Mon Sep 17 00:00:00 2001 From: ignotion Date: Fri, 28 May 2021 11:14:06 +0200 Subject: [PATCH 2/2] Now builds and cleanup comments --- ESC-POS-USB-NET/Enums/BarCodeCharSet.cs | 4 ---- ESC-POS-USB-NET/Interfaces/Printer/IPrinter.cs | 2 +- ESC-POS-USB-NET/Printer.cs | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ESC-POS-USB-NET/Enums/BarCodeCharSet.cs b/ESC-POS-USB-NET/Enums/BarCodeCharSet.cs index c55c07e..3889787 100644 --- a/ESC-POS-USB-NET/Enums/BarCodeCharSet.cs +++ b/ESC-POS-USB-NET/Enums/BarCodeCharSet.cs @@ -1,9 +1,5 @@ namespace ESC_POS_USB_NET.Enums { - /// - /// This enum is used to set postion of barcode label - /// - public enum BarCodeCharSet { A= 'A', diff --git a/ESC-POS-USB-NET/Interfaces/Printer/IPrinter.cs b/ESC-POS-USB-NET/Interfaces/Printer/IPrinter.cs index 681cbf4..144ae09 100644 --- a/ESC-POS-USB-NET/Interfaces/Printer/IPrinter.cs +++ b/ESC-POS-USB-NET/Interfaces/Printer/IPrinter.cs @@ -41,7 +41,7 @@ internal interface IPrinter void Image(Bitmap image); void QrCode(string qrData); void QrCode(string qrData, QrCodeSize qrCodeSize); - void Code128(string code, Positions positions); + void Code128(string code, Positions positions, BarCodeCharSet codeCharSet); void Code39(string code, Positions positions); void Ean13(string code, Positions positions); void InitializePrint(); diff --git a/ESC-POS-USB-NET/Printer.cs b/ESC-POS-USB-NET/Printer.cs index 803463f..d515a8a 100644 --- a/ESC-POS-USB-NET/Printer.cs +++ b/ESC-POS-USB-NET/Printer.cs @@ -269,9 +269,9 @@ public void QrCode(string qrData, QrCodeSize qrCodeSize ) Append(_command.QrCode.Print(qrData, qrCodeSize)); } - public void Code128(string code, Positions printString = Positions.NotPrint) + public void Code128(string code, Positions printString = Positions.NotPrint, BarCodeCharSet codeCharSet = BarCodeCharSet.C) { - Append(_command.BarCode.Code128(code, printString)); + Append(_command.BarCode.Code128(code, printString, codeCharSet)); } public void Code39(string code, Positions printString=Positions.NotPrint)