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 RotationSettingAwareBarcodePicker(CreateScanSettings()); SetNativeControl(barcodePicker.View); scanDelegate = new PickerScanDelegate { PickerView = pickerView, ContinuousAfterScan = pickerView.Settings.ContinuousAfterScan }; barcodePicker.ScanDelegate = scanDelegate; ApplyOverlaySettings(); barcodePicker.StartScanning(); } if (e.OldElement != null) { e.OldElement.StartScanningRequested -= OnStartScanningRequested; e.OldElement.PauseScanningRequested -= OnPauseScanningRequested; } }
partial void scanButtonClicked(Foundation.NSObject sender) { // 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); // 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 3 lines of code. NSMutableSet codeLengths = new NSMutableSet(); int i = 0; for (i = 7; i <= 20; i++) { codeLengths.Add(new NSNumber(i)); } settings.SettingsForSymbology(Symbology.Code128).ActiveSymbolCounts = codeLengths; // 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. // Setup the barcode scanner BarcodePicker picker = new BarcodePicker(settings); picker.OverlayView.ShowToolBar(true); // Add delegates for the scan and cancel 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; cancelDelegate = new OverlayCancelDelegate(this, picker); picker.OverlayView.CancelDelegate = cancelDelegate; PresentViewController(picker, true, null); picker.StartScanning(); }
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 generous set // of 1D symbologies. Matrix scan 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.DefaultSettings(); NSSet symbologiesToEnable = new NSSet( Symbology.EAN13, Symbology.EAN8, Symbology.UPC12, Symbology.UPCE, Symbology.Code39, Symbology.Code128, Symbology.ITF ); // Enable matrix scan 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.EnableSymbologies(symbologiesToEnable); settings.MatrixScanEnabled = true; settings.MaxNumberOfCodesPerFrame = 10; settings.HighDensityModeEnabled = true; // When matrix scan is enabled beeping/vibrating is often not wanted. BarcodePicker picker = new BarcodePicker(settings); picker.OverlayView.SetBeepEnabled(false); picker.OverlayView.SetVibrateEnabled(false); // Register a SBSScanDelegate delegate, in order to be notified about relevant events // (e.g. a successfully scanned bar code). scanDelegate = new PickerScanDelegate(); picker.ScanDelegate = scanDelegate; // Register a SBSProcessFrameDelegate delegate to be able to reject tracked codes. processFrameDelegate = new PickerProcessFrameDelegate(); picker.ProcessFrameDelegate = processFrameDelegate; AddChildViewController(picker); picker.View.Frame = View.Bounds; Add(picker.View); picker.DidMoveToParentViewController(this); picker.OverlayView.GuiStyle = GuiStyle.MatrixScan; picker.StartScanning(); }
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(); }