// In the status dictionary: // "FoundBarcodes" key is a NSSet of all discovered barcodes this scan session // "NewFoundBarcodes" is a NSSet of barcodes discovered in the most recent pass. // When a barcode is found, it is added to both sets. The NewFoundBarcodes // set is cleaned out each pass. // "Guidance" can be used to help guide the user through the process of discovering // a long barcode in sections. Currently only works for Code 39. // "Valid" is TRUE once there are valid barcode results. // "InRange" is TRUE if there's currently a barcode detected the viewfinder. The barcode // may not have been decoded yet. public override void StatusUpdated(BarcodePickerController picker, NSDictionary status) { NSNumber isValid = (NSNumber) status.ObjectForKey (new NSString ("Valid")); NSNumber inRange = (NSNumber) status.ObjectForKey (new NSString ("InRange")); SetArrows (inRange.BoolValue, true); if (isValid.BoolValue) { BeepOrVibrate (); ParentPicker.DoneScanning (); } NSNumber guidanceLevel = (NSNumber) status.ObjectForKey (new NSString ("Guidance")); if (guidanceLevel != null) { if (guidanceLevel.IntValue == 1) { textCue.Text = "Try moving the camera close to each part of the barcode"; } else if (guidanceLevel.IntValue == 2) { textCue.Text = (NSString) status.ObjectForKey (new NSString ("PartialBarcode")); } else { textCue.Text = ""; } } }
partial void scanPressed(MonoTouch.UIKit.UIBarButtonItem sender) { if (overlayController.ParentPicker == null) { BarcodePickerController picker = new BarcodePickerController (); // setup picker picker.Overlay = overlayController; picker.Delegate = new BarcodePickerDelegate (this); // Initialize with portrait mode as default picker.Orientation = UIImageOrientation.Up; // The active scanning region size is set in OverlayController.m } // Update barcode on/off settings overlayController.ParentPicker.ScanUPCE = enableUPCESwitch.On; overlayController.ParentPicker.ScanEAN8 = enableEAN8Switch.On; overlayController.ParentPicker.ScanEAN13 = enableEAN13Switch.On; overlayController.ParentPicker.ScanQRCODE = enableQRCodeSwitch.On; overlayController.ParentPicker.ScanCODE128 = enableCode128Switch.On; overlayController.ParentPicker.ScanCODE39 = enableCode39Switch.On; //overlayController.parentPicker.ScanDataMatrix = enableDataMatrixSwitch.On; overlayController.ParentPicker.ScanITF = enableITFSwitch.On; // Data matrix decoding does not work very well so it is disabled for now overlayController.ParentPicker.ScanDATAMATRIX = false; // hide the status bar UIApplication.SharedApplication.StatusBarHidden = true; // Show the scanner overlay this.PresentModalViewController (overlayController.ParentPicker, true); }
// In the status dictionary: // "FoundBarcodes" key is a NSSet of all discovered barcodes this scan session // "NewFoundBarcodes" is a NSSet of barcodes discovered in the most recent pass. // When a barcode is found, it is added to both sets. The NewFoundBarcodes // set is cleaned out each pass. // "Guidance" can be used to help guide the user through the process of discovering // a long barcode in sections. Currently only works for Code 39. // "Valid" is TRUE once there are valid barcode results. // "InRange" is TRUE if there's currently a barcode detected the viewfinder. The barcode // may not have been decoded yet. public override void StatusUpdated(BarcodePickerController picker, NSDictionary status) { NSNumber isValid = (NSNumber)status.ObjectForKey(new NSString("Valid")); NSNumber inRange = (NSNumber)status.ObjectForKey(new NSString("InRange")); SetArrows(inRange.BoolValue, true); if (isValid.BoolValue) { BeepOrVibrate(); ParentPicker.DoneScanning(); } NSNumber guidanceLevel = (NSNumber)status.ObjectForKey(new NSString("Guidance")); if (guidanceLevel != null) { if (guidanceLevel.IntValue == 1) { textCue.Text = "Try moving the camera close to each part of the barcode"; } else if (guidanceLevel.IntValue == 2) { textCue.Text = (NSString)status.ObjectForKey(new NSString("PartialBarcode")); } else { textCue.Text = ""; } } }
partial void scanPressed(MonoTouch.UIKit.UIBarButtonItem sender) { if (overlayController.ParentPicker == null) { BarcodePickerController picker = new BarcodePickerController(); // setup picker picker.Overlay = overlayController; picker.Delegate = new BarcodePickerDelegate(this); // Initialize with portrait mode as default picker.Orientation = UIImageOrientation.Up; // The active scanning region size is set in OverlayController.m } // Update barcode on/off settings overlayController.ParentPicker.ScanUPCE = enableUPCESwitch.On; overlayController.ParentPicker.ScanEAN8 = enableEAN8Switch.On; overlayController.ParentPicker.ScanEAN13 = enableEAN13Switch.On; overlayController.ParentPicker.ScanQRCODE = enableQRCodeSwitch.On; overlayController.ParentPicker.ScanCODE128 = enableCode128Switch.On; overlayController.ParentPicker.ScanCODE39 = enableCode39Switch.On; //overlayController.parentPicker.ScanDataMatrix = enableDataMatrixSwitch.On; overlayController.ParentPicker.ScanITF = enableITFSwitch.On; // Data matrix decoding does not work very well so it is disabled for now overlayController.ParentPicker.ScanDATAMATRIX = false; // hide the status bar UIApplication.SharedApplication.StatusBarHidden = true; // Show the scanner overlay this.PresentModalViewController(overlayController.ParentPicker, true); }
// New method (as 3.0.0), returns multiple barcode scan results public override void ReturnResults(BarcodePickerController picker, NSSet results) { UIApplication.SharedApplication.StatusBarHidden = false; // Restore main screen (and restore title bar for 3.0) controller.DismissModalViewControllerAnimated(true); // Note that it is possible to get multiple results discovered at the same time. // Even if you return as soon as you see result barcodes, there could be more than one. var foundCode = (results.AnyObject as BarcodeResult); if (foundCode != null) { controller.BarcodeScannedResult(foundCode); } }
// New method (as 3.0.0), returns multiple barcode scan results public override void ReturnResults(BarcodePickerController picker, NSSet results) { UIApplication.SharedApplication.StatusBarHidden = false; // Restore main screen (and restore title bar for 3.0) controller.DismissModalViewControllerAnimated (true); // Note that it is possible to get multiple results discovered at the same time. // Even if you return as soon as you see result barcodes, there could be more than one. var foundCode = (results.AnyObject as BarcodeResult); if (foundCode != null) { controller.BarcodeScannedResult (foundCode); } }