FrameScannerPage.xaml.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using Xamarin.Forms;
  4. using ZXing;
  5. namespace comal.timesheets
  6. {
  7. public partial class FrameScannerPage : ContentPage
  8. {
  9. public FrameScannerPage()
  10. {
  11. InitializeComponent();
  12. NavigationPage.SetHasNavigationBar(this, false);
  13. var options = new ZXing.Mobile.MobileBarcodeScanningOptions()
  14. {
  15. PossibleFormats = new List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE },
  16. AutoRotate = false,
  17. TryInverted = true,
  18. TryHarder = true,
  19. };
  20. _scanView.Options = options;
  21. _scanView.IsAnalyzing = false;
  22. _scanView.IsScanning = true;
  23. }
  24. protected override void OnAppearing()
  25. {
  26. base.OnAppearing();
  27. _scanView.IsAnalyzing = true;
  28. }
  29. protected override void OnDisappearing()
  30. {
  31. _scanView.IsAnalyzing = false;
  32. base.OnDisappearing();
  33. }
  34. void _scanView_OnScanResult(ZXing.Result result)
  35. {
  36. Device.BeginInvokeOnMainThread(async () =>
  37. {
  38. //var page = new FrameDetailsPage(result.Text);
  39. //await Navigation.PushModalAsync(page);
  40. //await DisplayAlert("Scanned result", "The barcode's text is " + result.Text + ". The barcode's format is " + result.BarcodeFormat, "OK");
  41. });
  42. }
  43. void Cancel_Clicked(System.Object sender, System.EventArgs e)
  44. {
  45. Navigation.PopModalAsync();
  46. }
  47. }
  48. }