Exemplo n.º 1
1
        private void barCodeDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            if(printArray == null)
            {
                return;
            }
            var height = 87;
            var numberToPrint = printArray.Count();
            for (int i = 0; i < numberToPrint; i++)
            {

            string code = printArray[i].EmployeePK.EmployeeId;
            BarcodeLib.Barcode barcode = new Barcode();
            string employeeName = printArray[i].EmployeeName;
            Image imageBC = barcode.Encode(BarcodeLib.TYPE.CODE39, code, Color.Black, Color.White, (int)(1.35 * e.Graphics.DpiX), (int)(0.45 * e.Graphics.DpiY));

            Bitmap bitmap1 = new Bitmap(imageBC);
            bitmap1.SetResolution(204, 204);

            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

            // draw title string

            // calculate scale for title
            var titleStrSize = e.Graphics.MeasureString(employeeName+ "0000", new Font("Arial", 10));
            float currTitleSize = new Font("Arial", 10).Size;
            float scaledTitleSize = (150 * currTitleSize) / titleStrSize.Width;
            Font _empFont = null;
            if (employeeName.Length < 17)
            {
                _empFont = new Font("Arial", 7);
            }
            else
            {
                _empFont = new Font("Arial", scaledTitleSize);
            }
            Font _titleFont = new Font("Arial", 7);

            var barCodeSize = e.Graphics.MeasureString(code, _titleFont);
            var empCodeSize = e.Graphics.MeasureString(employeeName, _empFont);
            /*Bitmap bitmapName = new Bitmap(nameString, true);
            Bitmap bitmapPrice = new Bitmap(priceString, true);*/

                System.Drawing.Rectangle rc = new System.Drawing.Rectangle((i % 3) * 135, 50, (int)(1.4 * 100), (int)(0.4 * 100));

                //(i % 3) * 124, (i / 3) * 87, 117, 79
                /*e.Graphics.DrawString(nameString, _titleFont, new SolidBrush(Color.Black), (i % 3) * 135 + XCentered(nameSize.Width, 140), 25);
                e.Graphics.DrawString(priceString, _titleFont, new SolidBrush(Color.Black), (i % 3) * 135 + XCentered(priceSize.Width, 140), (float)22.5 + nameSize.Height);*/
                e.Graphics.DrawString(code, _titleFont, new SolidBrush(Color.Black), (i % 3) * 140 + XCentered(barCodeSize.Width, 140), (float)25);
                e.Graphics.DrawImage(bitmap1, new Rectangle((i % 3) * 140 + (int)XCentered((float)(1.35 * 100), 140), (int)(25 + barCodeSize.Height), (int)(1.35 * 100), (int)(0.45 * 100)));
                e.Graphics.DrawString(employeeName, _empFont, new SolidBrush(Color.Black), (i % 3) * 140 + XCentered(empCodeSize.Width, 140), (float)88);

                //e.Graphics.DrawImage(barcodeControl1.GetMetaFile(), new Rectangle((i % 3) * 135, 120, (i % 3) * 135 + (int)(1.4 * 100), (int)(0.75 * 100)));

            }
        }
Exemplo n.º 2
0
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         string  vSql = $"SELECT * From productos Where id_productos Like('%" + txtcodigo.Text.Trim() + "%') ";
         DataSet dt   = new DataSet();
         dt.ejecuta(vSql);
         bool correcto = dt.ejecuta(vSql);
         if (utilidades.DsTieneDatos(dt))
         {
             string             codigobarras = dt.Tables[0].Rows[0]["id_productos"].ToString() + "-" + dt.Tables[0].Rows[0]["productos"].ToString().Trim();
             BarcodeLib.Barcode Codigo       = new BarcodeLib.Barcode();
             Codigo.IncludeLabel            = false;
             panelresultado.BackgroundImage = Codigo.Encode(BarcodeLib.TYPE.CODE128, codigobarras.ToString(), Color.Black, Color.White, 300, 100);
             button5.Enabled = true;
         }
         else
         {
             MessageBox.Show("ERROR");
         }
     }
     catch (Exception error)
     {
         MessageBox.Show("error" + error);
     }
 }
Exemplo n.º 3
0
        public static void GetBarcode(int height, int width, BarcodeLib.TYPE type, string code, out System.Drawing.Image image, string fileSaveUrl)
        {
            try
            {
                image = null;

                BarcodeLib.Barcode b = new BarcodeLib.Barcode();
                b.BackColor = System.Drawing.Color.White;//图片背景颜色
                b.ForeColor = System.Drawing.Color.Black;//条码颜色
                b.IncludeLabel = true;
                b.Alignment = BarcodeLib.AlignmentPositions.LEFT;
                b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER;//code的显示位置
                b.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;//图片格式
                System.Drawing.Font font = new System.Drawing.Font("verdana", 10f);//字体设置
                b.LabelFont = font;
                b.Height = height;//图片高度设置(px单位)
                b.Width = width;//图片宽度设置(px单位)

                image = b.Encode(type, code);//生成图片
                image.Save(fileSaveUrl, System.Drawing.Imaging.ImageFormat.Jpeg);

            }
            catch (Exception err)
            {
                err.ToString();
                image = null;
            }
        }
Exemplo n.º 4
0
        // Custom Barcode need to uncomment  this code in production
        private string GenerateCustomeBarCode()
        {
            var    randomNumber = new Random();
            string barCode      = randomNumber.Next().ToString();
            string strData      = barCode;
            int    imageHeight  = 125; //150;
            int    imageWidth   = 275; //300;
            string Forecolor    = "000000";
            string Backcolor    = "FFFFFF";
            // bool bIncludeLabel =true;
            string strImageFormat = "png";// Request.QueryString["if"].ToLower().Trim();

            //string strAlignment = "c";// Request.QueryString["align"].ToLower().Trim();

            BarcodeLib.Barcode b = new BarcodeLib.Barcode();
            b.IncludeLabel = true;
            b.Alignment    = BarcodeLib.AlignmentPositions.CENTER;
            System.Drawing.Image barcodeImage = b.Encode(BarcodeLib.TYPE.CODE128, barCode, System.Drawing.ColorTranslator.FromHtml("#" + Forecolor), System.Drawing.ColorTranslator.FromHtml("#" + Backcolor), imageWidth, imageHeight);
            //barcodeImage.
            System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
            using (MemoryStream ms = new MemoryStream())
            {
                barcodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] byteImage = ms.ToArray();

                Convert.ToBase64String(byteImage);
                imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
                //ms.WriteTo(Response.OutputStream);
            }
            plBarCode.Controls.Add(imgBarCode);
            return(barCode);
        }
Exemplo n.º 5
0
        private void Barcode_Generator(PictureBox picture)
        {
            try
            {
                BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
                {
                    IncludeLabel   = true,
                    Alignment      = AlignmentPositions.CENTER,
                    Width          = 300,
                    Height         = 100,
                    RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                    BackColor      = Color.White,
                    ForeColor      = Color.Black,
                };
                BaseFont             baseFont = BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Font font     = new iTextSharp.text.Font(baseFont, 14);

                Image img = barcode.Encode(TYPE.CODE128B, id.ToString(), Color.Black, Color.White, picture.Width, picture.Height);

                picture.Image = img;
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
        public System.Drawing.Image generarCupon()
        {
            BarcodeLib.Barcode codigo = new BarcodeLib.Barcode()
            {
                IncludeLabel = true,
                // Alignment = AlignmentPositions.CENTER,
                Height = 100,
                //Width = 150,
                //RotateFlipType = System.Drawing.RotateFlipType.RotateNoneFlipNone,
                BackColor      = System.Drawing.Color.White,
                ForeColor      = System.Drawing.Color.Black,
                EncodedType    = TYPE.CODE128,
                AlternateLabel = lblRut.Text + lblVencimiento.Text,
                BarWidth       = 140
            };


            codigo.ImageFormat = System.Drawing.Imaging.ImageFormat.Gif;
            System.Drawing.Image bitmap = codigo.Encode(TYPE.CODE128, lblVencimiento.Text.ToString(), 100, 150);
            using (MemoryStream ms = new MemoryStream())
            {
                bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);

                var base64 = Convert.ToBase64String(ms.ToArray());
                var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
                return(bitmap);
            }
        }
Exemplo n.º 7
0
        private void txtProducto_TextChanged(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtProducto.Text))
            {
                errorProvider1.Clear();
                //codigo que genera la libreria del codigo de barra
                BarcodeLib.Barcode codigo = new BarcodeLib.Barcode();
                codigo.AlternateLabel = txtProducto.Text;
                codigo.IncludeLabel   = true;
                panel1.Image          = codigo.Encode(BarcodeLib.TYPE.CODE128, txtCodBarra.Text, Color.Black, Color.White, 320, 150);


                if (panel1.Image != null)
                {
                    //codigo que añade el texto del textbox CodBarra a la imagen
                    var COD = txtCodBarra.Text;

                    Brush    mybrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
                    Font     myfont  = new Font("Calibri", 10, FontStyle.Bold);
                    Bitmap   BM      = new Bitmap(panel1.Image);
                    Graphics DIBUJO  = Graphics.FromImage(BM);
                    DIBUJO.TranslateTransform(30, 20);
                    DIBUJO.RotateTransform(-90);
                    DIBUJO.DrawString(COD, myfont, mybrush, -70, -15);
                    this.panel1.Image = BM;
                }
            }
        }
Exemplo n.º 8
0
        public ActionResult Etiqueta(int id)
        {
            //A partir del id genero 12 números para luego crear el EAN-13
            string codigo    = id.ToString();
            var    cantCeros = 11 - id.ToString().Count();

            for (int i = 0; i < cantCeros; i++)
            {
                codigo = "0" + codigo;
            }
            codigo = "1" + codigo;

            BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
            {
                IncludeLabel   = false,
                Alignment      = AlignmentPositions.CENTER,
                Width          = 300,
                Height         = 120,
                RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                BackColor      = Color.White,
                ForeColor      = Color.Black,
            };

            System.Drawing.Image img = barcode.Encode(TYPE.EAN13, codigo); //Cuando le ponemos muchos nros toma los 12 primeros.

            using (var streak = new MemoryStream())
            {
                img.Save(streak, ImageFormat.Png);

                return(File(streak.ToArray(), "image/png"));
            }
        }
Exemplo n.º 9
0
 private void btnGenerar_Click(object sender, EventArgs e)
 {
     BarcodeLib.Barcode Codigo = new BarcodeLib.Barcode();
     Codigo.IncludeLabel            = true;
     panelResultado.BackgroundImage = Codigo.Encode(BarcodeLib.TYPE.CODE128, txtCodigo.Text, Color.Black, Color.White, 400, 100);
     btnGuardar.Enabled             = true;
 }
Exemplo n.º 10
0
    protected void OnBtnGenerateClicked(object sender, EventArgs e)
    {
        try {
            BarcodeLib.Barcode codeBar = new BarcodeLib.Barcode ();
            codeBar.Alignment = BarcodeLib.AlignmentPositions.CENTER;
            codeBar.IncludeLabel = true;
            codeBar.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER;

            BarcodeLib.TYPE bCodeType = (BarcodeLib.TYPE)Enum.Parse (typeof(BarcodeLib.TYPE), cmbBarCodeType.ActiveText.ToString ());
            System.Drawing.Image imgTmpCodeBar = codeBar.Encode (bCodeType, txtData.Text.Trim (), System.Drawing.Color.Black, System.Drawing.Color.White, 300, 300);

            MemoryStream memoryStream = new MemoryStream();
            imgTmpCodeBar.Save(memoryStream, ImageFormat.Png);
            Gdk.Pixbuf pb = new Gdk.Pixbuf (memoryStream.ToArray());

            imgCodeBar.Pixbuf = pb;

        } catch (Exception err) {
            MessageDialog dlg = new MessageDialog (this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, string.Format ("Ocurrió un error \n {0}", err.Message));
            dlg.Run ();
            dlg.Destroy ();
            dlg.Dispose ();
            dlg = null;
        }
    }
Exemplo n.º 11
0
        public static string GetBarcodeString(int height, int width, BarcodeLib.TYPE type, string code, out System.Drawing.Image image)
        {
            image = null;
            BarcodeLib.Barcode b = new BarcodeLib.Barcode();
            b.BackColor     = System.Drawing.Color.White; //图片背景颜色
            b.ForeColor     = System.Drawing.Color.Black; //条码颜色
            b.IncludeLabel  = true;
            b.Alignment     = BarcodeLib.AlignmentPositions.CENTER;
            b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER;
            b.ImageFormat   = System.Drawing.Imaging.ImageFormat.Jpeg;          //图片格式
            System.Drawing.Font font = new System.Drawing.Font("verdana", 10f); //字体设置
            b.LabelFont = font;

            b.Height = height;                             //图片高度设置(px单位)
            b.Width  = width;                              //图片宽度设置(px单位)

            image = b.Encode(type, code);                  //生成图片
            byte[] buffer = b.GetImageData(SaveTypes.GIF); //转换byte格式
            //byte转换图片格式
            MemoryStream oMemoryStream = new MemoryStream(buffer);

            //設定資料流位置
            oMemoryStream.Position = 0;
            //return buffer;
            //return image;
            return(System.Convert.ToBase64String(buffer, 0, buffer.Length));
        }
Exemplo n.º 12
0
 private void btnCrear_Click(object sender, EventArgs e)
 {
     BarcodeLib.Barcode codigo = new BarcodeLib.Barcode();
     codigo.IncludeLabel          = true;
     panel_codigo.BackgroundImage = codigo.Encode(BarcodeLib.TYPE.CODE128, txtCodigo.Text, Color.Black, Color.White, 271, 100);
     btnGuardar.Enabled           = true;
 }
Exemplo n.º 13
0
        private void btnGenerarCodigoBarra_Click(object sender, EventArgs e)
        {
            int    c      = 0;
            Random r      = new Random();
            int    nro    = 0;
            string codigo = "";

            while (c < 10)
            {
                nro = r.Next(0, 10);
                if (c == 0)
                {
                    codigo = nro.ToString();
                }
                else
                {
                    codigo = codigo + nro.ToString();
                }
                c++;
            }

            BarcodeLib.Barcode CodBar = new BarcodeLib.Barcode();
            //panel1.BackgroundImage = codigo.Encode(BarcodeLib.TYPE.CODE128, "12345678988877744521", Color.Black, Color.White, 300, 300);
            //ImagenCodigo.Image = CodBar.Encode(BarcodeLib.TYPE.CODE128, codigo, Color.Black, Color.White, 300, 300);
        }
Exemplo n.º 14
0
    public static void GetBarcode(int height, int width, BarcodeLib.TYPE type, string code, out System.Drawing.Image image, string fileSaveUrl)
    {
        try
        {
            image = null;
            BarcodeLib.Barcode b = new BarcodeLib.Barcode();
            b.BackColor    = System.Drawing.Color.White; //图片背景颜色
            b.ForeColor    = System.Drawing.Color.Black; //条码颜色
            b.IncludeLabel = false;
            b.Alignment    = BarcodeLib.AlignmentPositions.LEFT;
            //b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER;
            b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMLEFT;
            b.ImageFormat   = System.Drawing.Imaging.ImageFormat.Jpeg;          //图片格式
            // b.ImageFormat = System.Drawing.Imaging.ImageFormat.Gif;//图片格式
            System.Drawing.Font font = new System.Drawing.Font("verdana", 10f); //字体设置
            b.LabelFont = font;
            b.Height    = height;                                               //图片高度设置(px单位)
            b.Width     = width;                                                //图片宽度设置(px单位)

            image = b.Encode(type, code);                                       //生成图片


            image.Save(fileSaveUrl, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
        catch (Exception ex)
        {
            image = null;
        }
    }
Exemplo n.º 15
0
        private string GenerateBarcode(string BarcodeData)
        {
            string result = string.Empty;

            try
            {
                BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
                {
                    IncludeLabel   = false,
                    Alignment      = AlignmentPositions.CENTER,
                    Width          = 500,
                    Height         = 150,
                    RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                    BackColor      = Color.White,
                    ForeColor      = Color.Black,
                };

                System.Drawing.Image img = barcode.Encode(TYPE.CODE39, BarcodeData);
                string BarcodePath       = Environment.CurrentDirectory + "\\CONDO\\REPORTING\\" + BarcodeData + ".jpg";
                if (File.Exists(BarcodePath))
                {
                    File.Delete(BarcodePath);
                }
                img.Save(BarcodePath);
                result = BarcodePath;
            }
            catch
            {
            }
            return(result);
        }
Exemplo n.º 16
0
        static void GenerateBarcodeNoLable(Stream stream, string source, TYPE type = TYPE.CODE128, int imageWidth = 200, int imageHeight = 50, string strImageFormat = "jpeg", AlignmentPositions positions = AlignmentPositions.CENTER)
        {
            try
            {
                BarcodeLib.Barcode b = new BarcodeLib.Barcode();

                if (type != TYPE.UNSPECIFIED)
                {
                    b.IncludeLabel = false;
                    b.Alignment    = positions;

                    var Forecolor = "000000";
                    var Backcolor = "FFFFFF";

                    //===== Encoding performed here =====
                    System.Drawing.Image barcodeImage;
                    if (!CheckInputInSpeacial(source.Trim()))
                    {
                        barcodeImage = b.Encode(type, source.Trim(),
                                                ColorTranslator.FromHtml("#" + Forecolor),
                                                ColorTranslator.FromHtml("#" + Backcolor),
                                                imageWidth, imageHeight);
                    }
                    else
                    {
                        barcodeImage = b.Encode(type, source.Trim(),
                                                ColorTranslator.FromHtml("#" + Forecolor),
                                                ColorTranslator.FromHtml("#" + Backcolor));
                    }



                    //===================================

                    //===== Static Encoding performed here =====
                    //barcodeImage = BarcodeLib.Barcode.DoEncode(type, this.txtData.Text.Trim(), this.chkGenerateLabel.Checked, this.btnForeColor.BackColor, this.btnBackColor.BackColor);
                    //==========================================

                    //Response.ContentType = "image/" + strImageFormat;

                    switch (strImageFormat)
                    {
                    case "gif": barcodeImage.Save(stream, ImageFormat.Gif); break;

                    case "jpeg": barcodeImage.Save(stream, ImageFormat.Jpeg); break;

                    case "png": barcodeImage.Save(stream, ImageFormat.Png); break;

                    case "bmp": barcodeImage.Save(stream, ImageFormat.Bmp); break;

                    case "tiff": barcodeImage.Save(stream, ImageFormat.Tiff); break;
                    } //switch
                }     //if
            }         //try
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 17
0
 public static string Encode(string barcode, string path)
 {
     var barcodeLib = new BarcodeLib.Barcode(barcode);
     barcodeLib.Encode(TYPE.CODE128, barcode);
     string filename = path + barcode + ".jpg";
     barcodeLib.SaveImage(filename, SaveTypes.JPG);
     barcodeLib.IncludeLabel = true;
     return filename;
 }
Exemplo n.º 18
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            // Importar la Librería BarcodeLib en NuGet

            BarcodeLib.Barcode CodigoBarras = new BarcodeLib.Barcode();
            CodigoBarras.IncludeLabel      = true;
            PanelResultado.BackgroundImage = CodigoBarras.Encode(BarcodeLib.TYPE.CODE128, txtTexto.Text, Color.Black, Color.White, 400, 100); // <---------
            btnGuardar.Enabled             = true;
            btnImprimir.Enabled            = true;
        }
Exemplo n.º 19
0
 private void Load()
 {
     LoadCat();
     LoadType();
     LoadValue();
     LoadDiff();
     code128         = new Barcode();
     txtcusname.Text = fullName;
     txtDateNow.Text = date_Order.ToString("dd/MM/yyyy");
 }
Exemplo n.º 20
0
        private Image TxmImage(string txm_data, int width, int height)
        {
            BarcodeLib.Barcode barcode = new BarcodeLib.Barcode();
            barcode.RawData   = txm_data.Trim();
            barcode.scale     = width;
            barcode.HeightTxm = height;
            TYPE iType = TYPE.CODE128;

            return(barcode.Encode(iType));
        }
Exemplo n.º 21
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            BarcodeLib.Barcode Codigo = new BarcodeLib.Barcode();
            Codigo.IncludeLabel = true;
            //panelResultado.BackgroundImage = Codigo.Encode(TYPE.UPCA, Convert.ToString(txtCodigo), Color.Black, Color.White, 290, 120);

            panelResultado.BackgroundImage = Codigo.Encode(TYPE.CODE128, txtCodigo.Text, Color.Black, Color.White, 290, 120);
            btnGuardar.Enabled             = true;

            // Image img = Codigo.Encode(TYPE.UPCA, "dsfsdvfdsfv", Color.Black, Color.White, 290, 120);
        }
Exemplo n.º 22
0
        //public static byte[] GenBarCodeToImage(string code)
        //{
        //    return GenBarCodeToImage(code, 1);
        //}

        //public static byte[] GenBarCodeToImage(string code, int weight)
        //{
        //    try
        //    {
        //        Image img = Code128Rendering.MakeBarcodeImage(code, weight, true);
        //        MemoryStream ms = new MemoryStream();
        //        img.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
        //        return  ms.ToArray();
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new ArgumentException(ex.Message);
        //    }
        //}
        #region GenerateBarCode
        public static Byte[] GetBarCodeData(string argStrData, string argStrFontName, int argIntWidth, int argIntHeight)
        {
            BarcodeLib.Barcode bc = new BarcodeLib.Barcode();
            bc.BackColor    = System.Drawing.Color.White;
            bc.ForeColor    = System.Drawing.Color.Black;
            bc.IncludeLabel = false;
            bc.LabelFont    = new System.Drawing.Font(argStrFontName, 10);
            System.Drawing.Image img = bc.Encode(BarcodeLib.TYPE.CODE128, argStrData, argIntWidth, argIntHeight);//350,80);
            byte[] bytes             = bc.GetImageData(BarcodeLib.SaveTypes.PNG);
            return(bytes);
        }
Exemplo n.º 23
0
        private void codigosBarrasF_Load(object sender, EventArgs e)
        {
            string id_def = tipo + " 301" + id;

            label2.Text        = id_def;
            id_def             = "301" + id;
            Login.usuario.code = id_def;
            BarcodeLib.Barcode code = new BarcodeLib.Barcode();
            code.IncludeLabel = true;
            pictureBox1.Image = code.Encode(BarcodeLib.TYPE.CODE128, label2.Text, Color.Black, Color.White);
        }
Exemplo n.º 24
0
        public static string Encode(string barcode, string path)
        {
            var barcodeLib = new BarcodeLib.Barcode(barcode);

            barcodeLib.Encode(TYPE.CODE128, barcode);
            string filename = path + barcode + ".jpg";

            barcodeLib.SaveImage(filename, SaveTypes.JPG);
            barcodeLib.IncludeLabel = true;
            return(filename);
        }
        public object GetCodBar(string id)
        {
            BarcodeLib.Barcode codbar = new BarcodeLib.Barcode();
            codbar.IncludeLabel = false;
            var img  = codbar.Encode(BarcodeLib.TYPE.Interleaved2of5, id, Color.Black, Color.White, 320, 60);
            var simg = new MemoryStream();

            img.Save(simg, ImageFormat.Jpeg);
            simg.Position = 0;
            return(new FileStreamResult(simg, "image/jpeg"));
        }
        protected override void OnPrintPage(PrintPageEventArgs e)
        {
            //条码高度和宽度
            try
            {
                StringFormat sf = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                Font Regularfont   = new System.Drawing.Font("Times New Roman, Times, serif", 25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                Font Regularfont1  = new System.Drawing.Font("Times New Roman, Times, serif", 40F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                Font Regularfont2  = new System.Drawing.Font("Times New Roman, Times, serif", 30F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                Font Regularfont3  = new System.Drawing.Font("Times New Roman, Times, serif", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                Font Regularfont4  = new System.Drawing.Font("Times New Roman, Times, serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                Font Regularfont5  = new System.Drawing.Font("Times New Roman, Times, serif", 17F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                Font Regularfont6  = new System.Drawing.Font("Times New Roman, Times, serif", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                Font Regularfont7  = new System.Drawing.Font("Times New Roman, Times, serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                Font Regularfont8  = new System.Drawing.Font("Times New Roman, Times, serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                Font Regularfont9  = new System.Drawing.Font("Times New Roman, Times, serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                Font Regularfont10 = new System.Drawing.Font("Times New Roman, Times, serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

                BarcodeLib.Barcode b    = new BarcodeLib.Barcode();
                BarcodeLib.TYPE    type = BarcodeLib.TYPE.CODE128;
                b.IncludeLabel = false;
                if (_packingLog.PostTypeNames.Length > 12)
                {
                    _packingLog.PostTypeNames = _packingLog.PostTypeNames.Insert(12, "\n");
                }
                string _countryArea = "BG国家/分区 : ";
                if (_packingLog.CountryNames.IndexOf(",") < 0)
                {
                    _countryArea += _packingLog.CountryNames;
                }
                var PostTypeNames = OrderSortService.GetPostTypeName(_packingLog.PostTypeIds);

                e.Graphics.DrawString(_countryArea, Regularfont4, Brushes.Black, 30, 30);
                string _dayPackage = _packingLog.OperationTime.ToString("MM/dd");
                e.Graphics.DrawImage(b.Encode(type, _packingLog.PackNumber, 150, 30), 80, 90);
                e.Graphics.DrawString(_packingLog.PackNumber, Regularfont7, Brushes.Black, 105, 125);
                e.Graphics.DrawString("运输方式:" + PostTypeNames, Regularfont4, Brushes.Black, 30, 150);
                e.Graphics.DrawString("日期:" + _dayPackage, Regularfont4, Brushes.Black, 30, 190);
                e.Graphics.DrawString("操作人:", Regularfont4, Brushes.Black, 30, 220);
                e.Graphics.DrawString("件数:" + _packingLog.OrderQty, Regularfont4, Brushes.Black, 30, 250);
                e.Graphics.DrawString("BGHZ  " + _packingLog.LatticeId, Regularfont4, Brushes.Black, 30, 280);
                e.Graphics.DrawString("重量:", Regularfont4, Brushes.Black, 130, 280);
                var image = GenerateQRByQrCodeNet(_packingLog.PackNumber);
                e.Graphics.DrawImage(image, 130, 170, 100, 100);

                this.Dispose();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 27
0
 void loadBar()
 {
     code128 = new Barcode();
     for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
     {
         string ID      = dataGridView1.Rows[i].Cells[0].Value.ToString();
         Image  barCode = code128.Encode(BarcodeLib.TYPE.CODE128, ID);
         imageListID.Images.Add(barCode);
         listView1.Items.Add(ID, i);
     }
     listView1.LargeImageList = imageListID;
 }
Exemplo n.º 28
0
        /* private void btnguardar_Click(object sender, EventArgs e)
         * {
         *   Image imgFinal = (Image)Panel_resultado.BackgroundImage.Clone();
         *   SaveFileDialog CajaDeDialogoGuardar = new SaveFileDialog();
         *   CajaDeDialogoGuardar.AddExtension = true;
         *   CajaDeDialogoGuardar.Filter = "Image PNG (*.png)|*.png";
         *   CajaDeDialogoGuardar.ShowDialog();
         *   if (!string.IsNullOrEmpty(CajaDeDialogoGuardar.FileName))
         *   {
         *       imgFinal.Save(CajaDeDialogoGuardar.FileName, System.Drawing.Imaging.ImageFormat.Png);
         *   }
         *   imgFinal.Dispose();
         * }*/

        private void Panel_resultado_Paint(object sender, PaintEventArgs e)
        {
            string variable = Path.GetDirectoryName(Application.ExecutablePath);

            variable = variable + "\\imprimir.txt";
            StreamReader leer = new StreamReader(@variable);
            string       linea;

            linea = leer.ReadLine();
            BarcodeLib.Barcode Codigo = new BarcodeLib.Barcode();
            Codigo.IncludeLabel             = true;
            Panel_resultado.BackgroundImage = Codigo.Encode(BarcodeLib.TYPE.CODE39, linea, Color.Black, Color.White, 238, 100);
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            //Generowanie zmiennych
            Image img       = null;
            int   szerokosc = 200;

            //Generowanie Sumy kontrolnej
            Console.Write("Ręcę do góry! Wyskakuj z kodu. 12 cyferek. Ale już! ");
            String kod = Console.ReadLine();

            long.Parse(kod);
            int sumakontrolna = 0;

            for (int i = 0; i < kod.Length - 1; i += 2)
            {
                sumakontrolna += Int32.Parse(kod[i] + "");
                sumakontrolna += 3 * Int32.Parse(kod[i + 1] + "");
            }
            sumakontrolna = sumakontrolna % 10;
            sumakontrolna = 10 - sumakontrolna;
            if (sumakontrolna == 10)
            {
                sumakontrolna = 0;
            }

            if (kod.Length != 12)
            {
                Console.WriteLine("Podaj dokladnie 12 cyfr kodu");
            }
            else
            {
                //Generowanie Kodu Kreskowego
                BarcodeLib.Barcode barcode = new BarcodeLib.Barcode();
                barcode.LabelFont    = new Font(barcode.LabelFont.FontFamily, szerokosc / 15);
                barcode.IncludeLabel = true;
                img = barcode.Encode(TYPE.EAN13, kod);
                Console.WriteLine("Ha! Ha! Mam sume kontrolna do Twojego kodu gagatku! " + sumakontrolna);
                Console.ReadLine();
                using (FileStream fs = new FileStream("kot.png", FileMode.Create, FileAccess.Write)) {
                    img.Save(fs, System.Drawing.Imaging.ImageFormat.Png);
                    fs.Close();
                }
                //Otwieranie
                string komenda;
                komenda = "/C C:\\Users\\lab\\Desktop\\MikolajJarek\\ConsoleApplication1\\ConsoleApplication1\\bin\\Debug\\kot.png";
                System.Diagnostics.Process.Start("cmd", komenda);
                //Drukowanie
                Druk();
            }
            Console.ReadLine();
        }
Exemplo n.º 30
0
        private void txtcodigo_Validating(object sender, CancelEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtcodigo.Text))
                {
                    return;
                }

                string  vSql     = $"SELECT * From productos Where id_productos Like ('%" + txtcodigo.Text.Trim() + "%') ";
                DataSet dt       = new DataSet();
                bool    correcto = dt.ejecuta(vSql);
                if (utilidades.DsTieneDatos(dt))
                {
                    txtcodigo.Text            = dt.Tables[0].Rows[0]["id_productos"].ToString();
                    txtproducto.Text          = dt.Tables[0].Rows[0]["productos"].ToString();
                    combounidad.SelectedValue = dt.Tables[0].Rows[0]["unidad"].ToString();
                }
                else
                {
                    MessageBox.Show("PRODUCTO NO ENCONTRADO");
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error" + error.Message);
            }

            try
            {
                string  vSql     = $"SELECT * From productos Where id_productos Like('%" + txtcodigo.Text.Trim() + "%') ";
                DataSet dt       = new DataSet();
                bool    correcto = dt.ejecuta(vSql);
                if (utilidades.DsTieneDatos(dt))
                {
                    string             codigobarras = dt.Tables[0].Rows[0]["id_productos"].ToString() + "-" + dt.Tables[0].Rows[0]["productos"].ToString().Trim();
                    BarcodeLib.Barcode Codigo       = new BarcodeLib.Barcode();
                    Codigo.IncludeLabel            = false;
                    panelresultado.BackgroundImage = Codigo.Encode(BarcodeLib.TYPE.CODE128, codigobarras.ToString(), Color.Black, Color.White, 290, 90);
                    button5.Enabled = true;
                }
                else
                {
                    MessageBox.Show("ERROR");
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("error" + error);
            }
        }
Exemplo n.º 31
0
        private void btn_generar_Click(object sender, EventArgs e)
        {
            //BRIAN SANTIZO
            //CODIGO PARA LA GENERACION DE EL CODIGO DE BARRAS DENTRO DEL PANEL

            btn_guardar.Enabled = true;
            BarcodeLib.Barcode Codigo = new BarcodeLib.Barcode();
            Codigo.IncludeLabel = true;
            pnl_codigobarras.BackgroundImage = Codigo.Encode(BarcodeLib.TYPE.CODE128, txt_codigo.Text + "_" + txt_nombre.Text + "_" + txt_apellido.Text, Color.Black, Color.White, 400, 100);
            Image    imgFinal = (Image)pnl_codigobarras.BackgroundImage.Clone();
            Bitacora bit      = new Bitacora();

            bit.grabar("23");
            Limpiar();
        }
 private void btnGenerar_Click(object sender, EventArgs e)
 {
     //para el codigo de barras
     try
     {
         BarcodeLib.Barcode codigo = new BarcodeLib.Barcode();
         codigo.IncludeLabel            = true;
         panelResultado.BackgroundImage = codigo.Encode(BarcodeLib.TYPE.CODE128, txtCodigo.Text, Color.Black, Color.White, 400, 100);
         btnGuardar.Enabled             = true;
     }
     catch (Exception)
     {
         MessageBox.Show("Error al crear el codigo de barras");
     }
 }
Exemplo n.º 33
0
 private Image GenerateBarcode(String _data, TYPE t)
 {
     BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
     {
         IncludeLabel = false,                                //แสดงข้อความด้านล่าง
         Alignment = AlignmentPositions.CENTER,              //ตำแหน่งของรูปบาร์โค้ดเป็นกึงกลาง
         Width = 400,                                        //ขนาดความกว้างของรูปบาร์โค้ด
         Height = 200,                                       //ขนาดความสูงของรูปบาร์โค้ด
         RotateFlipType = RotateFlipType.RotateNoneFlipNone, //ไม่กำหนดการหมุนของรูปบาร์โค้ด
         BackColor = Color.White,                            //สีของพื้นหลังบาร์โค้ด
         ForeColor = Color.Black,                            //สีของแท่งบาร์โค้ด
     };
     Image img = barcode.Encode(t, _data);                   //แปลงบาร์โค้ดเป็นรูปภาพ
     return img;                                             //return รูปบาร์โค้ด
 }
Exemplo n.º 34
0
        private void bunifuThinButton23_Click(object sender, EventArgs e)
        {
            BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
            {
                IncludeLabel   = true,
                Alignment      = AlignmentPositions.CENTER,
                Width          = 390,
                Height         = 150,
                RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                BackColor      = Color.White,
                ForeColor      = Color.Black,
            };

            puyt.Image = barcode.Encode(TYPE.CODE128B, bccode.Text);
        }
Exemplo n.º 35
0
        public System.Drawing.Image GiveBarcode(string value)
        {
            BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
            {
                IncludeLabel   = true,
                Alignment      = AlignmentPositions.CENTER,
                Width          = 250,
                Height         = 40,
                RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                BackColor      = Color.White,
                ForeColor      = Color.Black,
            };

            System.Drawing.Image img = barcode.Encode(TYPE.CODE128B, value);
            return(img);
        }
Exemplo n.º 36
0
        public String generaCodigoBarras(String codigo)
        {
            String nombreArchivo = codigo + ".jpg";
            var fileName = string.Format(AppDomain.CurrentDomain.BaseDirectory + "{0}", @"tmp\" + nombreArchivo);

            BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
            {
                IncludeLabel = true,
                Alignment = AlignmentPositions.CENTER,
                Width = 350,
                Height = 55,
                RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                BackColor = Color.White,
                ForeColor = Color.Black,
                AlternateLabel = codigo, //aca se podría poder otra leyenda cuando se lee.
            };

            Image img = barcode.Encode(TYPE.Interleaved2of5, codigo);
            img.Save(fileName);

            return nombreArchivo;
        }
Exemplo n.º 37
0
 public pad1()
 {
     InitializeComponent();
     this.FormClosing += myform_closing;
     this.Text = shared_data.shm_id;
     this.marquee.Text = shared_data.marquee_txt;
     marquee_alarm = new System.Timers.Timer(50);
     marquee_alarm.Elapsed += new ElapsedEventHandler(marquee_event);
     marquee_alarm.Start();
     // 2-D code image generate
     string shmid_code = shared_data.shm_id.Split('_')[1];
     this.shmid_label.Text = shmid_code;
     shmid_code = "2-20" + shmid_code.PadLeft(2, '0');
     Barcode bc = new Barcode();
     bc.IncludeLabel = true;//text label or not
     bc.Width = 400;
     bc.Height = 100;
     Image img = bc.Encode(TYPE.CODE39, shmid_code, bc.Width, bc.Height);
     //this.shmid_pic.Image = img;
     // label text init.
     this.item_name.Text = shared_data.name;
     this.item_num.Text = shared_data.num + "/" + shared_data.unit;
     this.itemid_label.Text = shared_data.id;
 }
Exemplo n.º 38
0
        private void GeraBarCode(string texto)
        {
            var barcode = new Barcode {
                IncludeLabel = true,
                Alignment = AlignmentPositions.CENTER,
                Width = 300,
                Height = 100,
                RotateFlipType = RotateFlipType.RotateNoneFlipNone
            };

            var img = barcode.Encode(TYPE.CODE128, texto);

            var ms = new MemoryStream();
            img.Save(ms, ImageFormat.Png);
            ms.Position = 0;

            var bi = new BitmapImage();
            bi.BeginInit();
            bi.StreamSource = ms;
            bi.EndInit();

            imgCodCod.Source = bi;
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["d"] != null)
        {
            //Read in the parameters
            string strData = Request.QueryString["d"];
            int imageHeight = Convert.ToInt32(Request.QueryString["h"]);
            int imageWidth = Convert.ToInt32(Request.QueryString["w"]);
            string Forecolor = Request.QueryString["fc"];
            string Backcolor = Request.QueryString["bc"];
            bool bIncludeLabel = Request.QueryString["il"].ToLower().Trim() == "true";
            string strImageFormat = Request.QueryString["if"].ToLower().Trim();
            string strAlignment = Request.QueryString["align"].ToLower().Trim();

            BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
            switch (Request.QueryString["t"].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 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 (Facing Identification Mark)": type = BarcodeLib.TYPE.FIM; break;
                case "Pharmacode": type = BarcodeLib.TYPE.PHARMACODE; break;
                default: break;
            }//switch

            System.Drawing.Image barcodeImage = null;
            try
            {
                BarcodeLib.Barcode b = new BarcodeLib.Barcode();
                if (type != BarcodeLib.TYPE.UNSPECIFIED)
                {
                    b.IncludeLabel = bIncludeLabel;

                    //alignment
                    switch (strAlignment.ToLower().Trim())
                    {
                        case "c": b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
                            break;
                        case "r": b.Alignment = BarcodeLib.AlignmentPositions.RIGHT;
                            break;
                        case "l": b.Alignment = BarcodeLib.AlignmentPositions.LEFT;
                            break;
                        default: b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
                            break;
                    }//switch

                    if (Forecolor.Trim() == "" && Forecolor.Trim().Length != 6)
                        Forecolor = "000000";
                    if (Backcolor.Trim() == "" && Backcolor.Trim().Length != 6)
                        Backcolor = "FFFFFF";
                    
                    //===== Encoding performed here =====
                    barcodeImage = b.Encode(type, strData.Trim(), System.Drawing.ColorTranslator.FromHtml("#" + Forecolor), System.Drawing.ColorTranslator.FromHtml("#" + Backcolor), imageWidth, imageHeight);
                    //===================================
                    
                    //===== Static Encoding performed here =====
                    //barcodeImage = BarcodeLib.Barcode.DoEncode(type, this.txtData.Text.Trim(), this.chkGenerateLabel.Checked, this.btnForeColor.BackColor, this.btnBackColor.BackColor);
                    //==========================================

                    Response.ContentType = "image/" + strImageFormat;
                    System.IO.MemoryStream MemStream = new System.IO.MemoryStream(); 

                    switch(strImageFormat)
                    {
                        case "gif": barcodeImage.Save(MemStream, ImageFormat.Gif); break;
                        case "jpeg": barcodeImage.Save(MemStream, ImageFormat.Jpeg); break;
                        case "png": barcodeImage.Save(MemStream, ImageFormat.Png); break;
                        case "bmp": barcodeImage.Save(MemStream, ImageFormat.Bmp); break;
                        case "tiff": barcodeImage.Save(MemStream, ImageFormat.Tiff); break;
                        default: break;
                    }//switch
                    MemStream.WriteTo(Response.OutputStream);
                }//if
            }//try
            catch (Exception ex)
            {
                //TODO: find a way to return this to display the encoding error message
            }//catch
            finally
            {
                if (barcodeImage != null)
                {
                    //Clean up / Dispose...
                    barcodeImage.Dispose();
                }
            }//finally
        }//if
    }
Exemplo n.º 40
0
 /// <summary>
 /// Barcodes from http://www.codeproject.com/KB/graphics/BarcodeLibrary.aspx by Brad Barnhill
 /// License: http://www.codeproject.com/info/cpol10.aspx GPL (*CPOL)
 /// </summary>
 /// <param name="barType">Type of the bar.</param>
 /// <param name="barValue">The bar value.</param>
 /// <param name="barOptions">The bar options.</param>
 /// <returns>
 /// Bitmap image
 /// </returns>
 public static System.Drawing.Bitmap BarCode( string barType, string barValue, Dictionary<string, object> barOptions )
 {
     ( "FUNCTION /w binaryStream barCode" ).Debug( 10 );
     JToken jtOpt = JToken.FromObject( barOptions );
     JsonSerializer serializer = new JsonSerializer();
     BarOptions options = null;
     using( JTokenReader jtr = new JTokenReader( jtOpt ) ) {
         options = ( BarOptions )serializer.Deserialize( jtr, typeof( BarOptions ) );
     }
     BarcodeLib.TYPE type = BarcodeLib.TYPE.UPCA;
     switch( barType.ToString().Trim().ToUpper() ) {
         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 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;
     }
     AlignmentPositions align = AlignmentPositions.CENTER;
     switch( options.Alignment.Trim().ToUpper() ) {
         case "CENTER": align = AlignmentPositions.CENTER; break;
         case "LEFT": align = AlignmentPositions.LEFT; break;
         case "RIGHT": align = AlignmentPositions.RIGHT; break;
     }
     System.Drawing.Bitmap oBmp = null;
     using( System.Drawing.Font font = new System.Drawing.Font( options.FontFamily, options.FontSize ) ) {
         using( BarcodeLib.Barcode bar = new BarcodeLib.Barcode() ) {
             using( MemoryStream stream = new MemoryStream() ) {
                 System.Drawing.Color foreground = System.Drawing.Color.FromName( options.Foreground );
                 System.Drawing.Color background = System.Drawing.Color.FromName( options.Background );
                 bar.Height = options.Height;
                 bar.Width = options.Width;
                 bar.IncludeLabel = options.IncludeLabel;
                 bar.LabelFont = font;
                 bar.Alignment = align;
                 System.Drawing.Image img = bar.Encode( type, barValue, foreground, background, options.Width, options.Height );
                 img.Save( stream, System.Drawing.Imaging.ImageFormat.Png );
                 oBmp = new System.Drawing.Bitmap( stream );
             }
         }
     }
     return oBmp;
 }
Exemplo n.º 41
0
        public void loadData()
        {
            try
            {
                string dirname = Application.StartupPath + "/bar/";
                string dirnameNew = dirname + generuin() + ".png";
                Barcode barcode = new Barcode()
                {
                    IncludeLabel = true,
                    Alignment = AlignmentPositions.CENTER,
                    Width = 150,
                    Height = 50,
                    RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                    BackColor = Color.White,
                    ForeColor = Color.Black,
                };
                Image img = barcode.Encode(TYPE.CODE128, "AF" + this.uin + "");
                img.Save(dirnameNew);
                dataTMain = dataTMain.Replace("{img}", dirnameNew);
            }
            catch (Exception) { }

                this.dataTSubFull = "";

                DataTable dataGG = db.FetchAllSql("SELECT id,d5,d14,d2,d8,d6 FROM billdata WHERE billUin = '" + this.uin + "'");

                foreach (DataRow rr in dataGG.Rows)
                {
                    string clientid = "", client = "", adress = "", supp = "", countbill = "", countplace = "", status = "";

                    #region findTheSupp
                    // Find and set the supp
                    DataTable dataSupp = db.FetchAllSql("SELECT title FROM `supps` WHERE id = '" + rr[3].ToString() + "'");
                    if (dataSupp.Rows.Count != 0)
                    {
                        supp = dataSupp.Rows[0][0].ToString();
                    }
                    #endregion

                    string[] CB = rr[4].ToString().Split(';');
                    countbill = CB.Length.ToString();

                    string[] CP = rr[5].ToString().Split(';');
                    countplace = CP.Length.ToString();

                    clientid = rr[0].ToString();
                    client = rr[1].ToString();
                    adress = rr[2].ToString();

                    string dataTSubBuffer = this.dataTSub;
                    dataTSubBuffer = dataTSubBuffer.Replace("{01}", client);
                    dataTSubBuffer = dataTSubBuffer.Replace("{02}", adress);
                  //  dataTSubBuffer = dataTSubBuffer.Replace("{03}", time);
                  //  dataTSubBuffer = dataTSubBuffer.Replace("{04}", note);
                    dataTSubBuffer = dataTSubBuffer.Replace("{05}", countbill);
                  //  dataTSubBuffer = dataTSubBuffer.Replace("{06}", phone);

                    dataTSubBuffer = dataTSubBuffer.Replace("{data}", generItemData(rr[0].ToString()));

                    dataTSubFull += dataTSubBuffer;
                }
        }
Exemplo n.º 42
0
        private void alarm_event(object sender, ElapsedEventArgs e)
        {
            try
            {
                // marquee
                string cur_time = System.DateTime.Now.ToString("yy/M/d tt h:mm:ss");
                for (int i = 0; i < 157; i++)
                    cur_time += " ";
                this.marquee.Invoke(new MethodInvoker(
                    delegate
                    {
                        marquee.Text = cur_time + data_bus.marquee_txt;
                        if ((this.marquee.Location.X + this.marquee.Size.Width) < 0)
                            this.marquee.Location = new System.Drawing.Point(this.Width, this.marquee.Location.Y);
                        this.marquee.Location = new System.Drawing.Point(this.marquee.Location.X - 2, this.marquee.Location.Y);
                    }));
                // marquee end
                switch (data_bus.state)
                {
                    case 0: this.p_state0.Invoke(new MethodInvoker(
                     delegate
                     {
                         if (!p_state0.Visible)
                             p_state0.Show();
                         p_state0.BackColor = System.Drawing.Color.FromArgb(192, 255, 192);
                         this.label1.Text = "等待伺服器連線";

                     }));
                        this.p_state1.Invoke(new MethodInvoker(
                     delegate
                     {
                         if (p_state1.Visible)
                             p_state1.Hide();
                     }));
                        break;

                    case 1: this.p_state0.Invoke(new MethodInvoker(
                    delegate
                    {
                        if (p_state0.Visible)
                            p_state0.Hide();
                    }));
                        this.p_state1.Invoke(new MethodInvoker(
                    delegate
                    {
                        if (!p_state1.Visible)
                            p_state1.Show();
                        string shmid_code = data_bus.shm_id.Split('_')[1];
                        this.shmid_label.Text = shmid_code;
                        Barcode bc = new Barcode();
                        bc.IncludeLabel = false;//text label or not
                        bc.Width = 400;
                        bc.Height = 75;
                        Image img = bc.Encode(TYPE.CODE39, shmid_code, bc.Width, bc.Height);
                        this.shmid_pic.Image = img;
                        // label text init.
                        this.item_name.Text = data_bus.name;
                        this.item_num.Text = data_bus.num + "/" + data_bus.unit;
                        StreamReader sr = new StreamReader("server_config");
                        string line = sr.ReadLine();
                        string[] splits = line.Split(' ');
                        this.item_pic.ImageLocation = "http://" + splits[2] + "/image/" + data_bus.image_url;
                    }));
                        break;
                    case 2:
                    case 4: this.p_state0.Invoke(new MethodInvoker(
                     delegate
                     {
                         count++;
                         if (!p_state0.Visible)
                             p_state0.Show();
                         if ((count % 10) == 0)
                             color = (color + 1) % 2;
                         if (color == 0)
                             this.p_state0.BackColor = System.Drawing.Color.FromArgb(255, 215, 0);
                         else
                             this.p_state0.BackColor = System.Drawing.Color.FromArgb(255, 99, 71);
                         if (data_bus.state == 2)
                             this.label1.Text = "條碼掃描錯誤";
                         else
                             this.label1.Text = "請在此料位放置";
                     }));
                        this.p_state1.Invoke(new MethodInvoker(
                     delegate
                     {
                         if (p_state1.Visible)
                             p_state1.Hide();
                     }));
                        break;
                    case 3:
                    case 5: this.p_state0.Invoke(new MethodInvoker(
                     delegate
                     {
                         if (!p_state0.Visible)
                             p_state0.Show();
                         p_state0.BackColor = System.Drawing.Color.FromArgb(191, 255, 0);
                         if (data_bus.state == 3)
                             this.label1.Text = "條碼掃描正確";
                         else
                             this.label1.Text = "物料放置正確";

                     }));
                        this.p_state1.Invoke(new MethodInvoker(
                     delegate
                     {
                         if (p_state1.Visible)
                             p_state1.Hide();
                     }));
                        break;
                }
            }
            catch { }
        }
Exemplo n.º 43
0
        private void barcodePrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            var height = 87;
            var numberToPrint = (int)numericUpDownBarcode.Value;
            string code = deptSIDetailList[dgvDeptStockIn.CurrentRow.Index].Product.ProductId;

            if (numberToPrint > 3)
            {
                height = (numberToPrint / 3) * 87;
                numberToPrint = 3;
            }
            var eventArgs = new MainStockInEventArgs{ProductMasterIdForPrice = deptSIDetailList[dgvDeptStockIn.CurrentRow.Index].Product.ProductMaster.ProductMasterId};
            EventUtility.fireEvent(GetPriceEvent, this, eventArgs);
            string titleString = "";
            string name = deptSIDetailList[dgvDeptStockIn.CurrentRow.Index].Product.ProductMaster.ProductName;
            if (eventArgs.DepartmentPrice != null)
            {
                //titleString = name + " Giá : " + eventArgs.DepartmentPrice.Price.ToString("#,##", CultureInfo.CreateSpecificCulture("de-DE")) ;
                titleString = name + " - " + eventArgs.DepartmentPrice.Price.ToString() + ".00 ";
            }
            var code39 = new Code39
                             {
                                 FontFamilyName = "3 of 9 Barcode",
                                 //2.FontFamilyName = "MW6 Code39MT",
                                 //3.FontFamilyName = "MW6 Code39S",
                                 //4.FontFamilyName = "MW6 Code39LT",
                                 //5.FontFamilyName = "Code EAN13",
                                 FontFileName = "Common\\3OF9_NEW.TTF",
                                 //2.FontFileName = "Common\\MW6Code39MT.TTF",
                                 //3.FontFileName = "Common\\MW6Code39S.TTF",
                                 //4.FontFileName = "Common\\MW6Code39LT.TTF",
                                 //5.FontFileName = "Common\\ean13.ttf",
                                 ShowCodeString = true,
                                 FontSize = 12,
                                 TitleFont = new Font("Tahoma", 12),
                                 CodeStringFont = new Font("Tahoma",12),
                                 Title = titleString + " VND"
                        };

            //barcodeControl1.BarcodeData = deptSIDetailList[dgvDeptStockIn.CurrentRow.Index].Product.ProductId;

            BarcodeLib.Barcode barcode = new Barcode();

            string barCodeStr = deptSIDetailList[dgvDeptStockIn.CurrentRow.Index].Product.ProductId;
            Image imageBC = barcode.Encode(BarcodeLib.TYPE.CODE39, barCodeStr, Color.Black, Color.White, (int)(1.35 * e.Graphics.DpiX), (int)(0.45 * e.Graphics.DpiY));

            /*var code39Gen = code39.GenerateBarcode(deptSIDetailList[dgvDeptStockIn.CurrentRow.Index].Product.ProductId,
                                                   (int)((float)(1.5*e.Graphics.DpiX)),(int)((float)(0.75*e.Graphics.DpiY)));*/

            Bitmap bitmap1 = new Bitmap(imageBC);
            bitmap1.SetResolution(204,204);
            /*Bitmap bitmap2 = new Bitmap(code39Gen);
            bitmap2.SetResolution(203,203);*/
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

            // draw title string

                // calculate scale for title
                var titleStrSize = e.Graphics.MeasureString(titleString.PadRight(25), new Font("Arial",10));
                float currTitleSize = new Font("Arial",10).Size;
                float scaledTitleSize = (150 * currTitleSize) / titleStrSize.Width;
                //Font _titleFont = new Font("Arial", scaledTitleSize);
                Font _titleFont = new Font("Arial", 7);
                string nameString = titleString.Substring(0, titleString.IndexOf(" - "));
                string priceString = titleString.Substring(titleString.IndexOf(" - "));
                var priceTotalSize = e.Graphics.MeasureString(titleString, _titleFont);
                var nameSize = e.Graphics.MeasureString(nameString, _titleFont);
                var priceSize = e.Graphics.MeasureString(priceString, _titleFont);
                var barCodeSize = e.Graphics.MeasureString(barCodeStr, _titleFont);
                /*Bitmap bitmapName = new Bitmap(nameString, true);
                Bitmap bitmapPrice = new Bitmap(priceString, true);*/
            for (int i = 0; i < numberToPrint; i++)
            {

                System.Drawing.Rectangle rc = new System.Drawing.Rectangle((i % 3) * 135, 50, (int)(1.4 * 100), (int)(0.4 * 100));

                //(i % 3) * 124, (i / 3) * 87, 117, 79
                /*e.Graphics.DrawString(nameString, _titleFont, new SolidBrush(Color.Black), (i % 3) * 135 + XCentered(nameSize.Width, 140), 25);
                e.Graphics.DrawString(priceString, _titleFont, new SolidBrush(Color.Black), (i % 3) * 135 + XCentered(priceSize.Width, 140), (float)22.5 + nameSize.Height);*/
                e.Graphics.DrawString(titleString, _titleFont, new SolidBrush(Color.Black), (i % 3) * 140 + XCentered(priceTotalSize.Width, 140), (float)25);
                e.Graphics.DrawImage(bitmap1, new Rectangle((i % 3) * 140 + (int)XCentered((float)(1.35 * 100), 140), (int)(25 + priceTotalSize.Height), (int)(1.35 * 100), (int)(0.45 * 100)));
                e.Graphics.DrawString(barCodeStr, _titleFont, new SolidBrush(Color.Black), (i % 3) * 140 + XCentered(barCodeSize.Width, 140), (float)88);
                //e.Graphics.DrawImage(barcodeControl1.GetMetaFile(), new Rectangle((i % 3) * 135, 120, (i % 3) * 135 + (int)(1.4 * 100), (int)(0.75 * 100)));

            }
        }
Exemplo n.º 44
0
 protected bool GenrateBarcode_Image(string Barcode_Value)
 {
     BarcodeLib.Barcode b = new BarcodeLib.Barcode();
     try
     {
         b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
         BarcodeLib.TYPE type = BarcodeLib.TYPE.CODE39;
         b.IncludeLabel = true;
         b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER;
         Image img = new Image();
         System.Drawing.Image imm = b.Encode(type, Barcode_Value.ToUpper(), System.Drawing.Color.Black, System.Drawing.Color.White, 250, 60);
         imm.Save(HttpContext.Current.Server.MapPath("~/Barcode/") + Barcode_Value + ".png", System.Drawing.Imaging.ImageFormat.Png);
         return true;
     }
     catch (Exception ex)
     {
         ErrHandler.WriteError(ex.Message);
         return false;
     }
 }
Exemplo n.º 45
0
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 2)
            {
                string appPath = Path.GetDirectoryName(Application.ExecutablePath);
                //create the connection string
                string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + appPath + @"\DBpinc.s3db";

                //create the database query
                string query = "SELECT * From Almacen";

                //create an OleDbDataAdapter to execute the query
                System.Data.SQLite.SQLiteDataAdapter dAdapter = new System.Data.SQLite.SQLiteDataAdapter(query, connString);

                //create a command builder
                System.Data.SQLite.SQLiteCommandBuilder cBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dAdapter);

                //create a DataTable to hold the query results
                DataTable dTable = new DataTable();

                //fill the DataTable
                dAdapter.Fill(dTable);
                BindingSource bSource = new BindingSource();
                bSource.DataSource = dTable;
                dataGridView1.DataSource = bSource;
                dAdapter.Update(dTable);

                dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;

                int i = 0;
                foreach (DataGridViewColumn c in dataGridView1.Columns)
                {
                    i += c.Width;

                }
                dataGridView1.Width = i + dataGridView1.RowHeadersWidth + 2;

            }
            else if (tabControl1.SelectedIndex == 3)
            {
                string appPath = Path.GetDirectoryName(Application.ExecutablePath);
                //create the connection string
                string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + appPath + @"\DBpinc.s3db";

                //create the database query
                string query = "SELECT ArticuloID, Nombrearticulo From Almacen";

                //create an OleDbDataAdapter to execute the query
                System.Data.SQLite.SQLiteDataAdapter dAdapter = new System.Data.SQLite.SQLiteDataAdapter(query, connString);

                //create a command builder
                System.Data.SQLite.SQLiteCommandBuilder cBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dAdapter);

                //create a DataTable to hold the query results
                DataTable dTable = new DataTable();

                //fill the DataTable
                dAdapter.Fill(dTable);
                BindingSource bSource = new BindingSource();
                bSource.DataSource = dTable;
                dataGridView2.DataSource = bSource;
                dAdapter.Update(dTable);

                dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;

                int i = 0;
                foreach (DataGridViewColumn c in dataGridView2.Columns)
                {
                    i += c.Width;

                }
                dataGridView2.Width = i + dataGridView2.RowHeadersWidth + 2;

                BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
                {
                    IncludeLabel = true,
                    Alignment = AlignmentPositions.CENTER,
                    Width = 300,
                    Height = 100,
                    RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                    BackColor = Color.White,
                    ForeColor = Color.Black,
                };
                try
                {
                    Image img = barcode.Encode(TYPE.CODE128B, dataGridView2.SelectedRows[0].Cells[0].Value.ToString());
                    pictureBox1.Image = img;
                }
                catch
                {
                }
            }
        }
Exemplo n.º 46
0
        private void dataGridView2_Click(object sender, EventArgs e)
        {
            BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
            {
                IncludeLabel = true,
                Alignment = AlignmentPositions.CENTER,
                Width = 300,
                Height = 100,
                RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                BackColor = Color.White,
                ForeColor = Color.Black,
            };

            Image img = barcode.Encode(TYPE.CODE128B, dataGridView2.SelectedRows[0].Cells[0].Value.ToString());
            pictureBox1.Image = img;
        }
Exemplo n.º 47
0
        private void barCodeDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            if(printArray == null)
            {
                return;
            }
            var height = 87;
            var numberToPrint = printArray.Count();
            var rowsToPrint = numberToPrint / 3;
            if( numberToPrint % 3 > 0)
            {
                rowsToPrint += 1;
            }
            for (int j = 0; j < 3; j++)
            {

                for (int i = 0; i < 2; i++)
                {
                    int index = (j*2) + i;
                    if(index > (printArray.Count() - 1))
                    {
                        break;
                    }
                    string code = printArray[index].Barcode;

                    BarcodeLib.Barcode barcode = new Barcode();
                    string employeeName = printArray[index].EmployeeName;
                    Image imageBC = barcode.Encode(BarcodeLib.TYPE.CODE128, code, Color.Black, Color.White,
                                                   (int) (1.1*e.Graphics.DpiX), (int) (0.4*e.Graphics.DpiY));

                    Bitmap bitmapBarcode = new Bitmap(imageBC);
                    bitmapBarcode.SetResolution(204, 204);

                    e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
                    e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

                    // draw title string

                    // calculate scale for title
                    var titleStrSize = e.Graphics.MeasureString(employeeName + "0000", new Font("Arial", 10));
                    float currTitleSize = new Font("Arial", 10).Size;
                    float scaledTitleSize = (220*currTitleSize)/titleStrSize.Width;
                    Font _empFont = null;

                    if (employeeName.Length < 17)
                    {
                        _empFont = new Font("Arial Black", 10);
                    }
                    else
                    {
                        _empFont = new Font("Arial Black", scaledTitleSize);
                    }

                    Font _titleFont = new Font("Arial", 8);
                    string titleName = "QUẢN LÝ";
                    var barCodeSize = e.Graphics.MeasureString(code, _titleFont);
                    var empCodeSize = e.Graphics.MeasureString(employeeName, _empFont);
                    var titleSize = e.Graphics.MeasureString(titleName, _titleFont);
                    Bitmap logoAChay = new Bitmap(AppFrameClient.Properties.Resources.AChayLogo);

                    Rectangle boundRec = new Rectangle((i%2)*(int) (3.6*100)+ 50 , (j%3)*(int)(2.3*100)+ 50 , (int) (3.45*100), (int) (2.15*100));
                    e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), boundRec);

                    e.Graphics.DrawImage(bitmapBarcode,
                                         new Rectangle((i % 2) * 360 + (int)XCentered((float)(1.1 * 100), 228) + 170,
                                                       (int)((j%3)*230 + 25) + 190 , (int)(1.1 * 100),(int)(0.4 * 100)));
                    System.Drawing.Rectangle rc = new System.Drawing.Rectangle((i % 3) * 135, 50, (int)(1.4 * 100), (int)(0.4 * 100));

                    e.Graphics.DrawImage(logoAChay, (i % 2) * 360 + 70 + 160, ((j % 3) * 230) + 52);
                    e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), (i % 2) * (int)(3.6 * 100) + 52, (j % 3) * (int)(2.3 * 100) + 52,
                                                (int)(1.18 * 100), (int)(1.97 * 100));
                    e.Graphics.DrawString(employeeName, _empFont, new SolidBrush(Color.Black),
                        (i % 2) * 360 + 170 + XCentered(empCodeSize.Width, 228) ,
                        (float)((j % 3) * 230 + 60 + _titleFont.Height + 70));

                    e.Graphics.DrawString(titleName, _titleFont, new SolidBrush(Color.Black),
                        (i % 2) * 360 + 170 + XCentered(titleSize.Width, 228),
                        (float)((j % 3) * 230 + 60 + _titleFont.Height + 90));

                }
            }
        }
Exemplo n.º 48
0
        private void printDocument2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            if (icodigo < 1)
            {
                xe = e.MarginBounds.Left;
                ye = e.MarginBounds.Top;
            }
            BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
            {
                IncludeLabel = true,
                Alignment = AlignmentPositions.CENTER,
                Width = 300,
                Height = 100,
                RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                BackColor = Color.White,
                ForeColor = Color.Black,
            };

            Image img = barcode.Encode(TYPE.CODE128B, codigos[icodigo].ToString());
            pictureBox1.Image = img;

            Bitmap bmp = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
            this.pictureBox1.DrawToBitmap(bmp, new Rectangle(0, 0, this.pictureBox1.Width, this.pictureBox1.Height));
            //e.Graphics.DrawImage((Image)bmp, x, y);

            if (icodigo <= 1)
            {
                e.Graphics.DrawImage((Image)bmp, xe, ye);
            }
            else if (icodigo == 2 || icodigo == 3)
            {
                if (icodigo == 2)
                {
                    ye = ye + 120;
                }
                e.Graphics.DrawImage((Image)bmp, xe, ye);
            }
            else if (icodigo == 4 || icodigo == 5)
            {
                if (icodigo == 4)
                {
                    ye = ye + 120;
                }
                e.Graphics.DrawImage((Image)bmp, xe, ye);
            }
            else if (icodigo == 6 || icodigo == 7)
            {
                if (icodigo == 6)
                {
                    ye = ye + 120;
                }
                e.Graphics.DrawImage((Image)bmp, xe, ye);
            }
            else if (icodigo == 8 || icodigo == 9)
            {
                if (icodigo == 8)
                {
                    ye = ye + 120;
                }
                e.Graphics.DrawImage((Image)bmp, xe, ye);
            }
            else if (icodigo == 10 || icodigo == 11)
            {
                if (icodigo == 10)
                {
                    ye = ye + 120;
                }
                e.Graphics.DrawImage((Image)bmp, xe, ye);
            }
            else if (icodigo == 12 || icodigo == 13)
            {
                if (icodigo == 12)
                {
                    ye = ye + 120;
                }
                e.Graphics.DrawImage((Image)bmp, xe, ye);
            }
            else if (icodigo == 14 || icodigo == 15)
            {
                if (icodigo == 14)
                {
                    ye = ye + 120;
                }
                e.Graphics.DrawImage((Image)bmp, xe, ye);
            }

            if ((icodigo + 1) % 2 != 0)
            {
                xe += 350;
            }
            else
            {
                xe = e.MarginBounds.Left;
            }
            icodigo++;
        }
Exemplo n.º 49
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string IdChar = "";
            bool checkChar = false;
            string code = "";
            bool hasText = false;

            string topleft = "";
            string topright = "";

            try
            {
                IdChar = Request["IdChar"].ToString();
            }
            catch (Exception)
            {

            }

            try
            {
                code = Request["code"].ToString();
            }
            catch (Exception)
            {

            }

            try
            {
                hasText = bool.Parse(Request["hasText"]);
            }
            catch (Exception)
            {

            }

            try
            {
                topleft = Request["topleft"];
            }
            catch (Exception)
            {

            }

            try
            {
                topright = Request["topright"];
            }
            catch (Exception)
            {

            }

            try
            {
                checkChar = bool.Parse(Request["checkChar"]);
            }
            catch (Exception)
            {

            }

            BarcodeLib.Barcode b = new BarcodeLib.Barcode();
            BarcodeLib.TYPE type = BarcodeLib.TYPE.CODE128;

            try
            {
                b.IncludeLabel = hasText;

                System.Drawing.Image img;

                int width = 100;
                //if (IdChar.Length + code.Length > 20)
                //    width = 350;

                //===== Encoding performed here =====

                string showString = "";
                if (IdChar == BarcodeBLL.DINIdChar)
                {
                    showString = IdChar + code.Substring(0, 5) + " " + code.Substring(5, 2) + " " + code.Substring(7, 6) + " " + code.Substring(13, 2);
                }
                else if (IdChar == BarcodeBLL.peopleIdChar)
                {
                    showString = IdChar + code.Substring(0, 4) + " " + code.Substring(4, 4) + " " + code.Substring(8, 4) + " " + code.Substring(12, 4);
                }

                if (hasText)
                {
                    img = b.Encode(type, IdChar + code, Color.Black, Color.White, width, 50, showString);
                }
                else
                {
                    img = b.Encode(type, IdChar + code, Color.Black, Color.White, width, 40, showString);
                }
                //===================================

                MemoryStream m = new MemoryStream();

                img.Save(m, ImageFormat.Png);

                Response.ContentType = "image/png";

                m.WriteTo(Response.OutputStream);

                m.Dispose();

            }//try
            catch (Exception)
            {
            }//catch
        }
        private void btnGenBarcode_Click(object sender, RoutedEventArgs e)
        {
            // TODO: generate barcodes
            //MessageBox.Show("Generating Barcode ...");
            Barcode bc = new Barcode();
            int _start = int.Parse(textSN.Text); // starting serial #
            int _end = int.Parse(textEN.Text); // ending serial #
            int serial;
            string textSerialNo = "0000";
            //System.Drawing.Image draw;
            //BarcodeLib.Barcode b = new BarcodeLib.Barcode();
            //BitmapImage bitmapBarcode = new BitmapImage();
            //bitmapBarcode.BeginInit();  // WTY : need to be placed outside the for loop
            for (serial = _start; serial <= _end; serial++)
            {
                textSerialNo = cbFactory.Text + cbYear.Text + cbMonth.Text + cbDay.Text + serial.ToString().PadLeft(4, '0');
                //System.Windows.Forms.PictureBox wtybarcode = new System.Windows.Forms.PictureBox();

                //wtybarcode.Image = b.Encode(BarcodeLib.TYPE.CODE128, textSerialNo);
                //wtybarcode.Image = b.Encode(BarcodeLib.TYPE.CODE128, "01234567");
                //imagefilename = "c:\\Users\\TaiYuan\\Google 雲端硬碟\\" + textSerialNo + ".bmp";
                //wtybarcode.Image.Save(@imagefilename, System.Drawing.Imaging.ImageFormat.Bmp);

                //bitmapBarcode.UriSource = new Uri(@imagefilename, UriKind.RelativeOrAbsolute);
                //bitmapBarcode.DecodePixelWidth = 40;
                //bitmapBarcode.DecodePixelHeight = 10;

                //imgBarcode.Source = bitmapBarcode;

                // print
                //PrintDocument printDoc = new PrintDocument();
                //printDoc.PrintPage += new PrintPageEventHandler(printDoc_Print);
                // printDoc.Print();  // WTY: TODO : dont' waste paper yet ~
                //MessageBox.Show(textSerialNo);

                //// ---> 4cm x 2cm : TSCLIB_DLL.PrintBarcodeWithText(textSerialNo);
                TSCLIB_DLL.PrintBarcodeWithTextForPreOperation(textSerialNo);
            }
            //bitmapBarcode.EndInit();  // WTY : need to be placed outside the for loop;

            // TODO: print barcodes
            //MessageBox.Show("TODO :Printing Barcode here");
        }
        private Bitmap CreateBarcodeX(BarcodeInfo bcInfo)
        {
            Bitmap bm = new Bitmap(2550, 3300);

            try
            {

                bm.SetResolution(300, 300);

                double dY = bm.Height / 2;
                double dX = bm.Width / 2;
                float dV = 0;
                BarcodeLib.Barcode b = new Barcode();

                using (Graphics g = Graphics.FromImage(bm))
                {
                    StringFormat sf1 = new StringFormat();
                    sf1.Alignment = StringAlignment.Center;
                    sf1.LineAlignment = StringAlignment.Center;

                    g.FillRectangle(Brushes.White, 0, 0, bm.Width, bm.Height);

                    //  Primary Barcode
                    dV = 200;
                    Font f = new Font("Arial", 26, GraphicsUnit.Point);
                    g.DrawString(bcInfo.PrimaryBarcodeTitle, f, Brushes.Black, new RectangleF(10, dV, 2540, 140), sf1);

                    dV = 350;
                    int bcWidth = (bcInfo.PrimaryBarcodeValue.Length * 100) + 400;

                    if (!String.IsNullOrWhiteSpace(bcInfo.PrimaryBarcodeValue))
                    {
                        using (Image myBarcodeImage = b.Encode(BarcodeLib.TYPE.CODE39Extended, bcInfo.PrimaryBarcodeValue, Color.Black, Color.White, bcWidth, 200))
                        {
                            g.DrawImage(myBarcodeImage, Convert.ToInt32((dX) - (myBarcodeImage.Width / 2)), Convert.ToInt32(dV), bcWidth, 200);
                        }
                    }

                    dV = 550;
                    f = new Font("Arial", 18, GraphicsUnit.Point);
                    g.DrawString(bcInfo.PrimaryBarcodeValue, f, Brushes.Black, new RectangleF(10, dV, 2540, 140), sf1);

                    if (CurrentBarcodeInfo.UseHalfSheets)
                    {
                        //  Secondary Barcode
                        dV = 1000;
                        f = new Font("Arial", 26, GraphicsUnit.Point);
                        g.DrawString(bcInfo.SecondaryBarcodeTitle, f, Brushes.Black, new RectangleF(10, dV, 2540, 140), sf1);

                        dV = 1150;
                        bcWidth = (bcInfo.SecondaryBarcodeValue.Length * 100) + 400;

                        if (!String.IsNullOrWhiteSpace(bcInfo.SecondaryBarcodeValue))
                        {
                            using (Image myBarcodeImage = b.Encode(BarcodeLib.TYPE.CODE39Extended, bcInfo.SecondaryBarcodeValue, Color.Black, Color.White, bcWidth, 200))
                            {
                                g.DrawImage(myBarcodeImage, Convert.ToInt32((dX) - (myBarcodeImage.Width / 2)), Convert.ToInt32(dV), bcWidth, 200);
                            }
                        }

                        dV = 1350;
                        f = new Font("Arial", 18, GraphicsUnit.Point);
                        g.DrawString(bcInfo.SecondaryBarcodeValue, f, Brushes.Black, new RectangleF(10, dV, 2540, 140), sf1);

                        //  Primary Barcode
                        dV = 1850;
                        f = new Font("Arial", 26, GraphicsUnit.Point);
                        g.DrawString(bcInfo.PrimaryBarcodeTitle, f, Brushes.Black, new RectangleF(10, dV, 2540, 140), sf1);

                        dV = 2000;
                        bcWidth = (bcInfo.PrimaryBarcodeValue.Length * 100) + 400;

                        if (!String.IsNullOrWhiteSpace(bcInfo.PrimaryBarcodeValue))
                        {
                            using (Image myBarcodeImage = b.Encode(BarcodeLib.TYPE.CODE39Extended, bcInfo.PrimaryBarcodeValue, Color.Black, Color.White, bcWidth, 200))
                            {
                                g.DrawImage(myBarcodeImage, Convert.ToInt32((dX) - (myBarcodeImage.Width / 2)), Convert.ToInt32(dV), bcWidth, 200);
                            }
                        }

                        dV = 2200;
                        f = new Font("Arial", 18, GraphicsUnit.Point);
                        g.DrawString(bcInfo.PrimaryBarcodeValue, f, Brushes.Black, new RectangleF(10, dV, 2540, 140), sf1);
                    }

                    //  Secondary Barcode
                    dV = 2650;
                    f = new Font("Arial", 26, GraphicsUnit.Point);
                    g.DrawString(bcInfo.SecondaryBarcodeTitle, f, Brushes.Black, new RectangleF(10, dV, 2540, 140), sf1);

                    dV = 2800;
                    bcWidth = (bcInfo.SecondaryBarcodeValue.Length * 100) + 400;

                    if (!String.IsNullOrWhiteSpace(bcInfo.SecondaryBarcodeValue))
                    {
                        using (Image myBarcodeImage = b.Encode(BarcodeLib.TYPE.CODE39Extended, bcInfo.SecondaryBarcodeValue, Color.Black, Color.White, bcWidth, 200))
                        {
                            g.DrawImage(myBarcodeImage, Convert.ToInt32((dX) - (myBarcodeImage.Width / 2)), Convert.ToInt32(dV), bcWidth, 200);
                        }
                    }

                    dV = 3000;
                    f = new Font("Arial", 18, GraphicsUnit.Point);
                    g.DrawString(bcInfo.SecondaryBarcodeValue, f, Brushes.Black, new RectangleF(10, dV, 2540, 140), sf1);

                    f.Dispose();
                }
            }
            catch (Exception ex)
            {
                HandleErrorMessage(ex, true);
            }
            return bm;
        }
Exemplo n.º 52
0
        private void barcodePrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            if (!chkContinuePrint.Checked)
            {
                var height = 87;
                var numberToPrint = (int)numericUpDownBarcode.Value;
                string code = deptStockOutDetailList[dgvStockOutDetail.CurrentRow.Index].StockOutDetail.Product.ProductId;

                if (numberToPrint > 3)
                {
                    height = (numberToPrint / 3) * 87;
                    numberToPrint = 3;
                }
                var eventArgs = new MainStockInEventArgs
                {
                    ProductMasterIdForPrice = deptStockOutDetailList[dgvStockOutDetail.CurrentRow.Index].StockOutDetail.ProductMaster.ProductMasterId
                };
                EventUtility.fireEvent(GetPriceEvent, this, eventArgs);
                string titleString = "";
                string name = deptStockOutDetailList[dgvStockOutDetail.CurrentRow.Index].StockOutDetail.ProductMaster.ProductName;
                if (chkPricePrint.Checked && eventArgs.DepartmentPrice != null)
                {
                    titleString = name + " - " + eventArgs.DepartmentPrice.Price.ToString() + ".00 ";
                }
                else
                {
                    titleString = name;
                }

                BarcodeLib.Barcode barcode = new Barcode();
                string barCodeStr = deptStockOutDetailList[dgvStockOutDetail.CurrentRow.Index].StockOutDetail.Product.ProductId;
                string colorSize = "";
                if (deptStockOutDetailList[dgvStockOutDetail.CurrentRow.Index].StockOutDetail.ProductMaster.ProductColor.ColorId > 0)
                {
                    colorSize += "M:" +
                                 deptStockOutDetailList[dgvStockOutDetail.CurrentRow.Index].StockOutDetail.ProductMaster.ProductColor.
                                     ColorName;
                }
                if (deptStockOutDetailList[dgvStockOutDetail.CurrentRow.Index].StockOutDetail.ProductMaster.ProductSize.SizeId > 0)
                {
                    if (colorSize.Length > 0)
                    {
                        colorSize += " - ";
                    }
                    colorSize += "S:" +
                                 deptStockOutDetailList[dgvStockOutDetail.CurrentRow.Index].StockOutDetail.ProductMaster.ProductSize.
                                     SizeName;
                }
                Image imageBC = null;
                if (ClientSetting.BarcodeType == BarcodeLib.TYPE.CODE128)
                {
                    imageBC = barcode.Encode(ClientSetting.BarcodeType, barCodeStr, Color.Black, Color.White,
                                                    (int)(1.3 * e.Graphics.DpiX), (int)(0.3 * e.Graphics.DpiY));
                }
                else
                {
                    imageBC = barcode.Encode(ClientSetting.BarcodeType, barCodeStr, Color.Black, Color.White,
                                                   (int)(1.35 * e.Graphics.DpiX), (int)(0.3 * e.Graphics.DpiY));
                }

                Bitmap bitmap1 = new Bitmap(imageBC);
                bitmap1.SetResolution(204, 204);
                e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

                // draw title string

                // calculate scale for title
                var titleStrSize = e.Graphics.MeasureString(titleString.PadRight(25), new Font("Arial", 10));
                float currTitleSize = new Font("Arial", 10).Size;
                float scaledTitleSize = (150 * currTitleSize) / titleStrSize.Width;
                Font _titleFont = new Font("Arial", 7);
                var priceTotalSize = e.Graphics.MeasureString(titleString, _titleFont);
                var colorSizeSize = e.Graphics.MeasureString(colorSize, _titleFont);
                var barCodeSize = e.Graphics.MeasureString(barCodeStr, _titleFont);
                for (int i = 0; i < numberToPrint; i++)
                {

                    System.Drawing.Rectangle rc = new System.Drawing.Rectangle((i % 3) * 135, 50, (int)(1.4 * 100),
                                                                               (int)(0.4 * 100));

                    //(i % 3) * 124, (i / 3) * 87, 117, 79
                    e.Graphics.DrawString(titleString, _titleFont, new SolidBrush(Color.Black),
                                          (i % 3) * 135 + XCentered(priceTotalSize.Width, 140), (float)25);

                    if (ClientSetting.BarcodeType == BarcodeLib.TYPE.CODE128)
                    {
                        e.Graphics.DrawImage(bitmap1,
                                             new Rectangle((i % 3) * 140 + (int)XCentered((float)(1.3 * 100), 140),
                                                           (int)(25 + priceTotalSize.Height), (int)(1.3 * 100),
                                                           (int)(0.3 * 100)));
                    }
                    else
                    {
                        e.Graphics.DrawImage(bitmap1,
                                             new Rectangle((i % 3) * 140 + (int)XCentered((float)(1.35 * 100), 140),
                                                           (int)(25 + priceTotalSize.Height), (int)(1.35 * 100),
                                                           (int)(0.3 * 100)));
                    }

                    e.Graphics.DrawString(barCodeStr, _titleFont, new SolidBrush(Color.Black),
                                          (i % 3) * 140 + XCentered(barCodeSize.Width, 140), (float)72);
                    e.Graphics.DrawString(colorSize, _titleFont, new SolidBrush(Color.Black),
                                          (i % 3) * 140 + XCentered(colorSizeSize.Width, 140), (float)88);

                }
            }
            else // continue printing
            {
                var height = 87;
                if (printList == null || printList.Count == 0)
                {
                    return;
                }
                var numberToPrint = printList.Count;

                for (int i = 0; i < numberToPrint; i++)
                {
                    string code = printList[i].ProductId;
                    var eventArgs = new MainStockInEventArgs
                    {
                        ProductMasterIdForPrice = printList[i].ProductMaster.ProductMasterId
                    };
                    EventUtility.fireEvent(GetPriceEvent, this, eventArgs);
                    string titleString = "";
                    string name = printList[i].ProductMaster.ProductName;
                    if (chkPricePrint.Checked && eventArgs.DepartmentPrice != null)
                    {
                        titleString = name + " - " + eventArgs.DepartmentPrice.Price.ToString() + ".00 ";
                    }
                    else
                    {
                        titleString = name;
                    }

                    BarcodeLib.Barcode barcode = new Barcode();
                    string barCodeStr = printList[i].ProductId;
                    string colorSize = "";
                    if (printList[i].ProductMaster.ProductColor.ColorId > 0)
                    {
                        colorSize += "M:" +
                                     printList[i].ProductMaster.ProductColor.ColorName;
                    }
                    if (printList[i].ProductMaster.ProductSize.SizeId > 0)
                    {
                        if (colorSize.Length > 0)
                        {
                            colorSize += " - ";
                        }
                        colorSize += "S:" +
                                     printList[i].ProductMaster.ProductSize.SizeName;
                    }
                    Image imageBC = null;
                    if (ClientSetting.BarcodeType == BarcodeLib.TYPE.CODE128)
                    {
                        imageBC = barcode.Encode(ClientSetting.BarcodeType, barCodeStr, Color.Black, Color.White,
                                                        (int)(1.3 * e.Graphics.DpiX), (int)(0.3 * e.Graphics.DpiY));
                    }
                    else
                    {
                        imageBC = barcode.Encode(ClientSetting.BarcodeType, barCodeStr, Color.Black, Color.White,
                                                       (int)(1.35 * e.Graphics.DpiX), (int)(0.3 * e.Graphics.DpiY));
                    }

                    Bitmap bitmap1 = new Bitmap(imageBC);
                    bitmap1.SetResolution(204, 204);
                    e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
                    e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

                    // draw title string

                    // calculate scale for title
                    var titleStrSize = e.Graphics.MeasureString(titleString.PadRight(25), new Font("Arial", 10));
                    float currTitleSize = new Font("Arial", 10).Size;
                    float scaledTitleSize = (150 * currTitleSize) / titleStrSize.Width;
                    Font _titleFont = new Font("Arial", 7);
                    Font _barCodeFont = new Font("Arial", 8);
                    var priceTotalSize = e.Graphics.MeasureString(titleString, _titleFont);
                    var colorSizeSize = e.Graphics.MeasureString(colorSize, _titleFont);
                    var barCodeSize = e.Graphics.MeasureString(barCodeStr, _barCodeFont);

                    System.Drawing.Rectangle rc = new System.Drawing.Rectangle((i % 3) * 135, 50, (int)(1.4 * 100),
                                                                               (int)(0.4 * 100));

                    e.Graphics.DrawString(titleString, _titleFont, new SolidBrush(Color.Black),
                                          (i % 3) * 135 + XCentered(priceTotalSize.Width, 140), (float)25);

                    if (ClientSetting.BarcodeType == BarcodeLib.TYPE.CODE128)
                    {
                        e.Graphics.DrawImage(bitmap1,
                                             new Rectangle((i % 3) * 140 + (int)XCentered((float)(1.3 * 100), 140),
                                                           (int)(25 + priceTotalSize.Height), (int)(1.3 * 100),
                                                           (int)(0.3 * 100)));
                    }
                    else
                    {
                        e.Graphics.DrawImage(bitmap1,
                                             new Rectangle((i % 3) * 140 + (int)XCentered((float)(1.35 * 100), 140),
                                                           (int)(25 + priceTotalSize.Height), (int)(1.35 * 100),
                                                           (int)(0.3 * 100)));
                    }
                    e.Graphics.DrawString(barCodeStr, _barCodeFont, new SolidBrush(Color.Black),
                                          (i % 3) * 140 + XCentered(barCodeSize.Width, 140), (float)72);
                    e.Graphics.DrawString(colorSize, _titleFont, new SolidBrush(Color.Black),
                                          (i % 3) * 140 + XCentered(colorSizeSize.Width, 140), (float)88);

                }
            }
        }
Exemplo n.º 53
0
 public FileResult BarCodeImage(string code)
 {
     using (var barCode = new Barcode())
     {
         barCode.IncludeLabel = true;
         barCode.LabelFont = new Font("Calibri", 11, FontStyle.Bold);
         barCode.LabelPosition = LabelPositions.BOTTOMCENTER;
         barCode.Encode(TYPE.ISBN, code, Color.Black, Color.White, 150, 80);
         return File(barCode.GetImageData(SaveTypes.PNG), "image/png");
     }
 }
 /// <summary>
 /// Encodes the raw data into binary form representing bars and spaces.  Also generates an Image of the barcode.
 /// </summary>
 /// <param name="iType">Type of encoding to use.</param>
 /// <param name="Data">Raw data to encode.</param>
 /// <param name="IncludeLabel">Include the label at the bottom of the image with data encoded.</param>
 /// <param name="DrawColor">Foreground color</param>
 /// <param name="BackColor">Background color</param>
 /// <returns>Image representing the barcode.</returns>
 public static Image DoEncode(TYPE iType, string Data, bool IncludeLabel, Color DrawColor, Color BackColor)
 {
     using (Barcode b = new Barcode())
     {
         b.IncludeLabel = IncludeLabel;
         return b.Encode(iType, Data, DrawColor, BackColor);
     }//using
 }
 /// <summary>
 /// Encodes the raw data into binary form representing bars and spaces.  Also generates an Image of the barcode.
 /// </summary>
 /// <param name="iType">Type of encoding to use.</param>
 /// <param name="Data">Raw data to encode.</param>
 /// <param name="IncludeLabel">Include the label at the bottom of the image with data encoded.</param>
 /// <param name="DrawColor">Foreground color</param>
 /// <param name="BackColor">Background color</param>
 /// <param name="Width">Width of the resulting barcode.(pixels)</param>
 /// <param name="Height">Height of the resulting barcode.(pixels)</param>
 /// <param name="XML">XML representation of the data and the image of the barcode.</param>
 /// <returns>Image representing the barcode.</returns>
 public static Image DoEncode(TYPE iType, string Data, bool IncludeLabel, Color DrawColor, Color BackColor, int Width, int Height, ref string XML)
 {
     using (Barcode b = new Barcode())
     {
         b.IncludeLabel = IncludeLabel;
         Image i = b.Encode(iType, Data, DrawColor, BackColor, Width, Height, "");
         XML = b.XML;
         return i;
     }//using
 }
 /// <summary>
 /// Encodes the raw data into binary form representing bars and spaces.  Also generates an Image of the barcode.
 /// </summary>
 /// <param name="iType">Type of encoding to use.</param>
 /// <param name="data">Raw data to encode.</param>
 /// <param name="IncludeLabel">Include the label at the bottom of the image with data encoded.</param>
 /// <param name="Width">Width of the resulting barcode.(pixels)</param>
 /// <param name="Height">Height of the resulting barcode.(pixels)</param>
 /// <returns>Image representing the barcode.</returns>
 public static Image DoEncode(TYPE iType, string Data, bool IncludeLabel, int Width, int Height)
 {
     using (Barcode b = new Barcode())
     {
         b.IncludeLabel = IncludeLabel;
         return b.Encode(iType, Data, Width, Height);
     }//using
 }
 /// <summary>
 /// Encodes the raw data into binary form representing bars and spaces.  Also generates an Image of the barcode.
 /// </summary>
 /// <param name="iType">Type of encoding to use.</param>
 /// <param name="Data">Raw data to encode.</param>
 /// <param name="IncludeLabel">Include the label at the bottom of the image with data encoded.</param>
 /// <returns>Image representing the barcode.</returns>
 public static Image DoEncode(TYPE iType, string Data, bool IncludeLabel)
 {
     using (Barcode b = new Barcode())
     {
         b.IncludeLabel = IncludeLabel;
         return b.Encode(iType, Data);
     }//using
 }
 /// <summary>
 /// Encodes the raw data into binary form representing bars and spaces.  Also generates an Image of the barcode.
 /// </summary>
 /// <param name="iType">Type of encoding to use.</param>
 /// <param name="Data">Raw data to encode.</param>
 /// <param name="XML">XML representation of the data and the image of the barcode.</param>
 /// <returns>Image representing the barcode.</returns>
 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;
         return i;
     }//using
 }
 /// <summary>
 /// Encodes the raw data into binary form representing bars and spaces.  Also generates an Image of the barcode.
 /// </summary>
 /// <param name="iType">Type of encoding to use.</param>
 /// <param name="Data">Raw data to encode.</param>
 /// <returns>Image representing the barcode.</returns>
 public static Image DoEncode(TYPE iType, string Data)
 {
     using (Barcode b = new Barcode())
     {
         return b.Encode(iType, Data);
     }//using
 }
Exemplo n.º 60
-1
        public string generBarcode(string code)
        {
            string dirname = Application.StartupPath + "/data/";
            string dirnameNew = dirname + code + ".png";

            if (File.Exists(dirnameNew)) return dirnameNew;

            BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
            {
                IncludeLabel = true,
                Alignment = AlignmentPositions.CENTER,
                Width = 300,
                Height = 100,
                RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                BackColor = Color.White,
                ForeColor = Color.Black,
            };
            Image img = barcode.Encode(TYPE.CODE128B, code);
            img.Save(dirnameNew);

            return dirnameNew;
        }