public async Task<string> ScanAsync() { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var scanResults = await scanner.Scan(); return scanResults.Text; }
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 } }
private async void GetScan(object s, object e) { ZXing.Mobile.MobileBarcodeScanner scanner = new ZXing.Mobile.MobileBarcodeScanner(); ZXing.Result result = await scanner.Scan(); if (result == null) { return; } Console.WriteLine("Scanned Barcode: " + result.Text); NSUrlComponents comps = NSUrlComponents.FromString(result.Text); if (comps != null && comps.QueryItems != null) { foreach (NSUrlQueryItem queryItem in comps.QueryItems) { if (queryItem.Name == "code") { var suppress = GetAndOpenActivity(queryItem.Value); return; } } } AppUtils.ShowSimpleDialog(this, "Not found", "Are you sure that was a valid OurPlace QR code?", "Got it"); }
public async Task ScanProofRequest() { var expectedFormat = ZXing.BarcodeFormat.QR_CODE; var opts = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { expectedFormat } }; var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(opts); if (result == null) { return; } RequestPresentationMessage presentationMessage; try { presentationMessage = await MessageDecoder.ParseMessageAsync(result.Text) as RequestPresentationMessage ?? throw new Exception("Unknown message type"); } catch (Exception) { DialogService.Alert("Invalid Proof Request!"); return; } if (presentationMessage == null) { return; } try { var request = presentationMessage.Requests?.FirstOrDefault((Attachment x) => x.Id == "libindy-request-presentation-0"); if (request == null) { DialogService.Alert("scanned qr code does not look like a proof request", "Error"); return; } var proofRequest = request.Data.Base64.GetBytesFromBase64().GetUTF8String().ToObject <ProofRequest>(); if (proofRequest == null) { return; } var proofRequestViewModel = _scope.Resolve <ProofRequestViewModel>(new NamedParameter("proofRequest", proofRequest), new NamedParameter("requestPresentationMessage", presentationMessage)); await NavigationService.NavigateToAsync(proofRequestViewModel); } catch (Exception xx) { DialogService.Alert(xx.Message); } }
bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType) { // If the URL is not our own custom scheme, just let the webView load the URL as usual var scheme = "app:"; if (request.Url.Scheme != scheme.Replace(":", "")) return true; var resources = request.Url.ResourceSpecifier.Split('?'); var method = resources[0]; if (method == "QR") { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); scanner.Scan().ContinueWith(result => { if (result != null){ var code = result.Result.Text; this.InvokeOnMainThread(new NSAction(() => webView.LoadRequest(new NSUrlRequest(new NSUrl(MainUrl + "code?value=" + code))))); } }); } return false; }
public async Task <BarcodeScanReturn> StartBarcodeScanner() { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); try { string[] Results = result.ToString().Split('*'); Console.WriteLine("Returned Data " + Results[1]); string Contra = (string)ViewController.MakeRequest3("data", Results[1]); string Name = Contra.GetStringOut("lastfirst"); string Email1 = Contra.GetStringOut("guardianemail"); string Email2 = Contra.GetStringOut("guardianemail_2"); string Email3 = Contra.GetStringOut("stud_email"); BarcodeScanReturn Student = new BarcodeScanReturn(Name, Results[1], Email1, Email2, Email3); AllReturned.Add(Student); return(Student); } catch { string[] Results = result.ToString().Split(' '); BarcodeScanReturn Staff = new BarcodeScanReturn((Results[2] + ", " + Results[1]), "", null, null, null); AllReturned.Add(Staff); return(Staff); } }
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("エラー", "カメラを使用できません", "了解"); } }
private async void ScanConfirmation() { try { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(this, ZXing.Mobile.MobileBarcodeScanningOptions.Default); if (result != null) { _onScanConfirmation.Invoke(this, Newtonsoft.Json.JsonConvert.DeserializeObject <Confirmation>(result.Text)); } } catch (Exception e) { new AlertDialog.Builder(this) .SetMessage("Pøi skenování došlo k chybì: " + e.Message) .SetNeutralButton("Ok", (o, ev) => { SetResult(Android.App.Result.Canceled); Finish(); }) .Create() .Show(); } }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.menu_add: _IsContactNew = true; CreateDialog(); _dialog.Show(); break; case Resource.Id.menu_contacts: AddContactFromPhone(); break; case Resource.Id.menu_qr: var scanner = new ZXing.Mobile.MobileBarcodeScanner(); RunOnUiThread(async() => { var result = await scanner.Scan(); if (!string.IsNullOrEmpty(result?.Text)) { SetUpAndShowAlert(result.Text); } }); break; default: break; } return(base.OnOptionsItemSelected(item)); }
public override async void OnLoadResource(WebView view, string url) { // If the URL is not our own custom scheme, just let the webView load the URL as usual var scheme = "hybrid:"; //if (!url.StartsWith(scheme)) // return false; if (url.EndsWith("Scanner")) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(view.Context, new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { ZXing.BarcodeFormat.QR_CODE } }); if (result != null) { Console.WriteLine("Scanned Barcode: " + result.Text); scanner.Cancel(); // TODO System.Net.WebClient client = new System.Net.WebClient(); var response = client.UploadString("https://idcoin.howell.no/Bank/Authenticated", result.Text); // - POST request to /Bank/AuthenticateOrWhatever with the keywords in the QR // - Navigate to /Authenticator/Success view.LoadUrl("https://idcoin.howell.no/Authenticator/Success"); } } }
async void scanClicked(object sender, System.EventArgs e) { //MobileBarcodeScanner.Initialize(Application); #if __ANDROID__ // Initialize the scanner first so it can track the current context MobileBarcodeScanner.Initialize(Application); #endif // Initialize the scanner first so it can track the current context //if (Device.RuntimePlatform == Device.Android) // { //ZXing.Mobile.MobileBarcodeScanner.Initialize(Application); //} var scanner = new ZXing.Mobile.MobileBarcodeScanner(); try { var result = await scanner.Scan(); bar.Text = result.Text; } catch { bar.Text = "no result"; } }
async void OnScan_Clicked(object sender, EventArgs eventArgs) { try { ZXing.Mobile.MobileBarcodeScanner scanner = new ZXing.Mobile.MobileBarcodeScanner(); scanner.Torch(true); ZXing.Result result = await scanner.Scan(); if (result != null) { Console.WriteLine("Scanned Barcode: " + result.Text); GoogleBooksService service = new GoogleBooksService(); Book bookResult = await service.GetBookAsync(result.Text); if (bookResult == null) { await DisplayAlert("Could not find Book", "Could not find book. Please check the barcode and try again.", "OK"); } else { this._book.Book = bookResult; } } } catch (Exception ex) { await DisplayAlert("Error Occured", "An Error occured while scanning. Try again later.", "Ok"); Log.Warning("Scanner", ex.Message); throw new Exception(ex.Message, ex); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.FirstView); Button buttonQR = this.FindViewById <Button>(Resource.Id.buttonQR); buttonQR.Click += async delegate { //NOTE: On Android you MUST pass a Context into the Constructor! var scanner = new ZXing.Mobile.MobileBarcodeScanner(this); var result = await scanner.Scan(); if (result != null) { System.Console.WriteLine("Scanned Barcode: " + result.Text); } }; /* * if (IsThereAnAppToTakePictures()) * { * CreateDirectoryForPictures(); * Button button = this.FindViewById<Button>(Resource.Id.button1); * * //Button button = FindViewById<Button>(Resource.Id.myButton); * _imageView = FindViewById<ImageView>(Resource.Id.imageView1); * if (App.bitmap != null) * { * _imageView.SetImageBitmap(App.bitmap); * //App.bitmap = null; * } * button.Click += TakeAPicture; * } */ }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.MyButton); button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; Button btn_Scanner = FindViewById <Button>(Resource.Id.btn_Scanner); btn_Scanner.Click += async(sender, e) => { //NOTE: On Android, you MUST pass a Context into the Constructor! var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) { Console.WriteLine("Scanned Barcode: " + result.Text); } }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); Button buttonScan = FindViewById <Button> (Resource.Id.buttonScan); TextView labelOutput = FindViewById <TextView> (Resource.Id.labelOutput); buttonScan.Click += delegate { var scanner = new ZXing.Mobile.MobileBarcodeScanner(this); scanner.UseCustomOverlay = false; scanner.TopText = "Hold the camera up to the barcode\nAbout 6 inches away"; scanner.BottomText = "Wait for the barcode to automatically scan!\nEvolve 2013"; scanner.Scan().ContinueWith(t => { if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion) { RunOnUiThread(() => labelOutput.Text = t.Result.Text); } }); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.QRCodeView); var txtQRResult = FindViewById <EditText> (Resource.Id.txtQRResult); var btnScan = FindViewById <Button> (Resource.Id.btnScan); btnScan.Click += async(object sender, EventArgs e) => { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) { Console.WriteLine("Scanned Barcode: " + result.Text); RunOnUiThread(() => { txtQRResult.Text = result.Text; }); } }; }
public async Task Navigate() { ZXing.Mobile.MobileBarcodeScanner option = new ZXing.Mobile.MobileBarcodeScanner(); var scanner = new ZXing.Mobile.MobileBarcodeScanningOptions() { TryHarder = true, AutoRotate = false, TryInverted = true, DelayBetweenContinuousScans = 2000, }; ZXingScannerPage scanPage = new ZXingScannerPage(scanner); await Navigation.PushAsync(scanPage); scanPage.OnScanResult += (result) => { scanPage.IsScanning = false; ZXing.BarcodeFormat barcodeFormat = result.BarcodeFormat; string type = barcodeFormat.ToString(); Device.BeginInvokeOnMainThread(() => { Navigation.PopAsync(); DisplayAlert("The Barcode type is : " + type, "The text is : " + result.Text, "OK"); }); }; }
private async Task ScanBarcode() { try { var barcodeScanner = new ZXing.Mobile.MobileBarcodeScanner(this); var barcodeResult = await barcodeScanner.Scan(); if (string.IsNullOrEmpty(barcodeResult.Text)) { return; } var Beers = await barcodeLookupService.SearchForBeer(barcodeResult.Text); if (Beers != null) { } } catch (Exception ex) { Insights.Report(ex); } finally { UserDialogs.Instance.HideLoading(); } }
public async Task<string> ScanAsync() { var scanner = new ZXing.Mobile.MobileBarcodeScanner(App.RootFrame.Dispatcher); var scanResults = await scanner.Scan(); return scanResults.Text; }
public override void ViewDidLoad() { base.ViewDidLoad (); View.BackgroundColor = UIColor.White; var button = UIButton.FromType (UIButtonType.RoundedRect); button.Frame = new System.Drawing.RectangleF (10, 10, 150, 44); button.SetTitle ("Scan Beer", UIControlState.Normal); var label = new UILabel (new System.Drawing.Rectangle (10, 70, 300, 44)); button.TouchUpInside += delegate { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); scanner.Scan().ContinueWith(t => { if (t.Result != null) { try { var foundBeer = Engine.Service.LookupBeerFromScanCode (t.Result.Text); label.Text = foundBeer.Name; } catch (Exception e) { label.Text = "Could not find beer"; } } }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext ()); }; View.Add (button); View.Add (label); }
private async void Scanner_Tapped(object sender, EventArgs e) { try { var options = new ZXing.Mobile.MobileBarcodeScanningOptions() { AutoRotate = false, TryInverted = true, TryHarder = true, }; //options.PossibleFormats = new List<ZXing.BarcodeFormat>() //{ // ZXing.BarcodeFormat.EAN_8, ZXing.BarcodeFormat.EAN_13 //}; var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(options); actLoading.IsRunning = true; HandleResult(result); actLoading.IsRunning = false; } catch (Exception ex) { } }
private async void onQRCodeConnectClicked(object sender, EventArgs e) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var scanResult = await scanner.Scan(); if (scanResult != null && scanResult.Text != "") { var connectInfo = Connection.DecodeBluetoothConnection(scanResult.Text); Guid guid = connectInfo.Guid; IBluetoothDevice bluetoothDevice = DependencyService.Get <IBluetoothManager>().GetBluetoothDevice(connectInfo.DeviceAddress); IConnectionManager connectionManager = DependencyService.Get <IConnectionManager>(); IClientConnection currentConnection = connectionManager.ControllerConnection as IClientConnection; ConnectionEstablishState connectState = ConnectionEstablishState.Failed; IClientConnection connection = DependencyService.Get <IBluetoothManager>().CreateRfcommClientConnection(bluetoothDevice, guid); if (connectionManager.ControllerConnection != null) { bool result = await DisplayAlert("Connect", "Stop Current Connection ?", "Yes", "No"); if (result) { if (currentConnection.ConnectionEstablishState == ConnectionEstablishState.Connecting) { currentConnection.AbortConnecting(); } } } connectionManager.ControllerConnection = connection; connectState = await connection.ConnectAsync(); } }
async private void PerformScanAsync() { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result == null) { return; } if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string fname = Path.Combine(dir, result.Text); if (File.Exists(fname)) { lblInfo.Text = "Чек был добавлен ранее"; return; } using (var streamWriter = new StreamWriter(fname, false)) { streamWriter.WriteLine(result.Text); } lblInfo.Text = "Чек успешно добавлен"; UpdateReceipts(); }
private async void ScanQRCode(object obj) { var options = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { ZXing.BarcodeFormat.QR_CODE } }; var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(options); try { if (result != null) { if (result.Text.StartsWith("http://", StringComparison.InvariantCulture) || result.Text.StartsWith("https://", StringComparison.InvariantCulture)) { Device.OpenUri(new Uri(result.Text)); } } Console.WriteLine("Scanned Barcode: " + result.Text); } catch (Exception ex) { Console.WriteLine(ex); } }
// Función para abrir la página del scanner async void ScanningPage(object sender, EventArgs e) { try { // Se configura el lector de códigos de barras var options = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.CODE_128 }, TryHarder = true, AssumeGS1 = true, AutoRotate = true }; var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(options); if (result != null) { // Capturamos el código de barras string scanResult = result.Text; // Asignamos su valor a la entrada de texto Entry_CodeBars.Text = scanResult; // Verificamos que el código de barras sea válido await VerifyCodeBars(); } } catch (Exception ex) { await DisplayAlert("Error", ex.Message, "OK"); return; } }
public override void ViewDidLoad() { base.ViewDidLoad(); /* 以下寫法會得到: * error CS4034: The 'await' operator can only be used within an * async lambda expression. Consider marking this lambda expression * with the 'async' modifier. * * buttonScan.TouchUpInside += (sender, e) => { * * //NOTE: On Android you MUST pass a Context into the Constructor! * var scanner = new ZXing.Mobile.MobileBarcodeScanner(); * var result = await scanner.Scan(); * * if (result != null) * Console.WriteLine("Scanned Barcode: " + result.Text); * }; */ //改成如下是可以 buttonScan.TouchUpInside += async(sender, e) => { //NOTE: On Android you MUST pass a Context into the Constructor! var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) { Console.WriteLine("Scanned Barcode: " + result.Text); } }; // Perform any additional setup after loading the view, typically from a nib. }
// The project requires the Google Glass Component from // https://components.xamarin.com/view/googleglass // so make sure you add that in to compile succesfully. protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); Window.AddFlags(WindowManagerFlags.KeepScreenOn); var scanner = new ZXing.Mobile.MobileBarcodeScanner(this); scanner.UseCustomOverlay = true; scanner.CustomOverlay = LayoutInflater.Inflate(Resource.Layout.QRScan, null);; var result = await scanner.Scan(); AudioManager audio = (AudioManager)GetSystemService(Context.AudioService); audio.PlaySoundEffect((SoundEffect)Sounds.Success); Window.ClearFlags(WindowManagerFlags.KeepScreenOn); if (result != null) { Console.WriteLine("Scanned Barcode: " + result.Text); var card2 = new Card(this); card2.SetText(result.Text); card2.SetFootnote("Just scanned!"); SetContentView(card2.ToView()); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button>(Resource.Id.MyButton); button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; Button btn_Scanner = FindViewById<Button>(Resource.Id.btn_Scanner); btn_Scanner.Click += async (sender, e) => { //NOTE: On Android, you MUST pass a Context into the Constructor! var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) Console.WriteLine("Scanned Barcode: " + result.Text); }; }
private async void ScanQrClicked(object sender, EventArgs e) { ILoggingService log = DependencyService.Get <ILoggingService>(); var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) { log.LogMessage(false, $"Read QR code. Text length = {result.Text.Length}"); var list = new DeviceList(); list.LoadDeviceListFromString(result.Text); log.LogMessage(false, $"{list.DeviceInfos.Count} connections read"); if (list.DeviceInfos.Count > 0) { this.Devices.Clear(); foreach (var info in list.DeviceInfos) { this.Devices.Add(info); } } } else { log.LogMessage(false, "No QR code read"); } }
private async void btn_Scanner_Clicked(object sender, EventArgs e) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); System.Diagnostics.Debug.WriteLine(result.Text); }
private async void InformarParticipante() { try { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) { String[] dados = result.ToString().Split(';'); NomeParticipante = dados[1]; EmailParticipante = dados[2]; TelParticipante = dados[3]; EmpresaParticipante = dados[4]; IsRunning = true; String sql = "insert into tb_participante02 (idcliente01, idparticipante01, dtpresenca) values (" + pesquisador.idcliente + ", " + dados[0] + " ,'" + String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now) + "')"; await new DadosPesquisaUtil().EnviarSQL(sql, 0); await this.page.DisplayAlert("Sucesso", "Participante registrado com sucesso.", "Ok"); } } catch (Exception ex) { await this.page.DisplayAlert("Erro", ex.Message, "Ok"); } finally { IsRunning = false; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); Button zaloguj = FindViewById <Button>(Resource.Id.zaloguj); EditText kod = FindViewById <EditText>(Resource.Id.editKod); zaloguj.Click += mButton_zaloguj; Button Skanuj = FindViewById <Button>(Resource.Id.Skanuj); MobileBarcodeScanner.Initialize(Application); Skanuj.Click += async(sender, e) => { var opt = new MobileBarcodeScanningOptions(); var scanner = new ZXing.Mobile.MobileBarcodeScanner(); opt.DelayBetweenContinuousScans = 3000; scanner.TopText = "Utrzymuj kreskę na kodzie kreskowym\ntak aby był cały na ekranie\n(ok 10 com od ekranu)"; scanner.BottomText = "Dotknij ekranu aby zlapac ostrość!"; // scanner.ScanContinuously(opt, HandleScanResultContinuous); var result = await scanner.Scan(); if (result != null) { kod.Text = result.Text; } }; }
private async void Scan_Clicked(object sender, EventArgs e) { try { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) { var content = result.Text; try { JsonConvert.PopulateObject(content, Item); OnPropertyChanged(nameof(Item)); } catch { DependencyService.Get <IMessage>().ShortAlert("二维码数据不正确。"); } } } catch (Exception ex) { DependencyService.Get <IMessage>().ShortAlert(ex.ToString()); } }
public Scanner() { var scanButton = new Button { Text = "Scan" }; scanButton.Clicked += async(sender, e) => { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) { DisplayAlert("ZXing", "Scanned Barcode: " + result.Text, "OK"); } }; Content = new StackLayout { Children = { scanButton } }; }
async void ScanItem_ClickedAsync(object sender, EventArgs e) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) { Debug.WriteLine("Scanned Barcode: " + result.Text); var book = app.Database.GetBookByBarcode(result.Text); if (book != null) { await Task.Delay(300); await Navigation.PushAsync(new BookDetailsPage() { Book = book }); } else { if (await DisplayAlert("Not Found!", "Книга с ISBN " + result.Text + " не найдена. Добавить эту книгу в библиотеку?", "Yes", "No")) { await Navigation.PushAsync(new NewBookEdit() { ISBN = result.Text }); } } } }
public GameCompletePage() { InitializeComponent(); viewModel = this.DataContext as GameCompleteViewModel; viewModel.PropertyChanged += HandlePropertyChanged; Loaded += GameCompletePage_Loaded; scanner = new ZXing.Mobile.MobileBarcodeScanner(Deployment.Current.Dispatcher); }
async Task Scan() { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) Console.WriteLine("Scanned Barcode: " + result.Text); TextDocumentProxy.InsertText (result.Text); }
async public Task<string> Scan() { //NOTE: On Android you MUST pass a Context into the Constructor! var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); //if (result != null) //Console.WriteLine("Scanned Barcode: " + result.Text); return result.Text; }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching (UIApplication app, NSDictionary options) { JsBridge.EnableJsBridge(); window = new UIWindow (UIScreen.MainScreen.Bounds); // get useragent UIWebView agentWebView = new UIWebView (); var userAgent = agentWebView.EvaluateJavascript ("navigator.userAgent"); agentWebView = null; userAgent += " XamarinBarcodeSampleApp"; // set default useragent NSDictionary dictionary = NSDictionary.FromObjectAndKey(NSObject.FromObject(userAgent), NSObject.FromObject("UserAgent")); NSUserDefaults.StandardUserDefaults.RegisterDefaults(dictionary); viewController = new Xamarin_iOS_BarcodeSampleViewController (); window.RootViewController = viewController; window.MakeKeyAndVisible (); viewController.MainWebView.LoadRequest(new NSUrlRequest(new NSUrl("http://xamarinbarcodesample.apphb.com/"))); // listen for the event triggered by the browser. viewController.MainWebView.AddEventListener( "scanBarcode", delegate(FireEventData arg) { // show a native action sheet BeginInvokeOnMainThread (delegate { //NOTE: On Android you MUST pass a Context into the Constructor! var scanningOptions = new ZXing.Mobile.MobileBarcodeScanningOptions(); scanningOptions.PossibleFormats = new List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.All_1D }; scanningOptions.TryInverted = true; scanningOptions.TryHarder = true; scanningOptions.AutoRotate = false; var scanner = new ZXing.Mobile.MobileBarcodeScanner(); scanner.TopText = "Hold camera up to barcode to scan"; scanner.BottomText = "Barcode will automatically scan"; scanner.Scan(scanningOptions).ContinueWith(t => { if (t.Result != null) { //Console.WriteLine("Scanned Barcode: " + t.Result.Text); // pass barcode back to browser. viewController.MainWebView.FireEvent( "scanComplete", new { code = t.Result.Text }); } }); }); }); return true; }
//Implementamos el metodo Scan definido en la interfaz IScan public async System.Threading.Tasks.Task<String> Scan(){ var ctx = Forms.Context; var scanner = new ZXing.Mobile.MobileBarcodeScanner(ctx); var result = await scanner.Scan(); if(result != null) return result.ToString (); return string.Empty; }
public override void ViewDidLoad () { base.ViewDidLoad (); buttonScan.TouchUpInside += (sender, e) => { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); scanner.Scan().ContinueWith(t => { if (t.Result != null) InvokeOnMainThread(() => labelOutput.Text = t.Result.Text); }); }; }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear (animated); Btn.TouchDown += async (object sender, EventArgs e) => { //NOTE: On Android you MUST pass a Context into the Constructor! var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) Console.WriteLine("Scanned Barcode: " + result.Text); }; }
public QuestPage() { InitializeComponent(); ViewModel = this.DataContext as QuestViewModel; ViewModel.PropertyChanged += HandlePropertyChanged; this.Loaded += PhasePage_Loaded; scanner = new ZXing.Mobile.MobileBarcodeScanner(Deployment.Current.Dispatcher); options.PossibleFormats = new List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE }; }
public override void ViewDidLoad() { base.ViewDidLoad(); viewModel = new GameCompleteViewModel(); scanner = new ZXing.Mobile.MobileBarcodeScanner(); ButtonShare.Layer.CornerRadius = 5; scanButton = new UIBarButtonItem("Scan", UIBarButtonItemStyle.Plain, async (sender, args) => { var result = await scanner.Scan(true); if (result == null) return; Console.WriteLine("Scanned Barcode: " + result.Text); viewModel.CheckBanana(result.Text); }); NavigationItem.RightBarButtonItem = scanButton; viewModel.PropertyChanged += HandlePropertyChanged; manager = new CLLocationManager(); manager.DidRangeBeacons += (sender2, e) => { if (e.Beacons == null) return; foreach (var beacon in e.Beacons) { if (beacon.Proximity != CLProximity.Immediate) { return; } if (beacon.Accuracy > .1)//close, but not close enough. return; viewModel.CheckBanana(beacon.Major.Int32Value, beacon.Minor.Int32Value); } }; viewModel.LoadGameCommand.Execute(null); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); UITapGestureRecognizer scanBarcodeTapped = new UITapGestureRecognizer(); scanBarcodeTapped.AddTarget(async() => { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); Console.WriteLine(result.Text); }); scanBarcodeView.AddGestureRecognizer(scanBarcodeTapped); }
partial void OnScan(MonoTouch.Foundation.NSObject sender) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); scanner.Scan().ContinueWith(t => { if (t.Result != null) { //Console.WriteLine("Scanned Barcode: " + t.Result.Text); var newCtrl = new UIViewController (); var beer = Engine.Service.LookupBeerFromScanCode (t.Result.Text); newCtrl.Title = beer.Name; newCtrl.View.BackgroundColor = UIColor.White; NavigationController.PushViewController (newCtrl, false); } }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext ()); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); App.CurrentActivity = this; ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); viewModel = new GameCompleteViewModel(); SetContentView(Resource.Layout.game_complete); viewModel.PropertyChanged += HandlePropertyChanged; mainImage = FindViewById<ImageView>(Resource.Id.main_image); progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar); beaconManager = new BeaconManager(this); scanner = new ZXing.Mobile.MobileBarcodeScanner(); var shareButton = FindViewById<Button>(Resource.Id.share_success); shareButton.Click += (sender, e) => { var intent = new Intent(Intent.ActionSend); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraText, Resources.GetString(Resource.String.success_tweet)); StartActivity(Intent.CreateChooser(intent, Resources.GetString(Resource.String.share_success))); }; beaconManager.Ranging += (sender, e) => { if (e.Beacons == null) return; foreach (var beacon in e.Beacons) { var proximity = Utils.ComputeProximity(beacon); if (proximity != Utils.Proximity.Immediate) continue; var accuracy = Utils.ComputeAccuracy(beacon); if (accuracy > .06) continue; viewModel.CheckBanana(beacon.Major, beacon.Minor); } }; viewModel.LoadGameCommand.Execute(null); }
public override UITableViewCell GetCell(UITableView tableView, Foundation.NSIndexPath indexPath) { if(indexPath.Section == 0) { var index = indexPath.Row; if (index == 0) { var cellIdentifier = new NSString("noRecentSearchesViewCell"); var cell = tableView.DequeueReusableCell(cellIdentifier) as NoRecentSearchesViewCell ?? new NoRecentSearchesViewCell(cellIdentifier); return cell; } } if(indexPath.Section == 1) { var cellIdentifier = new NSString("barcodeSearchTableViewCell"); var cell = tableView.DequeueReusableCell(cellIdentifier) as BarcodeSearchTableViewCell ?? new BarcodeSearchTableViewCell(cellIdentifier); cell.ScanBeer += async () => { try { var barcodeScanner = new ZXing.Mobile.MobileBarcodeScanner(viewController); var barcodeResult = await barcodeScanner.Scan(); if (string.IsNullOrEmpty(barcodeResult.Text)) return; var Beers = await barcodeLookupService.SearchForBeer(barcodeResult.Text); if (Beers != null) { } } catch (Exception ex) { Xamarin.Insights.Report(ex); } finally { UserDialogs.Instance.HideLoading(); } }; return cell; } return new UITableViewCell(); }
public static async Task<string> ReadQRCode(Context context) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(context); scanner.UseCustomOverlay = false; //We can customize the top and bottom text of the default overlay scanner.TopText = "Hold the camera up to the QR code\nAbout 6 inches away"; scanner.BottomText = "Wait for the QR Code to automatically scan!"; //Start scanning var result = await scanner.Scan(); if (result != null) { return result.Text; } return null; }
//Implementamos el metodo Scan definido en la interfaz IScan public async System.Threading.Tasks.Task<String> Scan(){ var ctx = Forms.Context; var options = new ZXing.Mobile.MobileBarcodeScanningOptions(); options.PossibleFormats = new System.Collections.Generic.List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE, }; var scanner = new ZXing.Mobile.MobileBarcodeScanner(ctx); var result = await scanner.Scan(options); if(result != null) return result.ToString (); return string.Empty; }
async public Task<string> Scan () { //NOTE: On Android you MUST pass a Context into the Constructor! var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) { Console.WriteLine ("Scanned Barcode: " + result.Text); return result.Text; } else { Console.WriteLine ("No barcode scanned"); return "50375264"; } // return result.Text; // return "We need to link to a real iphone to test"; }
private async void OnScanButtonClick (object sender, EventArgs e) { ZXing.Mobile.MobileBarcodeScanner scanner = new ZXing.Mobile.MobileBarcodeScanner(); ZXing.Result result = await scanner.Scan(); ProductEntity product = Model.FindProductByEAN (uint.Parse(result.Text)); AlertDialog.Builder alertBuilder = new AlertDialog.Builder (Activity); if (product != null) { alertBuilder.SetTitle ($"Product - {product.Name}"); alertBuilder.SetMessage (product.Description); } else { alertBuilder.SetTitle ("Error"); alertBuilder.SetMessage ($"Product with EAN {result.Text} couldnt be found!"); } alertBuilder.Show (); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); App.CurrentActivity = this; ViewModel = new QuestViewModel(); SetContentView(Resource.Layout.quest); ViewModel.PropertyChanged += HandlePropertyChanged; imageLoader = new ImageLoader(this, 256, 5); beacon1 = FindViewById<ImageView>(Resource.Id.beacon1); beacon2 = FindViewById<ImageView>(Resource.Id.beacon2); beacon3 = FindViewById<ImageView>(Resource.Id.beacon3); beacons = new List<ImageView> { beacon1, beacon2, beacon3 }; mainImage = FindViewById<ImageView>(Resource.Id.main_image); mainText = FindViewById<TextView>(Resource.Id.main_text); beaconNearby = FindViewById<TextView>(Resource.Id.text_beacons); progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar); buttonContinue = FindViewById<Button>(Resource.Id.button_continue); buttonContinue.Click += ButtonContinueClick; buttonContinue.Visibility = ViewStates.Gone; beaconManager = new BeaconManager(this); scanner = new ZXing.Mobile.MobileBarcodeScanner(); beaconManager.Ranging += BeaconManagerRanging; beaconManager.EnteredRegion += (sender, args) => SetBeaconText(true); beaconManager.ExitedRegion += (sender, args) => SetBeaconText(false); beacon1.Visibility = beacon2.Visibility = beacon3.Visibility = ViewStates.Invisible; options.PossibleFormats = new List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE }; ViewModel.LoadQuestCommand.Execute(null); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); //载入页面 SetContentView (Resource.Layout.Main); //将页面上的物件实体化 var btnScan = FindViewById<Button> (Resource.Id.btnScan); var txtResult = FindViewById<TextView> (Resource.Id.txtResult); var txInput = FindViewById<TextView> (Resource.Id.txInput); var imgBarcode = FindViewById<ImageView> (Resource.Id.imgBarcode); var btnGenerateBarcode = FindViewById<Button> (Resource.Id.btnGenerateBarcode); imgBarcode.Visibility = ViewStates.Invisible; //扫描条码 btnScan.Click += async (sender, e) => { var Scanner = new ZXing.Mobile.MobileBarcodeScanner(this); Scanner.UseCustomOverlay = false; Scanner.TopText = "请保持摄像头与条码至少六英寸的距离"; Scanner.BottomText = "请等候,扫描将自动完成"; var result = await Scanner.Scan(); if (result !=null) txtResult.Text = result.Text; }; btnGenerateBarcode.Click += (sender, e) => { var writer = new BarcodeWriter { Format = BarcodeFormat.QR_CODE }; var bitmap = writer.Write(txInput.Text); imgBarcode.SetImageBitmap(bitmap); imgBarcode.Visibility=ViewStates.Visible; }; }
/// <summary> /// Create connection by presenting in-app QR code scanner. /// </summary> /// <param name="ctx"></param> /// <returns></returns> public static async Task<bool> EstablishSenderConnection(Activity ctx) { var overlay = ctx.LayoutInflater.Inflate(Resource.Layout.ScannerOverlay, null); var options = new ZXing.Mobile.MobileBarcodeScanningOptions() { PossibleFormats = new System.Collections.Generic.List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE } }; var scanner = new ZXing.Mobile.MobileBarcodeScanner(ctx) { UseCustomOverlay = true, CustomOverlay = overlay }; var result = await scanner.Scan(options); if (result == null) return false; string resString = result.Text; if (resString == QR.DataSchemeWithSuffix + "sound") { // the secret special mode. makes it possible to test features without another device. // scan this: http://chart.apis.google.com/chart?chs=500x500&cht=qr&chl=dltsec://sound Network.SenderConnection.CreateWithoutEndpoint(); Network.SenderConnection.CurrentConnection.RemoteName = "nobody"; return true; } if (!Features.QR.IsValid(resString)) throw new InvalidQRCodeException(); string host, password; int port; Features.QR.GetComponents(resString, out host, out port, out password); return await EstablishSenderConnection(ctx, host, port, password); }
async public Task<string> Scan () { //NOTE: On Android you MUST pass a Context into the Constructor! var scanner = new ZXing.Mobile.MobileBarcodeScanner (); // scanner.ScanContinuously( HandleScanResult ); var result = await scanner.Scan (); if (result != null) { Console.WriteLine ("Scanned Barcode: " + result.Text); SystemSound.Vibrate.PlaySystemSound (); return result.Text; } else { Console.WriteLine ("No barcode scanned"); // SystemSound.Vibrate.PlaySystemSound (); // return "50375264"; return null; } return null; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.Main); Button buttonScan = FindViewById<Button> (Resource.Id.buttonScan); TextView labelOutput = FindViewById<TextView> (Resource.Id.labelOutput); buttonScan.Click += delegate { var scanner = new ZXing.Mobile.MobileBarcodeScanner (this); scanner.UseCustomOverlay = false; scanner.TopText = "Hold the camera up to the barcode\nAbout 6 inches away"; scanner.BottomText = "Wait for the barcode to automatically scan!\nEvolve 2013"; scanner.Scan ().ContinueWith (t => { if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion) RunOnUiThread (() => labelOutput.Text = t.Result.Text); }); }; }
// The project requires the Google Glass Component from // https://components.xamarin.com/view/googleglass // so make sure you add that in to compile succesfully. protected override async void OnCreate (Bundle bundle) { base.OnCreate (bundle); Window.AddFlags (WindowManagerFlags.KeepScreenOn); var scanner = new ZXing.Mobile.MobileBarcodeScanner(this); scanner.UseCustomOverlay = true; scanner.CustomOverlay = LayoutInflater.Inflate(Resource.Layout.QRScan, null);; var result = await scanner.Scan(); AudioManager audio = (AudioManager) GetSystemService(Context.AudioService); audio.PlaySoundEffect((SoundEffect)Sounds.Success); Window.ClearFlags (WindowManagerFlags.KeepScreenOn); if (result != null) { Console.WriteLine ("Scanned Barcode: " + result.Text); var card2 = new Card (this); card2.SetText (result.Text); card2.SetFootnote ("Just scanned!"); SetContentView (card2.ToView()); } }
private async void BtnScan_Click(object sender, EventArgs e) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); if (result != null) { // Toast.MakeText(this, "Scanned Barcode: " + result.ToString(), ToastLength.Short).Show(); //Show ID objDm = new DatabaseManager(); var PCHardwareInfo = objDm.CheckData(result.ToString()).DefaultView; //Search Database for ID //Change labels to show data foreach (System.Data.DataRowView PCHardwareItem in PCHardwareInfo) { txtAuditDate.Text = PCHardwareItem.Row[0].ToString(); txtAuditor.Text = PCHardwareItem.Row[1].ToString(); txtManu.Text = PCHardwareItem.Row[2].ToString(); txtModel.Text = PCHardwareItem.Row[3].ToString(); txtComputerName.Text = PCHardwareItem.Row[4].ToString(); txtOperSys.Text = PCHardwareItem.Row[5].ToString(); txtOperSysArch.Text = PCHardwareItem.Row[6].ToString(); txtServicePack.Text = PCHardwareItem.Row[7].ToString(); txtSerialNo.Text = PCHardwareItem.Row[8].ToString(); txtProcessorName.Text = PCHardwareItem.Row[9].ToString(); txtProcessorsAmt.Text = PCHardwareItem.Row[10].ToString(); txtRamAmt.Text = PCHardwareItem.Row[11].ToString(); txtHardDriveSize.Text = PCHardwareItem.Row[12].ToString(); txtAvailSpace.Text = PCHardwareItem.Row[13].ToString(); txtComments.Text = PCHardwareItem.Row[14].ToString(); } UpdateInformation = true; } else Toast.MakeText(this, "Invalid QRCode", ToastLength.Short).Show(); }
public async void ScanBarcode(Action<object> callback) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(_baseActivity); var result = await scanner.Scan(); if (result != null) _baseActivity.InvokeOnResume(() => callback(result.Text)); }