Пример #1
0
        //Ct50 code
        public void OnCreated(AidcManager aidcManager)
        {
            bool issuccessful = false;

            manager = aidcManager;
            // use the manager to create a BarcodeReader with a session
            // associated with the internal imager.
            try
            {
                reader       = manager.CreateBarcodeReader();
                issuccessful = true;
            }
            catch (Exception exc)
            {
                issuccessful = false;
            }

            if (issuccessful)
            {
                try
                {
                    // apply settings
                    reader.SetProperty(BarcodeReader.PropertyCode39Enabled, true);
                    reader.SetProperty(BarcodeReader.PropertyDatamatrixEnabled, true);

                    reader.SetProperty(BarcodeReader.PropertyCode128Enabled, true);
                    reader.SetProperty(BarcodeReader.PropertyGs1128Enabled, true);
                    reader.SetProperty(BarcodeReader.PropertyQrCodeEnabled, true);
                    reader.SetProperty(BarcodeReader.PropertyUpcAEnable, true);
                    reader.SetProperty(BarcodeReader.PropertyEan13Enabled, true);
                    reader.SetProperty(BarcodeReader.PropertyAztecEnabled, true);
                    reader.SetProperty(BarcodeReader.PropertyCodabarEnabled, true);
                    reader.SetProperty(BarcodeReader.PropertyInterleaved25Enabled, true);
                    reader.SetProperty(BarcodeReader.PropertyPdf417Enabled, true);
                    // Set Max Code 39 barcode length
                    reader.SetProperty(BarcodeReader.PropertyCode39MaximumLength, 10);

                    // Disable bad read response, handle in onFailureEvent
                    reader.SetProperty(BarcodeReader.PropertyNotificationBadReadEnabled, true);

                    // set the trigger mode to client control
                    reader.SetProperty(BarcodeReader.PropertyTriggerControlMode, BarcodeReader.TriggerControlModeClientControl);
                }
                catch (UnsupportedPropertyException)
                {
                    Toast.MakeText(this, "Failed to apply properties", ToastLength.Short).Show();
                }

                // register bar code event listener
                reader.AddBarcodeListener(this as BarcodeReader.IBarcodeListener);

                // register trigger state change listener
                reader.AddTriggerListener(this as BarcodeReader.ITriggerListener);

                reader.Claim();
            }
        }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.ManualBarcode);

            _initiateScanButton = (Button)FindViewById <Button>(Resource.Id.buttonInitiateScan);

            _initiateScanButton.Click += _initiateScanButton_Click;;

            _barcodeReader = MainActivity.BarcodeReader;

            if (_barcodeReader != null)
            {
                // register bar code event listener
                _barcodeReader.AddBarcodeListener(this);

                try
                {
                    _barcodeReader.SetProperty(BarcodeReader.PropertyTriggerControlMode,
                                               BarcodeReader.TriggerControlModeAutoControl);
                }
                catch (UnsupportedPropertyException e)
                {
                    Toast.MakeText(this, "Failed to apply properties", ToastLength.Short).Show();
                }


                _barcodeReader.AddTriggerListener(this);

                IDictionary <String, Java.Lang.Object> properties = new Dictionary <string, Java.Lang.Object>();
                // Set Symbologies On/Off
                properties.Add(BarcodeReader.PropertyCode128Enabled, true);
                properties.Add(BarcodeReader.PropertyGs1128Enabled, true);
                properties.Add(BarcodeReader.PropertyQrCodeEnabled, true);
                properties.Add(BarcodeReader.PropertyCode39Enabled, true);
                properties.Add(BarcodeReader.PropertyDatamatrixEnabled, true);
                properties.Add(BarcodeReader.PropertyUpcAEnable, true);
                properties.Add(BarcodeReader.PropertyEan13Enabled, false);
                properties.Add(BarcodeReader.PropertyAztecEnabled, false);
                properties.Add(BarcodeReader.PropertyCodabarEnabled, false);
                properties.Add(BarcodeReader.PropertyInterleaved25Enabled, false);
                properties.Add(BarcodeReader.PropertyPdf417Enabled, false);
                // Set Max Code 39 barcode length
                properties.Add(BarcodeReader.PropertyCode39MaximumLength, 10);
                // Turn on center decoding
                properties.Add(BarcodeReader.PropertyCenterDecode, true);
                // Disable bad read response, handle in onFailureEvent
                properties.Add(BarcodeReader.PropertyNotificationBadReadEnabled, false);
                // Apply the settings
                _barcodeReader.SetProperties(properties);
            }

            // get initial list
            _barcodeList = (ListView)FindViewById(Resource.Id.listViewBarcodeData);
        }