public override global::System.Data.DataSet Clone() { BarcodeXML cln = ((BarcodeXML)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { BarcodeXML ds = new BarcodeXML(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
} //Label_UPCA #endregion #endregion #region Misc private string GetXML() { if (EncodedValue == "") { throw new Exception("EGETXML-1: Could not retrieve XML due to the barcode not being encoded first. Please call Encode first."); } else { try { using (BarcodeXML xml = new BarcodeXML()) { BarcodeXML.BarcodeRow row = xml.Barcode.NewBarcodeRow(); row.Type = EncodedType.ToString(); row.RawData = RawData; row.EncodedValue = EncodedValue; row.EncodingTime = EncodingTime; row.IncludeLabel = IncludeLabel; row.Forecolor = ColorTranslator.ToHtml(ForeColor); row.Backcolor = ColorTranslator.ToHtml(BackColor); row.CountryAssigningManufacturingCode = Country_Assigning_Manufacturer_Code; row.ImageWidth = Width; row.ImageHeight = Height; row.RotateFlipType = this.RotateFlipType; row.LabelPosition = (int)this.LabelPosition; row.LabelFont = this.LabelFont.ToString(); row.ImageFormat = this.ImageFormat.ToString(); row.Alignment = (int)this.Alignment; //get image in base 64 using (MemoryStream ms = new MemoryStream()) { EncodedImage.Save(ms, ImageFormat); row.Image = Convert.ToBase64String(ms.ToArray(), Base64FormattingOptions.None); }//using xml.Barcode.AddBarcodeRow(row); StringWriter sw = new StringWriter(); xml.WriteXml(sw, XmlWriteMode.WriteSchema); return(sw.ToString()); } //using } //try catch (Exception ex) { throw new Exception("EGETXML-2: " + ex.Message); } //catch } //else }
public static Image GetImageFromXML(BarcodeXML internalXML) { try { //converting the base64 string to byte array Byte[] imageContent = new Byte[internalXML.Barcode[0].Image.Length]; //loading it to memory stream and then to image object using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(internalXML.Barcode[0].Image))) { return(Image.FromStream(ms)); } //using } //try catch (Exception ex) { throw new Exception("EGETIMAGEFROMXML-1: " + ex.Message); }//catch }
private string GetXML() { if (string.IsNullOrEmpty(EncodedValue)) { throw new Exception( "EGETXML-1: Could not retrieve XML due to the barcode not being encoded first. Please call Encode first."); } try { using (var xml = new BarcodeXML()) { var row = xml.Barcode.NewBarcodeRow(); row.Type = EncodedType.ToString(); row.RawData = RawData; row.EncodedValue = EncodedValue; row.EncodingTime = EncodingTime; row.IncludeLabel = IncludeLabel; row.Forecolor = ColorTranslator.ToHtml(ForeColor); row.Backcolor = ColorTranslator.ToHtml(BackColor); row.CountryAssigningManufacturingCode = Country_Assigning_Manufacturer_Code; row.ImageWidth = Width; row.ImageHeight = Height; //get image in base 64 using (var ms = new MemoryStream()) { EncodedImage.Save(ms, ImageFormat); row.Image = Convert.ToBase64String(ms.ToArray(), Base64FormattingOptions.None); } xml.Barcode.AddBarcodeRow(row); var sw = new StringWriter(); xml.WriteXml(sw, XmlWriteMode.WriteSchema); return(sw.ToString()); } } catch (Exception ex) { throw new Exception("EGETXML-2: " + ex.Message); } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); BarcodeXML ds = new BarcodeXML(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "BarcodeDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { BarcodeXML ds = new BarcodeXML(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
}//btnGetXML_Click //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void btnLoadXML_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { using (BarcodeXML XML = new BarcodeXML()) { XML.ReadXml(ofd.FileName); //load image from xml this.barcode.Width = XML.Barcode[0].ImageWidth; this.barcode.Height = XML.Barcode[0].ImageHeight; this.barcode.Image = BarcodeLib.Barcode.GetImageFromXML(XML); //populate the screen this.txtData.Text = XML.Barcode[0].RawData; this.chkGenerateLabel.Checked = XML.Barcode[0].IncludeLabel; switch (XML.Barcode[0].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": this.cbEncodeType.SelectedIndex = this.cbEncodeType.FindString("Interleaved 2 of 5"); break; case "Industrial2of5": 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.Barcode[0].EncodedValue; this.btnForeColor.BackColor = ColorTranslator.FromHtml(XML.Barcode[0].Forecolor); this.btnBackColor.BackColor = ColorTranslator.FromHtml(XML.Barcode[0].Backcolor); ; this.txtWidth.Text = XML.Barcode[0].ImageWidth.ToString(); this.txtHeight.Text = XML.Barcode[0].ImageHeight.ToString(); //populate the local object btnEncode_Click(sender, e); //reposition the barcode image to the middle barcode.Location = new Point((this.groupBox2.Location.X + this.groupBox2.Width / 2) - barcode.Width / 2, (this.groupBox2.Location.Y + this.groupBox2.Height / 2) - barcode.Height / 2); }//using }//if }//using }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); BarcodeXML ds = new BarcodeXML(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "BarcodeDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public static Image GetImageFromXML(BarcodeXML internalXML) { try { //converting the base64 string to byte array Byte[] imageContent = new Byte[internalXML.Barcode[0].Image.Length]; //loading it to memory stream and then to image object using (MemoryStream ms = new MemoryStream(System.Convert.FromBase64String(internalXML.Barcode[0].Image))) { return Image.FromStream(ms); }//using }//try catch (Exception ex) { throw new Exception("EGETIMAGEFROMXML-1: " + ex.Message); }//catch }
}//Label_UPCA #endregion #endregion #region Misc private string GetXML() { if (EncodedValue == "") throw new Exception("EGETXML-1: Could not retrieve XML due to the barcode not being encoded first. Please call Encode first."); else { try { using (BarcodeXML xml = new BarcodeXML()) { BarcodeXML.BarcodeRow row = xml.Barcode.NewBarcodeRow(); row.Type = EncodedType.ToString(); row.RawData = RawData; row.EncodedValue = EncodedValue; row.EncodingTime = EncodingTime; row.IncludeLabel = IncludeLabel; row.Forecolor = ColorTranslator.ToHtml(ForeColor); row.Backcolor = ColorTranslator.ToHtml(BackColor); row.CountryAssigningManufacturingCode = Country_Assigning_Manufacturer_Code; row.ImageWidth = Width; row.ImageHeight = Height; row.RotateFlipType = this.RotateFlipType; row.LabelPosition = (int)this.LabelPosition; row.LabelFont = this.LabelFont.ToString(); row.ImageFormat = this.ImageFormat.ToString(); row.Alignment = (int)this.Alignment; //get image in base 64 using (MemoryStream ms = new MemoryStream()) { EncodedImage.Save(ms, ImageFormat); row.Image = System.Convert.ToBase64String(ms.ToArray(), Base64FormattingOptions.None); }//using xml.Barcode.AddBarcodeRow(row); StringWriter sw = new StringWriter(); xml.WriteXml(sw, XmlWriteMode.WriteSchema); return sw.ToString(); }//using }//try catch (Exception ex) { throw new Exception("EGETXML-2: " + ex.Message); }//catch }//else }