Exemple #1
0
        public async Task CloseBarcodeReader()
        {
            if (mSelectedReader != null && mSelectedReader.IsReaderOpened)
            {
                if (mSoftOneShotScanStarted || mSoftContinuousScanStarted)
                {
                    // Turn off the software trigger.
                    await mSelectedReader.SoftwareTriggerAsync(false);

                    mSoftOneShotScanStarted    = false;
                    mSoftContinuousScanStarted = false;
                }

                BarcodeReader.Result result = await mSelectedReader.CloseAsync();

                if (result.Code == BarcodeReader.Result.Codes.SUCCESS)
                {
                }
                else
                {
                    await DisplayAlert("Error", "CloseAsync failed, Code:" + result.Code +
                                       " Message:" + result.Message, "OK");
                }
            }
        }
Exemple #2
0
        public async void CloseScanner(BarcodeReader mSelectedReader)
        {
            try
            {
                BarcodeReader.Result result = await mSelectedReader.CloseAsync();

                if (result.Code == BarcodeReader.Result.Codes.SUCCESS ||
                    result.Code == BarcodeReader.Result.Codes.NO_ACTIVE_CONNECTION)
                {
                    Debug.WriteLine("Scanner closed");
                }
            }
            catch (Exception e)
            {
                Analytics.TrackEvent("Error al cerrar el scanner: " + e.Message + "\n Escaner: " + Preferences.Get("LECTOR", "N/A"));
            }
        }
        /// <summary>
        /// Closes the selected scanner device.
        /// </summary>
        async void CloseBarcodeScanner()
        {
            myLog.doLog("CloseBarcodeScanner...");
            if (mBarcodeReader != null && mBarcodeReader.IsReaderOpened)
            {
                //settings.Clear();
                BarcodeReader.Result result = await mBarcodeReader.CloseAsync();

                if (result.Code == BarcodeReader.Result.Codes.SUCCESS)
                {
                    mBarcodeReader.BarcodeDataReady -= MBarcodeReader_BarcodeDataReady;
                    mBarcodeReader.Dispose();
                    mBarcodeReader = null;
                }
                else
                {
                    myLog.doLog("Error", "CloseAsync failed, Code:" + result.Code + " Message:" + result.Message);
                }
            }
        }
        /// <summary>
        /// Closes the barcode reader. This method should be called from the
        /// main UI thread because it also updates the button states.
        /// </summary>
        public async void CloseBarcodeReader()
        {
            if (mSelectedReader != null && mSelectedReader.IsReaderOpened)
            {
                if (mSoftOneShotScanStarted || mSoftContinuousScanStarted)
                {
                    // Turn off the software trigger.
                    await mSelectedReader.SoftwareTriggerAsync(false);

                    mSoftOneShotScanStarted    = false;
                    mSoftContinuousScanStarted = false;
                }

                BarcodeReader.Result result = await mSelectedReader.CloseAsync();

                if (result.Code == BarcodeReader.Result.Codes.SUCCESS)
                {
                    mScanButton.IsEnabled = false;
                    // Allow user to select another reader.
                    mReaderPicker.IsEnabled = true;

                    // Disable the Enable Scanning switch.
                    mEnableScanningLabel.IsEnabled  = false;
                    mEnableScanningSwitch.IsEnabled = false;
                    // Turn off the Enable Scanning switch.
                    mEnableScanningSwitch.IsToggled = false;

                    // Turn off the Continuous switch.
                    mContinuousSwitch.IsToggled = false;
                    // Disable the Continuous switch
                    mContinuousLabel.IsEnabled  = false;
                    mContinuousSwitch.IsEnabled = false;
                }
                else
                {
                    await DisplayAlert("Error", "CloseAsync failed, Code:" + result.Code +
                                       " Message:" + result.Message, "OK");
                }
            }
        }
Exemple #5
0
        public async void CloseBarcodeReader()
        {
            if (mSelectedReader != null && mSelectedReader.IsReaderOpened)
            {
                if (mSoftOneShotScanStarted || mSoftContinuousScanStarted)
                {
                    await mSelectedReader.SoftwareTriggerAsync(false);

                    mSoftOneShotScanStarted    = false;
                    mSoftContinuousScanStarted = false;
                }

                BarcodeReader.Result result = await mSelectedReader.CloseAsync();

                if (result.Code == BarcodeReader.Result.Codes.SUCCESS)
                {
                }
                else
                {
                    MessagingCenter.Send <App, string>((App)Xamarin.Forms.Application.Current, "exception", "ScannerInit/UpdateBarcodeInfo: Code:" + result.Code + " Message:" + result.Message);
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Closes the selected scanner device.
        /// </summary>
        public static async void CloseBarcodeScanner(BarcodeReader barcodeReader, bool bSoftOneShotScanStarted)
        {
            if (barcodeReader != null && barcodeReader.IsReaderOpened)
            {
                if (bSoftOneShotScanStarted)
                {
                    // Turn off the software trigger.
                    await barcodeReader.SoftwareTriggerAsync(false);

                    bSoftOneShotScanStarted = false;
                }

                BarcodeReader.Result result = await barcodeReader.CloseAsync();

                if (result.Code != BarcodeReader.Result.Codes.SUCCESS)
                {
                    DisplayAlert("Error", "CloseAsync failed, Code:" + result.Code +
                                 " Message:" + result.Message, Application.Context);
                }
            }

            barcodeReader = null;
        }
 private async Task CloseReaderAsync()
 {
     await _barcodeReader.CloseAsync();
 }