コード例 #1
0
ファイル: BarcodeLib.cs プロジェクト: satyaparmar/barcodeLib
        }     //Label_UPCA

        #endregion
        #endregion

        #region Misc
        private string GetXML()
        {
#if PocketPC
            return("not implemented");
#else
            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
#endif
        }
コード例 #2
0
        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 (SaveData xml = new SaveData())
                    {
                        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;

                        using (MemoryStream ms = new MemoryStream())
                        {
                            EncodedImage.Save(ms, ImageFormat);
                            xml.Image = Convert.ToBase64String(ms.ToArray(), Base64FormattingOptions.None);
                        }

                        XmlSerializer writer = new XmlSerializer(typeof(SaveData));
                        StringWriter  sw     = new StringWriter();
                        writer.Serialize(sw, xml);
                        return(sw.ToString());
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("EGETXML-2: " + ex.Message);
                }
            }
        }
コード例 #3
0
        private void savePictureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (EncodedImage == null)
            {
                MessageBox.Show("You Have Not Added A Message To The Image.");
            }
            else
            {
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        FileInfo file_info = new FileInfo(saveFileDialog1.FileName);
                        switch (file_info.Extension)
                        {
                        case ".png":
                            EncodedImage.Save(saveFileDialog1.FileName, ImageFormat.Png);
                            break;

                        case ".bmp":
                            EncodedImage.Save(saveFileDialog1.FileName, ImageFormat.Bmp);
                            break;

                        case ".gif":
                            EncodedImage.Save(saveFileDialog1.FileName, ImageFormat.Gif);
                            break;

                        case ".tiff":
                        case ".tif":
                            EncodedImage.Save(saveFileDialog1.FileName, ImageFormat.Tiff);
                            break;

                        case ".jpg":
                        case ".jpeg":
                            EncodedImage.Save(saveFileDialog1.FileName, ImageFormat.Jpeg);
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
コード例 #4
0
        }//CheckNumericOnly

        private string GetXML()
        {
            if (EncodedValue == "")
            {
                throw new System.Exception("EGETXML-1: Could not retrieve XML due to the barcode not being encoded first.  Please call Encode first.");
            }
            else
            {
                try
                {
                    using (PawnUtilities.BarcodeGenerator.BarcodeXML xml = new PawnUtilities.BarcodeGenerator.BarcodeXML())
                    {
                        PawnUtilities.BarcodeGenerator.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;

                        //get image in base 64
                        using (MemoryStream ms = new MemoryStream())
                        {
                            EncodedImage.Save(ms, getImageFormat(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 (System.Exception ex)
                {
                    throw new System.Exception("EGETXML-2: " + ex.Message);
                } //catch
            }     //else
        }
コード例 #5
0
        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);
            }
        }