void InitializeAndStartBarcodeScanning()
        {
            // The scanning behavior of the barcode picker is configured through scan
            // settings. We start with empty scan settings and enable a generous set
            // of 1D symbologies. MatrixScan is currently only supported for 1D
            // symbologies, enabling 2D symbologies will result in unexpected results.
            // In your own apps, only enable the symbologies you actually need.
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable = new int[] {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            foreach (int symbology in symbologiesToEnable)
            {
                settings.SetSymbologyEnabled(symbology, true);
            }

            // Enable MatrixScan and set the max number of barcodes that can be recognized per frame
            // to some reasonable number for your use case. The max number of codes per frame does not
            // limit the number of codes that can be tracked at the same time, it only limits the
            // number of codes that can be newly recognized per frame.
            settings.MatrixScanEnabled        = true;
            settings.MaxNumberOfCodesPerFrame = 10;

            // Prefer the back-facing camera, if there is any.
            settings.CameraFacingPreference = ScanSettings.CameraFacingBack;

            barcodePicker = new BarcodePicker(this, settings);
            barcodePicker.OverlayView.SetGuiStyle(ScanOverlay.GuiStyleMatrixScan);

            // Set the GUI style to MatrixScan to see a visualization of the tracked barcodes. If you
            // would like to visualize it yourself, set it to ScanOverlay.GuiStyleNone and update your
            // visualization in the didProcess() callback.
            barcodePicker.OverlayView.SetGuiStyle(ScanOverlay.GuiStyleMatrixScan);

            // When using MatrixScan vibrating is often not desired.
            barcodePicker.OverlayView.SetVibrateEnabled(false);

            // Register listener, in order to be notified about relevant events
            // (e.g. a successfully scanned bar code).
            barcodePicker.SetOnScanListener(this);

            // Register a process frame listener to be able to reject tracked codes.
            barcodePicker.SetProcessFrameListener(this);

            // Set listener for the scan event.
            barcodePicker.SetOnScanListener(this);

            // Show the scan user interface
            SetContentView(barcodePicker);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <PickerView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                pickerView = e.NewElement;

                e.NewElement.StartScanningRequested += OnStartScanningRequested;
                e.NewElement.PauseScanningRequested += OnPauseScanningRequested;

                barcodePicker = new BarcodePicker(context, CreateScanSettings());
                SetNativeControl(barcodePicker.OverlayView.RootView);
                onScanListener = new PickerOnScanListener
                {
                    PickerView          = pickerView,
                    ContinuousAfterScan = pickerView.Settings.ContinuousAfterScan
                };
                barcodePicker.SetOnScanListener(onScanListener);

                ApplyOverlaySettings();
                barcodePicker.StartScanning();
            }
            if (e.OldElement != null)
            {
                e.OldElement.StartScanningRequested -= OnStartScanningRequested;
                e.OldElement.PauseScanningRequested -= OnPauseScanningRequested;
            }
        }
示例#3
0
        void InitializeAndStartBarcodeScanning()
        {
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable = new int[] {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyDataMatrix,
                Barcode.SymbologyQr,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            foreach (int symbology in symbologiesToEnable)
            {
                settings.SetSymbologyEnabled(symbology, true);
            }

            SymbologySettings symSettings = settings.GetSymbologySettings(Barcode.SymbologyCode128);

            short[] activeSymbolCounts = new short[] {
                7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
            };
            symSettings.SetActiveSymbolCounts(activeSymbolCounts);
            barcodePicker = new BarcodePicker(this, settings);
            barcodePicker.SetOnScanListener(this);
            SetContentView(barcodePicker);
        }
        void InitializeBarcodeScanning()
        {
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable =
            {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            ScanAreaSettings scanAreaSettings = new ScanAreaSettings();

            scanAreaSettings.SquareCodeLocationConstraint = BarcodeScannerSettings.CodeLocationRestrict;
            scanAreaSettings.WideCodeLocationConstraint   = BarcodeScannerSettings.CodeLocationRestrict;
            scanAreaSettings.WideCodeLocationArea         = new RectF(0f, 0.475f, 1f, 0.525f);
            scanAreaSettings.SquareCodeLocationArea       = new RectF(0f, 0.3f, 1f, 0.7f);
            settings.AreaSettingsPortrait  = scanAreaSettings;
            settings.AreaSettingsLandscape = scanAreaSettings;
            settings.CodeDuplicateFilter   = 1000;

            foreach (int symbology in symbologiesToEnable)
            {
                settings.SetSymbologyEnabled(symbology, true);
            }

            barcodePicker = new BarcodePicker(this, settings);
            barcodePicker.OverlayView.SetGuiStyle(ScanOverlay.GuiStyleLaser);
            barcodePicker.SetOnScanListener(this);
            (FindViewById(Resource.Id.picker_container) as FrameLayout).AddView(barcodePicker, 0);
        }
示例#5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            // Set the app key before instantiating the picker.
            ScanditLicense.AppKey = appKey;

            // The scanning behavior of the barcode picker is configured through scan
            // settings. We start with empty scan settings and enable a very generous
            // set of symbologies. In your own apps, only enable the symbologies you
            // actually need.
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable = new int[] {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyDataMatrix,
                Barcode.SymbologyQr,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            for (int sym = 0; sym < symbologiesToEnable.Length; sym++)
            {
                settings.SetSymbologyEnabled(symbologiesToEnable[sym], true);
            }

            // Some 1d barcode symbologies allow you to encode variable-length data. By default, the
            // Scandit BarcodeScanner SDK only scans barcodes in a certain length range. If your
            // application requires scanning of one of these symbologies, and the length is falling
            // outside the default range, you may need to adjust the "active symbol counts" for this
            // symbology. This is shown in the following few lines of code.

            SymbologySettings symSettings = settings.GetSymbologySettings(Barcode.SymbologyCode128);

            short[] activeSymbolCounts = new short[] {
                7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
            };
            symSettings.SetActiveSymbolCounts(activeSymbolCounts);
            // For details on defaults and how to calculate the symbol counts for each symbology, take
            // a look at http://docs.scandit.com/stable/c_api/symbologies.html.

            picker = new BarcodePicker(this, settings);

            // Set listener for the scan event.
            picker.SetOnScanListener(this);

            // Show the scan user interface
            SetContentView(picker);
        }
示例#6
0
        void InitializeAndStartBarcodeScanning()
        {
            // The scanning behavior of the barcode picker is configured through scan
            // settings. We start with empty scan settings and enable a very generous
            // set of symbologies. In your own apps, only enable the symbologies you
            // actually need.
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable = new int[] {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyDataMatrix,
                Barcode.SymbologyQr,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            foreach (int symbology in symbologiesToEnable)
            {
                settings.SetSymbologyEnabled(symbology, true);
            }

            // Some 1d barcode symbologies allow you to encode variable-length data. By default, the
            // Scandit BarcodeScanner SDK only scans barcodes in a certain length range. If your
            // application requires scanning of one of these symbologies, and the length is falling
            // outside the default range, you may need to adjust the "active symbol counts" for this
            // symbology. This is shown in the following few lines of code.

            SymbologySettings symSettings = settings.GetSymbologySettings(Barcode.SymbologyCode128);

            short[] activeSymbolCounts = new short[] {
                7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
            };
            symSettings.SetActiveSymbolCounts(activeSymbolCounts);
            // For details on defaults and how to calculate the symbol counts for each symbology, take
            // a look at http://docs.scandit.com/stable/c_api/symbologies.html.

            barcodePicker = new BarcodePicker(this, settings);

            // Set listener for the scan event.
            barcodePicker.SetOnScanListener(this);

            // Show the scan user interface
            SetContentView(barcodePicker);
        }
示例#7
0
        void InitializeBarcodeScanning()
        {
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable =
            {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyUpce,
                Barcode.SymbologyDataMatrix,
                Barcode.SymbologyQr,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5
            };

            foreach (int symbology in symbologiesToEnable)
            {
                settings.SetSymbologyEnabled(symbology, true);
            }

            // Enable and set the restrict active area. This will make sure that codes are only scanned in a very thin band in the center of the image.
            settings.SetActiveScanningArea(ScanSettings.OrientationPortrait, new RectF(0f, 0.48f, 1f, 0.52f));

            // Setup the barcode scanner
            barcodePicker = new BarcodePicker(this, settings);

            // Add listener for the scan event. We keep references to the
            // delegates until the picker is no longer used as the delegates are softly
            // referenced and can be removed because of low memory.
            barcodePicker.SetOnScanListener(this);

            // Modify the GUI style to have a "laser" line instead of a square viewfinder.
            barcodePicker.OverlayView.SetGuiStyle(ScanOverlay.GuiStyleLaser);

            // Start scanning in paused state.
            barcodePicker.StartScanning(true);

            (FindViewById(Resource.Id.picker_container) as FrameLayout).AddView(barcodePicker, 0);

            GrantCameraPermissionsThenStartScanning();
        }
示例#8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
            ScanditLicense.AppKey = appKey;
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable = new int[] {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyDataMatrix,
                Barcode.SymbologyQr,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            for (int sym = 0; sym < symbologiesToEnable.Length; sym++)
            {
                settings.SetSymbologyEnabled(symbologiesToEnable[sym], true);
            }

            SymbologySettings symSettings = settings.GetSymbologySettings(Barcode.SymbologyCode128);

            short[] activeSymbolCounts = new short[] {
                7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
            };
            symSettings.SetActiveSymbolCounts(activeSymbolCounts);
            // For details on defaults and how to calculate the symbol counts for each symbology, take
            // a look at http://docs.scandit.com/stable/c_api/symbologies.html.

            picker = new BarcodePicker(this, settings);
            picker.SetOnScanListener(this);
            SetContentView(picker);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <CustomStackLayout> e)
        {
            base.OnElementChanged(e);

            //var test = this as ViewGroup;

            if (e.NewElement != null)
            {
                // Set the app key before instantiating the picker.
                ScanditLicense.AppKey = appKey;

                // The scanning behavior of the barcode picker is configured through scan
                // settings. We start with empty scan settings and enable a very generous
                // set of symbologies. In your own apps, only enable the symbologies you
                // actually need.
                ScanSettings settings            = ScanSettings.Create();
                int[]        symbologiesToEnable = new int[]
                {
                    Barcode.SymbologyEan13,
                    Barcode.SymbologyEan8,
                    Barcode.SymbologyUpca,
                    Barcode.SymbologyDataMatrix,
                    Barcode.SymbologyQr,
                    Barcode.SymbologyCode39,
                    Barcode.SymbologyCode128,
                    Barcode.SymbologyInterleaved2Of5,
                    Barcode.SymbologyUpce
                };

                for (int sym = 0; sym < symbologiesToEnable.Length; sym++)
                {
                    settings.SetSymbologyEnabled(symbologiesToEnable[sym], true);
                }

                //// Some 1d barcode symbologies allow you to encode variable-length data. By default, the
                //// Scandit BarcodeScanner SDK only scans barcodes in a certain length range. If your
                //// application requires scanning of one of these symbologies, and the length is falling
                //// outside the default range, you may need to adjust the "active symbol counts" for this
                //// symbology. This is shown in the following few lines of code.

                SymbologySettings symSettings        = settings.GetSymbologySettings(Barcode.SymbologyCode128);
                short[]           activeSymbolCounts = new short[]
                {
                    7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
                };
                symSettings.SetActiveSymbolCounts(activeSymbolCounts);
                // For details on defaults and how to calculate the symbol counts for each symbology, take
                // a look at http://docs.scandit.com/stable/c_api/symbologies.html.

                picker = new BarcodePicker(this.Context, settings);

                picker.OverlayView.SetViewfinderDimension(0.5f, 0.9f, 0.5f, 0.9f);
                picker.OverlayView.SetTorchEnabled(false);


                // Set listener for the scan event.
                picker.SetOnScanListener(this);

                picker.StartScanning();

                //picker.Scan += (sender, args) =>
                //{

                //};

                AddView(picker);

                //SetNativeControl(picker);
            }
        }