Esempio n. 1
0
        private async void CmdSearchBarcode_Clicked(object sender, EventArgs e)
        {
            if (!SettingsRepository.GetSettings().ContinuesBarcode)
            {
                scanPage = new ZXingScannerPage();

                scanPage.OnScanResult += result =>
                {
                    scanPage.IsScanning = false;

                    Navigation.PopModalAsync();

                    vm.SearchBarcode = result.Text;
                    vm.ExecuteSelectItemByBarCode();
                    vm.ExecuteRefreshSelectedSale(new object());
                };

                await Navigation.PushModalAsync(scanPage);

                vm.IsBarcodeModalShown = true;
            }
            else
            {
                scanPage = new ZXingScannerPage(new MobileBarcodeScanningOptions
                {
                    DelayBetweenContinuousScans = 1000
                });

                scanPage.OnScanResult += result =>
                {
                    Device.BeginInvokeOnMainThread(async() =>
                                                   await Application.Current.MainPage.DisplayAlert("Scanned Barcode", result.Text, "OK"));

                    System.Threading.Thread.Sleep(1000);

                    vm.SearchBarcode = result.Text;
                    vm.ExecuteSelectItemByContinuesBarCode();
                    vm.ExecuteRefreshSelectedSale(new object());
                };

                await Navigation.PushModalAsync(scanPage);

                vm.IsBarcodeModalShown = true;
            }
        }