This repository has been archived by the owner on Aug 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change barcode scanner to work similar to the iOS and Android version…
…s. In plugin.xml added reference to ZXing.Net so it is refered as plugin is installed. Similar to other platforms' versions, there is a focus area - only this area is scanned for barcodes. Signed-off-by: Nadya Atanasova <nadya.it@gmail.com>
- Loading branch information
1 parent
05a5a17
commit 3a377ef
Showing
10 changed files
with
311 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Navigation; | ||
using BarcodeScanner; | ||
using Microsoft.Phone.Controls; | ||
using WPCordovaClassLib.Cordova; | ||
using WPCordovaClassLib.Cordova.Commands; | ||
using WPCordovaClassLib.Cordova.JSON; | ||
|
||
namespace Cordova.Extension.Commands | ||
{ | ||
public class BarcodeScanner : BaseCommand | ||
{ | ||
private PhoneApplicationFrame currentRootVisual; | ||
private PhoneApplicationFrame CurrentRootVisual | ||
{ | ||
get | ||
{ | ||
if (this.currentRootVisual == null) | ||
{ | ||
this.currentRootVisual = (PhoneApplicationFrame)Application.Current.RootVisual; | ||
this.currentRootVisual.Navigated += this.OnFrameNavigated; | ||
} | ||
return this.currentRootVisual; | ||
} | ||
} | ||
|
||
public void scan(string options) | ||
{ | ||
Deployment.Current.Dispatcher.BeginInvoke(() => | ||
{ | ||
this.CurrentRootVisual.Navigate(new Uri("/Plugins/com.phonegap.plugins.barcodescanner/Scan.xaml", UriKind.Relative)); | ||
}); | ||
} | ||
|
||
public void OnScanFailed(string error) | ||
{ | ||
this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, error)); | ||
} | ||
|
||
public void OnScanSucceeded(BarcodeScannerResult scanResult) | ||
{ | ||
var resultString = JsonHelper.Serialize(scanResult); | ||
this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, resultString)); | ||
} | ||
|
||
private void OnFrameNavigated(object sender, NavigationEventArgs e) | ||
{ | ||
var scanPage = e.Content as Scan; | ||
if (scanPage != null) | ||
{ | ||
scanPage.BarcodeScannerPlugin = this; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
|
||
namespace BarcodeScanner | ||
{ | ||
[DataContract] | ||
public class BarcodeScannerResult | ||
{ | ||
[DataMember(Name = "format")] | ||
public string Format { get; set; } | ||
|
||
[DataMember(Name = "text")] | ||
public string Text { get; set; } | ||
} | ||
} |
Oops, something went wrong.