Barcode printing for CEVAK

This commit is contained in:
Milan Hanajik
2020-07-17 10:27:25 +02:00
parent e089b62006
commit 3fb79bb1ae
24 changed files with 1072 additions and 253 deletions
+2
View File
@@ -10,6 +10,8 @@ Encrypt/bin/
Encrypt/obj/
GemCard/bin
GemCard/obj
GenCode128/bin
GenCode128/obj
GraphLib/bin
GraphLib/obj
TracingDB/bin
+51
View File
@@ -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\<configuration>. 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("")]
+139
View File
@@ -0,0 +1,139 @@
namespace GenCode128
{
/// <summary>
/// Static tools for determining codes for individual characters in the content
/// </summary>
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;
/// <summary>
/// Indicates which code sets can represent a character -- CodeA, CodeB, or either
/// </summary>
public enum CodeSetAllowed
{
CodeA,
CodeB,
CodeAorB
}
/// <summary>
/// Get the Code128 code value(s) to represent an ASCII character, with
/// optional look-ahead for length optimization
/// </summary>
/// <param name="charAscii">The ASCII value of the character to translate</param>
/// <param name="lookAheadAscii">The next character in sequence (or -1 if none)</param>
/// <param name="currentCodeSet">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</param>
/// <returns>An array of integers representing the codes that need to be output to produce the
/// given character</returns>
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;
}
/// <summary>
/// Tells us which codesets a given character value is allowed in
/// </summary>
/// <param name="charAscii">ASCII value of character to look at</param>
/// <returns>Which codeset(s) can be used to represent this character</returns>
public static CodeSetAllowed CodesetAllowedForChar(int charAscii)
{
if (charAscii >= 32 && charAscii <= 95)
{
return CodeSetAllowed.CodeAorB;
}
else
{
return charAscii < 32 ? CodeSetAllowed.CodeA : CodeSetAllowed.CodeB;
}
}
/// <summary>
/// Determine if a character can be represented in a given codeset
/// </summary>
/// <param name="charAscii">character to check for</param>
/// <param name="currentCodeSet">codeset context to test</param>
/// <returns>true if the codeset contains a representation for the ASCII character</returns>
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);
}
/// <summary>
/// Gets the integer code128 code value for a character (assuming the appropriate code set)
/// </summary>
/// <param name="charAscii">character to convert</param>
/// <returns>code128 symbol value for the character</returns>
public static int CodeValueForChar(int charAscii)
{
return charAscii >= 32 ? charAscii - 32 : charAscii + 64;
}
/// <summary>
/// Return the appropriate START code depending on the codeset we want to be in
/// </summary>
/// <param name="cs">The codeset you want to start in</param>
/// <returns>The code128 code to start a barcode in that codeset</returns>
public static int StartCodeForCodeSet(CodeSet cs)
{
return cs == CodeSet.CodeA ? CStartA : CStartB;
}
/// <summary>
/// Return the Code128 stop code
/// </summary>
/// <returns>the stop code</returns>
public static int StopCode()
{
return CStop;
}
}
}
+97
View File
@@ -0,0 +1,97 @@
namespace GenCode128
{
using System.Collections;
using System.Text;
/// <summary>
/// Represent the set of code values to be output into barcode form
/// </summary>
public class Code128Content
{
/// <summary>
/// Create content based on a string of ASCII data
/// </summary>
/// <param name="asciiData">the string that should be represented</param>
public Code128Content(string asciiData)
{
this.Codes = this.StringToCode128(asciiData);
}
/// <summary>
/// Provides the Code128 code values representing the object's string
/// </summary>
public int[] Codes
{
get { return codes; }
set { codes = value; }
}
int[] codes;
/// <summary>
/// Transform the string into integers representing the Code128 codes
/// necessary to represent it
/// </summary>
/// <param name="asciiData">String to be encoded</param>
/// <returns>Code128 representation</returns>
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;
}
/// <summary>
/// Determines the best starting code set based on the the first two
/// characters of the string to be encoded
/// </summary>
/// <param name="csa1">First character of input string</param>
/// <param name="csa2">Second character of input string</param>
/// <returns>The codeset determined to be best to start with</returns>
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
}
}
}
+188
View File
@@ -0,0 +1,188 @@
namespace GenCode128
{
using System;
using System.Drawing;
/// <summary>
/// Summary description for Code128Rendering.
/// </summary>
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
};
/// <summary>
/// Make an image of a Code128 barcode for a given string
/// </summary>
/// <param name="inputData">Message to be encoded</param>
/// <param name="barWeight">Base thickness for bar width (1 or 2 works well)</param>
/// <param name="addQuietZone">Add required horizontal margins (use if output is tight)</param>
/// <returns>An Image of the Code128 barcode representing the message</returns>
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;
}
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace GenCode128
{
public enum CodeSet
{
CodeA,
CodeB
//// CodeC // not supported
}
}
+147
View File
@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{32817BF9-E380-4467-9C7F-936F4B122BC7}</ProjectGuid>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>GenCode128</AssemblyName>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>GenCode128</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<OldToolsVersion>2.0</OldToolsVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>
</NoWarn>
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>false</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>
</NoWarn>
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>none</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Drawing">
<Name>System.Drawing</Name>
</Reference>
<Reference Include="System.Windows.Forms">
<Name>System.Windows.Forms</Name>
</Reference>
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Code128Code.cs" />
<Compile Include="CodeSet.cs" />
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Code128Content.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Code128Rendering.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
@@ -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));
}
}
}
}
}
}
@@ -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;
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
namespace Results.Output.Printers
{
public enum BarcodeType
{
None,
Code_128_Horizontally,
Code_128_Vertically,
QR_Code,
Count
}
}
@@ -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
}
}
}
@@ -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;
+5
View File
@@ -134,6 +134,7 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="Output\Printers\Enhanced\EnhancedPrinterCfg.cs" />
<Compile Include="Output\Printers\Enums.cs" />
<Compile Include="Output\Printers\Label\LabelPrintDocument.cs">
<SubType>Component</SubType>
</Compile>
@@ -173,6 +174,10 @@
<Project>{743DF7DB-C7B6-42EB-986D-0F485E5588E4}</Project>
<Name>Config</Name>
</ProjectReference>
<ProjectReference Include="..\GenCode128\GenCode128.csproj">
<Project>{32817bf9-e380-4467-9c7f-936f4b122bc7}</Project>
<Name>GenCode128</Name>
</ProjectReference>
<ProjectReference Include="..\TracingDB\TracingDB.csproj">
<Project>{EFEC8A31-3022-4DA7-A8F6-16D30A94C3FF}</Project>
<Name>TracingDB</Name>
+12
View File
@@ -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
@@ -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++)
@@ -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;
@@ -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;
}
}
@@ -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));
@@ -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); } }
/// <summary> Data to print </summary>
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,
@@ -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()
);
}
}
+105 -136
View File
@@ -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;
}
}
@@ -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)
+2 -2
View File
@@ -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")]
+2
View File
@@ -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