private void BarCodeTask_Completed(object sender, BarCodeResult e) { if (null != e.Error) { XLog.WriteError("BarCodeTask_Completed occur ERROR " + e.Error.Message); DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Error.Message)); return; } switch (e.TaskResult) { case TaskResult.OK: DispatchCommandResult(new PluginResult(PluginResult.Status.OK, e.result)); break; case TaskResult.Cancel: DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled.")); break; default: DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Did not complete!")); break; } }
private void ScanPreviewBuffer() { try { _photoCamera.GetPreviewBufferY(_luminance.PreviewBufferY); var binarizer = new HybridBinarizer(_luminance); var binBitmap = new BinaryBitmap(binarizer); Result result = _reader.decode(binBitmap); if (result != null) { _timer.Stop(); SetStillPicture(); BarCodeRectSuccess(); BarCodeResult barCodeResult = new BarCodeResult(TaskResult.OK); barCodeResult.result = result.Text; Dispatcher.BeginInvoke(() => { this.result = barCodeResult; if (this.NavigationService.CanGoBack) { this.NavigationService.GoBack(); } }); } else { _photoCamera.Focus(); } } catch { //do nothing } }