日期:2014-05-18 浏览次数:20780 次
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace BarCodeTest { public partial class Form4 : Form { public Form4() { InitializeComponent(); this.Paint += new PaintEventHandler(Form4_Paint); } void Form4_Paint(object sender, PaintEventArgs e) { Rectangle barcoderect = new Rectangle(10, 10, 250, 48); BarCode39 barcode = new BarCode39(); barcode.BarcodeText = "69555555555555"; barcode.DrawBarcode(e.Graphics, barcoderect); } } /********************************分割线***********************************/ public class BarCode39 { public string BarcodeText = string.Empty; public int BarcodeHeight = 0; public int BarcodeWidth = 0; public Font footerFont = new Font("微软雅黑", 12.0f); /*修改了字体大小*/ private double wideToNarrowRatio = 3.0; public double WideToNarrowRatio { get { return wideToNarrowRatio; } set { wideToNarrowRatio = value; } } private int weight = 1; public int Weight { get { return weight; } set { weight = value; } } /// <summary> /// 39条码中能使用的字符 /// </summary> private String alphabet39 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*"; private String[] coded39Char = { /* 0 */ "001100100", /* 1 */ "100010100", /* 2 */ "010010100", /* 3 */ "110000100", /* 4 */ "001010100", /* 5 */ "101000100", /* 6 */ "011000100", /* 7 */ "000110100", /* 8 */ "100100100", /* 9 */ "010100100", /* A */ "100010010", /* B */ "010010010", /* C */ "110000010", /* D */ "001010010", /* E */ "101000010", /* F */ "011000010", /* G */ "000110010", /* H */ "100100010", /* I */ "010100010", /* J */ "001100010", /* K */ "100010001", /* L */ "010010001", /* M */ "110000001", /* N */ "001010001", /* O */ "101000001", /* P */ "011000001", /* Q */ "000110001", /* R */ "100100001", /* S */ "010100001", /* T */ "001100001", /* U */ "100011000",