public override void ViewDidLoad() { base.ViewDidLoad(); // 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.DefaultSettings(); NSSet symbologiesToEnable = new NSSet( Symbology.EAN13, Symbology.EAN8, Symbology.UPC12, Symbology.UPCE, Symbology.Datamatrix, Symbology.QR, Symbology.Code39, Symbology.Code128, Symbology.ITF ); settings.EnableSymbologies(symbologiesToEnable); // 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(new CoreGraphics.CGRect(0, 0.48, 1, 0.04)); // Setup the barcode scanner picker = new BarcodePicker(settings); picker.OverlayView.ShowToolBar(false); // Add delegate 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. scanDelegate = new PickerScanDelegate(); picker.ScanDelegate = scanDelegate; AddChildViewController(picker); picker.View.Frame = View.Bounds; Add(picker.View); picker.DidMoveToParentViewController(this); // Modify the GUI style to have a "laser" line instead of a square viewfinder. picker.OverlayView.GuiStyle = GuiStyle.Laser; // Start scanning in paused state. picker.StartScanning(true); showAimAndScanButton(); }
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(); }