diff --git a/.gitignore b/.gitignore index 914bf30ad..98a014701 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ Encrypt/bin/ Encrypt/obj/ GemCard/bin GemCard/obj +GenCode128/bin +GenCode128/obj GraphLib/bin GraphLib/obj TracingDB/bin diff --git a/GenCode128/AssemblyInfo.cs b/GenCode128/AssemblyInfo.cs new file mode 100644 index 000000000..4fe350d4c --- /dev/null +++ b/GenCode128/AssemblyInfo.cs @@ -0,0 +1,51 @@ +using System.Reflection; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("GenCode128")] +[assembly: AssemblyDescription("GenCode128")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Chris Wuestefeld")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("2006 Chris Wuestefeld")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] + +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/GenCode128/Code128Code.cs b/GenCode128/Code128Code.cs new file mode 100644 index 000000000..ea119b1a8 --- /dev/null +++ b/GenCode128/Code128Code.cs @@ -0,0 +1,139 @@ +namespace GenCode128 +{ + /// + /// Static tools for determining codes for individual characters in the content + /// + public static class Code128Code + { + private const int CShift = 98; + private const int CCodeA = 101; + private const int CCodeB = 100; + private const int CStartA = 103; + private const int CStartB = 104; + private const int CStop = 106; + + /// + /// Indicates which code sets can represent a character -- CodeA, CodeB, or either + /// + public enum CodeSetAllowed + { + CodeA, + CodeB, + CodeAorB + } + + /// + /// Get the Code128 code value(s) to represent an ASCII character, with + /// optional look-ahead for length optimization + /// + /// The ASCII value of the character to translate + /// The next character in sequence (or -1 if none) + /// The current codeset, that the returned codes need to follow; + /// if the returned codes change that, then this value will be changed to reflect it + /// An array of integers representing the codes that need to be output to produce the + /// given character + public static int[] CodesForChar(int charAscii, int lookAheadAscii, ref CodeSet currentCodeSet) + { + int[] result; + var shifter = -1; + + if (!CharCompatibleWithCodeset(charAscii, currentCodeSet)) + { + // if we have a lookahead character AND if the next character is ALSO not compatible + if ((lookAheadAscii != -1) && !CharCompatibleWithCodeset(lookAheadAscii, currentCodeSet)) + { + // we need to switch code sets + switch (currentCodeSet) + { + case CodeSet.CodeA: + shifter = CCodeB; + currentCodeSet = CodeSet.CodeB; + break; + case CodeSet.CodeB: + shifter = CCodeA; + currentCodeSet = CodeSet.CodeA; + break; + } + } + else + { + // no need to switch code sets, a temporary SHIFT will suffice + shifter = CShift; + } + } + + if (shifter != -1) + { + result = new int[2]; + result[0] = shifter; + result[1] = CodeValueForChar(charAscii); + } + else + { + result = new int[1]; + result[0] = CodeValueForChar(charAscii); + } + + return result; + } + + /// + /// Tells us which codesets a given character value is allowed in + /// + /// ASCII value of character to look at + /// Which codeset(s) can be used to represent this character + public static CodeSetAllowed CodesetAllowedForChar(int charAscii) + { + if (charAscii >= 32 && charAscii <= 95) + { + return CodeSetAllowed.CodeAorB; + } + else + { + return charAscii < 32 ? CodeSetAllowed.CodeA : CodeSetAllowed.CodeB; + } + } + + /// + /// Determine if a character can be represented in a given codeset + /// + /// character to check for + /// codeset context to test + /// true if the codeset contains a representation for the ASCII character + public static bool CharCompatibleWithCodeset(int charAscii, CodeSet currentCodeSet) + { + var csa = CodesetAllowedForChar(charAscii); + return csa == CodeSetAllowed.CodeAorB || (csa == CodeSetAllowed.CodeA && currentCodeSet == CodeSet.CodeA) + || (csa == CodeSetAllowed.CodeB && currentCodeSet == CodeSet.CodeB); + } + + /// + /// Gets the integer code128 code value for a character (assuming the appropriate code set) + /// + /// character to convert + /// code128 symbol value for the character + public static int CodeValueForChar(int charAscii) + { + return charAscii >= 32 ? charAscii - 32 : charAscii + 64; + } + + /// + /// Return the appropriate START code depending on the codeset we want to be in + /// + /// The codeset you want to start in + /// The code128 code to start a barcode in that codeset + public static int StartCodeForCodeSet(CodeSet cs) + { + return cs == CodeSet.CodeA ? CStartA : CStartB; + } + + /// + /// Return the Code128 stop code + /// + /// the stop code + public static int StopCode() + { + return CStop; + } + } +} \ No newline at end of file diff --git a/GenCode128/Code128Content.cs b/GenCode128/Code128Content.cs new file mode 100644 index 000000000..505efe4d4 --- /dev/null +++ b/GenCode128/Code128Content.cs @@ -0,0 +1,97 @@ +namespace GenCode128 +{ + using System.Collections; + using System.Text; + + /// + /// Represent the set of code values to be output into barcode form + /// + public class Code128Content + { + /// + /// Create content based on a string of ASCII data + /// + /// the string that should be represented + public Code128Content(string asciiData) + { + this.Codes = this.StringToCode128(asciiData); + } + + /// + /// Provides the Code128 code values representing the object's string + /// + public int[] Codes + { + get { return codes; } + set { codes = value; } + } + int[] codes; + + /// + /// Transform the string into integers representing the Code128 codes + /// necessary to represent it + /// + /// String to be encoded + /// Code128 representation + private int[] StringToCode128(string asciiData) + { + // turn the string into ascii byte data + var asciiBytes = Encoding.ASCII.GetBytes(asciiData); + + // decide which codeset to start with + var csa1 = asciiBytes.Length > 0 + ? Code128Code.CodesetAllowedForChar(asciiBytes[0]) + : Code128Code.CodeSetAllowed.CodeAorB; + var csa2 = asciiBytes.Length > 1 + ? Code128Code.CodesetAllowedForChar(asciiBytes[1]) + : Code128Code.CodeSetAllowed.CodeAorB; + var currentCodeSet = this.GetBestStartSet(csa1, csa2); + + // set up the beginning of the barcode + // assume no codeset changes, account for start, checksum, and stop + var codes = new ArrayList(asciiBytes.Length + 3) { Code128Code.StartCodeForCodeSet(currentCodeSet) }; + + // add the codes for each character in the string + for (var i = 0; i < asciiBytes.Length; i++) + { + int thischar = asciiBytes[i]; + var nextchar = asciiBytes.Length > i + 1 ? asciiBytes[i + 1] : -1; + + codes.AddRange(Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet)); + } + + // calculate the check digit + var checksum = (int)codes[0]; + for (var i = 1; i < codes.Count; i++) + { + checksum += i * (int)codes[i]; + } + + codes.Add(checksum % 103); + + codes.Add(Code128Code.StopCode()); + + var result = codes.ToArray(typeof(int)) as int[]; + return result; + } + + /// + /// Determines the best starting code set based on the the first two + /// characters of the string to be encoded + /// + /// First character of input string + /// Second character of input string + /// The codeset determined to be best to start with + private CodeSet GetBestStartSet(Code128Code.CodeSetAllowed csa1, Code128Code.CodeSetAllowed csa2) + { + var vote = 0; + + vote += csa1 == Code128Code.CodeSetAllowed.CodeA ? 1 : 0; + vote += csa1 == Code128Code.CodeSetAllowed.CodeB ? -1 : 0; + vote += csa2 == Code128Code.CodeSetAllowed.CodeA ? 1 : 0; + vote += csa2 == Code128Code.CodeSetAllowed.CodeB ? -1 : 0; + + return vote > 0 ? CodeSet.CodeA : CodeSet.CodeB; // ties go to codeB due to my own prejudices + } + } +} diff --git a/GenCode128/Code128Rendering.cs b/GenCode128/Code128Rendering.cs new file mode 100644 index 000000000..0dd7fc148 --- /dev/null +++ b/GenCode128/Code128Rendering.cs @@ -0,0 +1,188 @@ +namespace GenCode128 +{ + using System; + using System.Drawing; + + /// + /// Summary description for Code128Rendering. + /// + public static class Code128Rendering + { + private const int CQuietWidth = 10; + + // Code patterns: + // in principle these rows should each have 6 elements + // however, the last one -- STOP -- has 7. The cost of the + // extra integers is trivial, and this lets the code flow + // much more elegantly + private static readonly int[,] CPatterns = + { + { 2, 1, 2, 2, 2, 2, 0, 0 }, // 0 + { 2, 2, 2, 1, 2, 2, 0, 0 }, // 1 + { 2, 2, 2, 2, 2, 1, 0, 0 }, // 2 + { 1, 2, 1, 2, 2, 3, 0, 0 }, // 3 + { 1, 2, 1, 3, 2, 2, 0, 0 }, // 4 + { 1, 3, 1, 2, 2, 2, 0, 0 }, // 5 + { 1, 2, 2, 2, 1, 3, 0, 0 }, // 6 + { 1, 2, 2, 3, 1, 2, 0, 0 }, // 7 + { 1, 3, 2, 2, 1, 2, 0, 0 }, // 8 + { 2, 2, 1, 2, 1, 3, 0, 0 }, // 9 + { 2, 2, 1, 3, 1, 2, 0, 0 }, // 10 + { 2, 3, 1, 2, 1, 2, 0, 0 }, // 11 + { 1, 1, 2, 2, 3, 2, 0, 0 }, // 12 + { 1, 2, 2, 1, 3, 2, 0, 0 }, // 13 + { 1, 2, 2, 2, 3, 1, 0, 0 }, // 14 + { 1, 1, 3, 2, 2, 2, 0, 0 }, // 15 + { 1, 2, 3, 1, 2, 2, 0, 0 }, // 16 + { 1, 2, 3, 2, 2, 1, 0, 0 }, // 17 + { 2, 2, 3, 2, 1, 1, 0, 0 }, // 18 + { 2, 2, 1, 1, 3, 2, 0, 0 }, // 19 + { 2, 2, 1, 2, 3, 1, 0, 0 }, // 20 + { 2, 1, 3, 2, 1, 2, 0, 0 }, // 21 + { 2, 2, 3, 1, 1, 2, 0, 0 }, // 22 + { 3, 1, 2, 1, 3, 1, 0, 0 }, // 23 + { 3, 1, 1, 2, 2, 2, 0, 0 }, // 24 + { 3, 2, 1, 1, 2, 2, 0, 0 }, // 25 + { 3, 2, 1, 2, 2, 1, 0, 0 }, // 26 + { 3, 1, 2, 2, 1, 2, 0, 0 }, // 27 + { 3, 2, 2, 1, 1, 2, 0, 0 }, // 28 + { 3, 2, 2, 2, 1, 1, 0, 0 }, // 29 + { 2, 1, 2, 1, 2, 3, 0, 0 }, // 30 + { 2, 1, 2, 3, 2, 1, 0, 0 }, // 31 + { 2, 3, 2, 1, 2, 1, 0, 0 }, // 32 + { 1, 1, 1, 3, 2, 3, 0, 0 }, // 33 + { 1, 3, 1, 1, 2, 3, 0, 0 }, // 34 + { 1, 3, 1, 3, 2, 1, 0, 0 }, // 35 + { 1, 1, 2, 3, 1, 3, 0, 0 }, // 36 + { 1, 3, 2, 1, 1, 3, 0, 0 }, // 37 + { 1, 3, 2, 3, 1, 1, 0, 0 }, // 38 + { 2, 1, 1, 3, 1, 3, 0, 0 }, // 39 + { 2, 3, 1, 1, 1, 3, 0, 0 }, // 40 + { 2, 3, 1, 3, 1, 1, 0, 0 }, // 41 + { 1, 1, 2, 1, 3, 3, 0, 0 }, // 42 + { 1, 1, 2, 3, 3, 1, 0, 0 }, // 43 + { 1, 3, 2, 1, 3, 1, 0, 0 }, // 44 + { 1, 1, 3, 1, 2, 3, 0, 0 }, // 45 + { 1, 1, 3, 3, 2, 1, 0, 0 }, // 46 + { 1, 3, 3, 1, 2, 1, 0, 0 }, // 47 + { 3, 1, 3, 1, 2, 1, 0, 0 }, // 48 + { 2, 1, 1, 3, 3, 1, 0, 0 }, // 49 + { 2, 3, 1, 1, 3, 1, 0, 0 }, // 50 + { 2, 1, 3, 1, 1, 3, 0, 0 }, // 51 + { 2, 1, 3, 3, 1, 1, 0, 0 }, // 52 + { 2, 1, 3, 1, 3, 1, 0, 0 }, // 53 + { 3, 1, 1, 1, 2, 3, 0, 0 }, // 54 + { 3, 1, 1, 3, 2, 1, 0, 0 }, // 55 + { 3, 3, 1, 1, 2, 1, 0, 0 }, // 56 + { 3, 1, 2, 1, 1, 3, 0, 0 }, // 57 + { 3, 1, 2, 3, 1, 1, 0, 0 }, // 58 + { 3, 3, 2, 1, 1, 1, 0, 0 }, // 59 + { 3, 1, 4, 1, 1, 1, 0, 0 }, // 60 + { 2, 2, 1, 4, 1, 1, 0, 0 }, // 61 + { 4, 3, 1, 1, 1, 1, 0, 0 }, // 62 + { 1, 1, 1, 2, 2, 4, 0, 0 }, // 63 + { 1, 1, 1, 4, 2, 2, 0, 0 }, // 64 + { 1, 2, 1, 1, 2, 4, 0, 0 }, // 65 + { 1, 2, 1, 4, 2, 1, 0, 0 }, // 66 + { 1, 4, 1, 1, 2, 2, 0, 0 }, // 67 + { 1, 4, 1, 2, 2, 1, 0, 0 }, // 68 + { 1, 1, 2, 2, 1, 4, 0, 0 }, // 69 + { 1, 1, 2, 4, 1, 2, 0, 0 }, // 70 + { 1, 2, 2, 1, 1, 4, 0, 0 }, // 71 + { 1, 2, 2, 4, 1, 1, 0, 0 }, // 72 + { 1, 4, 2, 1, 1, 2, 0, 0 }, // 73 + { 1, 4, 2, 2, 1, 1, 0, 0 }, // 74 + { 2, 4, 1, 2, 1, 1, 0, 0 }, // 75 + { 2, 2, 1, 1, 1, 4, 0, 0 }, // 76 + { 4, 1, 3, 1, 1, 1, 0, 0 }, // 77 + { 2, 4, 1, 1, 1, 2, 0, 0 }, // 78 + { 1, 3, 4, 1, 1, 1, 0, 0 }, // 79 + { 1, 1, 1, 2, 4, 2, 0, 0 }, // 80 + { 1, 2, 1, 1, 4, 2, 0, 0 }, // 81 + { 1, 2, 1, 2, 4, 1, 0, 0 }, // 82 + { 1, 1, 4, 2, 1, 2, 0, 0 }, // 83 + { 1, 2, 4, 1, 1, 2, 0, 0 }, // 84 + { 1, 2, 4, 2, 1, 1, 0, 0 }, // 85 + { 4, 1, 1, 2, 1, 2, 0, 0 }, // 86 + { 4, 2, 1, 1, 1, 2, 0, 0 }, // 87 + { 4, 2, 1, 2, 1, 1, 0, 0 }, // 88 + { 2, 1, 2, 1, 4, 1, 0, 0 }, // 89 + { 2, 1, 4, 1, 2, 1, 0, 0 }, // 90 + { 4, 1, 2, 1, 2, 1, 0, 0 }, // 91 + { 1, 1, 1, 1, 4, 3, 0, 0 }, // 92 + { 1, 1, 1, 3, 4, 1, 0, 0 }, // 93 + { 1, 3, 1, 1, 4, 1, 0, 0 }, // 94 + { 1, 1, 4, 1, 1, 3, 0, 0 }, // 95 + { 1, 1, 4, 3, 1, 1, 0, 0 }, // 96 + { 4, 1, 1, 1, 1, 3, 0, 0 }, // 97 + { 4, 1, 1, 3, 1, 1, 0, 0 }, // 98 + { 1, 1, 3, 1, 4, 1, 0, 0 }, // 99 + { 1, 1, 4, 1, 3, 1, 0, 0 }, // 100 + { 3, 1, 1, 1, 4, 1, 0, 0 }, // 101 + { 4, 1, 1, 1, 3, 1, 0, 0 }, // 102 + { 2, 1, 1, 4, 1, 2, 0, 0 }, // 103 + { 2, 1, 1, 2, 1, 4, 0, 0 }, // 104 + { 2, 1, 1, 2, 3, 2, 0, 0 }, // 105 + { 2, 3, 3, 1, 1, 1, 2, 0 } // 106 + }; + + /// + /// Make an image of a Code128 barcode for a given string + /// + /// Message to be encoded + /// Base thickness for bar width (1 or 2 works well) + /// Add required horizontal margins (use if output is tight) + /// An Image of the Code128 barcode representing the message + public static Image MakeBarcodeImage(string inputData, int barWeight, bool addQuietZone) + { + // get the Code128 codes to represent the message + var content = new Code128Content(inputData); + var codes = content.Codes; + + var width = (((codes.Length - 3) * 11) + 35) * barWeight; + var height = Convert.ToInt32(Math.Ceiling(Convert.ToSingle(width) * .15F)); + + if (addQuietZone) + { + width += 2 * CQuietWidth * barWeight; // on both sides + } + + // get surface to draw on + Image myImage = new Bitmap(width, height); + using (var gr = Graphics.FromImage(myImage)) + { + // set to white so we don't have to fill the spaces with white + gr.FillRectangle(Brushes.White, 0, 0, width, height); + + // skip quiet zone + var cursor = addQuietZone ? CQuietWidth * barWeight : 0; + + for (var codeIdx = 0; codeIdx < codes.Length; codeIdx++) + { + var code = codes[codeIdx]; + + // take the bars two at a time: a black and a white + for (var bar = 0; bar < 8; bar += 2) + { + var barWidth = CPatterns[code, bar] * barWeight; + var spcWidth = CPatterns[code, bar + 1] * barWeight; + + // if width is zero, don't try to draw it + if (barWidth > 0) + { + gr.FillRectangle(Brushes.Black, cursor, 0, barWidth, height); + } + + // note that we never need to draw the space, since we + // initialized the graphics to all white + + // advance cursor beyond this pair + cursor += barWidth + spcWidth; + } + } + } + + return myImage; + } + } +} diff --git a/GenCode128/CodeSet.cs b/GenCode128/CodeSet.cs new file mode 100644 index 000000000..b59bfd2cf --- /dev/null +++ b/GenCode128/CodeSet.cs @@ -0,0 +1,9 @@ +namespace GenCode128 +{ + public enum CodeSet + { + CodeA, + CodeB + //// CodeC // not supported + } +} diff --git a/GenCode128/GenCode128.csproj b/GenCode128/GenCode128.csproj new file mode 100644 index 000000000..9d7c60b71 --- /dev/null +++ b/GenCode128/GenCode128.csproj @@ -0,0 +1,147 @@ + + + + Local + 8.0.50727 + 2.0 + {32817BF9-E380-4467-9C7F-936F4B122BC7} + + + + + + + + + Debug + AnyCPU + + + + + GenCode128 + + + JScript + Grid + IE50 + false + Library + GenCode128 + OnBuildSuccess + + + + + + + v4.0 + 2.0 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + bin\Debug\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.Drawing + + + System.Windows.Forms + + + System.XML + + + + + + + Code + + + Code + + + Code + + + + + False + .NET Framework 3.5 SP1 + true + + + + + + + + + + \ No newline at end of file diff --git a/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs b/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs index 3a4eebfc3..1ca9404ae 100644 --- a/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs +++ b/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs @@ -1,19 +1,24 @@ /// -/// Copyright (c) 2017 Sensus Metering Systems +/// Copyright (c) 2017-2020 Sensus Metering Systems /// using System; using System.Collections.Generic; using System.Drawing; +using System.Drawing.Drawing2D; using System.Drawing.Printing; using System.IO; using Config.Entities; +using GenCode128; +using Gma.QrCodeNet.Encoding; using Results.Resources; namespace Results.Output.Printers.Enhanced { public class EnhancedPrintDocument : PrintDocument { - /// Size of the printed area without margins, after taking into account 'pageOrientation' + static QrEncoder encoder = new QrEncoder(); + + /// Size of the printed area without margins, after taking into account 'pageOrientation' readonly int printHeight; readonly int printWidth; @@ -23,12 +28,14 @@ namespace Results.Output.Printers.Enhanced readonly int TitleX; readonly int TitleY; /// Depends on the size of the header - readonly int SpacingOne; - readonly int SpacingOneAndHalf; - readonly int SpacingOne4Header; - readonly int SpacingOneAndHalf4Header; + readonly int spacingOne; + readonly int spacingOneAndHalf; + readonly int spacingOne4Header; + readonly int spacingOneAndHalf4Header; + readonly int spacingOne4Footer; - readonly int SpacingOne4Footer; + int spacingAboveTable; + int spacingBelowTable; int CommonTop; /// = TitleY + 60 int BodyTop; /// = HdrTop + 160 @@ -124,11 +131,11 @@ namespace Results.Output.Printers.Enhanced } /// Document outline preliminary calculations - SpacingOne = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height; - SpacingOneAndHalf = (3 * SpacingOne) / 2; - SpacingOne4Header = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", headerFont).Height; - SpacingOneAndHalf4Header = (3 * SpacingOne4Header) / 2; - SpacingOne4Footer = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", footerFont).Height; + spacingOne = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height; + spacingOneAndHalf = (3 * spacingOne) / 2; + spacingOne4Header = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", headerFont).Height; + spacingOneAndHalf4Header = (3 * spacingOne4Header) / 2; + spacingOne4Footer = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", footerFont).Height; TitleX = cfg.LeftMargin; TitleY = cfg.TopMargin; @@ -178,17 +185,27 @@ namespace Results.Output.Printers.Enhanced /// Prepare document outline ///---------- titleHeight = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Height; - CommonTop = TitleY + titleHeight + SpacingOne4Header; + CommonTop = TitleY + titleHeight + spacingOne4Header; - commonHeight = commonItems.Count * SpacingOne; - BodyTop = CommonTop + commonHeight + SpacingOne4Header; + commonHeight = commonItems.Count * spacingOne; + BodyTop = CommonTop + commonHeight + spacingOne4Header; Table table0 = Table.Create_TestsAreRows(batch.WaterMeters[0], testItems, style); SizeF tableSize = table0.Measure(e); - int wmSectionHeight = (int)tableSize.Height + SpacingOne4Header * ((tableSize.Height > 0) ? 3 : 2); - nrWMsOnFirstPage = (printHeight - BodyTop + TitleY - 2 * SpacingOne) / wmSectionHeight; - nrWMsOnNextPage = (printHeight - 2 * SpacingOne) / wmSectionHeight; + if (cfg.BarcodeType == BarcodeType.None) + { + spacingAboveTable = spacingOneAndHalf4Header; + } + else + { + spacingAboveTable = Math.Max(spacingOneAndHalf4Header, cfg.BarcodeHeight + spacingOne4Header / 2); + } + spacingBelowTable = (tableSize.Height > 0) ? spacingOneAndHalf4Header : (spacingOne4Header / 2); + + int wmSectionHeight = (int)tableSize.Height + spacingAboveTable + spacingBelowTable; + nrWMsOnFirstPage = (printHeight - BodyTop + TitleY - 2 * spacingOne) / wmSectionHeight; + nrWMsOnNextPage = (printHeight - 2 * spacingOne) / wmSectionHeight; nrWMsOnNextPage = Math.Max(nrWMsOnNextPage, 1); /// Prevent division by zero if there are too many WM tests nrPages = 1 + (batch.WaterMeters.Count - nrWMsOnFirstPage + nrWMsOnNextPage - 1) / nrWMsOnNextPage; @@ -221,8 +238,8 @@ namespace Results.Output.Printers.Enhanced /// Write aligned columns for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++) { - PrintAt(e, leftMargin, CommonTop + SpacingOne * i, leftColumn[i]); - PrintAt(e, 300, CommonTop + SpacingOne * i, rightColumn[i]); + PrintAt(e, leftMargin, CommonTop + spacingOne * i, leftColumn[i]); + PrintAt(e, 300, CommonTop + spacingOne * i, rightColumn[i]); } } @@ -241,7 +258,7 @@ namespace Results.Output.Printers.Enhanced int wmPosition = true ? batch.WaterMeters[wmNr].WMPosition : (wmNr + 1); if (!cfg.GoodOnly || batch.WaterMeters[wmNr].Passed) { - nextWmTop = (int)PrintWM(e, batch.WaterMeters[wmNr], wmPosition, nextWmTop) + SpacingOneAndHalf4Header; + nextWmTop = (int)PrintWM(e, batch.WaterMeters[wmNr], wmPosition, nextWmTop) + spacingBelowTable; } } @@ -252,11 +269,11 @@ namespace Results.Output.Printers.Enhanced /// Footer ///---------- int footerWidth = (int)e.Graphics.MeasureString(footer, footerFont).Width; - PrintFooterAt(e, leftMargin + (printWidth - footerWidth) / 2, topMargin + printHeight - 2 * SpacingOne, footer); + PrintFooterAt(e, leftMargin + (printWidth - footerWidth) / 2, topMargin + printHeight - 2 * spacingOne, footer); string pageNrText = string.Format("{0} {1}/{2}", Strings.Page, pageNr++, nrPages); int pageNrWidth = (int)e.Graphics.MeasureString(pageNrText, font).Width; - PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - SpacingOne, pageNrText); + PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - spacingOne, pageNrText); } @@ -270,25 +287,48 @@ namespace Results.Output.Printers.Enhanced float PrintWM(System.Drawing.Printing.PrintPageEventArgs e, Results.Entities.WaterMeter wm, int printedWMNr, int top) { + int tableTop = top + spacingAboveTable; + /// Print the water meter number and the serial number - string wmText = string.Format("{0} {1}", Strings.Water_Meter, printedWMNr); - PrintHeaderAt(e, leftMargin, top, wmText); - if (!string.IsNullOrEmpty(wm.SerialNr)) + if (string.IsNullOrEmpty(wm.SerialNr)) { - PrintHeaderAt(e, leftMargin + (int)e.Graphics.MeasureString(wmText, headerFont).Width, top, - string.Format(" {0} = {1}", Strings.sn, wm.SerialNr)); + string wmText = string.Format("{0} {1}", Strings.Water_Meter, printedWMNr); + int wmTextWidth = (int)e.Graphics.MeasureString(wmText, headerFont).Width; + PrintHeaderAt(e, leftMargin, tableTop - spacingOneAndHalf4Header, wmText); + } + else + { + string wmText = string.Format("{0} {1} {2} = {3}", Strings.Water_Meter, printedWMNr, Strings.sn, wm.SerialNr); + int wmTextWidth = (int)e.Graphics.MeasureString(wmText, headerFont).Width; + PrintHeaderAt(e, leftMargin, tableTop - spacingOneAndHalf4Header, wmText); + + switch (cfg.BarcodeType) + { + case BarcodeType.Code_128_Horizontally: + { + Image img = Code128Rendering.MakeBarcodeImage(wm.SerialNr, 1, true); + e.Graphics.DrawImage(img, leftMargin + wmTextWidth + spacingOne4Header, top, cfg.BarcodeWidth, cfg.BarcodeHeight); + break; + } + case BarcodeType.Code_128_Vertically: + { + Image img = Code128Rendering.MakeBarcodeImage(wm.SerialNr, 1, true); + img.RotateFlip(RotateFlipType.Rotate90FlipNone); + e.Graphics.DrawImage(img, leftMargin + wmTextWidth + spacingOne4Header, top, cfg.BarcodeWidth, cfg.BarcodeHeight); + break; + } + case BarcodeType.QR_Code: + { + QrCode qrCode = encoder.Encode(wm.SerialNr); + DrawQR(e.Graphics, qrCode, leftMargin + wmTextWidth + spacingOne4Header, top, cfg.BarcodeWidth, cfg.BarcodeHeight); + break; + } + } } Table table = Table.Create_TestsAreRows(wm, testItems, style); - if (table.IsEmpty()) - { - return top; - } - else - { - return table.Draw(e, leftMargin, top + SpacingOneAndHalf4Header); - } + return table.IsEmpty() ? tableTop : table.Draw(e, leftMargin, tableTop); } @@ -298,7 +338,7 @@ namespace Results.Output.Printers.Enhanced } void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text) { - RectangleF printArea = new RectangleF(x, y, 2000, SpacingOne); + RectangleF printArea = new RectangleF(x, y, 2000, spacingOne); e.Graphics.DrawString(text, this.font, Brushes.Black, printArea); } @@ -309,7 +349,7 @@ namespace Results.Output.Printers.Enhanced } void PrintHeaderAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text) { - RectangleF printArea = new RectangleF(x, y, 2000, SpacingOne4Header); + RectangleF printArea = new RectangleF(x, y, 2000, spacingOne4Header); e.Graphics.DrawString(text, this.headerFont, Brushes.Black, printArea); } @@ -320,8 +360,33 @@ namespace Results.Output.Printers.Enhanced } void PrintFooterAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text) { - RectangleF printArea = new RectangleF(x, y, 2000, SpacingOne4Footer); + RectangleF printArea = new RectangleF(x, y, 2000, spacingOne4Footer); e.Graphics.DrawString(text, this.footerFont, Brushes.Black, printArea); } + + + public static void DrawQR(Graphics g, QrCode qrCode, float left, float top, float width, float height) + { + /// Assuming 100 dpi (printer) + g.SmoothingMode = SmoothingMode.AntiAlias; + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + + float qrPixWidth = width / qrCode.Matrix.Width; + float qrPixHeight = height / qrCode.Matrix.Height; + for (int i = 0; i < qrCode.Matrix.Height; i++) + { + for (int j = 0; j < qrCode.Matrix.Width; j++) + { + if (qrCode.Matrix[j, i]) + { + g.FillRectangle(Brushes.Black, new RectangleF(left + j * qrPixWidth, + top + i * qrPixHeight, + qrPixWidth, + qrPixHeight)); + } + } + } + } } } diff --git a/Results/Output/Printers/Enhanced/EnhancedPrinterCfg.cs b/Results/Output/Printers/Enhanced/EnhancedPrinterCfg.cs index 9635f68f8..1ca930fab 100644 --- a/Results/Output/Printers/Enhanced/EnhancedPrinterCfg.cs +++ b/Results/Output/Printers/Enhanced/EnhancedPrinterCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// namespace Results.Output.Printers.Enhanced @@ -30,5 +30,8 @@ namespace Results.Output.Printers.Enhanced public string[] CommonItems; public string[] TestItems; public string Footer; - } + public BarcodeType BarcodeType; /// s/n is printed as barcode when valid (BarcodeType.None < BarcodeType < BarcodeType.Count) + public int BarcodeWidth; + public int BarcodeHeight; + } } diff --git a/Results/Output/Printers/Enums.cs b/Results/Output/Printers/Enums.cs new file mode 100644 index 000000000..4a5985638 --- /dev/null +++ b/Results/Output/Printers/Enums.cs @@ -0,0 +1,13 @@ +using System; + +namespace Results.Output.Printers +{ + public enum BarcodeType + { + None, + Code_128_Horizontally, + Code_128_Vertically, + QR_Code, + Count + } +} diff --git a/Results/Output/Printers/Label/LabelPrintDocument.cs b/Results/Output/Printers/Label/LabelPrintDocument.cs index 6faeaeb16..e56476e4d 100644 --- a/Results/Output/Printers/Label/LabelPrintDocument.cs +++ b/Results/Output/Printers/Label/LabelPrintDocument.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2018 Sensus Slovensko a.s. +/// Copyright (c) 2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -10,6 +10,7 @@ using System.IO; using Gma.QrCodeNet.Encoding; using Config.Entities; using Results.Resources; +using GenCode128; namespace Results.Output.Printers.Label { @@ -98,16 +99,27 @@ namespace Results.Output.Printers.Label } } - if (cfg.DrawSNasBarcode) + if (cfg.BarcodeType != BarcodeType.None && cfg.BarcodeType < BarcodeType.Count) { - if (cfg.IsQR) + try { - QrCode qrCode = encoder.Encode(wm.SerialNr); - DrawQR(e.Graphics, qrCode, cfg.BarcodeLeft, cfg.BarcodeTop, cfg.BarcodeWidth, cfg.BarcodeHeight); + if (cfg.BarcodeType == BarcodeType.QR_Code) + { + QrCode qrCode = encoder.Encode(wm.SerialNr); + DrawQR(e.Graphics, qrCode, cfg.BarcodeLeft, cfg.BarcodeTop, cfg.BarcodeWidth, cfg.BarcodeHeight); + } + else if (cfg.BarcodeType == BarcodeType.Code_128_Horizontally || cfg.BarcodeType == BarcodeType.Code_128_Vertically) + { + Image img = Code128Rendering.MakeBarcodeImage(wm.SerialNr, 1, true); + if (cfg.BarcodeType == BarcodeType.Code_128_Vertically) + { + img.RotateFlip(RotateFlipType.Rotate90FlipNone); + } + e.Graphics.DrawImage(img, cfg.BarcodeLeft, cfg.BarcodeTop, cfg.BarcodeWidth, cfg.BarcodeHeight); + } } - else + catch (Exception) { - /// TODO } } } diff --git a/Results/Output/Printers/Label/LabelPrinterCfg.cs b/Results/Output/Printers/Label/LabelPrinterCfg.cs index 46c12520d..0ecc7a886 100644 --- a/Results/Output/Printers/Label/LabelPrinterCfg.cs +++ b/Results/Output/Printers/Label/LabelPrinterCfg.cs @@ -16,9 +16,7 @@ namespace Results.Output.Printers.Label public int FontStyle; public System.Globalization.CultureInfo CultureInfo; public bool GoodOnly; - public bool SupressPrinting; /// true = Bypass printing - public bool DrawSNasBarcode; - public bool IsQR; + public BarcodeType BarcodeType; /// s/n is printed as barcode when valid (BarcodeType.None < BarcodeType < BarcodeType.Count) public int BarcodeLeft; public int BarcodeTop; public int BarcodeWidth; diff --git a/Results/Results.csproj b/Results/Results.csproj index b3bf6684e..80836dac4 100644 --- a/Results/Results.csproj +++ b/Results/Results.csproj @@ -134,6 +134,7 @@ Component + Component @@ -173,6 +174,10 @@ {743DF7DB-C7B6-42EB-986D-0F485E5588E4} Config + + {32817bf9-e380-4467-9c7f-936f4b122bc7} + GenCode128 + {EFEC8A31-3022-4DA7-A8F6-16D30A94C3FF} TracingDB diff --git a/TBF.sln b/TBF.sln index a8419aff9..4f62fad0f 100644 --- a/TBF.sln +++ b/TBF.sln @@ -50,6 +50,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decrypt", "Decrypt\Decrypt. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encrypt", "Encrypt\Encrypt.csproj", "{DA9B09F3-A99D-4883-A954-537560453674}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenCode128", "GenCode128\GenCode128.csproj", "{32817BF9-E380-4467-9C7F-936F4B122BC7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -202,6 +204,16 @@ Global {DA9B09F3-A99D-4883-A954-537560453674}.Release|Mixed Platforms.Build.0 = Release|x86 {DA9B09F3-A99D-4883-A954-537560453674}.Release|x86.ActiveCfg = Release|x86 {DA9B09F3-A99D-4883-A954-537560453674}.Release|x86.Build.0 = Release|x86 + {32817BF9-E380-4467-9C7F-936F4B122BC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32817BF9-E380-4467-9C7F-936F4B122BC7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32817BF9-E380-4467-9C7F-936F4B122BC7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {32817BF9-E380-4467-9C7F-936F4B122BC7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {32817BF9-E380-4467-9C7F-936F4B122BC7}.Debug|x86.ActiveCfg = Debug|Any CPU + {32817BF9-E380-4467-9C7F-936F4B122BC7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32817BF9-E380-4467-9C7F-936F4B122BC7}.Release|Any CPU.Build.0 = Release|Any CPU + {32817BF9-E380-4467-9C7F-936F4B122BC7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {32817BF9-E380-4467-9C7F-936F4B122BC7}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {32817BF9-E380-4467-9C7F-936F4B122BC7}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TBF/BenchControl/Output/Printers/Enhanced/Printer.cs b/TBF/BenchControl/Output/Printers/Enhanced/Printer.cs index 88c3804d5..c8ba4ab89 100644 --- a/TBF/BenchControl/Output/Printers/Enhanced/Printer.cs +++ b/TBF/BenchControl/Output/Printers/Enhanced/Printer.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -102,6 +102,10 @@ namespace TBF.BenchControl.Output.Printers.Enhanced printerCfg.DocName = newCfg.DocName; printerCfg.NrOfCopies = newCfg.NrOfCopies; + printerCfg.BarcodeType = newCfg.BarcodeType; + printerCfg.BarcodeWidth = newCfg.BarcodeWidth; + printerCfg.BarcodeHeight = newCfg.BarcodeHeight; + ApplyConfig(); } } @@ -191,6 +195,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced CommonItems = printerCfg.CommonItems, TestItems = printerCfg.SelectedItems, Footer = printerCfg.Footer, + BarcodeType = printerCfg.BarcodeType, + BarcodeWidth = printerCfg.BarcodeWidth, + BarcodeHeight = printerCfg.BarcodeHeight, }; for (int i = 1; i <= printerCfg.NrOfCopies; i++) diff --git a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfg.cs b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfg.cs index 962d2e57e..d1dc8cfb8 100644 --- a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfg.cs +++ b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System.Xml.Serialization; using Config.Entities; @@ -44,6 +44,10 @@ namespace TBF.BenchControl.Output.Printers.Enhanced public string DocName; public int NrOfCopies; + public Results.Output.Printers.BarcodeType BarcodeType; + public int BarcodeWidth; + public int BarcodeHeight; + [XmlIgnore] public Config.Entities.MetersKind MetersKind; diff --git a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.Designer.cs b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.Designer.cs index 8c110964d..bfaae2a56 100644 --- a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.Designer.cs +++ b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.Designer.cs @@ -76,6 +76,12 @@ namespace TBF.BenchControl.Output.Printers.Enhanced this.templateLabel = new System.Windows.Forms.Label(); this.nrOfCopiesTextBox = new System.Windows.Forms.TextBox(); this.nrOfCopiesLabel = new System.Windows.Forms.Label(); + this.barcodeTypeComboBox = new System.Windows.Forms.ComboBox(); + this.barcodeLabel = new System.Windows.Forms.Label(); + this.barcodeWidthTextBox = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.barcodeHeightTextBox = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // nameTextBox @@ -108,7 +114,7 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // this.supressPrintingCheckBox.AutoSize = true; this.supressPrintingCheckBox.Enabled = false; - this.supressPrintingCheckBox.Location = new System.Drawing.Point(19, 259); + this.supressPrintingCheckBox.Location = new System.Drawing.Point(91, 307); this.supressPrintingCheckBox.Name = "supressPrintingCheckBox"; this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17); this.supressPrintingCheckBox.TabIndex = 33; @@ -187,9 +193,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // commonItemsButton // this.commonItemsButton.Enabled = false; - this.commonItemsButton.Location = new System.Drawing.Point(142, 259); + this.commonItemsButton.Location = new System.Drawing.Point(193, 259); this.commonItemsButton.Name = "commonItemsButton"; - this.commonItemsButton.Size = new System.Drawing.Size(218, 23); + this.commonItemsButton.Size = new System.Drawing.Size(167, 23); this.commonItemsButton.TabIndex = 36; this.commonItemsButton.Text = "Common items"; this.commonItemsButton.UseVisualStyleBackColor = true; @@ -198,9 +204,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // footerButton // this.footerButton.Enabled = false; - this.footerButton.Location = new System.Drawing.Point(142, 303); + this.footerButton.Location = new System.Drawing.Point(193, 303); this.footerButton.Name = "footerButton"; - this.footerButton.Size = new System.Drawing.Size(218, 23); + this.footerButton.Size = new System.Drawing.Size(167, 23); this.footerButton.TabIndex = 38; this.footerButton.Text = "Footer"; this.footerButton.UseVisualStyleBackColor = true; @@ -209,9 +215,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // headerButton // this.headerButton.Enabled = false; - this.headerButton.Location = new System.Drawing.Point(142, 237); + this.headerButton.Location = new System.Drawing.Point(193, 237); this.headerButton.Name = "headerButton"; - this.headerButton.Size = new System.Drawing.Size(218, 23); + this.headerButton.Size = new System.Drawing.Size(167, 23); this.headerButton.TabIndex = 35; this.headerButton.Text = "Title"; this.headerButton.UseVisualStyleBackColor = true; @@ -220,9 +226,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // testItemsButton // this.testItemsButton.Enabled = false; - this.testItemsButton.Location = new System.Drawing.Point(142, 281); + this.testItemsButton.Location = new System.Drawing.Point(193, 281); this.testItemsButton.Name = "testItemsButton"; - this.testItemsButton.Size = new System.Drawing.Size(218, 23); + this.testItemsButton.Size = new System.Drawing.Size(167, 23); this.testItemsButton.TabIndex = 37; this.testItemsButton.Text = "Test items"; this.testItemsButton.UseVisualStyleBackColor = true; @@ -251,9 +257,9 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // docNameTextBox // this.docNameTextBox.Enabled = false; - this.docNameTextBox.Location = new System.Drawing.Point(197, 328); + this.docNameTextBox.Location = new System.Drawing.Point(193, 328); this.docNameTextBox.Name = "docNameTextBox"; - this.docNameTextBox.Size = new System.Drawing.Size(163, 20); + this.docNameTextBox.Size = new System.Drawing.Size(167, 20); this.docNameTextBox.TabIndex = 40; // // docNameLabel @@ -269,7 +275,7 @@ namespace TBF.BenchControl.Output.Printers.Enhanced // this.goodOnlyCheckBox.AutoSize = true; this.goodOnlyCheckBox.Enabled = false; - this.goodOnlyCheckBox.Location = new System.Drawing.Point(19, 281); + this.goodOnlyCheckBox.Location = new System.Drawing.Point(15, 307); this.goodOnlyCheckBox.Name = "goodOnlyCheckBox"; this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17); this.goodOnlyCheckBox.TabIndex = 34; @@ -494,16 +500,74 @@ namespace TBF.BenchControl.Output.Printers.Enhanced this.nrOfCopiesLabel.TabIndex = 44; this.nrOfCopiesLabel.Text = "# copies"; // + // barcodeTypeComboBox + // + this.barcodeTypeComboBox.Enabled = false; + this.barcodeTypeComboBox.FormattingEnabled = true; + this.barcodeTypeComboBox.Location = new System.Drawing.Point(19, 257); + this.barcodeTypeComboBox.Name = "barcodeTypeComboBox"; + this.barcodeTypeComboBox.Size = new System.Drawing.Size(167, 21); + this.barcodeTypeComboBox.TabIndex = 45; + // + // barcodeLabel + // + this.barcodeLabel.AutoSize = true; + this.barcodeLabel.Location = new System.Drawing.Point(16, 241); + this.barcodeLabel.Name = "barcodeLabel"; + this.barcodeLabel.Size = new System.Drawing.Size(47, 13); + this.barcodeLabel.TabIndex = 46; + this.barcodeLabel.Text = "Barcode"; + // + // barcodeWidthTextBox + // + this.barcodeWidthTextBox.Enabled = false; + this.barcodeWidthTextBox.Location = new System.Drawing.Point(79, 281); + this.barcodeWidthTextBox.Name = "barcodeWidthTextBox"; + this.barcodeWidthTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeWidthTextBox.TabIndex = 14; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(42, 285); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(35, 13); + this.label5.TabIndex = 15; + this.label5.Text = "Width"; + // + // barcodeHeightTextBox + // + this.barcodeHeightTextBox.Enabled = false; + this.barcodeHeightTextBox.Location = new System.Drawing.Point(156, 281); + this.barcodeHeightTextBox.Name = "barcodeHeightTextBox"; + this.barcodeHeightTextBox.Size = new System.Drawing.Size(30, 20); + this.barcodeHeightTextBox.TabIndex = 17; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(116, 285); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(38, 13); + this.label6.TabIndex = 18; + this.label6.Text = "Height"; + // // PrinterCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.barcodeLabel); + this.Controls.Add(this.barcodeTypeComboBox); + this.Controls.Add(this.label6); this.Controls.Add(this.nrOfCopiesLabel); this.Controls.Add(this.nrOfCopiesTextBox); + this.Controls.Add(this.barcodeHeightTextBox); this.Controls.Add(this.templateTextBox); this.Controls.Add(this.templateLabel); + this.Controls.Add(this.label5); this.Controls.Add(this.footerItalicCheckBox); this.Controls.Add(this.footerBoldCheckBox); + this.Controls.Add(this.barcodeWidthTextBox); this.Controls.Add(this.footerFontSizeTextBox); this.Controls.Add(this.footerFontFamilyComboBox); this.Controls.Add(this.footerFontLabel); @@ -598,5 +662,11 @@ namespace TBF.BenchControl.Output.Printers.Enhanced private System.Windows.Forms.Label templateLabel; private System.Windows.Forms.TextBox nrOfCopiesTextBox; private System.Windows.Forms.Label nrOfCopiesLabel; + private System.Windows.Forms.ComboBox barcodeTypeComboBox; + private System.Windows.Forms.Label barcodeLabel; + private System.Windows.Forms.TextBox barcodeWidthTextBox; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox barcodeHeightTextBox; + private System.Windows.Forms.Label label6; } } diff --git a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.cs b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.cs index 0869150e4..3dba77cc4 100644 --- a/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.cs +++ b/TBF/BenchControl/Output/Printers/Enhanced/PrinterCfgCtrl.cs @@ -1,14 +1,15 @@ /// -/// Copyright (c) 2017 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using System.Windows.Forms; using log4net; using Config.Entities; +using Results.Output.Printers; +using TBF.BenchControl.Configs; using TBF.BenchControl.Generic; using TBF.Resources; -using TBF.BenchControl.Configs; namespace TBF.BenchControl.Output.Printers.Enhanced { @@ -49,7 +50,12 @@ namespace TBF.BenchControl.Output.Printers.Enhanced bodyFontFamilyComboBox.Items.Add(ff.Name); footerFontFamilyComboBox.Items.Add(ff.Name); } - } + + for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) + { + barcodeTypeComboBox.Items.Add(bt.ToString()); + } + } private void PrinterCfgCtrl_Load(object sender, EventArgs e) { @@ -114,6 +120,10 @@ namespace TBF.BenchControl.Output.Printers.Enhanced docNameTextBox.Text = config.DocName; nrOfCopiesTextBox.Text = config.NrOfCopies.ToString(); + + barcodeTypeComboBox.Text = config.BarcodeType.ToString(); + barcodeWidthTextBox.Text = config.BarcodeWidth.ToString(); + barcodeHeightTextBox.Text = config.BarcodeHeight.ToString(); } public void Unlock() @@ -149,6 +159,10 @@ namespace TBF.BenchControl.Output.Printers.Enhanced footerButton.Enabled = true; docNameTextBox.Enabled = true; nrOfCopiesTextBox.Enabled = true; + + barcodeTypeComboBox.Enabled = true; + barcodeWidthTextBox.Enabled = true; + barcodeHeightTextBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) @@ -216,6 +230,22 @@ namespace TBF.BenchControl.Output.Printers.Enhanced flags |= CfgUpdateFlags.Error; } + if (!barcodeTypeComboBox.Items.Contains(barcodeTypeComboBox.Text)) + { + message += Environment.NewLine + "Invalid barcode type"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(barcodeWidthTextBox.Text, out dummy) || dummy < 0 || dummy > 200) + { + message += Environment.NewLine + "Barcode 'Width' should be between 0 and 200"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(barcodeHeightTextBox.Text, out dummy) || dummy < 0 || dummy > 200) + { + message += Environment.NewLine + "Barcode 'Height' should be between 0 and 200"; + flags |= CfgUpdateFlags.Error; + } + return flags; } @@ -292,6 +322,18 @@ namespace TBF.BenchControl.Output.Printers.Enhanced flags |= UpdateDifferent(ref config.DocName, docNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.NrOfCopies, nrOfCopiesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) + { + if (bt.ToString().Equals(barcodeTypeComboBox.Text)) + { + config.BarcodeType = bt; + flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + break; + } + } + flags |= UpdateDifferent(ref config.BarcodeWidth, barcodeWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + flags |= UpdateDifferent(ref config.BarcodeHeight, barcodeHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0) { Printer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config)); diff --git a/TBF/BenchControl/Output/Printers/Label/Printer.cs b/TBF/BenchControl/Output/Printers/Label/Printer.cs index 6536b8390..de74fc356 100644 --- a/TBF/BenchControl/Output/Printers/Label/Printer.cs +++ b/TBF/BenchControl/Output/Printers/Label/Printer.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015-2018 Sensus Slovensko a.s. +/// Copyright (c) 2015-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -17,7 +17,7 @@ namespace TBF.BenchControl.Output.Printers.Label readonly PrinterCfg printerCfg; - public bool SupressPrinting { get { return printerCfg.SupressPrinting; } } + public bool SupressPrinting { get { return (printerCfg.NrOfCopies == 0); } } /// Data to print Results.Entities.Batch batch; @@ -75,9 +75,7 @@ namespace TBF.BenchControl.Output.Printers.Label printerCfg.Culture = newCfg.Culture; printerCfg.NrOfCopies = newCfg.NrOfCopies; printerCfg.GoodOnly = newCfg.GoodOnly; - printerCfg.SupressPrinting = newCfg.SupressPrinting; - printerCfg.DrawSNasBarcode = newCfg.DrawSNasBarcode; - printerCfg.IsQR = newCfg.IsQR; + printerCfg.BarcodeType = newCfg.BarcodeType; printerCfg.BarcodeLeft = newCfg.BarcodeLeft; printerCfg.BarcodeTop = newCfg.BarcodeTop; printerCfg.BarcodeWidth = newCfg.BarcodeWidth; @@ -151,9 +149,7 @@ namespace TBF.BenchControl.Output.Printers.Label FontStyle = printerCfg.FontStyle, CultureInfo = (printerCfg.Culture == Culture.system) ? Thread.CurrentThread.CurrentCulture : new CultureInfo(printerCfg.Culture.ToString()), GoodOnly = printerCfg.GoodOnly, - SupressPrinting = printerCfg.SupressPrinting, - DrawSNasBarcode = printerCfg.DrawSNasBarcode, - IsQR = printerCfg.IsQR, + BarcodeType = printerCfg.BarcodeType, BarcodeLeft = printerCfg.BarcodeLeft, BarcodeTop = printerCfg.BarcodeTop, BarcodeWidth = printerCfg.BarcodeWidth, diff --git a/TBF/BenchControl/Output/Printers/Label/PrinterCfg.cs b/TBF/BenchControl/Output/Printers/Label/PrinterCfg.cs index 0f91176b9..315378ef8 100644 --- a/TBF/BenchControl/Output/Printers/Label/PrinterCfg.cs +++ b/TBF/BenchControl/Output/Printers/Label/PrinterCfg.cs @@ -31,10 +31,8 @@ namespace TBF.BenchControl.Output.Printers.Label public Culture Culture; public int NrOfCopies; public bool GoodOnly; - public bool SupressPrinting; /// true = Bypass printing - public bool DrawSNasBarcode; - public bool IsQR; + public Results.Output.Printers.BarcodeType BarcodeType; public int BarcodeLeft; public int BarcodeTop; public int BarcodeWidth; @@ -62,21 +60,19 @@ namespace TBF.BenchControl.Output.Printers.Label FontStyle = 0; NrOfCopies = 1; GoodOnly = false; - SupressPrinting = false; - DrawSNasBarcode = false; + BarcodeType = Results.Output.Printers.BarcodeType.None; } public string ToString(int i) { - return string.Format("Name={0}, Orientation={1}, PaperWidth={2}, PaperHeight={3}, TemplateFile={4}, GoodOnly={5}, SupressPrinting={6}, Barcode={7}", + return string.Format("Name={0}, Orientation={1}, PaperWidth={2}, PaperHeight={3}, TemplateFile={4}, GoodOnly={5}, Barcode={6}", Name, PageOrientation, PaperWidth, PaperHeight, Template, GoodOnly ? "yes" : "no", - SupressPrinting ? "yes" : "no", - DrawSNasBarcode ? "yes" : "no" + BarcodeType.ToString() ); } } diff --git a/TBF/BenchControl/Output/Printers/Label/PrinterCfgCtrl.Designer.cs b/TBF/BenchControl/Output/Printers/Label/PrinterCfgCtrl.Designer.cs index fd04c5c4f..9951100e4 100644 --- a/TBF/BenchControl/Output/Printers/Label/PrinterCfgCtrl.Designer.cs +++ b/TBF/BenchControl/Output/Printers/Label/PrinterCfgCtrl.Designer.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems +/// Copyright (c) 2015-2020 Sensus Slovensko a.s. /// namespace TBF.BenchControl.Output.Printers.Label { @@ -34,7 +34,6 @@ namespace TBF.BenchControl.Output.Printers.Label this.nameTextBox = new System.Windows.Forms.TextBox(); this.nameLabel = new System.Windows.Forms.Label(); this.classNameLabel = new System.Windows.Forms.Label(); - this.supressPrintingCheckBox = new System.Windows.Forms.CheckBox(); this.orientationLabel = new System.Windows.Forms.Label(); this.orientationComboBox = new System.Windows.Forms.ComboBox(); this.templateTextBox = new System.Windows.Forms.TextBox(); @@ -55,18 +54,16 @@ namespace TBF.BenchControl.Output.Printers.Label this.cultureComboBox = new System.Windows.Forms.ComboBox(); this.cultureLabel = new System.Windows.Forms.Label(); this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox(); - this.snBarcodeGroupBox = new System.Windows.Forms.GroupBox(); - this.barcodeHeightLabel = new System.Windows.Forms.Label(); - this.barcodeHeightTextBox = new System.Windows.Forms.TextBox(); - this.isQrCheckBox = new System.Windows.Forms.CheckBox(); - this.barcodeWidthLabel = new System.Windows.Forms.Label(); - this.barcodeWidthTextBox = new System.Windows.Forms.TextBox(); - this.barcodeTopLabel = new System.Windows.Forms.Label(); - this.barcodeTopTextBox = new System.Windows.Forms.TextBox(); - this.barcodeLeftTextBox = new System.Windows.Forms.TextBox(); this.barcodeLeftLabel = new System.Windows.Forms.Label(); - this.snBarcodeCheckBox = new System.Windows.Forms.CheckBox(); - this.snBarcodeGroupBox.SuspendLayout(); + this.barcodeLeftTextBox = new System.Windows.Forms.TextBox(); + this.barcodeTopTextBox = new System.Windows.Forms.TextBox(); + this.barcodeTopLabel = new System.Windows.Forms.Label(); + this.barcodeWidthTextBox = new System.Windows.Forms.TextBox(); + this.barcodeWidthLabel = new System.Windows.Forms.Label(); + this.barcodeHeightTextBox = new System.Windows.Forms.TextBox(); + this.barcodeHeightLabel = new System.Windows.Forms.Label(); + this.barcodeTypeComboBox = new System.Windows.Forms.ComboBox(); + this.barcodeLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // nameTextBox @@ -95,17 +92,6 @@ namespace TBF.BenchControl.Output.Printers.Label this.classNameLabel.TabIndex = 0; this.classNameLabel.Text = "Class name"; // - // supressPrintingCheckBox - // - this.supressPrintingCheckBox.AutoSize = true; - this.supressPrintingCheckBox.Enabled = false; - this.supressPrintingCheckBox.Location = new System.Drawing.Point(245, 200); - this.supressPrintingCheckBox.Name = "supressPrintingCheckBox"; - this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17); - this.supressPrintingCheckBox.TabIndex = 11; - this.supressPrintingCheckBox.Text = "Supress printing"; - this.supressPrintingCheckBox.UseVisualStyleBackColor = true; - // // orientationLabel // this.orientationLabel.AutoSize = true; @@ -289,124 +275,112 @@ namespace TBF.BenchControl.Output.Printers.Label this.goodOnlyCheckBox.Text = "Good only"; this.goodOnlyCheckBox.UseVisualStyleBackColor = true; // - // snBarcodeGroupBox - // - this.snBarcodeGroupBox.Controls.Add(this.barcodeHeightLabel); - this.snBarcodeGroupBox.Controls.Add(this.barcodeHeightTextBox); - this.snBarcodeGroupBox.Controls.Add(this.isQrCheckBox); - this.snBarcodeGroupBox.Controls.Add(this.barcodeWidthLabel); - this.snBarcodeGroupBox.Controls.Add(this.barcodeWidthTextBox); - this.snBarcodeGroupBox.Controls.Add(this.barcodeTopLabel); - this.snBarcodeGroupBox.Controls.Add(this.barcodeTopTextBox); - this.snBarcodeGroupBox.Controls.Add(this.barcodeLeftTextBox); - this.snBarcodeGroupBox.Controls.Add(this.barcodeLeftLabel); - this.snBarcodeGroupBox.Controls.Add(this.snBarcodeCheckBox); - this.snBarcodeGroupBox.Location = new System.Drawing.Point(11, 227); - this.snBarcodeGroupBox.Name = "snBarcodeGroupBox"; - this.snBarcodeGroupBox.Size = new System.Drawing.Size(339, 59); - this.snBarcodeGroupBox.TabIndex = 56; - this.snBarcodeGroupBox.TabStop = false; - // - // barcodeHeightLabel - // - this.barcodeHeightLabel.AutoSize = true; - this.barcodeHeightLabel.Location = new System.Drawing.Point(207, 29); - this.barcodeHeightLabel.Name = "barcodeHeightLabel"; - this.barcodeHeightLabel.Size = new System.Drawing.Size(38, 13); - this.barcodeHeightLabel.TabIndex = 18; - this.barcodeHeightLabel.Text = "Height"; - // - // barcodeHeightTextBox - // - this.barcodeHeightTextBox.Enabled = false; - this.barcodeHeightTextBox.Location = new System.Drawing.Point(247, 25); - this.barcodeHeightTextBox.Name = "barcodeHeightTextBox"; - this.barcodeHeightTextBox.Size = new System.Drawing.Size(32, 20); - this.barcodeHeightTextBox.TabIndex = 17; - // - // isQrCheckBox - // - this.isQrCheckBox.AutoSize = true; - this.isQrCheckBox.Location = new System.Drawing.Point(293, 27); - this.isQrCheckBox.Name = "isQrCheckBox"; - this.isQrCheckBox.Size = new System.Drawing.Size(42, 17); - this.isQrCheckBox.TabIndex = 16; - this.isQrCheckBox.Text = "QR"; - this.isQrCheckBox.UseVisualStyleBackColor = true; - // - // barcodeWidthLabel - // - this.barcodeWidthLabel.AutoSize = true; - this.barcodeWidthLabel.Location = new System.Drawing.Point(135, 29); - this.barcodeWidthLabel.Name = "barcodeWidthLabel"; - this.barcodeWidthLabel.Size = new System.Drawing.Size(35, 13); - this.barcodeWidthLabel.TabIndex = 15; - this.barcodeWidthLabel.Text = "Width"; - // - // barcodeWidthTextBox - // - this.barcodeWidthTextBox.Enabled = false; - this.barcodeWidthTextBox.Location = new System.Drawing.Point(171, 25); - this.barcodeWidthTextBox.Name = "barcodeWidthTextBox"; - this.barcodeWidthTextBox.Size = new System.Drawing.Size(32, 20); - this.barcodeWidthTextBox.TabIndex = 14; - // - // barcodeTopLabel - // - this.barcodeTopLabel.AutoSize = true; - this.barcodeTopLabel.Location = new System.Drawing.Point(71, 29); - this.barcodeTopLabel.Name = "barcodeTopLabel"; - this.barcodeTopLabel.Size = new System.Drawing.Size(26, 13); - this.barcodeTopLabel.TabIndex = 13; - this.barcodeTopLabel.Text = "Top"; - // - // barcodeTopTextBox - // - this.barcodeTopTextBox.Enabled = false; - this.barcodeTopTextBox.Location = new System.Drawing.Point(99, 25); - this.barcodeTopTextBox.Name = "barcodeTopTextBox"; - this.barcodeTopTextBox.Size = new System.Drawing.Size(32, 20); - this.barcodeTopTextBox.TabIndex = 11; - // - // barcodeLeftTextBox - // - this.barcodeLeftTextBox.Enabled = false; - this.barcodeLeftTextBox.Location = new System.Drawing.Point(35, 25); - this.barcodeLeftTextBox.Name = "barcodeLeftTextBox"; - this.barcodeLeftTextBox.Size = new System.Drawing.Size(32, 20); - this.barcodeLeftTextBox.TabIndex = 10; - // // barcodeLeftLabel // this.barcodeLeftLabel.AutoSize = true; - this.barcodeLeftLabel.Location = new System.Drawing.Point(8, 29); + this.barcodeLeftLabel.Location = new System.Drawing.Point(97, 250); this.barcodeLeftLabel.Name = "barcodeLeftLabel"; this.barcodeLeftLabel.Size = new System.Drawing.Size(25, 13); this.barcodeLeftLabel.TabIndex = 9; this.barcodeLeftLabel.Text = "Left"; // - // snBarcodeCheckBox + // barcodeLeftTextBox // - this.snBarcodeCheckBox.AutoSize = true; - this.snBarcodeCheckBox.Location = new System.Drawing.Point(10, 0); - this.snBarcodeCheckBox.Name = "snBarcodeCheckBox"; - this.snBarcodeCheckBox.Size = new System.Drawing.Size(176, 17); - this.snBarcodeCheckBox.TabIndex = 0; - this.snBarcodeCheckBox.Text = "Print barcode with serial number"; - this.snBarcodeCheckBox.UseVisualStyleBackColor = true; - this.snBarcodeCheckBox.CheckedChanged += new System.EventHandler(this.snBarcodeCheckBox_CheckedChanged); + this.barcodeLeftTextBox.Enabled = false; + this.barcodeLeftTextBox.Location = new System.Drawing.Point(122, 246); + this.barcodeLeftTextBox.Name = "barcodeLeftTextBox"; + this.barcodeLeftTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeLeftTextBox.TabIndex = 10; + // + // barcodeTopTextBox + // + this.barcodeTopTextBox.Enabled = false; + this.barcodeTopTextBox.Location = new System.Drawing.Point(181, 246); + this.barcodeTopTextBox.Name = "barcodeTopTextBox"; + this.barcodeTopTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeTopTextBox.TabIndex = 11; + // + // barcodeTopLabel + // + this.barcodeTopLabel.AutoSize = true; + this.barcodeTopLabel.Location = new System.Drawing.Point(155, 250); + this.barcodeTopLabel.Name = "barcodeTopLabel"; + this.barcodeTopLabel.Size = new System.Drawing.Size(26, 13); + this.barcodeTopLabel.TabIndex = 13; + this.barcodeTopLabel.Text = "Top"; + // + // barcodeWidthTextBox + // + this.barcodeWidthTextBox.Enabled = false; + this.barcodeWidthTextBox.Location = new System.Drawing.Point(249, 246); + this.barcodeWidthTextBox.Name = "barcodeWidthTextBox"; + this.barcodeWidthTextBox.Size = new System.Drawing.Size(31, 20); + this.barcodeWidthTextBox.TabIndex = 14; + // + // barcodeWidthLabel + // + this.barcodeWidthLabel.AutoSize = true; + this.barcodeWidthLabel.Location = new System.Drawing.Point(214, 250); + this.barcodeWidthLabel.Name = "barcodeWidthLabel"; + this.barcodeWidthLabel.Size = new System.Drawing.Size(35, 13); + this.barcodeWidthLabel.TabIndex = 15; + this.barcodeWidthLabel.Text = "Width"; + // + // barcodeHeightTextBox + // + this.barcodeHeightTextBox.Enabled = false; + this.barcodeHeightTextBox.Location = new System.Drawing.Point(320, 246); + this.barcodeHeightTextBox.Name = "barcodeHeightTextBox"; + this.barcodeHeightTextBox.Size = new System.Drawing.Size(30, 20); + this.barcodeHeightTextBox.TabIndex = 17; + // + // barcodeHeightLabel + // + this.barcodeHeightLabel.AutoSize = true; + this.barcodeHeightLabel.Location = new System.Drawing.Point(282, 250); + this.barcodeHeightLabel.Name = "barcodeHeightLabel"; + this.barcodeHeightLabel.Size = new System.Drawing.Size(38, 13); + this.barcodeHeightLabel.TabIndex = 18; + this.barcodeHeightLabel.Text = "Height"; + // + // barcodeTypeComboBox + // + this.barcodeTypeComboBox.Enabled = false; + this.barcodeTypeComboBox.FormattingEnabled = true; + this.barcodeTypeComboBox.Location = new System.Drawing.Point(122, 222); + this.barcodeTypeComboBox.Name = "barcodeTypeComboBox"; + this.barcodeTypeComboBox.Size = new System.Drawing.Size(228, 21); + this.barcodeTypeComboBox.TabIndex = 19; + // + // barcodeLabel + // + this.barcodeLabel.AutoSize = true; + this.barcodeLabel.Location = new System.Drawing.Point(8, 225); + this.barcodeLabel.Name = "barcodeLabel"; + this.barcodeLabel.Size = new System.Drawing.Size(88, 13); + this.barcodeLabel.TabIndex = 56; + this.barcodeLabel.Text = "Barcode with s/n"; // // PrinterCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.snBarcodeGroupBox); + this.Controls.Add(this.barcodeLabel); + this.Controls.Add(this.barcodeTypeComboBox); + this.Controls.Add(this.barcodeHeightLabel); this.Controls.Add(this.goodOnlyCheckBox); + this.Controls.Add(this.barcodeHeightTextBox); this.Controls.Add(this.cultureComboBox); + this.Controls.Add(this.barcodeWidthLabel); this.Controls.Add(this.cultureLabel); + this.Controls.Add(this.barcodeWidthTextBox); + this.Controls.Add(this.barcodeTopLabel); this.Controls.Add(this.nrOfCopiesLabel); + this.Controls.Add(this.barcodeTopTextBox); this.Controls.Add(this.nrOfCopiesTextBox); + this.Controls.Add(this.barcodeLeftTextBox); this.Controls.Add(this.itemsToPrintButton); + this.Controls.Add(this.barcodeLeftLabel); this.Controls.Add(this.italicCheckBox); this.Controls.Add(this.boldCheckBox); this.Controls.Add(this.fontSizeTextBox); @@ -421,15 +395,12 @@ namespace TBF.BenchControl.Output.Printers.Label this.Controls.Add(this.templateLabel); this.Controls.Add(this.orientationComboBox); this.Controls.Add(this.orientationLabel); - this.Controls.Add(this.supressPrintingCheckBox); this.Controls.Add(this.nameTextBox); this.Controls.Add(this.nameLabel); this.Controls.Add(this.classNameLabel); this.Name = "PrinterCfgCtrl"; this.Size = new System.Drawing.Size(372, 327); this.Load += new System.EventHandler(this.PrinterCfgCtrl_Load); - this.snBarcodeGroupBox.ResumeLayout(false); - this.snBarcodeGroupBox.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -439,8 +410,7 @@ namespace TBF.BenchControl.Output.Printers.Label private System.Windows.Forms.TextBox nameTextBox; private System.Windows.Forms.Label nameLabel; - private System.Windows.Forms.Label classNameLabel; - private System.Windows.Forms.CheckBox supressPrintingCheckBox; + private System.Windows.Forms.Label classNameLabel; private System.Windows.Forms.Label orientationLabel; private System.Windows.Forms.ComboBox orientationComboBox; private System.Windows.Forms.TextBox templateTextBox; @@ -460,17 +430,16 @@ namespace TBF.BenchControl.Output.Printers.Label private System.Windows.Forms.TextBox nrOfCopiesTextBox; private System.Windows.Forms.ComboBox cultureComboBox; private System.Windows.Forms.Label cultureLabel; - private System.Windows.Forms.CheckBox goodOnlyCheckBox; - private System.Windows.Forms.GroupBox snBarcodeGroupBox; - private System.Windows.Forms.TextBox barcodeTopTextBox; - private System.Windows.Forms.TextBox barcodeLeftTextBox; + private System.Windows.Forms.CheckBox goodOnlyCheckBox; private System.Windows.Forms.Label barcodeLeftLabel; - private System.Windows.Forms.CheckBox snBarcodeCheckBox; - private System.Windows.Forms.Label barcodeWidthLabel; - private System.Windows.Forms.TextBox barcodeWidthTextBox; + private System.Windows.Forms.TextBox barcodeLeftTextBox; + private System.Windows.Forms.TextBox barcodeTopTextBox; private System.Windows.Forms.Label barcodeTopLabel; - private System.Windows.Forms.CheckBox isQrCheckBox; - private System.Windows.Forms.Label barcodeHeightLabel; + private System.Windows.Forms.TextBox barcodeWidthTextBox; + private System.Windows.Forms.Label barcodeWidthLabel; private System.Windows.Forms.TextBox barcodeHeightTextBox; + private System.Windows.Forms.Label barcodeHeightLabel; + private System.Windows.Forms.ComboBox barcodeTypeComboBox; + private System.Windows.Forms.Label barcodeLabel; } } diff --git a/TBF/BenchControl/Output/Printers/Label/PrinterCfgCtrl.cs b/TBF/BenchControl/Output/Printers/Label/PrinterCfgCtrl.cs index 173ff909b..1fb7d0e81 100644 --- a/TBF/BenchControl/Output/Printers/Label/PrinterCfgCtrl.cs +++ b/TBF/BenchControl/Output/Printers/Label/PrinterCfgCtrl.cs @@ -7,6 +7,7 @@ using System.IO; using System.Windows.Forms; using log4net; using Config.Entities; +using Results.Output.Printers; using TBF.BenchControl.Generic; using TBF.BenchControl.Configs; @@ -44,7 +45,10 @@ namespace TBF.BenchControl.Output.Printers.Label fontFamilyComboBox.Items.Add(ff.Name); } - ManageCheckGroupBox(snBarcodeCheckBox, snBarcodeGroupBox); + for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) + { + barcodeTypeComboBox.Items.Add(bt.ToString()); + } } private void PrinterCfgCtrl_Load(object sender, EventArgs e) @@ -82,10 +86,8 @@ namespace TBF.BenchControl.Output.Printers.Label cultureComboBox.Text = config.Culture.ToString(); nrOfCopiesTextBox.Text = config.NrOfCopies.ToString(); goodOnlyCheckBox.Checked = config.GoodOnly; - supressPrintingCheckBox.Checked = config.SupressPrinting; - snBarcodeCheckBox.Checked = config.DrawSNasBarcode; - isQrCheckBox.Checked = config.IsQR; + barcodeTypeComboBox.Text = config.BarcodeType.ToString(); barcodeLeftTextBox.Text = config.BarcodeLeft.ToString(); barcodeTopTextBox.Text = config.BarcodeTop.ToString(); barcodeWidthTextBox.Text = config.BarcodeWidth.ToString(); @@ -107,27 +109,19 @@ namespace TBF.BenchControl.Output.Printers.Label cultureComboBox.Enabled = true; nrOfCopiesTextBox.Enabled = true; goodOnlyCheckBox.Enabled = true; - supressPrintingCheckBox.Enabled = true; - snBarcodeCheckBox.Enabled = true; - ManageCheckGroupBox(snBarcodeCheckBox, snBarcodeGroupBox); - isQrCheckBox.Enabled = true; + barcodeTypeComboBox.Enabled = true; barcodeLeftTextBox.Enabled = true; barcodeTopTextBox.Enabled = true; barcodeWidthTextBox.Enabled = true; barcodeHeightTextBox.Enabled = true; } - private void snBarcodeCheckBox_CheckedChanged(object sender, EventArgs e) - { - ManageCheckGroupBox(snBarcodeCheckBox, snBarcodeGroupBox); - } - public CfgUpdateFlags VerifyCfg(ref string message) { CfgUpdateFlags flags = CfgUpdateFlags.None; - if (!File.Exists(Path.Combine("C:\\TBF\\Templates", templateTextBox.Text))) + if (!string.IsNullOrEmpty(templateTextBox.Text) && !File.Exists(Path.Combine("C:\\TBF\\Templates", templateTextBox.Text))) { message += Environment.NewLine + "Template file missing"; flags |= CfgUpdateFlags.Error; @@ -165,6 +159,12 @@ namespace TBF.BenchControl.Output.Printers.Label message += Environment.NewLine + "'Number of copies' should be between 0 and 9"; flags |= CfgUpdateFlags.Error; } + + if (!barcodeTypeComboBox.Items.Contains(barcodeTypeComboBox.Text)) + { + message += Environment.NewLine + "Invalid barcode type"; + flags |= CfgUpdateFlags.Error; + } if (!int.TryParse(barcodeLeftTextBox.Text, out dummy) || dummy < 0 || dummy > 2000) { message += Environment.NewLine + "Barcode 'Left' should be between 0 and 2000"; @@ -234,10 +234,16 @@ namespace TBF.BenchControl.Output.Printers.Label flags |= UpdateDifferent(ref config.NrOfCopies, nrOfCopiesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.GoodOnly, goodOnlyCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); - flags |= UpdateDifferent(ref config.SupressPrinting, supressPrintingCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); - flags |= UpdateDifferent(ref config.DrawSNasBarcode, snBarcodeCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); - flags |= UpdateDifferent(ref config.IsQR, isQrCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++) + { + if (bt.ToString().Equals(barcodeTypeComboBox.Text)) + { + config.BarcodeType = bt; + flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); + break; + } + } flags |= UpdateDifferent(ref config.BarcodeLeft, barcodeLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BarcodeTop, barcodeTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= UpdateDifferent(ref config.BarcodeWidth, barcodeWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); @@ -264,20 +270,6 @@ namespace TBF.BenchControl.Output.Printers.Label } } - private void ManageCheckGroupBox(CheckBox chk, GroupBox grp) - { - /// Make sure the CheckBox isn't in the GroupBox. This will only happen the first time. - if (chk.Parent == grp) - { - grp.Parent.Controls.Add(chk); /// Reparent the CheckBox so it's not in the GroupBox. - chk.Location = new Point(chk.Left + grp.Left, chk.Top + grp.Top); /// Adjust the CheckBox's location. - chk.BringToFront(); /// Move the CheckBox to the top of the stacking order. - } - - /// Enable or disable the GroupBox. - grp.Enabled = chk.Checked; - } - #region Configuration Change Handling public static void OnCmdResponse(object sender, CmdResponseArgs args) diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index fc6c454da..80836f39c 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.18.1412.0")] -[assembly: AssemblyFileVersion("2.18.1412.0")] +[assembly: AssemblyVersion("2.18.1504.0")] +[assembly: AssemblyFileVersion("2.18.1504.0")] diff --git a/clean.bat b/clean.bat index f3a34da4d..ee80a0f72 100644 --- a/clean.bat +++ b/clean.bat @@ -10,6 +10,8 @@ rmdir /s /q Encrypt\bin rmdir /s /q Encrypt\obj rmdir /s /q GemCard\bin rmdir /s /q GemCard\obj +rmdir /s /q GenCode128\bin +rmdir /s /q GenCode128\obj rmdir /s /q GraphLib\bin rmdir /s /q GraphLib\obj rmdir /s /q TracingDB\bin