diff --git a/BarcodeStandard/BarcodeLib.cs b/BarcodeStandard/BarcodeLib.cs
index a908da8..739a1eb 100644
--- a/BarcodeStandard/BarcodeLib.cs
+++ b/BarcodeStandard/BarcodeLib.cs
@@ -8,6 +8,9 @@
using BarcodeStandard;
using System.Xml.Serialization;
using System.Security;
+using System.Xml;
+using System.Text;
+using System.Text.Json;
/*
* ***************************************************
@@ -21,7 +24,6 @@
* barcode images from a string of data. *
* ***************************************************
*/
-[assembly: AllowPartiallyTrustedCallers]
namespace BarcodeLib
{
#region Enums
@@ -33,6 +35,7 @@ public enum LabelPositions : int { TOPLEFT, TOPCENTER, TOPRIGHT, BOTTOMLEFT, BOT
///
/// Generates a barcode image of a specified symbology from a string of data.
///
+ [SecuritySafeCritical]
public class Barcode : IDisposable
{
#region Variables
@@ -46,7 +49,6 @@ public class Barcode : IDisposable
private Color _BackColor = Color.White;
private int _Width = 300;
private int _Height = 150;
- private string _XML = "";
private ImageFormat _ImageFormat = ImageFormat.Jpeg;
private Font _LabelFont = new Font("Microsoft Sans Serif", 10 * DotsPerPointAt96Dpi, FontStyle.Bold, GraphicsUnit.Pixel);
private LabelPositions _LabelPosition = LabelPositions.BOTTOMCENTER;
@@ -253,13 +255,6 @@ public double EncodingTime
set;
}
///
- /// Gets the XML representation of the Barcode data and image.
- ///
- public string XML
- {
- get { return _XML; }
- }
- ///
/// Gets or sets the image format to use when encoding and returning images. (Jpeg is default)
///
public ImageFormat ImageFormat
@@ -408,8 +403,6 @@ internal Image Encode()
this.EncodingTime = ((TimeSpan)(DateTime.Now - dtStartTime)).TotalMilliseconds;
- _XML = GetXML();
-
return EncodedImage;
}//Encode
@@ -1057,7 +1050,44 @@ public ImageSize GetSizeOfImage(bool Metric)
#endregion
#region XML Methods
- private string GetXML()
+
+ private SaveData GetSaveData(Boolean includeImage = true)
+ {
+ SaveData saveData = new SaveData();
+ saveData.Type = EncodedType.ToString();
+ saveData.RawData = RawData;
+ saveData.EncodedValue = EncodedValue;
+ saveData.EncodingTime = EncodingTime;
+ saveData.IncludeLabel = IncludeLabel;
+ saveData.Forecolor = ColorTranslator.ToHtml(ForeColor);
+ saveData.Backcolor = ColorTranslator.ToHtml(BackColor);
+ saveData.CountryAssigningManufacturingCode = Country_Assigning_Manufacturer_Code;
+ saveData.ImageWidth = Width;
+ saveData.ImageHeight = Height;
+ saveData.RotateFlipType = RotateFlipType;
+ saveData.LabelPosition = (int)LabelPosition;
+ saveData.LabelFont = LabelFont.ToString();
+ saveData.ImageFormat = ImageFormat.ToString();
+ saveData.Alignment = (int)Alignment;
+
+ //get image in base 64
+ if (includeImage)
+ {
+ using (MemoryStream ms = new MemoryStream())
+ {
+ EncodedImage.Save(ms, ImageFormat);
+ saveData.Image = Convert.ToBase64String(ms.ToArray(), Base64FormattingOptions.None);
+ }//using
+ }
+ return saveData;
+ }
+ public string ToJSON(Boolean includeImage = true)
+ {
+ byte[] bytes = JsonSerializer.SerializeToUtf8Bytes(GetSaveData(includeImage));
+ return (new UTF8Encoding(false)).GetString(bytes); //no BOM
+ }
+
+ public string ToXML(Boolean includeImage = true)
{
if (EncodedValue == "")
throw new Exception("EGETXML-1: Could not retrieve XML due to the barcode not being encoded first. Please call Encode first.");
@@ -1065,35 +1095,14 @@ private string GetXML()
{
try
{
- using (SaveData xml = new SaveData())
+ using (SaveData xml = GetSaveData(includeImage))
{
- xml.Type = EncodedType.ToString();
- xml.RawData = RawData;
- xml.EncodedValue = EncodedValue;
- xml.EncodingTime = EncodingTime;
- xml.IncludeLabel = IncludeLabel;
- xml.Forecolor = ColorTranslator.ToHtml(ForeColor);
- xml.Backcolor = ColorTranslator.ToHtml(BackColor);
- xml.CountryAssigningManufacturingCode = Country_Assigning_Manufacturer_Code;
- xml.ImageWidth = Width;
- xml.ImageHeight = Height;
- xml.RotateFlipType = RotateFlipType;
- xml.LabelPosition = (int)LabelPosition;
- xml.LabelFont = LabelFont.ToString();
- xml.ImageFormat = ImageFormat.ToString();
- xml.Alignment = (int)Alignment;
-
- //get image in base 64
- using (MemoryStream ms = new MemoryStream())
- {
- EncodedImage.Save(ms, ImageFormat);
- xml.Image = Convert.ToBase64String(ms.ToArray(), Base64FormattingOptions.None);
- }//using
-
XmlSerializer writer = new XmlSerializer(typeof(SaveData));
- StringWriter sw = new StringWriter();
- writer.Serialize(sw, xml);
- return sw.ToString();
+ using (Utf8StringWriter sw = new Utf8StringWriter())
+ {
+ writer.Serialize(sw, xml);
+ return sw.ToString();
+ }
}//using
}//try
catch (Exception ex)
@@ -1102,36 +1111,46 @@ private string GetXML()
}//catch
}//else
}
- public static SaveData GetSaveDataFromFile(string fileContents)
+ public static SaveData FromJSON(Stream jsonStream)
+ {
+ using (jsonStream)
+ {
+ if (jsonStream is MemoryStream)
+ {
+ return JsonSerializer.Deserialize(((MemoryStream)jsonStream).ToArray());
+ }
+ else
+ {
+ using (var memoryStream = new MemoryStream())
+ {
+ jsonStream.CopyTo(memoryStream);
+ return JsonSerializer.Deserialize(memoryStream.ToArray());
+ }
+ }
+
+ }
+ }
+ public static SaveData FromXML(Stream xmlStream)
{
try
{
XmlSerializer serializer = new XmlSerializer(typeof(SaveData));
- SaveData saveData;
- using (TextReader reader = new StringReader(fileContents))
+ using (XmlReader reader = XmlReader.Create(xmlStream))
{
- saveData = (SaveData)serializer.Deserialize(reader);
+ return (SaveData)serializer.Deserialize(reader);
}
-
- return saveData;
}//try
catch (Exception ex)
{
throw new Exception("EGETIMAGEFROMXML-1: " + ex.Message);
}//catch
}
- public static Image GetImageFromXML(String internalXML)
+ public static Image GetImageFromSaveData(SaveData saveData)
{
try
{
- XmlSerializer serializer = new XmlSerializer(typeof(SaveData));
- SaveData result;
- using (TextReader reader = new StringReader(internalXML))
- {
- result = (SaveData)serializer.Deserialize(reader);
- }
//loading it to memory stream and then to image object
- using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(result.Image)))
+ using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(saveData.Image)))
{
return Image.FromStream(ms);
}//using
@@ -1141,6 +1160,11 @@ public static Image GetImageFromXML(String internalXML)
throw new Exception("EGETIMAGEFROMXML-1: " + ex.Message);
}//catch
}
+
+ public class Utf8StringWriter : StringWriter
+ {
+ public override Encoding Encoding => new UTF8Encoding(false);
+ }
#endregion
#region Static Encode Methods
@@ -1169,7 +1193,7 @@ public static Image DoEncode(TYPE iType, string Data, ref string XML)
using (Barcode b = new Barcode())
{
Image i = b.Encode(iType, Data);
- XML = b.XML;
+ XML = b.ToXML();
return i;
}//using
}
@@ -1259,7 +1283,7 @@ public static Image DoEncode(TYPE iType, string Data, bool IncludeLabel, Color D
{
b.IncludeLabel = IncludeLabel;
Image i = b.Encode(iType, Data, DrawColor, BackColor, Width, Height);
- XML = b.XML;
+ XML = b.ToXML();
return i;
}//using
}
@@ -1286,7 +1310,6 @@ protected virtual void Dispose(bool disposing)
_Encoded_Image?.Dispose();
_Encoded_Image = null;
- _XML = null;
Raw_Data = null;
Encoded_Value = null;
_Country_Assigning_Manufacturer_Code = null;
diff --git a/BarcodeStandard/BarcodeStandard.csproj b/BarcodeStandard/BarcodeStandard.csproj
index 28b8d52..09de9bf 100644
--- a/BarcodeStandard/BarcodeStandard.csproj
+++ b/BarcodeStandard/BarcodeStandard.csproj
@@ -3,7 +3,7 @@
netstandard2.0
true
- 2.2.10
+ 2.3.0
BarcodeLib
Pnuema Productions
BarcodeLib
@@ -19,8 +19,8 @@
LICENSE.txt
upca.jpg
- 2.2.10.0
- 2.2.10.0
+ 2.3.0.0
+ 2.3.0.0
@@ -28,7 +28,8 @@
-
+
+
diff --git a/BarcodeStandard/Release Notes.txt b/BarcodeStandard/Release Notes.txt
index 818df73..cb4a902 100644
--- a/BarcodeStandard/Release Notes.txt
+++ b/BarcodeStandard/Release Notes.txt
@@ -1,5 +1,8 @@
Release Notes for BarcodeLib.dll
================================
+2.3.0.0
+- Fix EAN13 country code lookup failure
+- Update to System.Drawing.Common 5.0.0
2.2.10.0
- Fix Standard 2 of 5 encoding bug
2.2.9.0
diff --git a/BarcodeStandardExample/BarcodeStandardExample.csproj b/BarcodeStandardExample/BarcodeStandardExample.csproj
index 08a229e..9ff54a5 100644
--- a/BarcodeStandardExample/BarcodeStandardExample.csproj
+++ b/BarcodeStandardExample/BarcodeStandardExample.csproj
@@ -92,10 +92,5 @@
-
-
- 4.5.1
-
-
\ No newline at end of file
diff --git a/BarcodeStandardExample/TestApp.Designer.cs b/BarcodeStandardExample/TestApp.Designer.cs
index f0036a3..e3d4c40 100644
--- a/BarcodeStandardExample/TestApp.Designer.cs
+++ b/BarcodeStandardExample/TestApp.Designer.cs
@@ -37,6 +37,8 @@ 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.btnSaveJSON = new System.Windows.Forms.Button();
+ this.btnLoadJSON = new System.Windows.Forms.Button();
this.lblAverageGenerationTime = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
@@ -76,6 +78,9 @@ 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.chkIncludeImageInSavedData = new System.Windows.Forms.CheckBox();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
this.statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
@@ -84,6 +89,8 @@ private void InitializeComponent()
this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit();
+ this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// statusStrip1
@@ -93,9 +100,10 @@ private void InitializeComponent()
this.tsslEncodedType,
this.tslblLibraryVersion,
this.tslblCredits});
- this.statusStrip1.Location = new System.Drawing.Point(0, 572);
+ this.statusStrip1.Location = new System.Drawing.Point(0, 908);
this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(1015, 24);
+ this.statusStrip1.Padding = new System.Windows.Forms.Padding(2, 0, 21, 0);
+ this.statusStrip1.Size = new System.Drawing.Size(1522, 36);
this.statusStrip1.SizingGrip = false;
this.statusStrip1.TabIndex = 30;
this.statusStrip1.Text = "statusStrip1";
@@ -104,20 +112,20 @@ private void InitializeComponent()
//
this.tsslEncodedType.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right;
this.tsslEncodedType.Name = "tsslEncodedType";
- this.tsslEncodedType.Size = new System.Drawing.Size(4, 19);
+ this.tsslEncodedType.Size = new System.Drawing.Size(4, 29);
//
// tslblLibraryVersion
//
this.tslblLibraryVersion.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right;
this.tslblLibraryVersion.Name = "tslblLibraryVersion";
- this.tslblLibraryVersion.Size = new System.Drawing.Size(861, 19);
+ this.tslblLibraryVersion.Size = new System.Drawing.Size(1293, 29);
this.tslblLibraryVersion.Spring = true;
this.tslblLibraryVersion.Text = "LibVersion";
//
// tslblCredits
//
this.tslblCredits.Name = "tslblCredits";
- this.tslblCredits.Size = new System.Drawing.Size(135, 19);
+ this.tslblCredits.Size = new System.Drawing.Size(202, 29);
this.tslblCredits.Text = "Written by: Brad Barnhill";
this.tslblCredits.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@@ -126,20 +134,21 @@ private void InitializeComponent()
this.barcode.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.barcode.Dock = System.Windows.Forms.DockStyle.Fill;
this.barcode.Location = new System.Drawing.Point(0, 0);
+ this.barcode.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.barcode.Name = "barcode";
- this.barcode.Size = new System.Drawing.Size(745, 572);
+ this.barcode.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.barcode.Size = new System.Drawing.Size(1066, 908);
this.barcode.TabIndex = 36;
this.barcode.TabStop = false;
this.barcode.Text = "Barcode Image";
//
// btnMassGeneration
//
- this.btnMassGeneration.Location = new System.Drawing.Point(7, 515);
- this.btnMassGeneration.Margin = new System.Windows.Forms.Padding(2);
+ this.btnMassGeneration.Location = new System.Drawing.Point(6, 25);
this.btnMassGeneration.Name = "btnMassGeneration";
- this.btnMassGeneration.Size = new System.Drawing.Size(257, 24);
+ this.btnMassGeneration.Size = new System.Drawing.Size(181, 51);
this.btnMassGeneration.TabIndex = 0;
- this.btnMassGeneration.Text = "Generate 1000 Barcodes";
+ this.btnMassGeneration.Text = "Generate 1000";
this.btnMassGeneration.UseVisualStyleBackColor = true;
this.btnMassGeneration.Click += new System.EventHandler(this.btnMassGeneration_Click);
//
@@ -149,23 +158,18 @@ private void InitializeComponent()
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.IsSplitterFixed = true;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+ this.splitContainer1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
- this.splitContainer1.Panel1.Controls.Add(this.lblAverageGenerationTime);
- this.splitContainer1.Panel1.Controls.Add(this.label14);
- this.splitContainer1.Panel1.Controls.Add(this.progressBar1);
- this.splitContainer1.Panel1.Controls.Add(this.btnMassGeneration);
+ this.splitContainer1.Panel1.Controls.Add(this.groupBox2);
+ this.splitContainer1.Panel1.Controls.Add(this.groupBox1);
this.splitContainer1.Panel1.Controls.Add(this.groupBox4);
this.splitContainer1.Panel1.Controls.Add(this.groupBox3);
this.splitContainer1.Panel1.Controls.Add(this.label10);
this.splitContainer1.Panel1.Controls.Add(this.cbRotateFlip);
- this.splitContainer1.Panel1.Controls.Add(this.btnSave);
- this.splitContainer1.Panel1.Controls.Add(this.btnSaveXML);
- this.splitContainer1.Panel1.Controls.Add(this.btnLoadXML);
this.splitContainer1.Panel1.Controls.Add(this.label8);
- this.splitContainer1.Panel1.Controls.Add(this.btnEncode);
this.splitContainer1.Panel1.Controls.Add(this.label4);
this.splitContainer1.Panel1.Controls.Add(this.txtEncoded);
this.splitContainer1.Panel1.Controls.Add(this.label5);
@@ -183,35 +187,60 @@ private void InitializeComponent()
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.barcode);
- this.splitContainer1.Size = new System.Drawing.Size(1015, 572);
- this.splitContainer1.SplitterDistance = 266;
+ this.splitContainer1.Size = new System.Drawing.Size(1522, 908);
+ this.splitContainer1.SplitterDistance = 450;
+ this.splitContainer1.SplitterWidth = 6;
this.splitContainer1.TabIndex = 37;
this.splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer1_SplitterMoved);
//
+ // btnSaveJSON
+ //
+ this.btnSaveJSON.Location = new System.Drawing.Point(302, 16);
+ this.btnSaveJSON.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.btnSaveJSON.Name = "btnSaveJSON";
+ this.btnSaveJSON.Size = new System.Drawing.Size(113, 35);
+ this.btnSaveJSON.TabIndex = 82;
+ this.btnSaveJSON.Text = "Save &JSON";
+ this.btnSaveJSON.UseVisualStyleBackColor = true;
+ this.btnSaveJSON.Click += new System.EventHandler(this.btnSaveJSON_Click);
+ //
+ // btnLoadJSON
+ //
+ this.btnLoadJSON.Location = new System.Drawing.Point(302, 61);
+ this.btnLoadJSON.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.btnLoadJSON.Name = "btnLoadJSON";
+ this.btnLoadJSON.Size = new System.Drawing.Size(113, 35);
+ this.btnLoadJSON.TabIndex = 83;
+ this.btnLoadJSON.Text = "Load JSON";
+ this.btnLoadJSON.UseVisualStyleBackColor = true;
+ this.btnLoadJSON.Click += new System.EventHandler(this.btnLoadJSON_Click);
+ //
// lblAverageGenerationTime
//
this.lblAverageGenerationTime.AutoSize = true;
- this.lblAverageGenerationTime.Location = new System.Drawing.Point(133, 554);
+ this.lblAverageGenerationTime.Location = new System.Drawing.Point(196, 101);
+ this.lblAverageGenerationTime.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblAverageGenerationTime.Name = "lblAverageGenerationTime";
- this.lblAverageGenerationTime.Size = new System.Drawing.Size(0, 13);
+ this.lblAverageGenerationTime.Size = new System.Drawing.Size(0, 20);
this.lblAverageGenerationTime.TabIndex = 81;
//
// label14
//
this.label14.AutoSize = true;
- this.label14.Location = new System.Drawing.Point(1, 554);
+ this.label14.Location = new System.Drawing.Point(-2, 101);
+ this.label14.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label14.Name = "label14";
- this.label14.Size = new System.Drawing.Size(134, 13);
+ this.label14.Size = new System.Drawing.Size(198, 20);
this.label14.TabIndex = 80;
this.label14.Text = "Average Generation Time: ";
//
// progressBar1
//
- this.progressBar1.Location = new System.Drawing.Point(8, 543);
+ this.progressBar1.Location = new System.Drawing.Point(8, 84);
+ this.progressBar1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.progressBar1.Name = "progressBar1";
- this.progressBar1.Size = new System.Drawing.Size(254, 5);
+ this.progressBar1.Size = new System.Drawing.Size(419, 8);
this.progressBar1.TabIndex = 79;
- this.progressBar1.Visible = false;
//
// groupBox4
//
@@ -224,84 +253,95 @@ private void InitializeComponent()
this.groupBox4.Controls.Add(this.label6);
this.groupBox4.Controls.Add(this.txtHeight);
this.groupBox4.Controls.Add(this.label9);
- this.groupBox4.Location = new System.Drawing.Point(136, 44);
+ this.groupBox4.Location = new System.Drawing.Point(204, 68);
+ this.groupBox4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(128, 93);
+ this.groupBox4.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.groupBox4.Size = new System.Drawing.Size(192, 143);
this.groupBox4.TabIndex = 78;
this.groupBox4.TabStop = false;
//
// textBoxAspectRatio
//
- this.textBoxAspectRatio.Location = new System.Drawing.Point(73, 67);
+ this.textBoxAspectRatio.Location = new System.Drawing.Point(110, 103);
+ this.textBoxAspectRatio.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxAspectRatio.Name = "textBoxAspectRatio";
- this.textBoxAspectRatio.Size = new System.Drawing.Size(35, 20);
+ this.textBoxAspectRatio.Size = new System.Drawing.Size(50, 26);
this.textBoxAspectRatio.TabIndex = 55;
//
// textBoxBarWidth
//
- this.textBoxBarWidth.Location = new System.Drawing.Point(16, 68);
+ this.textBoxBarWidth.Location = new System.Drawing.Point(24, 105);
+ this.textBoxBarWidth.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxBarWidth.Name = "textBoxBarWidth";
- this.textBoxBarWidth.Size = new System.Drawing.Size(35, 20);
+ this.textBoxBarWidth.Size = new System.Drawing.Size(50, 26);
this.textBoxBarWidth.TabIndex = 54;
//
// label13
//
this.label13.AutoSize = true;
- this.label13.Location = new System.Drawing.Point(59, 51);
+ this.label13.Location = new System.Drawing.Point(88, 78);
+ this.label13.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label13.Name = "label13";
- this.label13.Size = new System.Drawing.Size(65, 13);
+ this.label13.Size = new System.Drawing.Size(97, 20);
this.label13.TabIndex = 53;
this.label13.Text = "AspectRatio";
//
// label12
//
this.label12.AutoSize = true;
- this.label12.Location = new System.Drawing.Point(8, 51);
+ this.label12.Location = new System.Drawing.Point(12, 78);
+ this.label12.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label12.Name = "label12";
- this.label12.Size = new System.Drawing.Size(51, 13);
+ this.label12.Size = new System.Drawing.Size(75, 20);
this.label12.TabIndex = 52;
this.label12.Text = "BarWidth";
//
// txtWidth
//
- this.txtWidth.Location = new System.Drawing.Point(19, 25);
+ this.txtWidth.Location = new System.Drawing.Point(28, 38);
+ this.txtWidth.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtWidth.Name = "txtWidth";
- this.txtWidth.Size = new System.Drawing.Size(35, 20);
+ this.txtWidth.Size = new System.Drawing.Size(50, 26);
this.txtWidth.TabIndex = 43;
this.txtWidth.Text = "600";
//
// label7
//
this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(16, 8);
+ this.label7.Location = new System.Drawing.Point(24, 12);
+ this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(35, 13);
+ this.label7.Size = new System.Drawing.Size(50, 20);
this.label7.TabIndex = 41;
this.label7.Text = "Width";
//
// label6
//
this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(61, 8);
+ this.label6.Location = new System.Drawing.Point(92, 12);
+ this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(38, 13);
+ this.label6.Size = new System.Drawing.Size(56, 20);
this.label6.TabIndex = 42;
this.label6.Text = "Height";
//
// txtHeight
//
- this.txtHeight.Location = new System.Drawing.Point(64, 25);
+ this.txtHeight.Location = new System.Drawing.Point(96, 38);
+ this.txtHeight.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtHeight.Name = "txtHeight";
- this.txtHeight.Size = new System.Drawing.Size(35, 20);
+ this.txtHeight.Size = new System.Drawing.Size(50, 26);
this.txtHeight.TabIndex = 44;
this.txtHeight.Text = "300";
//
// label9
//
this.label9.AutoSize = true;
- this.label9.Location = new System.Drawing.Point(53, 27);
+ this.label9.Location = new System.Drawing.Point(80, 42);
+ this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(12, 13);
+ this.label9.Size = new System.Drawing.Size(16, 20);
this.label9.TabIndex = 51;
this.label9.Text = "x";
//
@@ -312,25 +352,29 @@ private void InitializeComponent()
this.groupBox3.Controls.Add(this.label11);
this.groupBox3.Controls.Add(this.cbLabelLocation);
this.groupBox3.Controls.Add(this.lblLabelLocation);
- this.groupBox3.Location = new System.Drawing.Point(136, 141);
+ this.groupBox3.Location = new System.Drawing.Point(204, 217);
+ this.groupBox3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(128, 120);
+ this.groupBox3.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.groupBox3.Size = new System.Drawing.Size(192, 185);
this.groupBox3.TabIndex = 77;
this.groupBox3.TabStop = false;
//
// textBox1
//
- this.textBox1.Location = new System.Drawing.Point(4, 52);
+ this.textBox1.Location = new System.Drawing.Point(6, 80);
+ this.textBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(101, 20);
+ this.textBox1.Size = new System.Drawing.Size(150, 26);
this.textBox1.TabIndex = 54;
//
// chkGenerateLabel
//
this.chkGenerateLabel.AutoSize = true;
- this.chkGenerateLabel.Location = new System.Drawing.Point(6, 14);
+ this.chkGenerateLabel.Location = new System.Drawing.Point(9, 22);
+ this.chkGenerateLabel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.chkGenerateLabel.Name = "chkGenerateLabel";
- this.chkGenerateLabel.Size = new System.Drawing.Size(95, 17);
+ this.chkGenerateLabel.Size = new System.Drawing.Size(140, 24);
this.chkGenerateLabel.TabIndex = 40;
this.chkGenerateLabel.Text = "Generate label";
this.chkGenerateLabel.UseVisualStyleBackColor = true;
@@ -338,9 +382,10 @@ private void InitializeComponent()
// label11
//
this.label11.AutoSize = true;
- this.label11.Location = new System.Drawing.Point(3, 39);
+ this.label11.Location = new System.Drawing.Point(4, 60);
+ this.label11.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(102, 13);
+ this.label11.Size = new System.Drawing.Size(151, 20);
this.label11.TabIndex = 55;
this.label11.Text = "Alternate Label Text";
//
@@ -355,26 +400,29 @@ private void InitializeComponent()
"TopCenter",
"TopLeft",
"TopRight"});
- this.cbLabelLocation.Location = new System.Drawing.Point(6, 94);
+ this.cbLabelLocation.Location = new System.Drawing.Point(9, 145);
+ this.cbLabelLocation.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cbLabelLocation.Name = "cbLabelLocation";
- this.cbLabelLocation.Size = new System.Drawing.Size(99, 21);
+ this.cbLabelLocation.Size = new System.Drawing.Size(146, 28);
this.cbLabelLocation.TabIndex = 0;
//
// lblLabelLocation
//
this.lblLabelLocation.AutoSize = true;
- this.lblLabelLocation.Location = new System.Drawing.Point(3, 78);
+ this.lblLabelLocation.Location = new System.Drawing.Point(4, 120);
+ this.lblLabelLocation.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblLabelLocation.Name = "lblLabelLocation";
- this.lblLabelLocation.Size = new System.Drawing.Size(77, 13);
+ this.lblLabelLocation.Size = new System.Drawing.Size(113, 20);
this.lblLabelLocation.TabIndex = 48;
this.lblLabelLocation.Text = "Label Location";
//
// label10
//
this.label10.AutoSize = true;
- this.label10.Location = new System.Drawing.Point(5, 90);
+ this.label10.Location = new System.Drawing.Point(8, 138);
+ this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(39, 13);
+ this.label10.Size = new System.Drawing.Size(58, 20);
this.label10.TabIndex = 76;
this.label10.Text = "Rotate";
//
@@ -386,16 +434,18 @@ private void InitializeComponent()
"Center",
"Left",
"Right"});
- this.cbRotateFlip.Location = new System.Drawing.Point(7, 106);
+ this.cbRotateFlip.Location = new System.Drawing.Point(10, 163);
+ this.cbRotateFlip.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cbRotateFlip.Name = "cbRotateFlip";
- this.cbRotateFlip.Size = new System.Drawing.Size(127, 21);
+ this.cbRotateFlip.Size = new System.Drawing.Size(188, 28);
this.cbRotateFlip.TabIndex = 75;
//
// btnSave
//
- this.btnSave.Location = new System.Drawing.Point(116, 448);
+ this.btnSave.Location = new System.Drawing.Point(7, 81);
+ this.btnSave.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnSave.Name = "btnSave";
- this.btnSave.Size = new System.Drawing.Size(57, 46);
+ this.btnSave.Size = new System.Drawing.Size(125, 45);
this.btnSave.TabIndex = 61;
this.btnSave.Text = "&Save As";
this.btnSave.UseVisualStyleBackColor = true;
@@ -403,9 +453,10 @@ private void InitializeComponent()
//
// btnSaveXML
//
- this.btnSaveXML.Location = new System.Drawing.Point(179, 448);
+ this.btnSaveXML.Location = new System.Drawing.Point(173, 16);
+ this.btnSaveXML.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnSaveXML.Name = "btnSaveXML";
- this.btnSaveXML.Size = new System.Drawing.Size(84, 23);
+ this.btnSaveXML.Size = new System.Drawing.Size(118, 35);
this.btnSaveXML.TabIndex = 71;
this.btnSaveXML.Text = "Save &XML";
this.btnSaveXML.UseVisualStyleBackColor = true;
@@ -413,9 +464,10 @@ private void InitializeComponent()
//
// btnLoadXML
//
- this.btnLoadXML.Location = new System.Drawing.Point(179, 474);
+ this.btnLoadXML.Location = new System.Drawing.Point(173, 61);
+ this.btnLoadXML.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnLoadXML.Name = "btnLoadXML";
- this.btnLoadXML.Size = new System.Drawing.Size(84, 23);
+ this.btnLoadXML.Size = new System.Drawing.Size(118, 35);
this.btnLoadXML.TabIndex = 72;
this.btnLoadXML.Text = "Load XML";
this.btnLoadXML.UseVisualStyleBackColor = true;
@@ -424,17 +476,19 @@ private void InitializeComponent()
// label8
//
this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(5, 132);
+ this.label8.Location = new System.Drawing.Point(8, 203);
+ this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(53, 13);
+ this.label8.Size = new System.Drawing.Size(80, 20);
this.label8.TabIndex = 74;
this.label8.Text = "Alignment";
//
// btnEncode
//
- this.btnEncode.Location = new System.Drawing.Point(7, 448);
+ this.btnEncode.Location = new System.Drawing.Point(7, 16);
+ this.btnEncode.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnEncode.Name = "btnEncode";
- this.btnEncode.Size = new System.Drawing.Size(105, 46);
+ this.btnEncode.Size = new System.Drawing.Size(125, 55);
this.btnEncode.TabIndex = 60;
this.btnEncode.Text = "&Encode";
this.btnEncode.UseVisualStyleBackColor = true;
@@ -443,38 +497,42 @@ private void InitializeComponent()
// label4
//
this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(5, 176);
+ this.label4.Location = new System.Drawing.Point(8, 271);
+ this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(61, 13);
+ this.label4.Size = new System.Drawing.Size(92, 20);
this.label4.TabIndex = 68;
this.label4.Text = "Foreground";
//
// txtEncoded
//
- this.txtEncoded.Location = new System.Drawing.Point(7, 262);
+ this.txtEncoded.Location = new System.Drawing.Point(10, 403);
+ this.txtEncoded.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
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, 170);
+ this.txtEncoded.Size = new System.Drawing.Size(436, 227);
this.txtEncoded.TabIndex = 62;
this.txtEncoded.TabStop = false;
//
// label5
//
this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(69, 176);
+ this.label5.Location = new System.Drawing.Point(104, 271);
+ this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(65, 13);
+ this.label5.Size = new System.Drawing.Size(95, 20);
this.label5.TabIndex = 69;
this.label5.Text = "Background";
//
// btnBackColor
//
this.btnBackColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btnBackColor.Location = new System.Drawing.Point(72, 192);
+ this.btnBackColor.Location = new System.Drawing.Point(108, 295);
+ this.btnBackColor.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnBackColor.Name = "btnBackColor";
- this.btnBackColor.Size = new System.Drawing.Size(58, 23);
+ this.btnBackColor.Size = new System.Drawing.Size(87, 35);
this.btnBackColor.TabIndex = 67;
this.btnBackColor.UseVisualStyleBackColor = true;
this.btnBackColor.Click += new System.EventHandler(this.btnBackColor_Click);
@@ -487,17 +545,19 @@ private void InitializeComponent()
"Center",
"Left",
"Right"});
- this.cbBarcodeAlign.Location = new System.Drawing.Point(7, 148);
+ this.cbBarcodeAlign.Location = new System.Drawing.Point(10, 228);
+ this.cbBarcodeAlign.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cbBarcodeAlign.Name = "cbBarcodeAlign";
- this.cbBarcodeAlign.Size = new System.Drawing.Size(127, 21);
+ this.cbBarcodeAlign.Size = new System.Drawing.Size(188, 28);
this.cbBarcodeAlign.TabIndex = 73;
//
// btnForeColor
//
this.btnForeColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btnForeColor.Location = new System.Drawing.Point(7, 192);
+ this.btnForeColor.Location = new System.Drawing.Point(10, 295);
+ this.btnForeColor.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnForeColor.Name = "btnForeColor";
- this.btnForeColor.Size = new System.Drawing.Size(58, 23);
+ this.btnForeColor.Size = new System.Drawing.Size(87, 35);
this.btnForeColor.TabIndex = 66;
this.btnForeColor.UseVisualStyleBackColor = true;
this.btnForeColor.Click += new System.EventHandler(this.btnForeColor_Click);
@@ -505,26 +565,29 @@ private void InitializeComponent()
// label2
//
this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(5, 246);
+ this.label2.Location = new System.Drawing.Point(8, 378);
+ this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(80, 13);
+ this.label2.Size = new System.Drawing.Size(118, 20);
this.label2.TabIndex = 64;
this.label2.Text = "Encoded Value";
//
// lblEncodingTime
//
this.lblEncodingTime.AutoSize = true;
- this.lblEncodingTime.Location = new System.Drawing.Point(89, 244);
+ this.lblEncodingTime.Location = new System.Drawing.Point(134, 375);
+ this.lblEncodingTime.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblEncodingTime.Name = "lblEncodingTime";
- this.lblEncodingTime.Size = new System.Drawing.Size(0, 13);
+ this.lblEncodingTime.Size = new System.Drawing.Size(0, 20);
this.lblEncodingTime.TabIndex = 70;
//
// label3
//
this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(5, 48);
+ this.label3.Location = new System.Drawing.Point(8, 74);
+ this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(52, 13);
+ this.label3.Size = new System.Drawing.Size(76, 20);
this.label3.TabIndex = 65;
this.label3.Text = "Encoding";
//
@@ -532,7 +595,7 @@ private void InitializeComponent()
//
this.cbEncodeType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbEncodeType.FormattingEnabled = true;
- this.cbEncodeType.ItemHeight = 13;
+ this.cbEncodeType.ItemHeight = 20;
this.cbEncodeType.Items.AddRange(new object[] {
"UPC-A",
"UPC-E",
@@ -563,25 +626,28 @@ private void InitializeComponent()
"Telepen",
"FIM",
"Pharmacode"});
- this.cbEncodeType.Location = new System.Drawing.Point(7, 64);
+ this.cbEncodeType.Location = new System.Drawing.Point(10, 98);
+ this.cbEncodeType.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cbEncodeType.Name = "cbEncodeType";
- this.cbEncodeType.Size = new System.Drawing.Size(127, 21);
+ this.cbEncodeType.Size = new System.Drawing.Size(188, 28);
this.cbEncodeType.TabIndex = 59;
//
// txtData
//
- this.txtData.Location = new System.Drawing.Point(7, 24);
+ this.txtData.Location = new System.Drawing.Point(10, 37);
+ this.txtData.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtData.Name = "txtData";
- this.txtData.Size = new System.Drawing.Size(251, 20);
+ this.txtData.Size = new System.Drawing.Size(374, 26);
this.txtData.TabIndex = 58;
this.txtData.Text = "038000356216";
//
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(5, 8);
+ this.label1.Location = new System.Drawing.Point(8, 12);
+ this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(86, 13);
+ this.label1.Size = new System.Drawing.Size(127, 20);
this.label1.TabIndex = 63;
this.label1.Text = "Value to Encode";
//
@@ -589,16 +655,55 @@ private void InitializeComponent()
//
this.errorProvider1.ContainerControl = this;
//
+ // chkIncludeImageInSavedData
+ //
+ this.chkIncludeImageInSavedData.AutoSize = true;
+ this.chkIncludeImageInSavedData.Location = new System.Drawing.Point(279, 108);
+ this.chkIncludeImageInSavedData.Name = "chkIncludeImageInSavedData";
+ this.chkIncludeImageInSavedData.Size = new System.Drawing.Size(136, 24);
+ this.chkIncludeImageInSavedData.TabIndex = 0;
+ this.chkIncludeImageInSavedData.Text = "Include Image";
+ this.chkIncludeImageInSavedData.UseVisualStyleBackColor = true;
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.chkIncludeImageInSavedData);
+ this.groupBox1.Controls.Add(this.btnSaveJSON);
+ this.groupBox1.Controls.Add(this.btnLoadXML);
+ this.groupBox1.Controls.Add(this.btnLoadJSON);
+ this.groupBox1.Controls.Add(this.btnSaveXML);
+ this.groupBox1.Controls.Add(this.btnSave);
+ this.groupBox1.Controls.Add(this.btnEncode);
+ this.groupBox1.Location = new System.Drawing.Point(12, 638);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(423, 139);
+ this.groupBox1.TabIndex = 84;
+ this.groupBox1.TabStop = false;
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.progressBar1);
+ this.groupBox2.Controls.Add(this.btnMassGeneration);
+ this.groupBox2.Controls.Add(this.lblAverageGenerationTime);
+ this.groupBox2.Controls.Add(this.label14);
+ this.groupBox2.Location = new System.Drawing.Point(12, 783);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(434, 122);
+ this.groupBox2.TabIndex = 85;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Bulk Operations";
+ //
// TestApp
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1015, 596);
+ this.ClientSize = new System.Drawing.Size(1522, 944);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.statusStrip1);
this.DoubleBuffered = true;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.MinimumSize = new System.Drawing.Size(635, 386);
+ this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.MinimumSize = new System.Drawing.Size(1024, 768);
this.Name = "TestApp";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Barcode Encoder";
@@ -615,6 +720,10 @@ private void InitializeComponent()
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit();
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -668,6 +777,11 @@ private void InitializeComponent()
private System.Windows.Forms.Label lblAverageGenerationTime;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.ProgressBar progressBar1;
+ private System.Windows.Forms.Button btnSaveJSON;
+ private System.Windows.Forms.Button btnLoadJSON;
+ private System.Windows.Forms.CheckBox chkIncludeImageInSavedData;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.GroupBox groupBox1;
}
}
diff --git a/BarcodeStandardExample/TestApp.cs b/BarcodeStandardExample/TestApp.cs
index 267c4d7..0417167 100644
--- a/BarcodeStandardExample/TestApp.cs
+++ b/BarcodeStandardExample/TestApp.cs
@@ -215,6 +215,46 @@ private void btnBackColor_Click(object sender, EventArgs e)
}//using
}//btnBackColor_Click
+ private void btnSaveJSON_Click(object sender, EventArgs e)
+ {
+ btnEncode_Click(sender, e);
+
+ using (SaveFileDialog sfd = new SaveFileDialog())
+ {
+ sfd.Filter = "JSON Files|*.json";
+ if (sfd.ShowDialog() == DialogResult.OK)
+ {
+ using (StreamWriter sw = new StreamWriter(sfd.FileName))
+ {
+ sw.Write(b.ToJSON(chkIncludeImageInSavedData.Checked));
+ }//using
+ }//if
+ }//using
+ }
+
+ private void btnLoadJSON_Click(object sender, EventArgs e)
+ {
+ using (OpenFileDialog ofd = new OpenFileDialog())
+ {
+ ofd.Multiselect = false;
+ ofd.Filter = "JSON Files|*.json";
+ if (ofd.ShowDialog() == DialogResult.OK)
+ {
+ string fileContents = File.ReadAllText(ofd.FileName);
+ using (BarcodeStandard.SaveData savedData = Barcode.FromJSON(ofd.OpenFile()))
+ {
+ LoadFromSaveData(savedData);
+ }//using
+ }//if
+ }//using
+
+ //populate the local object
+ btnEncode_Click(sender, e);
+
+ //reposition the barcode image to the middle
+ barcode.Location = new Point((this.barcode.Location.X + this.barcode.Width / 2) - barcode.Width / 2, (this.barcode.Location.Y + this.barcode.Height / 2) - barcode.Height / 2);
+ }
+
private void btnSaveXML_Click(object sender, EventArgs e)
{
btnEncode_Click(sender, e);
@@ -226,7 +266,7 @@ private void btnSaveXML_Click(object sender, EventArgs e)
{
using (StreamWriter sw = new StreamWriter(sfd.FileName))
{
- sw.Write(b.XML);
+ sw.Write(b.ToXML(chkIncludeImageInSavedData.Checked));
}//using
}//if
}//using
@@ -237,132 +277,142 @@ private void btnLoadXML_Click(object sender, EventArgs e)
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.Multiselect = false;
+ ofd.Filter = "XML Files|*.xml";
if (ofd.ShowDialog() == DialogResult.OK)
{
string fileContents = File.ReadAllText(ofd.FileName);
- using (BarcodeStandard.SaveData XML = Barcode.GetSaveDataFromFile(fileContents))
+ using (BarcodeStandard.SaveData savedData = Barcode.FromXML(ofd.OpenFile()))
{
- //load image from xml
- this.barcode.Width = XML.ImageWidth;
- this.barcode.Height = XML.ImageHeight;
- this.barcode.BackgroundImage = Barcode.GetImageFromXML(fileContents);
-
- //populate the screen
- this.txtData.Text = XML.RawData;
- this.chkGenerateLabel.Checked = XML.IncludeLabel;
-
- switch (XML.Type)
- {
- case "UCC12":
- case "UPCA":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("UPC-A");
- break;
- case "UCC13":
- 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 "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;
- case "LOGMARS":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("LOGMARS");
- break;
- case "CODE39":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 39");
- break;
- case "CODE39Extended":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 39 Extended");
- break;
- case "CODE39_Mod43":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 39 Mod 43");
- break;
- case "Codabar":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Codabar");
- break;
- case "PostNet":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("PostNet");
- break;
- case "ISBN":
- case "BOOKLAND":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Bookland/ISBN");
- break;
- case "JAN13":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("JAN-13");
- break;
- case "UPC_SUPPLEMENTAL_2DIGIT":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("UPC 2 Digit Ext.");
- break;
- case "MSI_Mod10":
- case "MSI_2Mod10":
- case "MSI_Mod11":
- case "MSI_Mod11_Mod10":
- case "Modified_Plessey":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("MSI");
- break;
- case "UPC_SUPPLEMENTAL_5DIGIT":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("UPC 5 Digit Ext.");
- break;
- case "UPCE":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("UPC-E");
- break;
- case "EAN8":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("EAN-8");
- break;
- case "USD8":
- case "CODE11":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 11");
- break;
- case "CODE128":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 128");
- break;
- case "CODE128A":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 128-A");
- break;
- case "CODE128B":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 128-B");
- break;
- case "CODE128C":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 128-C");
- break;
- case "ITF14":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("ITF-14");
- break;
- case "CODE93":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 93");
- break;
- case "FIM":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("FIM");
- break;
- case "Pharmacode":
- this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Pharmacode");
- break;
-
- default: throw new Exception("ELOADXML-1: Unsupported encoding type in XML.");
- }//switch
-
- this.txtEncoded.Text = XML.EncodedValue;
- this.btnForeColor.BackColor = ColorTranslator.FromHtml(XML.Forecolor);
- this.btnBackColor.BackColor = ColorTranslator.FromHtml(XML.Backcolor);
- this.txtWidth.Text = XML.ImageWidth.ToString();
- this.txtHeight.Text = XML.ImageHeight.ToString();
-
- //populate the local object
- btnEncode_Click(sender, e);
-
- //reposition the barcode image to the middle
- barcode.Location = new Point((this.barcode.Location.X + this.barcode.Width / 2) - barcode.Width / 2, (this.barcode.Location.Y + this.barcode.Height / 2) - barcode.Height / 2);
+ LoadFromSaveData(savedData);
}//using
}//if
}//using
+
+ //populate the local object
+ btnEncode_Click(sender, e);
+
+ //reposition the barcode image to the middle
+ barcode.Location = new Point((this.barcode.Location.X + this.barcode.Width / 2) - barcode.Width / 2, (this.barcode.Location.Y + this.barcode.Height / 2) - barcode.Height / 2);
+ }
+
+ private void LoadFromSaveData(BarcodeStandard.SaveData saveData)
+ {
+ //load image from xml
+ this.barcode.Width = saveData.ImageWidth;
+ this.barcode.Height = saveData.ImageHeight;
+
+ if (saveData.Image != null)
+ {
+ this.barcode.BackgroundImage = Barcode.GetImageFromSaveData(saveData);
+ }
+
+ //populate the screen
+ this.txtData.Text = saveData.RawData;
+ this.chkGenerateLabel.Checked = saveData.IncludeLabel;
+
+ this.txtEncoded.Text = saveData.EncodedValue;
+ this.btnForeColor.BackColor = ColorTranslator.FromHtml(saveData.Forecolor);
+ this.btnBackColor.BackColor = ColorTranslator.FromHtml(saveData.Backcolor);
+ this.txtWidth.Text = saveData.ImageWidth.ToString();
+ this.txtHeight.Text = saveData.ImageHeight.ToString();
+
+ switch (saveData.Type)
+ {
+ case "UCC12":
+ case "UPCA":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("UPC-A");
+ break;
+ case "UCC13":
+ 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 "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;
+ case "LOGMARS":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("LOGMARS");
+ break;
+ case "CODE39":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 39");
+ break;
+ case "CODE39Extended":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 39 Extended");
+ break;
+ case "CODE39_Mod43":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 39 Mod 43");
+ break;
+ case "Codabar":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Codabar");
+ break;
+ case "PostNet":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("PostNet");
+ break;
+ case "ISBN":
+ case "BOOKLAND":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Bookland/ISBN");
+ break;
+ case "JAN13":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("JAN-13");
+ break;
+ case "UPC_SUPPLEMENTAL_2DIGIT":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("UPC 2 Digit Ext.");
+ break;
+ case "MSI_Mod10":
+ case "MSI_2Mod10":
+ case "MSI_Mod11":
+ case "MSI_Mod11_Mod10":
+ case "Modified_Plessey":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("MSI");
+ break;
+ case "UPC_SUPPLEMENTAL_5DIGIT":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("UPC 5 Digit Ext.");
+ break;
+ case "UPCE":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("UPC-E");
+ break;
+ case "EAN8":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("EAN-8");
+ break;
+ case "USD8":
+ case "CODE11":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 11");
+ break;
+ case "CODE128":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 128");
+ break;
+ case "CODE128A":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 128-A");
+ break;
+ case "CODE128B":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 128-B");
+ break;
+ case "CODE128C":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 128-C");
+ break;
+ case "ITF14":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("ITF-14");
+ break;
+ case "CODE93":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Code 93");
+ break;
+ case "FIM":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("FIM");
+ break;
+ case "Pharmacode":
+ this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Pharmacode");
+ break;
+
+ default: throw new Exception("ELOADXML-1: Unsupported encoding type in XML.");
+ }//switch
}
private void btnMassGeneration_Click(object sender, EventArgs e)
@@ -370,7 +420,6 @@ private void btnMassGeneration_Click(object sender, EventArgs e)
int x = 1000;
double sum = 0;
- progressBar1.Visible = true;
progressBar1.Value = 0;
progressBar1.Maximum = x;