Esempio n. 1
0
        public static void GeneratePackingLabel(Bitmap bmLabel, string orderNumber, string VLNumber, string size, string qty, string description, string distributor, string clientName, string labelText, string savingPath)
        {
            BarcodeLib.Barcode b = new BarcodeLib.Barcode();
            b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
            BarcodeLib.TYPE type = BarcodeLib.TYPE.CODE93;

            try
            {
                if (type != BarcodeLib.TYPE.UNSPECIFIED)
                {
                    b.IncludeLabel = false; // true;

                    //b.RotateFlipType = (RotateFlipType)Enum.Parse(typeof(RotateFlipType), this.cbRotateFlip.SelectedItem.ToString(), true);

                    ////label alignment and position
                    //switch (this.cbLabelLocation.SelectedItem.ToString().Trim().ToUpper())
                    //{
                    //    case "BOTTOMLEFT": b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMLEFT; break;
                    //    case "BOTTOMRIGHT": b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMRIGHT; break;
                    //    case "TOPCENTER": b.LabelPosition = BarcodeLib.LabelPositions.TOPCENTER; break;
                    //    case "TOPLEFT": b.LabelPosition = BarcodeLib.LabelPositions.TOPLEFT; break;
                    //    case "TOPRIGHT": b.LabelPosition = BarcodeLib.LabelPositions.TOPRIGHT; break;
                    //    default: b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER; break;
                    //}//switch

                    //string tempPath = "C:\\Barcode\\temp.jpg";
                    //Bitmap lblBM = new Bitmap(378, 113);

                    //using (Graphics gfx = Graphics.FromImage(lblBM))
                    //using (SolidBrush brush = new SolidBrush(Color.White))
                    //{
                    //    gfx.FillRectangle(brush, 0, 0, 378, 113);
                    //}

                    //lblBM.Save(tempPath);

                    // Image lblImg = Image.

                    //===== Encoding performed here =====
                    //Image barCodeIMG = b.Encode(type, labelText, 378, 75); //, Color.Black, Color.White, W, H);
                    labelText = "P" + labelText;
                    Image barCodeIMG = b.Encode(type, labelText, 270, 50);

                    // Bitmap bm = new Bitmap(barCodeIMG);
                    //Graphics graphics = Graphics.FromImage(bm);
                    //graphics.DrawString("Hello", new Font("Times New Roman", 10), Brushes.Black, 0, 0);

                    //bm.Save(savingPath, barCodeIMG.RawFormat);

                    //Bitmap bmpp = MergeTwoImages(Image.FromFile(tempPath), barCodeIMG);

                    //qty = "9999/9999";

                    Graphics graphics = Graphics.FromImage(bmLabel);
                    graphics.DrawString(distributor + " - " + clientName, new Font("Calibri", 8, FontStyle.Regular), Brushes.Black, 10, 10);
                    //graphics.DrawString(clientName, new Font("Calibri", 8, FontStyle.Bold), Brushes.Black, 135, 10);
                    graphics.DrawString("Order: " + orderNumber, new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, 10, 22);
                    graphics.DrawString(VLNumber, new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, 100, 22);
                    graphics.DrawString("Size: " + size, new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, 180, 22);
                    graphics.DrawString("Qty: " + qty, new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, 250, 22);
                    graphics.DrawString(description, new Font("Calibri", 8), Brushes.Black, 10, 34);
                    graphics.DrawImage(barCodeIMG, 0, 50, 300, 50); //  ("Order: " + orderNumber, new Font("Calibri", 8, FontStyle.Bold), Brushes.Black, 50, 10);
                    graphics.DrawString(labelText, new Font("Calibri", 8, FontStyle.Bold), Brushes.Black, 250, 100);

                    //var logo = new Bitmap(IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\Logo\\blackchrome_logo.jpg");
                    //graphics.DrawImage(logo, 310, 50);

                    bmLabel.Save(savingPath, bmLabel.RawFormat);

                    //lblBM.Dispose();
                    //lblBM.Dispose();
                    //File.Delete(tempPath);

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

                    //show the encoding time
                    //this.lblEncodingTime.Text = "(" + Math.Round(b.EncodingTime, 0, MidpointRounding.AwayFromZero).ToString() + "ms)";

                    string encodedvalue = b.EncodedValue;
                }//if

                //reposition the barcode image to the middle
                // barcode.Location = new Point((this.groupBox2.Location.X + this.groupBox2.Width / 2) - barcode.Width / 2, (this.groupBox2.Location.Y + this.groupBox2.Height / 2) - barcode.Height / 2);
            }//try
            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message);
            }//catch
        }
Esempio n. 2
0
        }//Form1_Load

        private void btnEncode_Click(object sender, EventArgs e)
        {
            //errorProvider1.Clear();》
            int W = Convert.ToInt32(this.txtWidth.Text.Trim());
            int H = Convert.ToInt32(this.txtHeight.Text.Trim());
            BarcodeLib.AlignmentPositions Align = BarcodeLib.AlignmentPositions.CENTER;

            //barcode alignment
            switch (cbBarcodeAlign.SelectedItem.ToString().Trim().ToLower())
            {
                case "left": Align = BarcodeLib.AlignmentPositions.LEFT; break;
                case "right": Align = BarcodeLib.AlignmentPositions.RIGHT; break;
                default: Align = BarcodeLib.AlignmentPositions.CENTER; break;
            }//switch

            BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
            switch (cbEncodeType.SelectedItem.ToString().Trim())
            {
                case "UPC-A": type = BarcodeLib.TYPE.UPCA; break;
                case "UPC-E": type = BarcodeLib.TYPE.UPCE; break;
                case "UPC 2 Digit Ext.": type = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_2DIGIT; break;
                case "UPC 5 Digit Ext.": type = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_5DIGIT; break;
                case "EAN-13": type = BarcodeLib.TYPE.EAN13; break;
                case "JAN-13": type = BarcodeLib.TYPE.JAN13; break;
                case "EAN-8": type = BarcodeLib.TYPE.EAN8; break;
                case "ITF-14": type = BarcodeLib.TYPE.ITF14; break;
                case "Codabar": type = BarcodeLib.TYPE.Codabar; break;
                case "PostNet": type = BarcodeLib.TYPE.PostNet; break;
                case "Bookland/ISBN": type = BarcodeLib.TYPE.BOOKLAND; break;
                case "Code 11": type = BarcodeLib.TYPE.CODE11; break;
                case "Code 39": type = BarcodeLib.TYPE.CODE39; break;
                case "Code 39 Extended": type = BarcodeLib.TYPE.CODE39Extended; break;
                case "Code 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;
                default: MessageBox.Show("请选择一个编码类型"); break;
                //default: MessageBox.Show("Please specify the encoding type."); break;
            }//switch

            try
            {
                if (type != BarcodeLib.TYPE.UNSPECIFIED)
                {
                    b.IncludeLabel = this.chkGenerateLabel.Checked;

                    b.Alignment = Align;
                    b.RotateFlipType = (RotateFlipType)Enum.Parse(typeof(RotateFlipType), this.cbRotateFlip.SelectedItem.ToString(), true);

                    //label alignment and position
                    switch (this.cbLabelLocation.SelectedItem.ToString().Trim().ToUpper())
                    {
                        case "BOTTOMLEFT":  b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMLEFT; break;
                        case "BOTTOMRIGHT": b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMRIGHT; break;
                        case "TOPCENTER": b.LabelPosition = BarcodeLib.LabelPositions.TOPCENTER; break;
                        case "TOPLEFT": b.LabelPosition = BarcodeLib.LabelPositions.TOPLEFT; break;
                        case "TOPRIGHT": b.LabelPosition = BarcodeLib.LabelPositions.TOPRIGHT; break;
                        default: b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER; break;
                    }//switch

                    //===== Encoding performed here =====
                    barcode.Image = b.Encode(type, this.txtData.Text.Trim(), this.btnForeColor.BackColor, this.btnBackColor.BackColor, W, H);
                    //===================================

                    //show the encoding time
                    this.lblEncodingTime.Text = "(" + Math.Round(b.EncodingTime, 0, MidpointRounding.AwayFromZero).ToString() + "ms)";
                    
                    txtEncoded.Text = b.EncodedValue;

                    tsslEncodedType.Text = "编码类型: " + b.EncodedType.ToString();
                    //tsslEncodedType.Text = "Encoding Type: " + b.EncodedType.ToString();
                }//if

                barcode.Width = barcode.Image.Width;
                barcode.Height = barcode.Image.Height;
                
                //reposition the barcode image to the middle
                barcode.Location = new Point((this.groupBox2.Location.X + this.groupBox2.Width / 2) - barcode.Width / 2, (this.groupBox2.Location.Y + this.groupBox2.Height / 2) - barcode.Height / 2);
            }//try
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }//catch
        }//btnEncode_Click
Esempio n. 3
0
        public static void GenerateCartonLabel(Bitmap bmLabel, string cartonNo, List <KeyValuePair <int, string> > listOrderDetails, string labelText, string savingLocation, string invoiceno /*DistributorClientAddressBO objDistributorClientAddress, string ShipmentMode*/)
        {
            BarcodeLib.Barcode b = new BarcodeLib.Barcode();
            b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
            BarcodeLib.TYPE type = BarcodeLib.TYPE.CODE128;

            List <IGrouping <int, KeyValuePair <int, string> > > lstGroupedODs = listOrderDetails.GroupBy(m => m.Key).ToList();
            int orderDetailCount = lstGroupedODs.Count();
            int cartonLabelCount = (orderDetailCount % maxODCount == 0) ? orderDetailCount / maxODCount : (orderDetailCount / maxODCount) + 1;

            labelText = "C-" + labelText;

            try
            {
                if (type != BarcodeLib.TYPE.UNSPECIFIED)
                {
                    for (int k = 0; k < cartonLabelCount; k++)
                    {
                        b.IncludeLabel = false;
                        Image    barCodeIMG = b.Encode(type, labelText, 250, 50);
                        Bitmap   originalBM = new Bitmap(bmLabel);
                        Graphics graphics   = Graphics.FromImage(originalBM);

                        graphics.DrawString("Carton #: " + cartonNo + ((cartonLabelCount > 1) ? " - " + (k + 1).ToString() : ""), new Font("Calibri", 22, FontStyle.Bold), Brushes.Black, 20, 10);
                        graphics.DrawString(invoiceno, new Font("Calibri", 12, FontStyle.Bold), Brushes.Black, 180, 15);
                        graphics.DrawString("Po No", new Font("Calibri", 8, FontStyle.Bold), Brushes.Black, 10, 40);
                        graphics.DrawString("Client", new Font("Calibri", 8, FontStyle.Bold), Brushes.Black, 50, 40);
                        graphics.DrawString("VL No", new Font("Calibri", 8, FontStyle.Bold), Brushes.Black, 150, 40);
                        graphics.DrawString("Sizes", new Font("Calibri", 8, FontStyle.Bold), Brushes.Black, 250, 40);

                        float yValue = 40;

                        foreach (IGrouping <int, KeyValuePair <int, string> > objOrderDetail in lstGroupedODs.GetRange(0, (lstGroupedODs.Count > maxODCount) ? maxODCount : lstGroupedODs.Count))
                        {
                            yValue += 15;
                            int i = 0;

                            foreach (KeyValuePair <int, string> item in objOrderDetail.OrderBy(m => m.Key))
                            {
                                switch (++i)
                                {
                                case 1:
                                    graphics.DrawString(item.Value, new Font("Calibri", 8), Brushes.Black, 10, yValue);
                                    break;

                                case 2:
                                    graphics.DrawString(item.Value.Substring(0, Math.Min(15, item.Value.Length)), new Font("Calibri", 8), Brushes.Black, 50, yValue);
                                    break;

                                case 3:
                                    graphics.DrawString(item.Value, new Font("Calibri", 8), Brushes.Black, 150, yValue);
                                    break;

                                case 4:     // size
                                    graphics.DrawString(item.Value, new Font("Calibri", 8), Brushes.Black, 250, yValue);
                                    break;
                                }
                            }
                        }

                        lstGroupedODs.RemoveRange(0, (lstGroupedODs.Count > maxODCount) ? maxODCount : lstGroupedODs.Count);
                        graphics.DrawImage(barCodeIMG, 10, 200, 250, 50);
                        originalBM.Save(savingLocation + labelText.Replace('/', '_') + "-" + k + ".jpg", originalBM.RawFormat);
                        //originalBM.Dispose();
                        graphics.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        }//Form1_Load

        private void btnEncode_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            int W = Convert.ToInt32(this.txtWidth.Text.Trim());
            int H = Convert.ToInt32(this.txtHeight.Text.Trim());
            b.Alignment = BarcodeLib.AlignmentPositions.CENTER;

            //barcode alignment
            switch (cbBarcodeAlign.SelectedItem.ToString().Trim().ToLower())
            {
                case "left": b.Alignment = BarcodeLib.AlignmentPositions.LEFT; break;
                case "right": b.Alignment = BarcodeLib.AlignmentPositions.RIGHT; break;
                default: b.Alignment = BarcodeLib.AlignmentPositions.CENTER; break;
            }//switch

            BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
            switch (cbEncodeType.SelectedItem.ToString().Trim())
            {
                case "UPC-A": type = BarcodeLib.TYPE.UPCA; break;
                case "UPC-E": type = BarcodeLib.TYPE.UPCE; break;
                case "UPC 2 Digit Ext.": type = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_2DIGIT; break;
                case "UPC 5 Digit Ext.": type = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_5DIGIT; break;
                case "EAN-13": type = BarcodeLib.TYPE.EAN13; break;
                case "JAN-13": type = BarcodeLib.TYPE.JAN13; break;
                case "EAN-8": type = BarcodeLib.TYPE.EAN8; break;
                case "ITF-14": type = BarcodeLib.TYPE.ITF14; break;
                case "Codabar": type = BarcodeLib.TYPE.Codabar; break;
                case "PostNet": type = BarcodeLib.TYPE.PostNet; break;
                case "Bookland/ISBN": type = BarcodeLib.TYPE.BOOKLAND; break;
                case "Code 11": type = BarcodeLib.TYPE.CODE11; break;
                case "Code 39": type = BarcodeLib.TYPE.CODE39; break;
                case "Code 39 Extended": type = BarcodeLib.TYPE.CODE39Extended; break;
                case "Code 39 Mod 43": type = BarcodeLib.TYPE.CODE39_Mod43; break;
                case "Code 93": type = BarcodeLib.TYPE.CODE93; break;
                case "LOGMARS": type = BarcodeLib.TYPE.LOGMARS; break;
                case "MSI": type = BarcodeLib.TYPE.MSI_Mod10; break;
                case "Interleaved 2 of 5": type = BarcodeLib.TYPE.Interleaved2of5; break;
                case "Standard 2 of 5": type = BarcodeLib.TYPE.Standard2of5; break;
                case "Code 128": type = BarcodeLib.TYPE.CODE128; break;
                case "Code 128-A": type = BarcodeLib.TYPE.CODE128A; break;
                case "Code 128-B": type = BarcodeLib.TYPE.CODE128B; break;
                case "Code 128-C": type = BarcodeLib.TYPE.CODE128C; break;
                case "Telepen": type = BarcodeLib.TYPE.TELEPEN; break;
                case "FIM": type = BarcodeLib.TYPE.FIM; break;
                case "Pharmacode": type = BarcodeLib.TYPE.PHARMACODE; break;
                default: MessageBox.Show("Please specify the encoding type."); break;
            }//switch

            try
            {
                if (type != BarcodeLib.TYPE.UNSPECIFIED)
                {
                    try
                    {
                        b.BarWidth = textBoxBarWidth.Text.Trim().Length < 1 ? null : (int?)Convert.ToInt32(textBoxBarWidth.Text.Trim());
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Unable to parse BarWidth: " + ex.Message, ex);
                    }
                    try
                    {
                        b.AspectRatio = textBoxAspectRatio.Text.Trim().Length < 1 ? null : (double?)Convert.ToDouble(textBoxAspectRatio.Text.Trim());
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Unable to parse AspectRatio: " + ex.Message, ex);
                    }

                    b.IncludeLabel = this.chkGenerateLabel.Checked;
                    b.RotateFlipType = (RotateFlipType)Enum.Parse(typeof(RotateFlipType), this.cbRotateFlip.SelectedItem.ToString(), true);

                    if (!String.IsNullOrEmpty(this.textBox1.Text.Trim()))
                        b.AlternateLabel = this.textBox1.Text;
                    else
                        b.AlternateLabel = this.txtData.Text;

                    //label alignment and position
                    switch (this.cbLabelLocation.SelectedItem.ToString().Trim().ToUpper())
                    {
                        case "BOTTOMLEFT":  b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMLEFT; break;
                        case "BOTTOMRIGHT": b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMRIGHT; break;
                        case "TOPCENTER": b.LabelPosition = BarcodeLib.LabelPositions.TOPCENTER; break;
                        case "TOPLEFT": b.LabelPosition = BarcodeLib.LabelPositions.TOPLEFT; break;
                        case "TOPRIGHT": b.LabelPosition = BarcodeLib.LabelPositions.TOPRIGHT; break;
                        default: b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER; break;
                    }//switch

                    //===== Encoding performed here =====
                    barcode.BackgroundImage = b.Encode(type, this.txtData.Text.Trim(), this.btnForeColor.BackColor, this.btnBackColor.BackColor, W, H);
                    //===================================
                    
                    //show the encoding time
                    this.lblEncodingTime.Text = "(" + Math.Round(b.EncodingTime, 0, MidpointRounding.AwayFromZero).ToString() + "ms)";
                    
                    txtEncoded.Text = b.EncodedValue;

                    tsslEncodedType.Text = "Encoding Type: " + b.EncodedType.ToString();

                    // Read dynamically calculated Width/Height because the user is interested.
                    if (b.BarWidth.HasValue)
                        txtWidth.Text = b.Width.ToString();
                    if (b.AspectRatio.HasValue)
                        txtHeight.Text = b.Height.ToString();
                }//if

                //reposition the barcode image to the middle
                barcode.Location = new Point((this.barcode.Location.X + this.barcode.Width / 2) - barcode.Width / 2, (this.barcode.Location.Y + this.barcode.Height / 2) - barcode.Height / 2);
            }//try
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }//catch
        }//btnEncode_Click
Esempio n. 5
0
        private void Vewiooo()
        {
            errorProvider1.Clear();

            int W = Convert.ToInt32(this.txtWidth.Text.Trim());
            int H = Convert.ToInt32(this.txtHeight.Text.Trim());

            b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
            b.LabelFont = lblfonttitle.Font;

            //barcode alignment
            switch (cbBarcodeAlign.SelectedItem.ToString().Trim().ToLower())
            {
            case "يسار": b.Alignment = BarcodeLib.AlignmentPositions.LEFT; break;

            case "يمين": b.Alignment = BarcodeLib.AlignmentPositions.RIGHT; break;

            default: b.Alignment = BarcodeLib.AlignmentPositions.CENTER; break;
            }//switch

            BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
            switch (cbEncodeType.SelectedItem.ToString().Trim())
            {
            case "UPC-A": type = BarcodeLib.TYPE.UPCA; break;

            case "UPC-E": type = BarcodeLib.TYPE.UPCE; break;

            case "UPC 2 Digit Ext.": type = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_2DIGIT; break;

            case "UPC 5 Digit Ext.": type = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_5DIGIT; break;

            case "EAN-13": type = BarcodeLib.TYPE.EAN13; break;

            case "JAN-13": type = BarcodeLib.TYPE.JAN13; break;

            case "EAN-8": type = BarcodeLib.TYPE.EAN8; break;

            case "ITF-14": type = BarcodeLib.TYPE.ITF14; break;

            case "Codabar": type = BarcodeLib.TYPE.Codabar; break;

            case "PostNet": type = BarcodeLib.TYPE.PostNet; break;

            case "Bookland/ISBN": type = BarcodeLib.TYPE.BOOKLAND; break;

            case "Code 11": type = BarcodeLib.TYPE.CODE11; break;

            case "Code 39": type = BarcodeLib.TYPE.CODE39; break;

            case "Code 39 Extended": type = BarcodeLib.TYPE.CODE39Extended; break;

            case "Code 93": type = BarcodeLib.TYPE.CODE93; break;

            case "LOGMARS": type = BarcodeLib.TYPE.LOGMARS; break;

            case "MSI": type = BarcodeLib.TYPE.MSI_Mod10; break;

            case "Interleaved 2 of 5": type = BarcodeLib.TYPE.Interleaved2of5; break;

            case "Standard 2 of 5": type = BarcodeLib.TYPE.Standard2of5; break;

            case "Code 128": type = BarcodeLib.TYPE.CODE128; break;

            case "Code 128-A": type = BarcodeLib.TYPE.CODE128A; break;

            case "Code 128-B": type = BarcodeLib.TYPE.CODE128B; break;

            case "Code 128-C": type = BarcodeLib.TYPE.CODE128C; break;

            case "Telepen": type = BarcodeLib.TYPE.TELEPEN; break;

            case "FIM": type = BarcodeLib.TYPE.FIM; break;

            default: MessageBox.Show("باركود باركود الرجاء حدد نوع تشفير باركود"); break;
            }//switch

            try
            {
                if (type != BarcodeLib.TYPE.UNSPECIFIED)
                {
                    b.IncludeLabel = (this.chkGenerateLabel.Checked);
                    if (checkBox1.Checked)
                    {
                        b.AnotherDate = combotypes.Text;
                    }
                    else
                    {
                        b.AnotherDate = "";
                    }
                    //  b.RotateFlipType = (RotateFlipType)Enum.Parse(typeof(RotateFlipType), this.cbRotateFlip.SelectedItem.ToString(), true);
                    b.RotateFlipType = GetThe(this.cbRotateFlip.Text);

                    //label alignment and position
                    switch (this.cbLabelLocation.SelectedItem.ToString().Trim().ToUpper())
                    {
                    case "توسط أيسر": b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMLEFT; break;

                    case "توسط أيمن": b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMRIGHT; break;

                    case "توسط علوي": b.LabelPosition = BarcodeLib.LabelPositions.TOPCENTER; break;

                    case "أعلى اليسار": b.LabelPosition = BarcodeLib.LabelPositions.TOPLEFT; break;

                    case "أعلى اليمين": b.LabelPosition = BarcodeLib.LabelPositions.TOPRIGHT; break;

                    default: b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER; break;
                    }//switch

                    //===== Encoding performed here =====
                    barcode.Image = b.Encode(type, this.txtData.Text.Trim(), this.btnForeColor.BackColor, this.btnBackColor.BackColor, W, H);
                    //===================================

                    //show the encoding time
                    //this.lblEncodingTime.Text = "(" + Math.Round(b.EncodingTime, 0, MidpointRounding.AwayFromZero).ToString() + "ms)";

                    // txtEncoded.Text = b.EncodedValue;

                    tsslEncodedType.Text = " نوع تشفير باركود : " + b.EncodedType.ToString();
                }//if

                barcode.Width  = barcode.Image.Width;
                barcode.Height = barcode.Image.Height;

                //reposition the barcode image to the middle
                barcode.Location = new Point((this.groupBox2.Location.X + this.groupBox2.Width / 2) - barcode.Width / 2, (this.groupBox2.Location.Y + this.groupBox2.Height / 2) - barcode.Height / 2);
            }//try
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            } //catch
        }     //Vewiooo
Esempio n. 6
0
        }//Form1_Load

        private void btnEncode_Click(object sender, EventArgs e)
        {
            int W = Convert.ToInt32(this.txtWidth.Text.Trim());
            int H = Convert.ToInt32(this.txtHeight.Text.Trim());

            BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
            switch (cbEncodeType.SelectedItem.ToString().Trim())
            {
                case "UPC-A": type = BarcodeLib.TYPE.UPCA; break;
                case "UPC-A (Numbered)": 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;
                default: MessageBox.Show("Please specify the encoding type."); break;
            }//switch

            try
            {
                if (type != BarcodeLib.TYPE.UNSPECIFIED)
                {
                    b.IncludeLabel = this.chkGenerateLabel.Checked;

                    //===== Encoding performed here =====
                    barcode.Image = b.Encode(type, this.txtData.Text.Trim(), this.btnForeColor.BackColor, this.btnBackColor.BackColor, W, H);
                    //===================================

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

                    txtEncoded.Text = b.EncodedValue;

                    barcode.Width = barcode.Image.Width;
                    barcode.Height = barcode.Image.Height;

                    tsslEncodedType.Text = "Encoding Type: " + b.EncodedType.ToString();
                }//if

                barcode.Width = barcode.Image.Width;
                barcode.Height = barcode.Image.Height;
                
                //reposition the barcode image to the middle
                barcode.Location = new Point((this.groupBox2.Location.X + this.groupBox2.Width / 2) - barcode.Width / 2, (this.groupBox2.Location.Y + this.groupBox2.Height / 2) - barcode.Height / 2);

            }//try
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }//catch
        }//btnEncode_Click
Esempio n. 7
0
        /// <summary>
        /// Decode barcode style name to enum value
        /// </summary>
        /// <param name="barcodeStyle"></param>
        /// <returns></returns>
        public BarcodeLib.TYPE DecodeBarcodeStyle(string barcodeStyle)
        {
            BarcodeLib.TYPE barcodeType = BarcodeLib.TYPE.CODE128;
            switch (barcodeStyle.ToUpper())
            {
            case "UNSPECIFIED":
                barcodeType = BarcodeLib.TYPE.UNSPECIFIED;
                break;

            case "UPCA":
                barcodeType = BarcodeLib.TYPE.UPCA;
                break;

            case "UPCE":
                barcodeType = BarcodeLib.TYPE.UPCE;
                break;

            case "UPC_SUPPLEMENTAL_2DIGIT":
                barcodeType = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_2DIGIT;
                break;

            case "UPC_SUPPLEMENTAL_5DIGIT":
                barcodeType = BarcodeLib.TYPE.UPC_SUPPLEMENTAL_5DIGIT;
                break;

            case "EAN13":
                barcodeType = BarcodeLib.TYPE.EAN13;
                break;

            case "EAN8":
                barcodeType = BarcodeLib.TYPE.EAN8;
                break;

            case "Interleaved2of5":
                barcodeType = BarcodeLib.TYPE.Interleaved2of5;
                break;

            case "Interleaved2of5_Mod10":
                barcodeType = BarcodeLib.TYPE.Interleaved2of5_Mod10;
                break;

            case "Standard2of5":
                barcodeType = BarcodeLib.TYPE.Standard2of5;
                break;

            case "Standard2of5_Mod10":
                barcodeType = BarcodeLib.TYPE.Standard2of5_Mod10;
                break;

            case "Industrial2of5":
                barcodeType = BarcodeLib.TYPE.Industrial2of5;
                break;

            case "Industrial2of5_Mod10":
                barcodeType = BarcodeLib.TYPE.Industrial2of5_Mod10;
                break;

            case "CODE39":
                barcodeType = BarcodeLib.TYPE.CODE39;
                break;

            case "CODE39Extended":
                barcodeType = BarcodeLib.TYPE.CODE39Extended;
                break;

            case "CODE39_Mod43":
                barcodeType = BarcodeLib.TYPE.CODE39_Mod43;
                break;

            case "Codabar":
                barcodeType = BarcodeLib.TYPE.Codabar;
                break;

            case "PostNet":
                barcodeType = BarcodeLib.TYPE.PostNet;
                break;

            case "BOOKLAND":
                barcodeType = BarcodeLib.TYPE.BOOKLAND;
                break;

            case "ISBN":
                barcodeType = BarcodeLib.TYPE.ISBN;
                break;

            case "JAN13":
                barcodeType = BarcodeLib.TYPE.JAN13;
                break;

            case "MSI_Mod10":
                barcodeType = BarcodeLib.TYPE.MSI_Mod10;
                break;

            case "MSI_2Mod10":
                barcodeType = BarcodeLib.TYPE.MSI_2Mod10;
                break;

            case "MSI_Mod11":
                barcodeType = BarcodeLib.TYPE.MSI_Mod11;
                break;

            case "MSI_Mod11_Mod10":
                barcodeType = BarcodeLib.TYPE.MSI_Mod11_Mod10;
                break;

            case "Modified_Plessey":
                barcodeType = BarcodeLib.TYPE.Modified_Plessey;
                break;

            case "CODE11":
                barcodeType = BarcodeLib.TYPE.CODE11;
                break;

            case "USD8":
                barcodeType = BarcodeLib.TYPE.USD8;
                break;

            case "UCC12":
                barcodeType = BarcodeLib.TYPE.UCC12;
                break;

            case "UCC13":
                barcodeType = BarcodeLib.TYPE.UCC13;
                break;

            case "LOGMARS":
                barcodeType = BarcodeLib.TYPE.LOGMARS;
                break;

            case "CODE128":
                barcodeType = BarcodeLib.TYPE.CODE128;
                break;

            case "CODE128A":
                barcodeType = BarcodeLib.TYPE.CODE128A;
                break;

            case "CODE128B":
                barcodeType = BarcodeLib.TYPE.CODE128B;
                break;

            case "CODE128C":
                barcodeType = BarcodeLib.TYPE.CODE128C;
                break;

            case "ITF14":
                barcodeType = BarcodeLib.TYPE.ITF14;
                break;

            case "CODE93":
                barcodeType = BarcodeLib.TYPE.CODE93;
                break;

            case "TELEPEN":
                barcodeType = BarcodeLib.TYPE.TELEPEN;
                break;

            case "FIM":
                barcodeType = BarcodeLib.TYPE.FIM;
                break;

            case "PHARMACODE":
                barcodeType = BarcodeLib.TYPE.PHARMACODE;
                break;
            }

            return(barcodeType);
        }