2 using System.Collections.Generic;
3 using System.ComponentModel;
15 private static List<IMotorolaBarcodeScanner> _scanners;
16 private static string _lastScanned;
21 BarcodeScannerManager.Instance.Open();
23 BarcodeScannerManager.Instance.RegisterForEvents(
31 BarcodeScannerManager.Instance.UnRegisterForEvents(
39 if (BarcodeScannerManager.Instance.RegisteredEvents.Contains(EventType.Image))
45 BarcodeScannerManager.Instance.Keyboard.EnableEmulation =
false;
48 _scanners = BarcodeScannerManager.Instance.GetDevices();
51 foreach (var scanner
in _scanners)
53 scanner.SetHostMode(HostMode.USB_SNAPI_Imaging);
57 BarcodeScannerManager.Instance.DataReceived += OnDataReceived;
59 Console.WriteLine(
"Ready to scan.. (Enter to quit)");
64 private static void OnDataReceived(
object sender, BarcodeScanEventArgs e)
66 _lastScanned = e.Data;
67 Console.WriteLine(
"Barcode type: " + e.BarcodeType.GetDescription());
68 Console.WriteLine(
"Data: " + e.Data);
72 public static string GetDescription(
this Enum value)
74 FieldInfo fi = value.GetType().GetField(value.ToString());
76 DescriptionAttribute[] attributes =
77 (DescriptionAttribute[])fi.GetCustomAttributes(
78 typeof(DescriptionAttribute),
81 if (attributes != null &&
82 attributes.Length > 0)
83 return attributes[0].Description;
85 return value.ToString();
Definition: BarcodeOrientation.cs:7
Definition: BarcodeScanEventArgs.cs:9