The Barcode extension component uses ZXing.Net to generate Barcodes on the server and render them on the client. Supports: UPC-A, EAN-8, EAN-13, Code 39, Code 128, ITF, Codabar, Plessey, MSI, QR Code, PDF-417, Aztec, Data Matrix.
Features
Generate Barcodes
Read Barcodes using the device's camera.
How to Use
The Barcode extension can be added to a Wisej.NET project using NuGet Package Manager.
This class can be used to display values as Barcodes.
Use the Text property to set the value and the BarcodeType property to select the type of Barcode.
The BarcodeType determines the list of allowed values/formats.
Use the ShowLabel property to optionally show the value as a label text (if supported by the BarcodeType).
Private Sub button1_Click(ByVal sender AsObject, ByVal e As EventArgs) Dim myBarcodeImage = Image.FromFile("path/to/image.png") Dim reader =NewBarcodeReader() Dim resultString = reader.DecodeBarcode(myBarcodeImage) AlertBox.Show(resultString)End Sub
Using a Camera Instance
When attaching to a Camera instance, the processing of images takes place on the client using zxing-js.
Three scan modes are available:
Automatic: Continuously scans the environment for barcodes.
AutomaticOnce: Stops scanning after one successful barcode detection.
Manual: Requires the user to call the ScanImage method.
You must attach a handler for ScanError and ScanSuccess to receive the scanning data from the client widget.
The following example shows how to attach and continuously scan images from the camera instance.
privatevoidbutton1_Click(object sender,EventArgs e){var reader =newBarcodeReader(); // attach the reader to the camera.reader.Camera=this.camera1; // continuously have the camera watching for barcodes.reader.ScanMode=ScanMode.Automatic; // handle successful scans.reader.ScanSuccess+= Reader_ScanSuccess; // handle failed scans.reader.ScanError+= Reader_ScanError;}privatevoidReader_ScanError(object sender,ScanEventArgs e){ // handle failure.AlertBox.Show(e.Data);}privatevoidReader_ScanSuccess(object sender,ScanEventArgs e){ // handle success.AlertBox.Show(e.Data);}
Private Sub button1_Click(ByVal sender AsObject, ByVal e As EventArgs) Dim reader =NewBarcodeReader()// attach the reader to the camera. reader.Camera = Me.camera1// continuously have the camera watching for barcodes. reader.ScanMode = ScanMode.Automatic// handle successful scans. reader.ScanSuccess += AddressOf Reader_ScanSuccess// handle failed scans. reader.ScanError += AddressOf Reader_ScanErrorEnd SubPrivate Sub Reader_ScanError(ByVal sender AsObject, ByVal e As ScanEventArgs) AlertBox.Show(e.Data)End SubPrivate Sub Reader_ScanSuccess(ByVal sender AsObject, ByVal e As ScanEventArgs) AlertBox.Show(e.Data)End Sub