diff --git a/README.md b/README.md
index 72ca807..1eb77cc 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,7 @@ What | Type | Description
`BarcodeScanner.PreviewActive` | Property | If `true` the preview image gets updated. `false` no preview for you!
`BarcodeScanner.BarcodeDecoder` | Property | If `true` the decoder is active and tries to decode barcodes out of the image. `false` turns the decoder off, the preview is still active but barcodes will not be decoded.
+Every event is also provided as `Command`. e.g. `BarcodeChanged` => `BarcodeChangedCommand`
### Configuration
Configuration can be applied by passing a `RbConfig` object to the `BarcodeScannerRenderer.Init()` method. As the available options are platform specific, the configuration has to be done in the according platform solution. The corresponding [Android](Rb.Forms.Barcode.Droid/RbConfig.cs) class documentation should give you a solid understanding of the available options.
diff --git a/Rb.Forms.Barcode.Droid/Resources/Resource.designer.cs b/Rb.Forms.Barcode.Droid/Resources/Resource.designer.cs
index a7f56a9..aaf1c3f 100644
--- a/Rb.Forms.Barcode.Droid/Resources/Resource.designer.cs
+++ b/Rb.Forms.Barcode.Droid/Resources/Resource.designer.cs
@@ -75,14 +75,14 @@ private Layout()
public partial class String
{
+ // aapt resource value: 0x7f030002
+ public static int ApplicationName = 2130903042;
+
// aapt resource value: 0x7f030001
- public static int ApplicationName = 2130903041;
+ public static int Hello = 2130903041;
// aapt resource value: 0x7f030000
- public static int Hello = 2130903040;
-
- // aapt resource value: 0x7f030002
- public static int library_name = 2130903042;
+ public static int library_name = 2130903040;
static String()
{
diff --git a/Rb.Forms.Barcode.Pcl/BarcodeScanner.cs b/Rb.Forms.Barcode.Pcl/BarcodeScanner.cs
index 5be9d59..6e00be8 100644
--- a/Rb.Forms.Barcode.Pcl/BarcodeScanner.cs
+++ b/Rb.Forms.Barcode.Pcl/BarcodeScanner.cs
@@ -3,11 +3,72 @@
using Xamarin.Forms;
using System.Diagnostics;
using Rb.Forms.Barcode.Pcl.Extensions;
+using System.Windows.Input;
namespace Rb.Forms.Barcode.Pcl
{
public class BarcodeScanner : View
- {
+ {
+ ///
+ /// Command property gets called only when the barcode text changes.
+ ///
+ public static BindableProperty BarcodeChangedCommandProperty = BindableProperty.Create(
+ propertyName: "BarcodeChangedCommand",
+ returnType: typeof(ICommand),
+ declaringType: typeof(BarcodeScanner),
+ defaultValue: null
+ );
+
+ ///
+ /// Command property gets called every time when a barcode is decoded from the preview, even if the value is the same as the previews one.
+ ///
+ public static BindableProperty BarcodeDecodedCommandProperty = BindableProperty.Create(
+ propertyName: "BarcodeDecodedCommand",
+ returnType: typeof(ICommand),
+ declaringType: typeof(BarcodeScanner),
+ defaultValue: null
+ );
+
+ ///
+ /// Command property gets called as soon as the surfaces starts previewing.
+ ///
+ public static BindableProperty PreviewActivatedCommandProperty = BindableProperty.Create(
+ propertyName: "PreviewActivatedCommand",
+ returnType: typeof(ICommand),
+ declaringType: typeof(BarcodeScanner),
+ defaultValue: null
+ );
+
+ ///
+ /// Command property gets called when the surfaces stops previewing.
+ ///
+ public static BindableProperty PreviewDeactivatedCommandProperty = BindableProperty.Create(
+ propertyName: "PreviewDeactivatedCommand",
+ returnType: typeof(ICommand),
+ declaringType: typeof(BarcodeScanner),
+ defaultValue: null
+ );
+
+ ///
+ /// Command property gets called after the camera was opened.
+ ///
+ public static BindableProperty CameraOpenedCommandProperty = BindableProperty.Create(
+ propertyName: "CameraOpenedCommand",
+ returnType: typeof(ICommand),
+ declaringType: typeof(BarcodeScanner),
+ defaultValue: null
+ );
+
+ ///
+ /// Command property gets called after the camera was released.
+ ///
+ public static BindableProperty CameraReleasedCommandProperty = BindableProperty.Create(
+ propertyName: "CameraReleasedCommand",
+ returnType: typeof(ICommand),
+ declaringType: typeof(BarcodeScanner),
+ defaultValue: null
+ );
+
///
/// OneWay source to target binding for the current barcode.
///
@@ -57,6 +118,54 @@ public bool PreviewActive
p => p.BarcodeDecoder, true, BindingMode.TwoWay
);
+ ///
+ /// Command gets called only when the barcode text changes.
+ ///
+ public ICommand BarcodeChangedCommand {
+ get { return (ICommand) GetValue(BarcodeChangedCommandProperty); }
+ set { SetValue(BarcodeChangedCommandProperty, value); }
+ }
+
+ ///
+ /// Command gets called every time when a barcode is decoded from the preview, even if the value is the same as the previews one.
+ ///
+ public ICommand BarcodeDecodedCommand {
+ get { return (ICommand) GetValue(BarcodeDecodedCommandProperty); }
+ set { SetValue(BarcodeDecodedCommandProperty, value); }
+ }
+
+ ///
+ /// Command gets called as soon as the surfaces starts previewing.
+ ///
+ public ICommand PreviewActivatedCommand {
+ get { return (ICommand) GetValue(PreviewActivatedCommandProperty); }
+ set { SetValue(PreviewActivatedCommandProperty, value); }
+ }
+
+ ///
+ /// Command gets called when the surfaces stops previewing.
+ ///
+ public ICommand PreviewDeactivatedCommand {
+ get { return (ICommand) GetValue(PreviewDeactivatedCommandProperty); }
+ set { SetValue(PreviewDeactivatedCommandProperty, value); }
+ }
+
+ ///
+ /// Command gets called after the camera was opened.
+ ///
+ public ICommand CameraOpenedCommand {
+ get { return (ICommand) GetValue(CameraOpenedCommandProperty); }
+ set { SetValue(CameraOpenedCommandProperty, value); }
+ }
+
+ ///
+ /// Command gets called after the camera was released.
+ ///
+ public ICommand CameraReleasedCommand {
+ get { return (ICommand) GetValue(CameraReleasedCommandProperty); }
+ set { SetValue(CameraReleasedCommandProperty, value); }
+ }
+
///
/// Gets or controlls the decoder state.
///
@@ -99,11 +208,13 @@ public bool BarcodeDecoder
public void OnCameraOpened()
{
+ CameraOpenedCommand.Raise();
CameraOpened.Raise(this, EventArgs.Empty);
}
public void OnCameraReleased()
{
+ CameraReleasedCommand.Raise();
CameraReleased.Raise(this, EventArgs.Empty);
}
@@ -111,7 +222,7 @@ private static void OnBarcodeChanged(BindableObject bindable, String oldValue, S
{
Debug.WriteLine("[ScannerView] OnBarcodeChanged [{0}]", newBarcode, null);
var b = (BarcodeScanner) bindable;
-
+ b.BarcodeChangedCommand.Raise(newBarcode);
b.BarcodeChanged.Raise(b, new BarcodeEventArgs(newBarcode));
}
@@ -119,16 +230,19 @@ private void OnBarcodeDecoded(String barcode)
{
Debug.WriteLine("[ScannerView] OnBarcodeDecoded [{0}]", barcode, null);
+ BarcodeDecodedCommand.Raise(barcode);
BarcodeDecoded.Raise(this, new BarcodeEventArgs(barcode));
}
public void OnPreviewActivated()
{
+ PreviewActivatedCommand.Raise();
PreviewActivated.Raise(this, EventArgs.Empty);
}
public void OnPreviewDeactivated()
{
+ PreviewDeactivatedCommand.Raise();
PreviewDeactivated.Raise(this, EventArgs.Empty);
}
}
diff --git a/Rb.Forms.Barcode.Pcl/Extensions/CommandExtension.cs b/Rb.Forms.Barcode.Pcl/Extensions/CommandExtension.cs
new file mode 100644
index 0000000..4f5a4c8
--- /dev/null
+++ b/Rb.Forms.Barcode.Pcl/Extensions/CommandExtension.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Windows.Input;
+
+namespace Rb.Forms.Barcode.Pcl
+{
+ public static class CommandExtension
+ {
+ public static void Raise(this ICommand comand, object parameter)
+ {
+ if (comand != null && comand.CanExecute(parameter)) {
+ comand.Execute(parameter);
+ }
+ }
+
+ public static void Raise(this ICommand comand)
+ {
+ Raise(comand, EventArgs.Empty);
+ }
+ }
+}
+
diff --git a/Rb.Forms.Barcode.Pcl/Rb.Forms.Barcode.Pcl.csproj b/Rb.Forms.Barcode.Pcl/Rb.Forms.Barcode.Pcl.csproj
index 0a04060..e183ed9 100644
--- a/Rb.Forms.Barcode.Pcl/Rb.Forms.Barcode.Pcl.csproj
+++ b/Rb.Forms.Barcode.Pcl/Rb.Forms.Barcode.Pcl.csproj
@@ -36,6 +36,7 @@
+
diff --git a/Rb.Forms.Barcode.nuspec b/Rb.Forms.Barcode.nuspec
index 1e1adf3..c151b8f 100644
--- a/Rb.Forms.Barcode.nuspec
+++ b/Rb.Forms.Barcode.nuspec
@@ -3,7 +3,7 @@
Rb.Forms.Barcode
Barcode scanner plugin for Xamarin.Forms
- 0.3.5-beta
+ 0.4.0-beta
Ota Mares
reBuy reCommerce GmbH
https://github.com/rebuy-de/rb-forms-barcode/blob/master/LICENSE
@@ -14,27 +14,8 @@ Please check the website for further details.
Beta notice: Currently only android is supported.
Rb.Forms.Barcode is a Xamarin.Forms view for scanning barcodes.
- 0.3.5-beta:
-* Fixed: Prevent dispose if object is null.
-
-0.3.4-beta:
-* Fixed: Surface changed does not start preview anymore.
-* Improved: Dispose all buffers.
-* Improved: Update to Xamarin.Forms to 1.4.2.6355 version.
-
-0.3.3-beta:
-* Fixed: UPC-A codes are not padded to 13 signs.
-
-0.3.2-beta:
-* Fixed: Even more oom issues.
-
-0.3.1-beta:
-* Fixed: Memory issue when restarting camera.
-
-0.3.0-beta:
-* New: Improved performance by using buffers and FastAndroidCamera.
-* New: Added plenty configuration options!
-* Fixed: Various preview halting and runtime issues.
+ 0.4.0-beta:
+* New: Add every event as command
barcode scanner scanning scan zxing xamarin xamarin.forms rebuy unicorns
diff --git a/Sample/Sample.Droid/Resources/Resource.designer.cs b/Sample/Sample.Droid/Resources/Resource.designer.cs
index 721a81a..d8cb3a6 100644
--- a/Sample/Sample.Droid/Resources/Resource.designer.cs
+++ b/Sample/Sample.Droid/Resources/Resource.designer.cs
@@ -109,20 +109,20 @@ private Layout()
public partial class String
{
- // aapt resource value: 0x7f040002
- public const int ApplicationName = 2130968578;
-
- // aapt resource value: 0x7f040001
- public const int Hello = 2130968577;
-
// aapt resource value: 0x7f040004
- public const int app_name = 2130968580;
+ public const int ApplicationName = 2130968580;
// aapt resource value: 0x7f040003
- public const int hello = 2130968579;
+ public const int Hello = 2130968579;
+
+ // aapt resource value: 0x7f040001
+ public const int app_name = 2130968577;
// aapt resource value: 0x7f040000
- public const int library_name = 2130968576;
+ public const int hello = 2130968576;
+
+ // aapt resource value: 0x7f040002
+ public const int library_name = 2130968578;
static String()
{