private async void PopulateReaderPicker() { try { // Queries the list of readers that are connected to the mobile computer. IList <BarcodeReaderInfo> readerList = await BarcodeReader.GetConnectedBarcodeReaders(); if (readerList.Count > 0) { foreach (BarcodeReaderInfo reader in readerList) { mReaderPicker.Items.Add(reader.ScannerName); } } else { mReaderPicker.Items.Add(DEFAULT_READER_KEY); } } catch (Exception ex) { mReaderPicker.Items.Add(DEFAULT_READER_KEY); await DisplayAlert("Error", "Failed to query connected readers, " + ex.Message, "OK"); } mReaderPicker.SelectedIndex = 0; }
private async void PopulateReaderPicker() { try { // Queries the list of readers that are connected to the mobile computer. IList <BarcodeReaderInfo> readerList = await BarcodeReader.GetConnectedBarcodeReaders(); if (readerList.Count > 0) { foreach (BarcodeReaderInfo reader in readerList) { _scannerName = reader.ScannerName; break; } } else { _scannerName = ""; } } catch (Exception ex) { await DisplayAlert("Error", "Failed to query connected readers, " + ex.Message, "OK"); } }
/// <summary> /// Reades the device list for scanner devices /// </summary> /// <returns></returns> public static async Task <List <string> > PopulateReaderPicker() { IList <BarcodeReaderInfo> readerList = null; List <string> readerNames = new List <string>(); try { readerList = await BarcodeReader.GetConnectedBarcodeReaders(AppContext); if (readerList.Count > 0) { foreach (BarcodeReaderInfo reader in readerList) { readerNames.Add(reader.ScannerName); } } else { readerNames.Add(DEFAULT_READER_KEY); } return(readerNames); } catch (Exception ex) { readerNames.Add(DEFAULT_READER_KEY); DisplayAlert("Error", "Failed to query connected readers, " + ex.Message); return(readerNames); } }
public async void GetScanner(bool bOpenClose) { try { IList <BarcodeReaderInfo> readerList = await BarcodeReader.GetConnectedBarcodeReaders(); foreach (BarcodeReaderInfo reader in readerList) { Debug.WriteLine("SCANNER FOUND: " + reader.ScannerName.ToString()); } if (readerList.Count > 0) { if (bOpenClose) { OpenScanner(GetBarcodeReader(readerList[0].ScannerName)); Debug.WriteLine("GOT SCANNER"); } else { CloseScanner(GetBarcodeReader(readerList[0].ScannerName)); Debug.WriteLine("CLOSED SCANNER: " + readerList[0].ScannerName); } } else { OpenScanner(GetBarcodeReader("default")); Debug.WriteLine("NO SCANNER"); } } catch (Exception e) { Analytics.TrackEvent("Error al encontrar escaner " + e.Message + "\n Escaner: " + Preferences.Get("LECTOR", "N/A")); throw; } }
private async Task GetReaderAsync() { IList <BarcodeReaderInfo> readerInfoList = await BarcodeReader.GetConnectedBarcodeReaders(); var readerName = readerInfoList.FirstOrDefault().ScannerName; _barcodeReader = new BarcodeReader(readerName); _barcodeReader.BarcodeDataReady += _barcodeReader_BarcodeDataReady; }
public async void OpenBarcodeReader() { mBarcodeReaders = new Dictionary <string, BarcodeReader>(); readerList = await BarcodeReader.GetConnectedBarcodeReaders(); mSelectedReader = GetBarcodeReader(readerList.First().ScannerName); if (!mSelectedReader.IsReaderOpened) { BarcodeReader.Result result = await mSelectedReader.OpenAsync(); if (result.Code == BarcodeReader.Result.Codes.SUCCESS || result.Code == BarcodeReader.Result.Codes.READER_ALREADY_OPENED) { SetScannerAndSymbologySettings(); } else { MessagingCenter.Send <App, string>((App)Xamarin.Forms.Application.Current, "exception", "ScannerInit/OpenBarcodeReader: Code:" + result.Code + " Message:" + result.Message); } } }