From 2b9b875d1ddbdaa47ea0522703be3645629c9968 Mon Sep 17 00:00:00 2001 From: Brad Barnhill Date: Wed, 19 Dec 2018 21:25:53 -0600 Subject: [PATCH] Add Interleaved 2 of 5 Mod 10, Add Standard 2 of 5 Mod 10 --- BarcodeStandard/BarcodeLib.cs | 9 +- BarcodeStandard/BarcodeStandard.csproj | 4 +- BarcodeStandard/Release Notes.txt | 5 + .../Symbologies/Interleaved2of5.cs | 35 ++++-- BarcodeStandard/Symbologies/Standard2of5.cs | 22 +++- .../Properties/AssemblyInfo.cs | 4 +- BarcodeStandardExample/TestApp.Designer.cs | 113 +++++++++--------- BarcodeStandardExample/TestApp.cs | 113 ++++++++++-------- 8 files changed, 174 insertions(+), 131 deletions(-) diff --git a/BarcodeStandard/BarcodeLib.cs b/BarcodeStandard/BarcodeLib.cs index 5c5117b..3bbf7ad 100644 --- a/BarcodeStandard/BarcodeLib.cs +++ b/BarcodeStandard/BarcodeLib.cs @@ -23,7 +23,7 @@ namespace BarcodeLib { #region Enums - public enum TYPE : int { UNSPECIFIED, UPCA, UPCE, UPC_SUPPLEMENTAL_2DIGIT, UPC_SUPPLEMENTAL_5DIGIT, EAN13, EAN8, Interleaved2of5, Standard2of5, Industrial2of5, CODE39, CODE39Extended, CODE39_Mod43, Codabar, PostNet, BOOKLAND, ISBN, JAN13, MSI_Mod10, MSI_2Mod10, MSI_Mod11, MSI_Mod11_Mod10, Modified_Plessey, CODE11, USD8, UCC12, UCC13, LOGMARS, CODE128, CODE128A, CODE128B, CODE128C, ITF14, CODE93, TELEPEN, FIM, PHARMACODE }; + public enum TYPE : int { UNSPECIFIED, UPCA, UPCE, UPC_SUPPLEMENTAL_2DIGIT, UPC_SUPPLEMENTAL_5DIGIT, EAN13, EAN8, Interleaved2of5, Interleaved2of5_Mod10, Standard2of5, Standard2of5_Mod10, Industrial2of5, Industrial2of5_Mod10, CODE39, CODE39Extended, CODE39_Mod43, Codabar, PostNet, BOOKLAND, ISBN, JAN13, MSI_Mod10, MSI_2Mod10, MSI_Mod11, MSI_Mod11_Mod10, Modified_Plessey, CODE11, USD8, UCC12, UCC13, LOGMARS, CODE128, CODE128A, CODE128B, CODE128C, ITF14, CODE93, TELEPEN, FIM, PHARMACODE }; public enum SaveTypes : int { JPG, BMP, PNG, GIF, TIFF, UNSPECIFIED }; public enum AlignmentPositions : int { CENTER, LEFT, RIGHT }; public enum LabelPositions : int { TOPLEFT, TOPCENTER, TOPRIGHT, BOTTOMLEFT, BOTTOMCENTER, BOTTOMRIGHT }; @@ -391,12 +391,15 @@ internal Image Encode() case TYPE.EAN13: //Encode_EAN13(); ibarcode = new EAN13(Raw_Data); break; + case TYPE.Interleaved2of5_Mod10: case TYPE.Interleaved2of5: //Encode_Interleaved2of5(); - ibarcode = new Interleaved2of5(Raw_Data); + ibarcode = new Interleaved2of5(Raw_Data, Encoded_Type); break; + case TYPE.Industrial2of5_Mod10: case TYPE.Industrial2of5: + case TYPE.Standard2of5_Mod10: case TYPE.Standard2of5: //Encode_Standard2of5(); - ibarcode = new Standard2of5(Raw_Data); + ibarcode = new Standard2of5(Raw_Data, Encoded_Type); break; case TYPE.LOGMARS: case TYPE.CODE39: //Encode_Code39(); diff --git a/BarcodeStandard/BarcodeStandard.csproj b/BarcodeStandard/BarcodeStandard.csproj index cc4c69d..ac054ca 100644 --- a/BarcodeStandard/BarcodeStandard.csproj +++ b/BarcodeStandard/BarcodeStandard.csproj @@ -3,13 +3,13 @@ netstandard2.0 true - 2.1.0 + 2.2.0 BarcodeLib Pnuema Productions BarcodeLib Brad Barnhill This library was designed to give an easy class for developers to use when they need to generate barcode images from a string of data. - Copyright 2007-2017 Brad Barnhill + Copyright 2007-2018 Brad Barnhill https://github.com/bbarnhill/barcodelib/blob/master/LICENSE https://github.com/barnhill/barcodelib https://github.com/barnhill/barcodelib/blob/master/BarcodeStandard/examples/upca.gif diff --git a/BarcodeStandard/Release Notes.txt b/BarcodeStandard/Release Notes.txt index 63963dc..f4b9cc5 100644 --- a/BarcodeStandard/Release Notes.txt +++ b/BarcodeStandard/Release Notes.txt @@ -1,5 +1,10 @@ Release Notes for BarcodeLib.dll ================================ +2.2.0.0 +- Add Interleaved 2 of 5 Mod 10 +- Add Standard 2 of 5 Mod 10 +2.1.0.0 +- Fix massive memory leak 2.0.0.0 - Conversion to .NET Standard 2.0 - Build nuget package on every build diff --git a/BarcodeStandard/Symbologies/Interleaved2of5.cs b/BarcodeStandard/Symbologies/Interleaved2of5.cs index 60d4fff..e2aab30 100644 --- a/BarcodeStandard/Symbologies/Interleaved2of5.cs +++ b/BarcodeStandard/Symbologies/Interleaved2of5.cs @@ -8,10 +8,12 @@ namespace BarcodeLib.Symbologies /// class Interleaved2of5 : BarcodeCommon, IBarcode { - private string[] I25_Code = { "NNWWN", "WNNNW", "NWNNW", "WWNNN", "NNWNW", "WNWNN", "NWWNN", "NNNWW", "WNNWN", "NWNWN" }; + private readonly string[] I25_Code = { "NNWWN", "WNNNW", "NWNNW", "WWNNN", "NNWNW", "WNWNN", "NWWNN", "NNNWW", "WNNWN", "NWNWN" }; + private readonly TYPE Encoded_Type = TYPE.UNSPECIFIED; - public Interleaved2of5(string input) + public Interleaved2of5(string input, TYPE EncodedType) { + Encoded_Type = EncodedType; Raw_Data = input; } /// @@ -19,20 +21,21 @@ public Interleaved2of5(string input) /// private string Encode_Interleaved2of5() { - //check length of input - if (Raw_Data.Length % 2 != 0) + //check length of input (only even if no checkdigit, else with check digit odd) + if (Raw_Data.Length % 2 != (Encoded_Type == TYPE.Interleaved2of5_Mod10 ? 1 : 0)) Error("EI25-1: Data length invalid."); if (!CheckNumericOnly(Raw_Data)) Error("EI25-2: Numeric Data Only"); - + string result = "1010"; + string data = Raw_Data + (Encoded_Type == TYPE.Interleaved2of5_Mod10 ? CalculateMod10CheckDigit().ToString() : ""); - for (int i = 0; i < Raw_Data.Length; i += 2) + for (int i = 0; i < data.Length; i += 2) { bool bars = true; - string patternbars = I25_Code[Int32.Parse(Raw_Data[i].ToString())]; - string patternspaces = I25_Code[Int32.Parse(Raw_Data[i + 1].ToString())]; + string patternbars = I25_Code[Int32.Parse(data[i].ToString())]; + string patternspaces = I25_Code[Int32.Parse(data[i + 1].ToString())]; string patternmixed = ""; //interleave @@ -61,14 +64,26 @@ private string Encode_Interleaved2of5() }//else bars = !bars; }//foreach - }//foreach - + //add ending bars result += "1101"; return result; }//Encode_Interleaved2of5 + private int CalculateMod10CheckDigit() + { + int sum = 0; + bool even = true; + for (int i = Raw_Data.Length - 1; i >= 0; --i) + { + sum += Raw_Data[i] * (even ? 3 : 1); + even = !even; + } + + return sum % 10; + } + #region IBarcode Members public string Encoded_Value diff --git a/BarcodeStandard/Symbologies/Standard2of5.cs b/BarcodeStandard/Symbologies/Standard2of5.cs index 45814f2..eeaa920 100644 --- a/BarcodeStandard/Symbologies/Standard2of5.cs +++ b/BarcodeStandard/Symbologies/Standard2of5.cs @@ -8,12 +8,15 @@ namespace BarcodeLib.Symbologies /// class Standard2of5 : BarcodeCommon, IBarcode { - private string[] S25_Code = { "11101010101110", "10111010101110", "11101110101010", "10101110101110", "11101011101010", "10111011101010", "10101011101110", "10101110111010", "11101010111010", "10111010111010" }; + private readonly string[] S25_Code = { "11101010101110", "10111010101110", "11101110101010", "10101110101110", "11101011101010", "10111011101010", "10101011101110", "10101110111010", "11101010111010", "10111010111010" }; + private readonly TYPE Encoded_Type = TYPE.UNSPECIFIED; - public Standard2of5(string input) + public Standard2of5(string input, TYPE EncodedType) { Raw_Data = input; + Encoded_Type = EncodedType; }//Standard2of5 + /// /// Encode the raw data using the Standard 2 of 5 algorithm. /// @@ -29,11 +32,26 @@ private string Encode_Standard2of5() result += S25_Code[Int32.Parse(c.ToString())]; }//foreach + string checkPattern = Encoded_Type == TYPE.Standard2of5_Mod10 ? S25_Code[CalculateMod10CheckDigit()] : ""; + //add ending bars result += "1101011"; return result; }//Encode_Standard2of5 + private int CalculateMod10CheckDigit() + { + int sum = 0; + bool even = true; + for (int i = Raw_Data.Length - 1; i >= 0; --i) + { + sum += Raw_Data[i] * (even ? 3 : 1); + even = !even; + } + + return sum % 10; + } + #region IBarcode Members public string Encoded_Value diff --git a/BarcodeStandardExample/Properties/AssemblyInfo.cs b/BarcodeStandardExample/Properties/AssemblyInfo.cs index 6f662d3..b707849 100644 --- a/BarcodeStandardExample/Properties/AssemblyInfo.cs +++ b/BarcodeStandardExample/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/BarcodeStandardExample/TestApp.Designer.cs b/BarcodeStandardExample/TestApp.Designer.cs index fcfd741..f0036a3 100644 --- a/BarcodeStandardExample/TestApp.Designer.cs +++ b/BarcodeStandardExample/TestApp.Designer.cs @@ -37,6 +37,9 @@ private void InitializeComponent() this.barcode = new System.Windows.Forms.GroupBox(); this.btnMassGeneration = new System.Windows.Forms.Button(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.lblAverageGenerationTime = new System.Windows.Forms.Label(); + this.label14 = new System.Windows.Forms.Label(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.textBoxAspectRatio = new System.Windows.Forms.TextBox(); this.textBoxBarWidth = new System.Windows.Forms.TextBox(); @@ -73,9 +76,6 @@ private void InitializeComponent() this.txtData = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components); - this.progressBar1 = new System.Windows.Forms.ProgressBar(); - this.label14 = new System.Windows.Forms.Label(); - this.lblAverageGenerationTime = new System.Windows.Forms.Label(); this.statusStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); @@ -127,19 +127,19 @@ private void InitializeComponent() this.barcode.Dock = System.Windows.Forms.DockStyle.Fill; this.barcode.Location = new System.Drawing.Point(0, 0); this.barcode.Name = "barcode"; - this.barcode.Size = new System.Drawing.Size(746, 572); + this.barcode.Size = new System.Drawing.Size(745, 572); this.barcode.TabIndex = 36; this.barcode.TabStop = false; this.barcode.Text = "Barcode Image"; // // btnMassGeneration // - this.btnMassGeneration.Location = new System.Drawing.Point(7, 504); + this.btnMassGeneration.Location = new System.Drawing.Point(7, 515); this.btnMassGeneration.Margin = new System.Windows.Forms.Padding(2); this.btnMassGeneration.Name = "btnMassGeneration"; this.btnMassGeneration.Size = new System.Drawing.Size(257, 24); this.btnMassGeneration.TabIndex = 0; - this.btnMassGeneration.Text = "Generate 1500 Barcodes"; + this.btnMassGeneration.Text = "Generate 1000 Barcodes"; this.btnMassGeneration.UseVisualStyleBackColor = true; this.btnMassGeneration.Click += new System.EventHandler(this.btnMassGeneration_Click); // @@ -147,7 +147,6 @@ private void InitializeComponent() // this.splitContainer1.BackColor = System.Drawing.SystemColors.Control; this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; this.splitContainer1.IsSplitterFixed = true; this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Name = "splitContainer1"; @@ -185,10 +184,35 @@ private void InitializeComponent() // this.splitContainer1.Panel2.Controls.Add(this.barcode); this.splitContainer1.Size = new System.Drawing.Size(1015, 572); - this.splitContainer1.SplitterDistance = 265; + this.splitContainer1.SplitterDistance = 266; this.splitContainer1.TabIndex = 37; this.splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer1_SplitterMoved); // + // lblAverageGenerationTime + // + this.lblAverageGenerationTime.AutoSize = true; + this.lblAverageGenerationTime.Location = new System.Drawing.Point(133, 554); + this.lblAverageGenerationTime.Name = "lblAverageGenerationTime"; + this.lblAverageGenerationTime.Size = new System.Drawing.Size(0, 13); + this.lblAverageGenerationTime.TabIndex = 81; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(1, 554); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(134, 13); + this.label14.TabIndex = 80; + this.label14.Text = "Average Generation Time: "; + // + // progressBar1 + // + this.progressBar1.Location = new System.Drawing.Point(8, 543); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(254, 5); + this.progressBar1.TabIndex = 79; + this.progressBar1.Visible = false; + // // groupBox4 // this.groupBox4.Controls.Add(this.textBoxAspectRatio); @@ -202,20 +226,20 @@ private void InitializeComponent() this.groupBox4.Controls.Add(this.label9); this.groupBox4.Location = new System.Drawing.Point(136, 44); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(128, 91); + this.groupBox4.Size = new System.Drawing.Size(128, 93); this.groupBox4.TabIndex = 78; this.groupBox4.TabStop = false; // // textBoxAspectRatio // - this.textBoxAspectRatio.Location = new System.Drawing.Point(71, 67); + this.textBoxAspectRatio.Location = new System.Drawing.Point(73, 67); this.textBoxAspectRatio.Name = "textBoxAspectRatio"; this.textBoxAspectRatio.Size = new System.Drawing.Size(35, 20); this.textBoxAspectRatio.TabIndex = 55; // // textBoxBarWidth // - this.textBoxBarWidth.Location = new System.Drawing.Point(13, 68); + this.textBoxBarWidth.Location = new System.Drawing.Point(16, 68); this.textBoxBarWidth.Name = "textBoxBarWidth"; this.textBoxBarWidth.Size = new System.Drawing.Size(35, 20); this.textBoxBarWidth.TabIndex = 54; @@ -223,7 +247,7 @@ private void InitializeComponent() // label13 // this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(56, 51); + this.label13.Location = new System.Drawing.Point(59, 51); this.label13.Name = "label13"; this.label13.Size = new System.Drawing.Size(65, 13); this.label13.TabIndex = 53; @@ -232,7 +256,7 @@ private void InitializeComponent() // label12 // this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(5, 51); + this.label12.Location = new System.Drawing.Point(8, 51); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(51, 13); this.label12.TabIndex = 52; @@ -240,7 +264,7 @@ private void InitializeComponent() // // txtWidth // - this.txtWidth.Location = new System.Drawing.Point(16, 25); + this.txtWidth.Location = new System.Drawing.Point(19, 25); this.txtWidth.Name = "txtWidth"; this.txtWidth.Size = new System.Drawing.Size(35, 20); this.txtWidth.TabIndex = 43; @@ -249,7 +273,7 @@ private void InitializeComponent() // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(13, 8); + this.label7.Location = new System.Drawing.Point(16, 8); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(35, 13); this.label7.TabIndex = 41; @@ -258,7 +282,7 @@ private void InitializeComponent() // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(59, 8); + this.label6.Location = new System.Drawing.Point(61, 8); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(38, 13); this.label6.TabIndex = 42; @@ -266,7 +290,7 @@ private void InitializeComponent() // // txtHeight // - this.txtHeight.Location = new System.Drawing.Point(61, 25); + this.txtHeight.Location = new System.Drawing.Point(64, 25); this.txtHeight.Name = "txtHeight"; this.txtHeight.Size = new System.Drawing.Size(35, 20); this.txtHeight.TabIndex = 44; @@ -275,7 +299,7 @@ private void InitializeComponent() // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(50, 27); + this.label9.Location = new System.Drawing.Point(53, 27); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(12, 13); this.label9.TabIndex = 51; @@ -333,7 +357,7 @@ private void InitializeComponent() "TopRight"}); this.cbLabelLocation.Location = new System.Drawing.Point(6, 94); this.cbLabelLocation.Name = "cbLabelLocation"; - this.cbLabelLocation.Size = new System.Drawing.Size(90, 21); + this.cbLabelLocation.Size = new System.Drawing.Size(99, 21); this.cbLabelLocation.TabIndex = 0; // // lblLabelLocation @@ -364,13 +388,12 @@ private void InitializeComponent() "Right"}); this.cbRotateFlip.Location = new System.Drawing.Point(7, 106); this.cbRotateFlip.Name = "cbRotateFlip"; - this.cbRotateFlip.Size = new System.Drawing.Size(108, 21); + this.cbRotateFlip.Size = new System.Drawing.Size(127, 21); this.cbRotateFlip.TabIndex = 75; // // btnSave // - this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnSave.Location = new System.Drawing.Point(116, 435); + this.btnSave.Location = new System.Drawing.Point(116, 448); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(57, 46); this.btnSave.TabIndex = 61; @@ -380,8 +403,7 @@ private void InitializeComponent() // // btnSaveXML // - this.btnSaveXML.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnSaveXML.Location = new System.Drawing.Point(179, 435); + this.btnSaveXML.Location = new System.Drawing.Point(179, 448); this.btnSaveXML.Name = "btnSaveXML"; this.btnSaveXML.Size = new System.Drawing.Size(84, 23); this.btnSaveXML.TabIndex = 71; @@ -391,8 +413,7 @@ private void InitializeComponent() // // btnLoadXML // - this.btnLoadXML.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnLoadXML.Location = new System.Drawing.Point(179, 460); + this.btnLoadXML.Location = new System.Drawing.Point(179, 474); this.btnLoadXML.Name = "btnLoadXML"; this.btnLoadXML.Size = new System.Drawing.Size(84, 23); this.btnLoadXML.TabIndex = 72; @@ -411,8 +432,7 @@ private void InitializeComponent() // // btnEncode // - this.btnEncode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnEncode.Location = new System.Drawing.Point(7, 435); + this.btnEncode.Location = new System.Drawing.Point(7, 448); this.btnEncode.Name = "btnEncode"; this.btnEncode.Size = new System.Drawing.Size(105, 46); this.btnEncode.TabIndex = 60; @@ -431,14 +451,12 @@ private void InitializeComponent() // // txtEncoded // - this.txtEncoded.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); this.txtEncoded.Location = new System.Drawing.Point(7, 262); this.txtEncoded.Multiline = true; this.txtEncoded.Name = "txtEncoded"; this.txtEncoded.ReadOnly = true; this.txtEncoded.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtEncoded.Size = new System.Drawing.Size(256, 167); + this.txtEncoded.Size = new System.Drawing.Size(256, 170); this.txtEncoded.TabIndex = 62; this.txtEncoded.TabStop = false; // @@ -471,7 +489,7 @@ private void InitializeComponent() "Right"}); this.cbBarcodeAlign.Location = new System.Drawing.Point(7, 148); this.cbBarcodeAlign.Name = "cbBarcodeAlign"; - this.cbBarcodeAlign.Size = new System.Drawing.Size(107, 21); + this.cbBarcodeAlign.Size = new System.Drawing.Size(127, 21); this.cbBarcodeAlign.TabIndex = 73; // // btnForeColor @@ -525,7 +543,9 @@ private void InitializeComponent() "EAN-8", "ITF-14", "Interleaved 2 of 5", + "Interleaved 2 of 5 Mod 10", "Standard 2 of 5", + "Standard 2 of 5 Mod 10", "Codabar", "PostNet", "Bookland/ISBN", @@ -545,7 +565,7 @@ private void InitializeComponent() "Pharmacode"}); this.cbEncodeType.Location = new System.Drawing.Point(7, 64); this.cbEncodeType.Name = "cbEncodeType"; - this.cbEncodeType.Size = new System.Drawing.Size(108, 21); + this.cbEncodeType.Size = new System.Drawing.Size(127, 21); this.cbEncodeType.TabIndex = 59; // // txtData @@ -569,31 +589,6 @@ private void InitializeComponent() // this.errorProvider1.ContainerControl = this; // - // progressBar1 - // - this.progressBar1.Location = new System.Drawing.Point(8, 531); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(254, 5); - this.progressBar1.TabIndex = 79; - this.progressBar1.Visible = false; - // - // label14 - // - this.label14.AutoSize = true; - this.label14.Location = new System.Drawing.Point(8, 543); - this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(134, 13); - this.label14.TabIndex = 80; - this.label14.Text = "Average Generation Time: "; - // - // lblAverageGenerationTime - // - this.lblAverageGenerationTime.AutoSize = true; - this.lblAverageGenerationTime.Location = new System.Drawing.Point(140, 543); - this.lblAverageGenerationTime.Name = "lblAverageGenerationTime"; - this.lblAverageGenerationTime.Size = new System.Drawing.Size(0, 13); - this.lblAverageGenerationTime.TabIndex = 81; - // // TestApp // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -603,7 +598,7 @@ private void InitializeComponent() this.Controls.Add(this.statusStrip1); this.DoubleBuffered = true; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MinimumSize = new System.Drawing.Size(637, 392); + this.MinimumSize = new System.Drawing.Size(635, 386); this.Name = "TestApp"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Barcode Encoder"; diff --git a/BarcodeStandardExample/TestApp.cs b/BarcodeStandardExample/TestApp.cs index e41d893..c903ffb 100644 --- a/BarcodeStandardExample/TestApp.cs +++ b/BarcodeStandardExample/TestApp.cs @@ -14,7 +14,7 @@ namespace BarcodeStandardExample /// public partial class TestApp : Form { - BarcodeLib.Barcode b = new BarcodeLib.Barcode(); + Barcode b = new Barcode(); public TestApp() { @@ -39,7 +39,7 @@ private void TestApp_Load(object sender, EventArgs e) this.cbRotateFlip.SelectedIndex = i; //Show library version - this.tslblLibraryVersion.Text = "Barcode Library Version: " + BarcodeLib.Barcode.Version.ToString(); + this.tslblLibraryVersion.Text = "Barcode Library Version: " + Barcode.Version.ToString(); this.btnBackColor.BackColor = this.b.BackColor; this.btnForeColor.BackColor = this.b.ForeColor; @@ -50,52 +50,54 @@ private void btnEncode_Click(object sender, EventArgs e) errorProvider1.Clear(); int W = Convert.ToInt32(this.txtWidth.Text.Trim()); int H = Convert.ToInt32(this.txtHeight.Text.Trim()); - b.Alignment = BarcodeLib.AlignmentPositions.CENTER; + b.Alignment = AlignmentPositions.CENTER; //barcode alignment switch (cbBarcodeAlign.SelectedItem.ToString().Trim().ToLower()) { - case "left": b.Alignment = BarcodeLib.AlignmentPositions.LEFT; break; - case "right": b.Alignment = BarcodeLib.AlignmentPositions.RIGHT; break; - default: b.Alignment = BarcodeLib.AlignmentPositions.CENTER; break; + case "left": b.Alignment = AlignmentPositions.LEFT; break; + case "right": b.Alignment = AlignmentPositions.RIGHT; break; + default: b.Alignment = AlignmentPositions.CENTER; break; }//switch - BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED; + TYPE type = TYPE.UNSPECIFIED; switch (cbEncodeType.SelectedItem.ToString().Trim()) { - case "UPC-A": type = BarcodeLib.TYPE.UPCA; break; - case "UPC-E": type = BarcodeLib.TYPE.UPCE; break; - case "UPC 2 Digit Ext.": type = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_2DIGIT; break; - case "UPC 5 Digit Ext.": type = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_5DIGIT; break; - case "EAN-13": type = BarcodeLib.TYPE.EAN13; break; - case "JAN-13": type = BarcodeLib.TYPE.JAN13; break; - case "EAN-8": type = BarcodeLib.TYPE.EAN8; break; - case "ITF-14": type = BarcodeLib.TYPE.ITF14; break; - case "Codabar": type = BarcodeLib.TYPE.Codabar; break; - case "PostNet": type = BarcodeLib.TYPE.PostNet; break; - case "Bookland/ISBN": type = BarcodeLib.TYPE.BOOKLAND; break; - case "Code 11": type = BarcodeLib.TYPE.CODE11; break; - case "Code 39": type = BarcodeLib.TYPE.CODE39; break; - case "Code 39 Extended": type = BarcodeLib.TYPE.CODE39Extended; break; - case "Code 39 Mod 43": type = BarcodeLib.TYPE.CODE39_Mod43; break; - case "Code 93": type = BarcodeLib.TYPE.CODE93; break; - case "LOGMARS": type = BarcodeLib.TYPE.LOGMARS; break; - case "MSI": type = BarcodeLib.TYPE.MSI_Mod10; break; - case "Interleaved 2 of 5": type = BarcodeLib.TYPE.Interleaved2of5; break; - case "Standard 2 of 5": type = BarcodeLib.TYPE.Standard2of5; break; - case "Code 128": type = BarcodeLib.TYPE.CODE128; break; - case "Code 128-A": type = BarcodeLib.TYPE.CODE128A; break; - case "Code 128-B": type = BarcodeLib.TYPE.CODE128B; break; - case "Code 128-C": type = BarcodeLib.TYPE.CODE128C; break; - case "Telepen": type = BarcodeLib.TYPE.TELEPEN; break; - case "FIM": type = BarcodeLib.TYPE.FIM; break; - case "Pharmacode": type = BarcodeLib.TYPE.PHARMACODE; break; + case "UPC-A": type = TYPE.UPCA; break; + case "UPC-E": type = TYPE.UPCE; break; + case "UPC 2 Digit Ext.": type = TYPE.UPC_SUPPLEMENTAL_2DIGIT; break; + case "UPC 5 Digit Ext.": type = TYPE.UPC_SUPPLEMENTAL_5DIGIT; break; + case "EAN-13": type = TYPE.EAN13; break; + case "JAN-13": type = TYPE.JAN13; break; + case "EAN-8": type = TYPE.EAN8; break; + case "ITF-14": type = TYPE.ITF14; break; + case "Codabar": type = TYPE.Codabar; break; + case "PostNet": type = TYPE.PostNet; break; + case "Bookland/ISBN": type = TYPE.BOOKLAND; break; + case "Code 11": type = TYPE.CODE11; break; + case "Code 39": type = TYPE.CODE39; break; + case "Code 39 Extended": type = TYPE.CODE39Extended; break; + case "Code 39 Mod 43": type = TYPE.CODE39_Mod43; break; + case "Code 93": type = TYPE.CODE93; break; + case "LOGMARS": type = TYPE.LOGMARS; break; + case "MSI": type = TYPE.MSI_Mod10; break; + case "Interleaved 2 of 5": type = TYPE.Interleaved2of5; break; + case "Interleaved 2 of 5 Mod 10": type = TYPE.Interleaved2of5_Mod10; break; + case "Standard 2 of 5": type = TYPE.Standard2of5; break; + case "Standard 2 of 5 Mod 10": type = TYPE.Standard2of5_Mod10; break; + case "Code 128": type = TYPE.CODE128; break; + case "Code 128-A": type = TYPE.CODE128A; break; + case "Code 128-B": type = TYPE.CODE128B; break; + case "Code 128-C": type = TYPE.CODE128C; break; + case "Telepen": type = TYPE.TELEPEN; break; + case "FIM": type = TYPE.FIM; break; + case "Pharmacode": type = TYPE.PHARMACODE; break; default: MessageBox.Show("Please specify the encoding type."); break; }//switch try { - if (type != BarcodeLib.TYPE.UNSPECIFIED) + if (type != TYPE.UNSPECIFIED) { try { @@ -125,12 +127,12 @@ private void btnEncode_Click(object sender, EventArgs e) //label alignment and position switch (this.cbLabelLocation.SelectedItem.ToString().Trim().ToUpper()) { - case "BOTTOMLEFT": b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMLEFT; break; - case "BOTTOMRIGHT": b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMRIGHT; break; - case "TOPCENTER": b.LabelPosition = BarcodeLib.LabelPositions.TOPCENTER; break; - case "TOPLEFT": b.LabelPosition = BarcodeLib.LabelPositions.TOPLEFT; break; - case "TOPRIGHT": b.LabelPosition = BarcodeLib.LabelPositions.TOPRIGHT; break; - default: b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER; break; + case "BOTTOMLEFT": b.LabelPosition = LabelPositions.BOTTOMLEFT; break; + case "BOTTOMRIGHT": b.LabelPosition = LabelPositions.BOTTOMRIGHT; break; + case "TOPCENTER": b.LabelPosition = LabelPositions.TOPCENTER; break; + case "TOPLEFT": b.LabelPosition = LabelPositions.TOPLEFT; break; + case "TOPRIGHT": b.LabelPosition = LabelPositions.TOPRIGHT; break; + default: b.LabelPosition = LabelPositions.BOTTOMCENTER; break; }//switch //===== Encoding performed here ===== @@ -168,14 +170,14 @@ private void btnSave_Click(object sender, EventArgs e) sfd.AddExtension = true; if (sfd.ShowDialog() == DialogResult.OK) { - BarcodeLib.SaveTypes savetype = BarcodeLib.SaveTypes.UNSPECIFIED; + SaveTypes savetype = SaveTypes.UNSPECIFIED; switch (sfd.FilterIndex) { - case 1: /* BMP */ savetype = BarcodeLib.SaveTypes.BMP; break; - case 2: /* GIF */ savetype = BarcodeLib.SaveTypes.GIF; break; - case 3: /* JPG */ savetype = BarcodeLib.SaveTypes.JPG; break; - case 4: /* PNG */ savetype = BarcodeLib.SaveTypes.PNG; break; - case 5: /* TIFF */ savetype = BarcodeLib.SaveTypes.TIFF; break; + case 1: /* BMP */ savetype = SaveTypes.BMP; break; + case 2: /* GIF */ savetype = SaveTypes.GIF; break; + case 3: /* JPG */ savetype = SaveTypes.JPG; break; + case 4: /* PNG */ savetype = SaveTypes.PNG; break; + case 5: /* TIFF */ savetype = SaveTypes.TIFF; break; default: break; }//switch b.SaveImage(sfd.FileName, savetype); @@ -222,7 +224,7 @@ private void btnSaveXML_Click(object sender, EventArgs e) sfd.Filter = "XML Files|*.xml"; if (sfd.ShowDialog() == DialogResult.OK) { - using (System.IO.StreamWriter sw = new System.IO.StreamWriter(sfd.FileName)) + using (StreamWriter sw = new StreamWriter(sfd.FileName)) { sw.Write(b.XML); }//using @@ -237,13 +239,13 @@ private void btnLoadXML_Click(object sender, EventArgs e) ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { - string fileContents = System.IO.File.ReadAllText(ofd.FileName); - using (BarcodeStandard.SaveData XML = BarcodeLib.Barcode.GetSaveDataFromFile(fileContents)) + string fileContents = File.ReadAllText(ofd.FileName); + using (BarcodeStandard.SaveData XML = Barcode.GetSaveDataFromFile(fileContents)) { //load image from xml this.barcode.Width = XML.ImageWidth; this.barcode.Height = XML.ImageHeight; - this.barcode.BackgroundImage = BarcodeLib.Barcode.GetImageFromXML(fileContents); + this.barcode.BackgroundImage = Barcode.GetImageFromXML(fileContents); //populate the screen this.txtData.Text = XML.RawData; @@ -259,10 +261,15 @@ private void btnLoadXML_Click(object sender, EventArgs e) case "EAN13": this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("EAN-13"); break; + case "Interleaved2of5_Mod10": + this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Interleaved 2 of 5 Mod 10"); + break; case "Interleaved2of5": this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Interleaved 2 of 5"); break; - case "Industrial2of5": + case "Standard2of5_Mod10": + this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Standard 2 of 5 Mod 10"); + break; case "Standard2of5": this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Standard 2 of 5"); break; @@ -360,7 +367,7 @@ private void btnLoadXML_Click(object sender, EventArgs e) private void btnMassGeneration_Click(object sender, EventArgs e) { - int x = 1500; + int x = 1000; double sum = 0; progressBar1.Visible = true;