async void ScanClicked(object sender, EventArgs eventArgs) { //Navigation.PushAsync(new Search.BookSearchPage("4121024109")); var scanner = new ZXing.Mobile.MobileBarcodeScanner(); scanner.CancelButtonText = "キャンセル"; scanner.FlashButtonText = "フラッシュ"; scanner.AutoFocus(); var options = new ZXing.Mobile.MobileBarcodeScanningOptions(); var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Camera); if (status == Plugin.Permissions.Abstractions.PermissionStatus.Granted) { var result = await scanner.Scan(options); if (result != null) { await Navigation.PushAsync(new Search.BookSearchPage(result.Text)); } } else { await DisplayAlert("エラー", "カメラを使用できません", "了解"); } }
async void BtnScann_Clicked(object sender, System.EventArgs e) { try { bool scanned = true; var scanner = new ZXing.Mobile.MobileBarcodeScanner(); Device.StartTimer(TimeSpan.FromSeconds(3), () => { scanner.AutoFocus(); return(scanned); }); var result = await scanner.Scan(); Device.BeginInvokeOnMainThread(() => { scanned = false; if (result != null) { var text = result.Text; (ViewModel as RentViewModel).SearchByBarcodeCommand.Execute(text); } }); } catch (Exception ex) { // Handle exception } }
public override void ViewDidLoad() { base.ViewDidLoad(); var submitButton = UIButton.FromType(UIButtonType.RoundedRect); nfloat h = 31.0f; nfloat w = View.Bounds.Width; submitButton.Frame = new CGRect(10, 170, w - 20, 44); submitButton.SetTitle("Сканировать QRCOde", UIControlState.Normal); submitButton.TouchUpInside += async(sender, e) => { var scanner = new ZXing.Mobile.MobileBarcodeScanner(this); //scanner.TopText = "Hold camera up to barcode to scan"; //scanner.BottomText = "Barcode will automatically scan"; //scanner.UseCustomOverlay = false; scanner.FlashButtonText = "Подсветка"; scanner.CancelButtonText = "Выход"; scanner.Torch(true); scanner.AutoFocus(); //scanner.opt var result = await scanner.Scan(true); HandleScanResult(result); //var customScanPage = new ScannerBarcodeView(); //var page = new NavigationPage(); ////this.NavigationController.PushViewController(customScanPage, true); //await NavigationPage.PushAsync(customScanPage); //// Console.WriteLine("Submit button pressed"); }; View.AddSubview(submitButton); //try //{ //var l_srv = new IOSTestApp.WebReference.Service1(); //bool val = true; //this.txtFIO.Text = l_srv.GetData(10, val); // // Perform any additional setup after loading the view, typically from a nib. //} //catch (Exception ex) //{ // throw new Exception(ex.Message); //} }
async void ButtonBarCodeReader_Clicked(object sender, EventArgs e) { Console.WriteLine("Button Barcode!"); //SearchOn(); //var option = new ZXing.Mobile.MobileBarcodeScanningOptions(); //option.DelayBetweenContinuousScans = 3000; //option.PureBarcode = true; //await scanner.Scan(option, true); //Configuracion de formatos soportados por el lector var options = new ZXing.Mobile.MobileBarcodeScanningOptions(); options.PossibleFormats = new List <ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.EAN_8, ZXing.BarcodeFormat.EAN_13, ZXing.BarcodeFormat.CODE_128, ZXing.BarcodeFormat.QR_CODE, ZXing.BarcodeFormat.CODE_39 }; var scanner = new ZXing.Mobile.MobileBarcodeScanner(); scanner.FlashButtonText = "Flash"; scanner.TopText = "Manten la camara sobre el código QR/Barras"; scanner.BottomText = "Espera a que la camara lea automaticamente el código"; scanner.AutoFocus(); var result = await scanner.Scan(options, true); if (result != null) { Console.WriteLine("Scaned Barcode " + result.Text); searchBarItems.Text = result.Text.ToLower().Trim();// SearchOn(searchBarItems.Text); } }
protected async void SetUpScanner(Label labelToSet, ZXing.BarcodeFormat expectedFormat, string topText) { var scanner = new ZXing.Mobile.MobileBarcodeScanner { TopText = topText,//"Scan Asset Id Code", CancelButtonText = "Exit" }; var opts = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { expectedFormat } }; try { scanner.AutoFocus(); var result = await scanner.Scan(opts); scanner.CameraUnsupportedMessage = "camera Unsupported"; if (result != null) { labelToSet.Text = result.ToString(); labelToSet.TextColor = Color.Gray; scanner.Cancel(); } else { scanner.Cancel(); } }catch (Exception e) { await DisplayAlert(Constants.ERROR_TITLE, e.Message, Constants.BUTTON_POS); scanner.Cancel(); }finally { scanner.Cancel(); } }
public override void ViewDidLoad() { try { txtVin.ShouldChangeCharacters = (textField, range, replacementString) => { var newLength = textField.Text.Length + replacementString.Length - range.Length; return(newLength <= 17); }; txtPhone.ShouldChangeCharacters = (textField, range, replacementString) => { var newLength = textField.Text.Length + replacementString.Length - range.Length; return(newLength <= 10); }; txtMileage.ShouldChangeCharacters = (textField, range, replacementString) => { var newLength = textField.Text.Length + replacementString.Length - range.Length; return(newLength <= 6); }; txtVin.AutocapitalizationType = UITextAutocapitalizationType.AllCharacters; txtVin.ShouldReturn = (tf) => { //txtMileage.SecureTextEntry = true; txtMileage.ReturnKeyType = UIReturnKeyType.Next; txtMileage.BecomeFirstResponder(); return(true); }; txtMileage.ShouldReturn = (tf) => { //txtFirstName.SecureTextEntry = true; txtFirstName.ReturnKeyType = UIReturnKeyType.Next; txtFirstName.BecomeFirstResponder(); return(true); }; txtFirstName.ShouldReturn = (tf) => { txtLastName.ReturnKeyType = UIReturnKeyType.Next; txtLastName.BecomeFirstResponder(); return(true); }; txtLastName.ShouldReturn = (tf) => { txtEmail.ReturnKeyType = UIReturnKeyType.Next; txtEmail.BecomeFirstResponder(); return(true); }; txtEmail.ShouldReturn = (tf) => { txtPhone.ReturnKeyType = UIReturnKeyType.Done; txtPhone.BecomeFirstResponder(); return(true); }; txtPhone.ShouldReturn = (tf) => { txtPhone.EndEditing(true); DoneDecodeVin(); return(true); }; if (AppDelegate.appDelegate.CustomerLogin) { if (!string.IsNullOrEmpty(AppDelegate.appDelegate.GuestLastName)) { txtLastName.Text = AppDelegate.appDelegate.GuestLastName; } if (!string.IsNullOrEmpty(AppDelegate.appDelegate.GuestEmail)) { txtEmail.Text = AppDelegate.appDelegate.GuestEmail; txtPhone.Placeholder = ""; } if (!string.IsNullOrEmpty(AppDelegate.appDelegate.GuestPhone)) { txtPhone.Text = AppDelegate.appDelegate.GuestPhone; txtEmail.Placeholder = ""; } } // hide keyboard on touch outside area var g = new UITapGestureRecognizer(() => View.EndEditing(true)); g.CancelsTouchesInView = false; //for iOS5 View.AddGestureRecognizer(g); base.ViewDidLoad(); AppDelegate.appDelegate.photoAcesss = false; // Perform any additional setup after loading the view, typically from a nib. if (this.btnScan != null) { this.btnScan.TouchUpInside += async(sender, e) => { scanner = new ZXing.Mobile.MobileBarcodeScanner(this); scanner.UseCustomOverlay = false; scanner.TopText = "Hold camera up to barcode to scan"; scanner.BottomText = "Barcode will automatically scan"; //scanner.FlashButtonText = "Flash"; scanner.CancelButtonText = "Cancel"; //scanner.Torch(true); scanner.AutoFocus(); var result = await scanner.Scan(true); HandleScanResult(result); }; } } catch (Exception exc) { System.Diagnostics.Debug.WriteLine("Exception :: " + exc.Message); } }