public override void DidScan(BarcodePicker picker, IScanSession session) { if (session.NewlyRecognizedCodes.Count > 0) { if (!ContinuousAfterScan) { // Stop the scanner directly on the session. session.PauseScanning(); } // If you want to edit something in the view hierarchy make sure to run it on the UI thread. UIApplication.SharedApplication.InvokeOnMainThread(() => { var symbologies = ""; var data = ""; foreach (var code in session.NewlyRecognizedCodes) { var separator = symbologies.Length == 0 ? "" : ", "; symbologies += separator + code.SymbologyString; data += separator + code.Data; } PickerView.DidScan(symbologies, data); }); } }
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); }
public override void DidScan(BarcodePicker picker, IScanSession session) { if (session.NewlyRecognizedCodes.Count > 0) { Barcode code = session.NewlyRecognizedCodes.GetItem <Barcode> (0); Console.WriteLine("barcode scanned: {0}, '{1}'", code.SymbologyString, code.Data); // Stop the scanner directly on the session. session.StopScanning(); // If you want to edit something in the view hierarchy make sure to run it on the UI thread. UIApplication.SharedApplication.InvokeOnMainThread(() => { UIAlertView alert = new UIAlertView() { Title = code.SymbologyString + " Barcode Detected", Message = "" + code.Data }; alert.AddButton("OK"); alert.Clicked += (object o, UIButtonEventArgs e) => { picker.StartScanning(); }; alert.Show(); }); } }
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; } }
protected void InitializePicker() { if (picker == null) { picker = new BarcodePicker(Context, GetScanSettings()); } }
protected void UpdateScanUi(BarcodePicker picker) { InitializePicker(); picker.OverlayView.SetGuiStyle(ScanOverlay.GuiStyleNone); picker.OverlayView.SetTorchEnabled(false); picker.OverlayView.SetViewfinderDimension(0.9f, 0.75f, 0.95f, 0.9f); }
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); }
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(); }
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); }
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 MatrixScanOverlayListener(Context context, Action <TrackedBarcode> bubbleClickAction, BarcodePicker picker) { this.context = context; this.bubbleClickAction = bubbleClickAction; this.picker = picker; var size = new Point(); (context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>()) .DefaultDisplay.GetSize(size); screenWidth = size.X; bubbleFactory = new IndicatorViewModelFactory(context); }
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 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); }
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(); }
public override void DidCaptureImage(BarcodePicker picker, CMSampleBuffer frame, IScanSession session) { if (session.TrackedCodes != null) { // For each tracked codes in the last processed frame. foreach (TrackedBarcode code in session.TrackedCodes.Values) { // As an example, let's visually reject all EAN8 codes. if (code.Symbology == Symbology.EAN8) { session.RejectTrackedCode(code); } } // If you want to implement your own visualization of the code matrix scan, // you should update it in this callback. } frame.Dispose(); }
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); }
public override void ViewDidLoad() { base.ViewDidLoad(); contatinerView = new UIView(CGRect.Empty); View.AddSubview(contatinerView); freezeButton = new UIButton(CGRect.Empty); freezeButton.SetTitle("Freeze", UIControlState.Normal); freezeButton.SetBackgroundImage(UIImageExtensions.Brand.GetImage(), UIControlState.Normal); freezeButton.TouchUpInside += (sender, e) => { var scanning = picker.IsScanning(); if (scanning) { matrixScanHandler.Enabled = false; picker.PauseScanning(); freezeButton.SetTitle("Done", UIControlState.Normal); } else { matrixScanHandler.RemoveAllAugmentations(); matrixScanHandler.Enabled = true; picker.StartScanning(); freezeButton.SetTitle("Freeze", UIControlState.Normal); } }; View.AddSubview(freezeButton); freezeButton.TranslatesAutoresizingMaskIntoConstraints = false; contatinerView.TranslatesAutoresizingMaskIntoConstraints = false; View.AddConstraints(new[] { contatinerView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), contatinerView.TopAnchor.ConstraintEqualTo(View.TopAnchor), contatinerView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), contatinerView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor), freezeButton.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor, 20), freezeButton.BottomAnchor.ConstraintEqualTo(View.BottomAnchor, -20), freezeButton.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor, -20), freezeButton.HeightAnchor.ConstraintEqualTo(60) }); var settings = ScanSettings.DefaultSettings(); settings.SetSymbologyEnabled(Symbology.EAN13, true); settings.MatrixScanEnabled = true; settings.MaxNumberOfCodesPerFrame = 15; settings.HighDensityModeEnabled = true; picker = new BarcodePicker(settings); picker.OverlayView.GuiStyle = GuiStyle.None; matrixScanHandler = new MatrixScanHandler(picker); matrixScanHandler.ShouldReject += (matrixScanHandler, trackedBarcode) => false; // This delegate method is called every time a new frame has been processed. // In this case we use it to update the offset of the augmentation. matrixScanHandler.DidProcess += (sender, e) => { DispatchQueue.MainQueue.DispatchAsync(() => { foreach (var item in e.Frame.TrackedCodes) { var offset = GetYOffSet(item.Value as TrackedBarcode); viewBasedMatrixScanOverlay.SetOffset(offset, item.Key as NSNumber); } }); }; viewBasedMatrixScanOverlay = new ViewBasedMatrixScanOverlay(); // This method is called every time a new barcode has been tracked. // You can implement this method to return the offset that will be used to position the augmentation // with respect to the center of the tracked barcode. viewBasedMatrixScanOverlay.OffsetForOverlay += (overlay, barcode, identifier) => GetYOffSet(barcode); // This delegate method is called every time a new barcode has been tracked. // You can implement this method to return the view that will be used as the augmentation. viewBasedMatrixScanOverlay.ViewForOverlay += (overlay, barcode, identifier) => { if (barcode.Data == null) { return(new UIView(CGRect.Empty)); } var view = new StockView(new CGRect(0, 0, StockView.StandardWidth, StockView.StandardHeight)); var model = Model.MockedModel(barcode.Data); view.AddGestureRecognizer(new UITapGestureRecognizer(() => { var overlayViewController = new OverlayViewController { Model = model, ModalTransitionStyle = UIModalTransitionStyle.CoverVertical, ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext }; PresentViewController(overlayViewController, false, null); })); view.Model = model; return(view); }; // Add a ViewBasedMatrixScanOverlay in order to have custom UIView instances as augmentations. matrixScanHandler.AddOverlay(viewBasedMatrixScanOverlay); simpleMatrixScanOverlay = new SimpleMatrixScanOverlay(); // This method is called every time a new barcode has been tracked. // You can implement this method to customize the color of the highlight. simpleMatrixScanOverlay.ColorForOverlay += (overlay, barcode, identifier) => Model.MockedColor(barcode.Data); // Add a SimpleMatrixScanOverlay in order to highlight the barcodes. matrixScanHandler.AddOverlay(simpleMatrixScanOverlay); AddChildViewController(picker); picker.View.Frame = contatinerView.Frame; picker.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; contatinerView.AddSubview(picker.View); picker.DidMoveToParentViewController(this); picker.StartScanning(); }
public override void DidScan(BarcodePicker picker, IScanSession session) { // This delegate method acts the same as when not in matrix scan and can be used for the events such as // when a code is newly recognized. Rejecting tracked codes has to be done in barcodePicker(_:didProcessFrame:session:). }
public OverlayCancelDelegate(UIViewController controller, BarcodePicker picker) { presentingViewController = controller; this.picker = picker; }
/// <summary> /// On element changed event /// </summary> /// <param name="e"></param> protected override void OnElementChanged(ElementChangedEventArgs <ScandItCamera> e) { base.OnElementChanged(e); //assign new elemnt value to scanned it camera _scanedItCamera = e.NewElement; if (Control == null) { try { var scanLicense = new ScanditLicense(); scanLicense.AppKey = ScanditAppKey; ScanSettings scanSettings = ScanSettings.DefaultSettings(); //set code duplication filter if (_scanedItCamera.AllowDuplicate) { scanSettings.CodeDuplicateFilter = 1500; //1.5 sec delay for duplication scanning } else { scanSettings.CodeDuplicateFilter = -1; } //Bar code symbologies scanSettings.SetSymbologyEnabled(Symbology.EAN13, true); scanSettings.SetSymbologyEnabled(Symbology.QR, true); scanSettings.SetSymbologyEnabled(Symbology.UPC12, true); scanSettings.SetSymbologyEnabled(Symbology.Code128, true); scanSettings.SetSymbologyEnabled(Symbology.Code39, true); scanSettings.SetSymbologyEnabled(Symbology.EAN8, true); //update code 128 settings var code128Settings = scanSettings.SettingsForSymbology(Symbology.Code128); var countArray = NSArray.FromObjects(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40); code128Settings.ActiveSymbolCounts = new NSSet(countArray); //apply scan settings _picker = new BarcodePicker(scanSettings); _picker.OverlayView.SetBeepEnabled(true); _picker.OverlayView.SetVibrateEnabled(true); _picker.OverlayView.SetCameraSwitchVisibility(CameraSwitchVisibility.Never); _picker.OverlayView.GuiStyle = GuiStyle.None; //to set picker gui style if (_scanedItCamera.ShowFocus) { _picker.OverlayView.GuiStyle = GuiStyle.Default; } else { _picker.OverlayView.GuiStyle = GuiStyle.None; } _picker.DidScan += DidScan; //set native control as picker view SetNativeControl(_picker.View); //enable action for start and stop scanning if (_scanedItCamera != null) { _scanedItCamera.StartScanning = StartScanning; _scanedItCamera.StopScanning = StopScanning; } } catch (Exception ex) { Debug.WriteLine(ex); } } }
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); } }