/// <summary>
        /// Opens the selected scanner device.
        /// </summary>
        async void OpenBarcodeReader()
        {
            myLog.doLog("OpenBarcodeReader...");
            if (mBarcodeReader == null)
            {
                myLog.doLog("mOpenReader...");
                mBarcodeReader = new BarcodeReader(DCS_Imager);
                if (!mBarcodeReader.IsReaderOpened)
                {
                    myLog.doLog("IsReaderOpened...");
                    BarcodeReader.Result result = await mBarcodeReader.OpenAsync();

                    mBarcodeReader.BarcodeDataReady += new EventHandler <BarcodeDataArgs>(MBarcodeReader_BarcodeDataReady);

                    // Check to see is reader opened or is already open
                    if (result.Code == BarcodeReader.Result.Codes.SUCCESS ||
                        result.Code == BarcodeReader.Result.Codes.READER_ALREADY_OPENED)
                    {
                        ScanCount = 0;
                    }
                    else
                    {
                        myLog.doLog("Error", "OpenAsync failed, Code:" + result.Code + " Message:" + result.Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public async Task OpenBarcodeReader()
        {
            mSelectedReader = GetBarcodeReader(_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
                {
                    await DisplayAlert("Error", "OpenAsync failed, Code:" + result.Code +
                                       " Message:" + result.Message, "OK");
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Opens the selected scanner device.
        /// </summary>
        public static async void OpenBarcodeReader(BarcodeReader barcodeReader)
        {
            if (!barcodeReader.IsReaderOpened)
            {
                BarcodeReader.Result result = await barcodeReader.OpenAsync();

                // Check to see is reader opened or is already open
                if (result.Code == BarcodeReader.Result.Codes.SUCCESS ||
                    result.Code == BarcodeReader.Result.Codes.READER_ALREADY_OPENED)
                {
                    SetScannerAndSymbologySettings(barcodeReader, Application.Context);
                }
                else
                {
                    DisplayAlert("Error", "OpenAsync failed, Code:" + result.Code +
                                 " Message:" + result.Message, Application.Context);
                }
            }
        }
Exemplo n.º 4
0
        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);
                }
            }
        }
Exemplo n.º 5
0
        public async void OpenScanner(BarcodeReader mSelectedReader)
        {
            try
            {
                Debug.WriteLine("DataSetting: " + mSelectedReader.SettingKeys.DataProcessorLaunchBrowser);
                BarcodeReader.Result result = await mSelectedReader.OpenAsync();

                if (result.Code == BarcodeReader.Result.Codes.SUCCESS ||
                    result.Code == BarcodeReader.Result.Codes.READER_ALREADY_OPENED)
                {
                    Debug.WriteLine("Scanner oppened");
                    SetScannerAndSymbologySettings(mSelectedReader);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error en el metodo openscanner");
                Analytics.TrackEvent("Error al abrir el scanner: " + e.Message + "\n Escaner: " + Preferences.Get("LECTOR", "N/A"));
                throw;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Opens the barcode reader. This method should be called from the
        /// main UI thread because it also updates the button states.
        /// </summary>
        public async void OpenBarcodeReader()
        {
            if (mOpenReader) // Open Reader switch is in the On state.
            {
                mSelectedReader = GetBarcodeReader(GetSelectedReaderName());
                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();

                        // Prevent user from selecting another reader.
                        mReaderPicker.IsEnabled = false;

                        // Turn on the Enable Scanning switch.
                        mEnableScanningSwitch.IsToggled = true;
                        // Enable the Enable Scanning switch.
                        mEnableScanningLabel.IsEnabled  = true;
                        mEnableScanningSwitch.IsEnabled = true;

                        // Clear barcode data information
                        mScanDataEditor.Text = "";
                        mSymbologyLabel.Text = "";
                        mTimestampLabel.Text = "";
                    }
                    else
                    {
                        await DisplayAlert("Error", "OpenAsync failed, Code:" + result.Code +
                                           " Message:" + result.Message, "OK");
                    }
                }
            } //endif (mOpenReader)
        }
Exemplo n.º 7
0
 private async Task OpenReaderAsync()
 {
     BarcodeReader.Result openResult = await _barcodeReader.OpenAsync();
 }