2016-05-06 8 views
1

Dies wird getestet, um in Win 10 UWP-App zum Scannen von 1D-Barcodes (Format 39 & 128) integriert zu werden. Ich habe den letzten update bis nugget 2.0.4.46 aktualisiert. Referenzierter Beitrag unter http://www.yortondotnet.com/2015/07/mobile-barcode-scanning-with-zxingnet.html über einige Optionen Einstellung vor dem Scan() ohne Glück. Der Scanner (Kamera) öffnet sich, erkennt aber nie erfolgreich einen Barcode-Scan - oder einen Fehler in diesem Fall. Es scheint, dass überhaupt nichts geschieht. Ich habe einen direkten, passenden Beispielcode mit einigen Optionen zur Überprüfung hinzugefügt. Ich habe Scandit API zum Arbeiten bekommen und wollte es mit Manateeworks versuchen, aber beide sind sehr teuer und keine Option. Ich entwickle auf Surface Pro 3 (Win 10) und dieser Build wird auch Zielmaschinen sein, wenn sie fertig sind.ZXing.Net.Mobile Sample.WindowsUniversal Sample wird nicht gescannt

public sealed partial class MainPage : Page 
{ 
    UIElement customOverlayElement = null; 
    MobileBarcodeScanner scanner; 

    public MainPage() 
    { 
     this.InitializeComponent(); 

     //Create a new instance of our scanner 
     scanner = new MobileBarcodeScanner(this.Dispatcher); 
     scanner.Dispatcher = this.Dispatcher; 
    } 

    private void buttonScanDefault_Click(object sender, RoutedEventArgs e) 
    { 
     //Tell our scanner to use the default overlay 
     scanner.UseCustomOverlay = false; 
     //We can customize the top and bottom text of our default overlay 
     scanner.TopText = "Hold camera up to barcode"; 
     scanner.BottomText = "Camera will automatically scan barcode\r\n\r\nPress the 'Back' button to Cancel"; 

     // GWS Set Options 
     var options = new MobileBarcodeScanningOptions(); 
     options.PossibleFormats = new List<ZXing.BarcodeFormat>() { 
      ZXing.BarcodeFormat.CODE_39, ZXing.BarcodeFormat.CODE_128 
     }; 
     options.AutoRotate = false; 
     options.TryHarder = false; 
     options.TryInverted = false; 

     //Start scanning 
     scanner.Scan(options).ContinueWith(t => 
     { 
      if (t.Result != null) 
       HandleScanResult(t.Result); 
     }); 
    } 
    private void buttonScanContinuously_Click(object sender, RoutedEventArgs e) 
    { 
     //Tell our scanner to use the default overlay 
     scanner.UseCustomOverlay = false; 
     //We can customize the top and bottom text of our default overlay 
     scanner.TopText = "Hold camera up to barcode"; 
     scanner.BottomText = "Camera will automatically scan barcode\r\n\r\nPress the 'Back' button to Cancel"; 

     // GWS Set Options 
     var options = new MobileBarcodeScanningOptions(); 
     options.PossibleFormats = new List<ZXing.BarcodeFormat>() { 
      ZXing.BarcodeFormat.CODE_39, ZXing.BarcodeFormat.CODE_128 
     }; 
     options.AutoRotate = false; 
     options.TryHarder = false; 
     options.TryInverted = false; 

     //Start scanning 
     scanner.ScanContinuously(options, async (result) => 
     { 
      var msg = "Found Barcode: " + result.Text; 

      await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => 
      { 
       await MessageBox(msg); 
      }); 
     }); 
    } 
    async void HandleScanResult(ZXing.Result result) 
    { 
     string msg = ""; 

     if (result != null && !string.IsNullOrEmpty(result.Text)) 
      msg = "Found Barcode: " + result.Text; 
     else 
      msg = "Scanning Canceled!"; 

     await MessageBox(msg); 

    } 

}

+0

Haben Sie versucht, indem Sie versuchen, härter zu wahren? – gayan1991

Antwort

0

Simon,

Ich habe genau das gleiche Problem. Ich habe deinen Code mit dem neuesten nugget 2.1.47 getestet, das Problem besteht immer noch.

Sie benötigen die neueste von Github und fügen Sie die folgenden Projekte (oder DLLs) zu einem Projekt zum Download:

ZXing.Net (project: zxing.portable.csproj) 
ZXing.Net.Mobile.Core 
ZXing.Net.Mobile.WindowsUniversal 

Ich habe Ihren Code getestet und es funktioniert gut. Ich hoffe diese Hilfe.

Cheers, Sam

0

denke ich, dass das Problem in der Hardware, die Sie mit testen. Oberfläche Pro 3 (Win 10) does not have an auto focus camera. Ich habe es nie geschafft, mit ZXing mit meinem Surface Pro 3 zu scannen, während die gleiche Anwendung mit meinem anderen Windows 10-Gerät funktioniert.