Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Change barcode scanner to work similar to the iOS and Android version…
Browse files Browse the repository at this point in the history
…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
nadyaA authored and EddyVerbruggen committed Jun 26, 2014
1 parent 05a5a17 commit 3a377ef
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 279 deletions.
33 changes: 13 additions & 20 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,24 @@
<framework src="QuartzCore.framework" />
</platform>

<platform name="wp7">
<config-file target="config.xml" parent="/*">
<!-- wp8 -->
<platform name="wp8">
<config-file target="config.xml" parent="/*">
<feature name="BarcodeScanner">
<param name="wp-package" value="BarcodeScanner"/>
</feature>
</config-file>

<source-file src="src/wp/BarcodeScanner.cs" />
<source-file src="src/wp/BarcodeScannerResult.cs" />
<source-file src="src/wp/Scan.xaml.cs" />
<source-file src="src/wp/Scan.xaml" />
</platform>

<platform name="wp8">
<config-file target="config.xml" parent="/*">
<feature name="BarcodeScanner">
<param name="wp-package" value="BarcodeScanner"/>
</feature>

<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
<Capability Name="ID_CAP_ISV_CAMERA" />
</config-file>

<source-file src="src/wp/BarcodeScanner.cs" />
<source-file src="src/wp/BarcodeScannerResult.cs" />
<source-file src="src/wp/Scan.xaml.cs" />
<source-file src="src/wp/Scan.xaml" />
</platform>

<source-file src="src/wp8/BarcodeScanner.cs" />
<source-file src="src/wp8/BarcodeScannerResult.cs" />
<source-file src="src/wp8/Scan.xaml" />
<source-file src="src/wp8/Scan.xaml.cs" />
<source-file src="src/wp8/zxing.wp8.0.dll" />
</platform>

<!-- android -->
<platform name="android">
Expand Down
46 changes: 0 additions & 46 deletions src/wp/BarcodeScanner.cs

This file was deleted.

22 changes: 0 additions & 22 deletions src/wp/BarcodeScannerResult.cs

This file was deleted.

40 changes: 0 additions & 40 deletions src/wp/Scan.xaml

This file was deleted.

151 changes: 0 additions & 151 deletions src/wp/Scan.xaml.cs

This file was deleted.

56 changes: 56 additions & 0 deletions src/wp8/BarcodeScanner.cs
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;
}
}
}
}
16 changes: 16 additions & 0 deletions src/wp8/BarcodeScannerResult.cs
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; }
}
}
Loading

0 comments on commit 3a377ef

Please sign in to comment.