public SingleEntry() { InitializeComponent(); lblStatus.Text = "Initializing..."; _scanApiHelper = new ScanApiHelper.ScanApiHelper(); _scanApiHelper.SetNotification(this); }
// ScanAPI Helper provides a series of Callbacks // indicating some asynchronous events has occurred #region ScanApiHelperNotification Members // a scanner has connected to the host public void OnDeviceArrival(long result, ScanApiHelper.DeviceInfo newDevice) { if (SktScanErrors.SKTSUCCESS(result)) { UpdateStatusText("New Scanner: " + newDevice.Name); _device = newDevice; } else { string strMsg = String.Format("Unable to open scanner, error = {0}.", result); MessageBox.Show(strMsg, strAppName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private bool bDoGoodScan = true; // used to alternate between a 'good' ack and a 'bad' ack for demo #endif public SingleEntry() { InitializeComponent(); lblStatus.Text = "Initializing..."; _scanApiHelper = new ScanApiHelper.ScanApiHelper(); _scanApiHelper.SetNotification(this); // This is for the Host Acknowledgment feature. These lines can // be safely removed from #if to the #endif from your application // if this feature is not needed #if HOSTACK _scanApiHelper.PostSetConfirmationMode((char)ScanAPI.ISktScanProperty.values.confirmationMode.kSktScanDataConfirmationModeApp, null); #else _scanApiHelper.PostSetConfirmationMode((char)ScanAPI.ISktScanProperty.values.confirmationMode.kSktScanDataConfirmationModeDevice, null); #endif }
public SingleEntry() { InitializeComponent(); lblStatus.Text = "Initializing..."; _scanApiHelper = new ScanApiHelper.ScanApiHelper(); _scanApiHelper.SetNotification(this); // This is for the Host Acknowledgment feature. These lines can // be safely removed from #if to the #endif from your application // if this feature is not needed #if HOSTACK _scanApiHelper.PostSetConfirmationMode((char)ScanAPI.ISktScanProperty.values.confirmationMode.kSktScanDataConfirmationModeApp, null); #else _scanApiHelper.PostSetConfirmationMode((char)ScanAPI.ISktScanProperty.values.confirmationMode.kSktScanDataConfirmationModeDevice, null); #endif }
// some decoded data have been received public void OnDecodedData(ScanApiHelper.DeviceInfo device, ISktScanDecodedData decodedData) { UpdateDecodedDataText(decodedData.DataToUTF8String); }
// a scanner has disconnected from the host public void OnDeviceRemoval(ScanApiHelper.DeviceInfo deviceRemoved) { UpdateStatusText("Scanner Removed: " + deviceRemoved.Name); _device = null; }
private bool bDoGoodScan = true; // used to alternate between a 'good' ack and a 'bad' ack for demo #endif #region Methods // some decoded data have been received public void OnDecodedData(ScanApiHelper.DeviceInfo device, ISktScanDecodedData decodedData) { UpdateDecodedDataText(decodedData.DataToUTF8String); // This is for the Host Acknowledgment feature. These lines can // be safely removed from #if to the #endif from your application // if this feature is not needed #if HOSTACK Thread.Sleep(3 * 1000); // just a delay to show the trigger lock... // Send confirmation to scanner, good or bad _scanApiHelper.PostSetDataConfirmation(_device, bDoGoodScan, null); bDoGoodScan = !bDoGoodScan; // Alternate between a good read and a bad read.. #endif }
// a scanner has connected to the host public void OnDeviceArrival(long result, ScanApiHelper.DeviceInfo newDevice) { if (SktScanErrors.SKTSUCCESS(result)) { UpdateStatusText("New Scanner: " + newDevice.Name); _device = newDevice; // This is for the Host Acknowledgment feature. These lines can // be safely removed from #if to the #endif from your application // if this feature is not needed #if HOSTACK // Set the device to NOT acknowledge itself _scanApiHelper.PostSetLocalAcknowledgement(_device, false, null); // And make sure it does not give any indication after a scan _scanApiHelper.PostSetDecodeAction(_device, ISktScanProperty.values.localDecodeAction.kSktScanLocalDecodeActionNone, null); #else // Set the device to NOT acknowledge itself _scanApiHelper.PostSetLocalAcknowledgement(_device, true, null); // And make sure it does not give any indication after a scan int decode = ISktScanProperty.values.localDecodeAction.kSktScanLocalDecodeActionBeep | ISktScanProperty.values.localDecodeAction.kSktScanLocalDecodeActionFlash | ISktScanProperty.values.localDecodeAction.kSktScanLocalDecodeActionRumble; _scanApiHelper.PostSetDecodeAction(_device, decode, null); #endif } else { string strMsg = String.Format("Unable to open scanner, error = {0}.", result); MessageBox.Show(strMsg, strAppName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }