コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            scanData = FindViewById <TextView>(Resource.Id.scanDataView);

            btnClearScan        = FindViewById <Button>(Resource.Id.BtnClearScan);
            btnClearScan.Click += BtnClearScan_Click;

            btnScan        = FindViewById <Button>(Resource.Id.BtnScan);
            btnScan.Click += BtnScan_Click;

            btnSecondActivity        = FindViewById <Button>(Resource.Id.BtnSecondActivity);
            btnSecondActivity.Click += BtnSecondActivity_Click;

#if HONEYWELLSCANNER
            // this only needs to be done once per Application
            // in this case the first activity is MainActivity
            // populates a list of connected barcode reader names
            ScannerCode.GetReaderList(Application.Context);
#endif
        }
コード例 #2
0
        /// <summary>
        /// Closes the selected scanner device.
        /// </summary>
        public void CloseBarcodeScanner()
        {
            if (mSelectedReader != null)
            {
                mSelectedReader.BarcodeDataReady -= MBarcodeReader_BarcodeDataReady;
            }

            ScannerCode.CloseBarcodeScanner(mSelectedReader, mSoftOneShotScanStarted);
        }
コード例 #3
0
        /// <summary>
        /// Opens the selected scanner device.
        /// </summary>
        public void OpenBarcodeReader()
        {
            mSelectedReader = new BarcodeReader(ScannerCode.SelectedScannerName, Application.Context);

            if (mSelectedReader != null)
            {
                mSelectedReader.BarcodeDataReady += MBarcodeReader_BarcodeDataReady;
            }

            ScannerCode.OpenBarcodeReader(mSelectedReader);
        }
コード例 #4
0
        private async void BtnScan_Click(object sender, EventArgs e)
        {
#if HONEYWELLSCANNER
            if (mSelectedReader != null && mSelectedReader.IsReaderOpened)
            {
                BarcodeReader.Result result = await mSelectedReader.SoftwareTriggerAsync(true);

                if (result.Code == BarcodeReader.Result.Codes.SUCCESS)
                {
                    // Set mSoftOneShotScanStarted to true if not in continuous scan mode.
                    // The mSoftOneShotScanStarted flag is used to turn off the software
                    // trigger after a barcode is read successfully.
                    mSoftOneShotScanStarted = true;
                }
                else
                {
                    ScannerCode.DisplayAlert("Error", "Failed to turn on software trigger, Code:" + result.Code +
                                             " Message:" + result.Message, Application.Context);
                }
            }
#endif
        }