diff --git a/BarcodeXlsx/BarcodeXlsx.csproj b/BarcodeXlsx/BarcodeXlsx.csproj index fd37bae..3230d64 100644 --- a/BarcodeXlsx/BarcodeXlsx.csproj +++ b/BarcodeXlsx/BarcodeXlsx.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.1 + netcoreapp2.2 + + diff --git a/BarcodeXlsx/DecodeArgumentParamaters.cs b/BarcodeXlsx/DecodeArgumentParamaters.cs index 3e0558a..2ebd917 100644 --- a/BarcodeXlsx/DecodeArgumentParamaters.cs +++ b/BarcodeXlsx/DecodeArgumentParamaters.cs @@ -12,6 +12,9 @@ public string destinationFileName; public bool enabledVerbose = false; public bool enabledProgress = false; + public bool enabledLabel = false; + public int imageWidht = 256; + public int imageHeight = 64; public DecodeArgumentParamaters(string[] args) { @@ -24,6 +27,8 @@ bool destinationFlag = false; bool preCharsFlag = false; bool postCharsFlag = false; + bool imageWidthFlag = false; + bool imageHeightFlag = false; foreach (var arg in args) { @@ -43,6 +48,18 @@ { postCharsFlag = true; } + else if (arg == "-width") + { + imageWidthFlag = true; + } + else if (arg == "-height") + { + imageHeightFlag = true; + } + else if (arg == "-showlabel") + { + enabledLabel = true; + } else if (arg == "-progress") { enabledProgress = true; @@ -71,6 +88,22 @@ postCharsFlag = false; postChars = arg; } + else if (imageWidthFlag) + { + imageWidthFlag = false; + if (int.TryParse(arg, out imageWidht)) + { + + } + } + else if (imageHeightFlag) + { + imageHeightFlag = false; + if (int.TryParse(arg, out imageHeight)) + { + + } + } } } } diff --git a/BarcodeXlsx/Program.cs b/BarcodeXlsx/Program.cs index d5b8e51..e3b1214 100644 --- a/BarcodeXlsx/Program.cs +++ b/BarcodeXlsx/Program.cs @@ -18,8 +18,15 @@ { try { + Console.WriteLine("BarcodeXlsx v0.1"); + DecodeArgumentParamaters param = new DecodeArgumentParamaters(args); + if (param.enabledVerbose) + { + Console.WriteLine("--source {0}", param.sourceFileName); + } + XLWorkbook book = new XLWorkbook(param.sourceFileName); foreach (var sheet in book.Worksheets) { @@ -48,12 +55,14 @@ try { BarcodeLib.Barcode barcode = new BarcodeLib.Barcode(); - barcode.Height = 256; - barcode.Width = 512; + barcode.Height = param.imageHeight; + barcode.Width = param.imageWidht; barcode.Alignment = BarcodeLib.AlignmentPositions.CENTER; + barcode.IncludeLabel = param.enabledLabel; + barcode.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER; + barcode.LabelFont = new Font(FontFamily.GenericSansSerif, 8); barcode.BackColor = Color.White; barcode.ImageFormat = ImageFormat.Bmp; - barcode.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER; barcode.Encode(DecodeBarcodeStyle(barcodeType), barcodeValue); MemoryStream tempStream = new MemoryStream();