using System; using System.Drawing; using System.Windows.Forms; using System.Data; using ZXing;
namespace BarcodeUtility { public partial class frmScanGenerate : Form { public frmScanGenerate() { InitializeComponent(); }
private void frmScanGenerate_Load(object sender, EventArgs e) { LblBarcode.Visible = false; LblQRcode.Visible = false; BtnPrintBarcode.Visible = false; BtnPrintQRcode.Visible = false; }
private void BtnExit_Click(object sender, EventArgs e) { this.Hide(); frmBarcodemain barcodemain = new frmBarcodemain(); barcodemain.ShowDialog(); } int icount = 0; private void BtnPaletStart_Click(object sender, EventArgs e) { LblBarcode.Visible = true; LblQRcode.Visible = true; BtnPrintBarcode.Visible = true; BtnPrintQRcode.Visible = true;
dataGridViewScan.Rows.Clear(); for (int icount = 1; icount < 16; icount++) { string barcodeData = ScanBarcode(); dataGridViewScan.Rows.Add(icount, barcodeData); } GenerateBarcodeAndQRcode(); } private string ScanBarcode() { //return "1234567890"; BarcodeScanner scanner = new BarcodeScanner(); // create a new instance of the barcode scanner scanner.Connect(); string barcode = scanner.Scan(); // read the barcode from the scanner scanner.Disconnect(); return barcode; } private void GenerateBarcodeAndQRcode() { // generate barcode BarcodeWriter barcodeWriter = new BarcodeWriter(); barcodeWriter.Format = BarcodeFormat.CODE_128; Bitmap barcodeBitmap = barcodeWriter.Write("1234567890");
// generate qrcode BarcodeWriter qrCodeWriter = new BarcodeWriter(); qrCodeWriter.Format = BarcodeFormat.QR_CODE; Bitmap qrCodeBitmap = qrCodeWriter.Write("1234567890");
// display barcode and qrcode PictBarcodeImage.Image = barcodeBitmap; PictQRcodeimage.Image = qrCodeBitmap; } } }