Ejemplo n.º 1
0
        public void ScanProduct()
        {
            var opt = new MobileBarcodeScanningOptions();

            opt.DelayBetweenContinuousScans = 3000;

            // Reset scanner
            ScanStatus(false);

            scanner.Torch(false);
            torchFab.SetImageDrawable(ContextCompat.GetDrawable(Activity, Resource.Drawable.ic_flash_on_white_24dp));

            // Start scanning
            scanner.ScanContinuously(opt, HandleScanResult);
        }
Ejemplo n.º 2
0
        private async void btn_clicked(object sender, EventArgs e)
        {
            var scanner = new MobileBarcodeScanner();
            var mobileBarcodeScanningOptions = new MobileBarcodeScanningOptions();

            mobileBarcodeScanningOptions.AutoRotate = true;
            scanner.AutoFocus();
            if (!scanner.IsTorchOn)
            {
                scanner.Torch(true);
            }
            scanner.TopText    = "Hold the camera up to  the barcode ";
            scanner.BottomText = "wait for the barcode automatically  scan!";

            ZXing.Result result = await scanner.Scan(mobileBarcodeScanningOptions);

            HandleResult(result);
        }
Ejemplo n.º 3
0
        private async void ScanBarcode(long?burialAppId)
        {
            _scanner = new MobileBarcodeScanner
            {
                TopText          = "Hold the camera up to the barcode\nAbout 6 inches away",
                BottomText       = "Wait for the barcode to automatically scan!",
                CancelButtonText = "Return",
                FlashButtonText  = "Flash"
            };

            var opt = new MobileBarcodeScanningOptions {
                DelayBetweenContinuousScans = 3000
            };

            opt.AutoRotate = true;
            _scanner.Torch(true);
            _scanner.AutoFocus();
            try
            {
                var results = await _scanner.Scan(opt);

                HandleScanResult(results, burialAppId);

                if (_burialOutPut != null)
                {
                    _burialOutPut.SupervisorId = SupervisorId;
                    await Application.Current.MainPage.Navigation.PushAsync(
                        new Undertaker(_burialOutPut, _apiBurial) { Title = _burialOutPut.Cemetery + " Burials" });
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error on scanner Api",
                                                                ex.Message,
                                                                "OK");
            }
        }
Ejemplo n.º 4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            UDID = UIDevice.CurrentDevice.IdentifierForVendor.ToString();

            backBn.TouchUpInside += (s, e) =>
            {
                this.NavigationController.PopViewController(true);
            };

            linkStickerBn.TouchUpInside += async(s, e) =>
            {
                _scanner = new MobileBarcodeScanner();
                var customView = new UIView();
                customView.Frame          = View.Frame;
                _scanner.UseCustomOverlay = true;
                _scanner.CustomOverlay    = customView;

                var bottomView = new UIView {
                    BackgroundColor = UIColor.FromRGB(36, 43, 52)
                };
                customView.AddSubview(bottomView);
                bottomView.Frame = new CGRect(0, customView.Frame.Height - 100, View.Frame.Width, 100);

                var cancelBn = new UIButton();
                cancelBn.SetTitle("Отмена", UIControlState.Normal);
                cancelBn.SetTitleColor(UIColor.White, UIControlState.Normal);
                cancelBn.Font = UIFont.FromName(Constants.fira_sans, 15f);
                bottomView.AddSubview(cancelBn);
                cancelBn.Frame          = new CGRect(0, 0, View.Frame.Width / 3, 60);
                cancelBn.TouchUpInside += (s1, e1) =>
                {
                    _scanner.Cancel();
                };

                var flashBn = new UIButton();
                flashBn.SetTitle("Вспышка", UIControlState.Normal);
                flashBn.SetTitleColor(UIColor.White, UIControlState.Normal);
                flashBn.Font = UIFont.FromName(Constants.fira_sans, 15f);
                bottomView.AddSubview(flashBn);
                flashBn.Frame          = new CGRect(View.Frame.Width - View.Frame.Width / 3, 0, View.Frame.Width / 3, 60);
                flashBn.TouchUpInside += (s1, e1) =>
                {
                    _scanner.Torch(!_scanner.IsTorchOn);
                };

                var shotRectangleIv = new UIImageView();
                var rectangleSide   = View.Frame.Width - View.Frame.Width / 3;
                shotRectangleIv.Frame = new CGRect(View.Frame.Width / 6, (customView.Frame.Height - bottomView.Frame.Height) / 2 - rectangleSide / 2, rectangleSide, rectangleSide);
                shotRectangleIv.Image = UIImage.FromBundle("scanner_rectangle.png");
                customView.AddSubview(shotRectangleIv);

                _optionsCustom            = new MobileBarcodeScanningOptions();
                _optionsCustom.AutoRotate = false;

                await LaunchScanner();
            };

            orderStickerBn.TouchUpInside += (s, e) => OpenOrderLink();

            InitElements();
        }