101
CITIZEN UWP POS Print SDK - Programming Manual
4.
Barcode Scanner Control
4.1.
Program structure
Here is an example program in C# which uses the SDK
// Create an instance.
Scanner scanner = new Scanner();
// Data event definition.
void OnDataEvent(byte[] data)
{
Debug.WriteLine("Data call back: " + Encoding.UTF8.GetString(data));
}
// Status event definition.
void OnStatusUpdateEvent(int status)
{
Debug.WriteLine("Status update call back: " + status);
}
// Start scan.
void StartScan()
{
// Add event handler.
scanner.Dat= new DataEventHandler(OnDataEvent);
scanner.StatusUpdat=
new StatusUpdateEventHandler(OnStatusUpdateEvent);
// Connect scanner.
int result = await scanner.ConnectAsync(ScannerConst.CSC_PORT_WiFi,
"192.168.0.10");
}
// Stop scan.
void StopScan()
{
// disonnect scanner.
await scanner.DisconnectAsync();
// Delete event handler.
scanner.DataEvent -= new DataEventHandler(OnDataEvent);
scanner.StatusUpdateEvent -=
new StatusUpdateEventHandler(OnStatusUpdateEvent);
}
Class definition
Connect
processes
Callback
processes
Disconnect
processes