Occurs for every barcode symbology read.
public event EventHandler<BarcodeReadSymbologyEventArgs> ReadSymbology Public Event ReadSymbology As EventHandler(Of BarcodeReadSymbologyEventArgs) public event EventHandler<BarcodeReadSymbologyEventArgs> ReadSymbology @property (nonatomic, weak, nullable) id<LTReadSymbologyDelegate> delegate public void addReadSymbologyListener(BarcodeReadSymbologyListener listener)public void removeReadSymbologyListener(BarcodeReadSymbologyListener listener)
add_ReadSymbology(function(sender, e))remove_ReadSymbology(function(sender, e))
public:event EventHandler<BarcodeReadSymbologyEventArgs^>^ ReadSymbology
The event handler receives an argument of type BarcodeReadSymbologyEventArgs containing data related to this event. The following BarcodeReadSymbologyEventArgs properties provide information specific to this event.
| Property | Description |
|---|---|
| Data | Gets the barcode data found. |
| Error | Any error that may have occurred during the read operation. |
| HResult | Any error that may have occurred during the read operation. |
| Operation | Gets the current barcode read operation. |
| Options | Gets the options being used to read the symbologies. |
| Options | For information about this method please see Options. |
| Status | Gets or sets the status of the read operation. |
| SymbologiesCount | Get Symbologies Count |
Use the ReadSymbology event to obtain information and set the status of the current barcode read operation.
When you read barcodes using BarcodeReader.ReadBarcode or BarcodeReader.ReadBarcodes, the BarcodeReader object will fire the ReadSymbology event multiple times depending on the symbologies being read.
LEADTOOLS barcode reading is designed for speed; multiple barcode symbologies can be read (or searched for) in one operation as these barcodes have similar characteristics. Therefore, the symbologies being read are stored in a BarcodeSymbology array and obtained with the BarcodeReadSymbologyEventArgs.GetSymbologies method.
The following table lists the event members and their meaning:
| Member | Description |
|---|---|
| BarcodeReadSymbologyEventArgs.Operation |
Can be either BarcodeReadSymbologyOperation.PreRead , when the BarcodeReader is about to try to read the symbologies or BarcodeReadSymbologyOperation.PreRead when the reader has finished reading the objects. |
| BarcodeReadSymbologyEventArgs.GetSymbologies |
Will return the current symbologies being searched for or that have been read. |
| BarcodeReadSymbologyEventArgs.Options |
The BarcodeReadOptions or one of its derived classes that specify the options being used to read the symbologies. This could be the options passed through the read methods or the default options set in BarcodeReader. |
| BarcodeReadSymbologyEventArgs.Data |
A BarcodeData object that contains the data of the barcode found. Only valid if Operation is BarcodeReadSymbologyOperation.PostRead and no error occurred. Otherwise, it will be null (Nothing in Visual Basic). |
| BarcodeReadSymbologyEventArgs.Error |
An Exception object that contains any error encountered during the current operation. If no errors are encountered, then this member will be null (Nothing in Visual Basic). |
| BarcodeReadSymbologyEventArgs.Status |
The status of the operation. The BarcodeReader will always set this member to BarcodeReadSymbologyEventArgs.Continue, which means proceed to the next phase of the read operation. You can set this member to BarcodeReadSymbologyStatus.Skip to skip reading the current symbologies (only when BarcodeReadSymbologyEventArgs.Operation is BarcodeReadSymbologyOperation.PreRead) or to abort the whole read operation by setting it to BarcodeReadSymbologyStatus.Abort. |
This example shows how to use ReadSymbology to get the current status of barcode reading.
using Leadtools;using Leadtools.Codecs;using Leadtools.Forms;using Leadtools.Barcode;using Leadtools.ImageProcessing;public void BarcodeReader_ReadSymbologyExample(){string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.tif");// Create a Barcode engineBarcodeEngine engine = new BarcodeEngine();// Get the Barcode reader instanceBarcodeReader reader = engine.Reader;// Load the imageusing (RasterCodecs codecs = new RasterCodecs()){using (RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)){// Subscribe to the ReadSymbology eventreader.ReadSymbology += new EventHandler<BarcodeReadSymbologyEventArgs>(reader_ReadSymbology);// Read all barcodes in the imagereader.ReadBarcodes(image, LogicalRectangle.Empty, 0, null);reader.ReadSymbology -= new EventHandler<BarcodeReadSymbologyEventArgs>(reader_ReadSymbology);}}}private void reader_ReadSymbology(object sender, BarcodeReadSymbologyEventArgs e){if (e.Operation == BarcodeReadSymbologyOperation.PreRead){// Before reading, show the symbologies the engine is going to try to readConsole.WriteLine("Trying to read the following symbologies:");BarcodeSymbology[] symbologies = e.GetSymbologies();for (int i = 0; i < symbologies.Length; i++){Console.Write(symbologies[i]);if (i != (symbologies.Length - 1)){Console.Write(", ");}else{Console.WriteLine();}}}else if (e.Operation == BarcodeReadSymbologyOperation.PostRead){if (e.Error == null){// No errorsBarcodeData barcode = e.Data;if (barcode != null){// Found a barcode, show itConsole.WriteLine(" {0} at {1} with data {2}", barcode.Symbology, barcode.Bounds, barcode.Value);}else{Console.WriteLine(" No barcodes found");}}else{// Show the errorConsole.WriteLine("Error: {0}", e.Error.Message);// Tell the reader top stop reading barcodese.Status = BarcodeReadSymbologyStatus.Abort;}}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.FormsImports Leadtools.BarcodeImports Leadtools.ImageProcessingPublic Sub BarcodeReader_ReadSymbologyExample()Dim imageFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.tif")' Create a Barcode engineDim engine As New BarcodeEngine()' Get the Barcode reader instanceDim reader As BarcodeReader = engine.Reader' Load the imageUsing codecs As New RasterCodecs()Using image As RasterImage = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)' Subscribe to the ReadSymbology eventAddHandler reader.ReadSymbology, AddressOf reader_ReadSymbology' Read all barcodes in the imagereader.ReadBarcodes(image, LogicalRectangle.Empty, 0, Nothing)RemoveHandler reader.ReadSymbology, AddressOf reader_ReadSymbologyEnd UsingEnd UsingEnd SubPrivate Sub reader_ReadSymbology(ByVal sender As Object, ByVal e As BarcodeReadSymbologyEventArgs)If e.Operation = BarcodeReadSymbologyOperation.PreRead Then' Before reading, show the symbologies the engine is going to try to readConsole.WriteLine("Trying to read the following symbologies:")Dim symbologies As BarcodeSymbology() = e.GetSymbologies()For i As Integer = 0 To symbologies.Length - 1Console.Write(symbologies(i))If i <> (symbologies.Length - 1) ThenConsole.Write(", ")ElseConsole.WriteLine()End IfNextElseIf e.Operation = BarcodeReadSymbologyOperation.PostRead ThenIf IsNothing(e.Error) Then' No errorsDim barcode As BarcodeData = e.DataIf Not IsNothing(barcode) Then' Found a barcode, show itConsole.WriteLine(" {0} at {1} with data {2}", barcode.Symbology, barcode.Bounds, barcode.Value)ElseConsole.WriteLine(" No barcodes found")End IfElse' Show the errorConsole.WriteLine("Error: {0}", e.Error.Message)' Tell the reader top stop reading barcodese.Status = BarcodeReadSymbologyStatus.AbortEnd IfEnd IfEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools;using Leadtools.Codecs;using Leadtools.Forms;using Leadtools.Barcode;using Leadtools.ImageProcessing;using Leadtools.Examples;public void BarcodeReader_ReadSymbologyExample(RasterImage image){// Create a Barcode engineBarcodeEngine engine = new BarcodeEngine();// Get the Barcode reader instanceBarcodeReader reader = engine.Reader;// Load the imageRasterCodecs codecs = new RasterCodecs();// Subscribe to the ReadSymbology eventreader.ReadSymbology += new EventHandler<BarcodeReadSymbologyEventArgs>(reader_ReadSymbology);// Read all barcodes in the imagereader.ReadBarcodes(image, LogicalRectangle.Empty, 0, null);reader.ReadSymbology -= new EventHandler<BarcodeReadSymbologyEventArgs>(reader_ReadSymbology);}private void reader_ReadSymbology(object sender, BarcodeReadSymbologyEventArgs e){if (e.Operation == BarcodeReadSymbologyOperation.PreRead){// Before reading, show the symbologies the engine is going to try to readConsole.WriteLine("Trying to read the following symbologies:");BarcodeSymbology[] symbologies = e.GetSymbologies();for (int i = 0; i < symbologies.Length; i++){Console.Write(symbologies[i]);if (i != (symbologies.Length - 1)){Console.Write(", ");}else{Console.WriteLine();}}}else if (e.Operation == BarcodeReadSymbologyOperation.PostRead){if (e.Error == null){// No errorsBarcodeData barcode = e.Data;if (barcode != null){// Found a barcode, show itConsole.WriteLine(" {0} at {1} with data {2}", barcode.Symbology, barcode.Bounds, barcode.Value);}else{Console.WriteLine(" No barcodes found");}}else{// Show the errorConsole.WriteLine("Error: {0}", e.Error.Message);// Tell the reader top stop reading barcodese.Status = BarcodeReadSymbologyStatus.Abort;}}}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.FormsImports Leadtools.BarcodeImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorPublic Sub BarcodeReader_ReadSymbologyExample(ByVal image As RasterImage)' Create a Barcode engineDim engine As BarcodeEngine = New BarcodeEngine()' Get the Barcode reader instanceDim reader As BarcodeReader = engine.Reader' Load the imageDim codecs As RasterCodecs = New RasterCodecs()' Subscribe to the ReadSymbology eventAddHandler reader.ReadSymbology, AddressOf reader_ReadSymbology' Read all barcodes in the imagereader.ReadBarcodes(image, LogicalRectangle.Empty, 0, Nothing)RemoveHandler reader.ReadSymbology, AddressOf reader_ReadSymbologyEnd SubPrivate Sub reader_ReadSymbology(ByVal sender As Object, ByVal e As BarcodeReadSymbologyEventArgs)If e.Operation = BarcodeReadSymbologyOperation.PreRead Then' Before reading, show the symbologies the engine is going to try to readConsole.WriteLine("Trying to read the following symbologies:")Dim symbologies As BarcodeSymbology() = e.GetSymbologies()Dim i As Integer = 0Do While i < symbologies.LengthConsole.Write(symbologies(i))If i <> (symbologies.Length - 1) ThenConsole.Write(", ")ElseConsole.WriteLine()End Ifi += 1LoopElseIf e.Operation = BarcodeReadSymbologyOperation.PostRead ThenIf e.Error Is Nothing Then' No errorsDim barcode As BarcodeData = e.DataIf Not barcode Is Nothing Then' Found a barcode, show itConsole.WriteLine(" {0} at {1} with data {2}", barcode.Symbology, barcode.Bounds, barcode.Value)ElseConsole.WriteLine(" No barcodes found")End IfElse' Show the errorConsole.WriteLine("Error: {0}", e.Error.Message)' Tell the reader top stop reading barcodese.Status = BarcodeReadSymbologyStatus.AbortEnd IfEnd IfEnd Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
