diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/MvvmCross.Plugins.BarcodeScanner.WindowsCommon.csproj b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/MvvmCross.Plugins.BarcodeScanner.WindowsCommon.csproj new file mode 100644 index 00000000..263b1260 --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/MvvmCross.Plugins.BarcodeScanner.WindowsCommon.csproj @@ -0,0 +1,89 @@ + + + + + 12.0 + Debug + AnyCPU + {AAA4065C-46B6-4403-A84A-6D8ACF1534DE} + Library + Properties + MvvmCross.Plugins.Accelerometer.WindowsCommon + MvvmCross.Plugins.Accelerometer.WindowsCommon + en-US + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile32 + v4.6 + + + true + full + false + ..\..\bin\Debug\Mvx\WindowsCommon\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\bin\Release\Mvx\WindowsCommon\ + TRACE + prompt + 4 + true + + + + + + + + + + + + + ..\..\packages\MvvmCross.Binding.4.1.6\lib\portable-win81+wpa81\MvvmCross.Binding.dll + True + + + ..\..\packages\MvvmCross.Core.4.1.6\lib\portable-win81+wpa81\MvvmCross.Core.dll + True + + + ..\..\packages\MvvmCross.Binding.4.1.6\lib\portable-win81+wpa81\MvvmCross.Localization.dll + True + + + ..\..\packages\MvvmCross.Platform.4.1.6\lib\portable-win81+wpa81\MvvmCross.Platform.dll + True + + + ..\..\packages\MvvmCross.Platform.4.1.6\lib\portable-win81+wpa81\MvvmCross.Platform.WindowsCommon.dll + True + + + ..\..\packages\MvvmCross.Core.4.1.6\lib\portable-win81+wpa81\MvvmCross.WindowsCommon.dll + True + + + + + + + + {0e10e61c-78b8-437a-b044-6d1886f82ed9} + MvvmCross.Plugins.BarcodeScanner + + + + + \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/MvxWindowsCommonBarcodeScanner.cs b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/MvxWindowsCommonBarcodeScanner.cs new file mode 100644 index 00000000..180801a9 --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/MvxWindowsCommonBarcodeScanner.cs @@ -0,0 +1,230 @@ +// +// (c) Copyright Cirrious. http://www.cirrious.com +// This source is subject to the Microsoft Public License (Ms-PL) +// Please see license.txt on http://opensource.org/licenses/ms-pl.html +// All other rights reserved. +// +// +// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com - Hire me - I'm worth it! + +using System; +using MvvmCross.Platform.Core; +using MvvmCross.Platform.Exceptions; +using Windows.Devices.Sensors; +//using Windows.Devices.PointOfService = POS; + + +namespace MvvmCross.Plugins.BarcodeScanner.WindowsStore { + public class MvxBarcodeScanner : IMvxBarcodeScanner { + + private MvxBarcodeScannerReading _lastReading; + + private bool _started; + private Windows.Devices.PointOfService.BarcodeScanner _barcodeScanner; + private Windows.Devices.PointOfService.ClaimedBarcodeScanner _claimedBarcodeScanner; + + public async void Start() { + if (_started) { + throw new MvxException("Barcodescanner already started"); + } + + if (await CreateScanner()) { + Log.Trace("BarcodeScanner Registration Successfull"); + if (await ClaimScanner()) { + Log.Trace("BarcodeScanner Claimed Successfull"); + _started = true; + // Make sure the scanner remains claimed for our app + _claimedBarcodeScanner.ReleaseDeviceRequested += _claimedBarcodeScanner_ReleaseDeviceRequested; + _claimedBarcodeScanner.DataReceived += _claimedBarcodeScanner_DataReceived; + _claimedBarcodeScanner.IsDecodeDataEnabled = true; + if (await EnableScanner()) { + Log.Trace("Barcode Scanner ready to Scan"); + } + } + } + } + + private void _claimedBarcodeScanner_DataReceived(Windows.Devices.PointOfService.ClaimedBarcodeScanner sender, Windows.Devices.PointOfService.BarcodeScannerDataReceivedEventArgs args) { + var rawdata = Windows.Storage.Streams.DataReader.FromBuffer(args.Report.ScanData); + var barcodedata = Windows.Storage.Streams.DataReader.FromBuffer(args.Report.ScanDataLabel); + + // Remove the checksum + string strippedbc = barcodedata.ReadString(args.Report.ScanDataLabel.Length); + strippedbc = strippedbc.Remove(strippedbc.Length - 2); + // Trim the end + strippedbc = strippedbc.TrimEnd(); + + OnBarcodeScanned(args.Report.ScanDataType, rawdata.ReadString(args.Report.ScanData.Length), strippedbc); + } + + + protected virtual void OnBarcodeScanned(uint scanDataType, string rawData, string barcode) { + Log.MethodEnter(); + Log.Debug($"scanDataType {scanDataType}"); + Log.Debug($"rawData {rawData}"); + Log.Debug($"barcode {barcode}"); + ReadingAvailable?.Invoke(this, new MvxValueEventArgs(new MvxBarcodeScannerReading(scanDataType, rawData, barcode))); + Log.MethodExit(); + } + + private void _claimedBarcodeScanner_ReleaseDeviceRequested(object sender, Windows.Devices.PointOfService.ClaimedBarcodeScanner e) { + e.RetainDevice(); + Log.Trace("Event ReleaseDeviceRequest received. Retaining the Barcode Scanner."); + + } + + public void Stop() { + _started = false; + ReleaseScanner(); + } + + public MvxBarcodeScannerReading LastReading + { + get { return _lastReading; } + } + + public event EventHandler> ReadingAvailable; + + /// + /// Create a barcodescanner object + /// + /// true if system has a barcodescanner + public async Task CreateScanner() { + _barcodeScanner = await Windows.Devices.PointOfService.BarcodeScanner.GetDefaultAsync(); + + if (_barcodeScanner == null) { + DeviceInformationCollection col = await DeviceInformation.FindAllAsync(Windows.Devices.PointOfService.BarcodeScanner.GetDeviceSelector()); + if (col.Count > 0) { + _barcodeScanner = await Windows.Devices.PointOfService.BarcodeScanner.FromIdAsync(col[0].Id); + } + } + + return _barcodeScanner != null; + } + /// + /// Claim the barcode scanner + /// + /// true if claimed + private async Task ClaimScanner() { + if (_claimedBarcodeScanner != null) { + Log.Trace("Scanner was allready claimed"); + return true; + + } else { + // claim the barcode scanner + _claimedBarcodeScanner = await _barcodeScanner.ClaimScannerAsync(); + // enable the claimed barcode scanner + if (_claimedBarcodeScanner == null) { + return false; + } + } + return true; + } + + private async Task EnableScanner() { + // enable the claimed barcode scanner + if (_claimedBarcodeScanner == null) { + return false; + } else { + await _claimedBarcodeScanner.EnableAsync(); + + Log.Trace("Enable Barcode Scanner succeeded."); + + return true; + } + + } + + public void ReleaseScanner() { + if (_claimedBarcodeScanner != null) { + // Detach the event handlers + _claimedBarcodeScanner.DataReceived -= _claimedBarcodeScanner_DataReceived; + _claimedBarcodeScanner.ReleaseDeviceRequested -= _claimedBarcodeScanner_ReleaseDeviceRequested; + // Release the Barcode Scanner and set to null + _claimedBarcodeScanner.Dispose(); + _claimedBarcodeScanner = null; + } + _barcodeScanner = null; + } + } +} + +namespace MvvmCross.Plugins.Accelerometer.WindowsCommon +{ + public class MvxWindowsCommonBarcodeScanner : IMvxAccelerometer + { + private bool _started; + private Windows.Devices.Sensors.Accelerometer _accelerometer; + + public void Start() + { + if (_started) + { + throw new MvxException("Accelerometer already started"); + } + _accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault(); + if (_accelerometer != null) + { + _accelerometer.ReadingChanged += AccelerometerOnReadingChanged; + } + _started = true; + } + + public void Stop() + { + if (!_started) + { + throw new MvxException("Accelerometer not started"); + } + if (_accelerometer != null) + { + _accelerometer.ReadingChanged -= AccelerometerOnReadingChanged; + _accelerometer = null; + } + _started = false; + } + + private void AccelerometerOnReadingChanged(Windows.Devices.Sensors.Accelerometer sender, AccelerometerReadingChangedEventArgs args) + { + var handler = ReadingAvailable; + + if (handler == null) + return; + + var reading = ToReading(args.Reading); + + handler(this, new MvxValueEventArgs(reading)); + } + + private static MvxAccelerometerReading ToReading(AccelerometerReading sensorReading) + { + var reading = new MvxAccelerometerReading + { + X = sensorReading.AccelerationX, + Y = sensorReading.AccelerationY, + Z = sensorReading.AccelerationZ + }; + return reading; + } + + public bool Started => _accelerometer != null; + + public MvxAccelerometerReading LastReading + { + get + { + try + { + var reading = ToReading(_accelerometer.GetCurrentReading()); + return reading; + } + catch (Exception exception) + { + throw exception.MvxWrap("Problem getting current Accelerometer reading"); + } + } + } + + public event EventHandler> ReadingAvailable; + } +} \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/Plugin.cs b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/Plugin.cs new file mode 100644 index 00000000..b5312951 --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/Plugin.cs @@ -0,0 +1,23 @@ +// +// (c) Copyright Cirrious. http://www.cirrious.com +// This source is subject to the Microsoft Public License (Ms-PL) +// Please see license.txt on http://opensource.org/licenses/ms-pl.html +// All other rights reserved. +// +// +// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com - Hire me - I'm worth it! + +using MvvmCross.Platform; +using MvvmCross.Platform.Plugins; + +namespace MvvmCross.Plugins.Accelerometer.WindowsCommon +{ + public class Plugin + : IMvxPlugin + { + public void Load() + { + Mvx.RegisterSingleton(new MvxWindowsCommonBarcodeScanner()); + } + } +} \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/Properties/AssemblyInfo.cs b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..97831cf3 --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/Properties/AssemblyInfo.cs @@ -0,0 +1,28 @@ +using System.Reflection; +using System.Resources; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MvvmCross.Plugins.Accelerometer.WindowsCommon")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MvvmCross.Plugins.Accelerometer.WindowsCommon")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("4.0.0.0")] +[assembly: AssemblyFileVersion("4.0.0.0")] \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/packages.config b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/packages.config new file mode 100644 index 00000000..d238b51a --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsCommon/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/MvvmCross.Plugins.BarcodeScanner.WindowsStore.csproj b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/MvvmCross.Plugins.BarcodeScanner.WindowsStore.csproj new file mode 100644 index 00000000..2de0ccb8 --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/MvvmCross.Plugins.BarcodeScanner.WindowsStore.csproj @@ -0,0 +1,91 @@ + + + + + Debug + AnyCPU + {6535F213-3EF5-4243-8F0E-9FFC97959662} + Library + Properties + MvvmCross.Plugins.BarcodeScanner.WindowsStore + MvvmCross.Plugins.BarcodeScanner.WindowsStore + en-US + 512 + {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 8.1 + 12 + + + + true + full + false + ..\..\bin\Debug\Mvx\WindowsStore\ + DEBUG;TRACE;NETFX_CORE + prompt + 4 + + + pdbonly + true + ..\..\bin\Release\Mvx\WindowsStore\ + TRACE;NETFX_CORE + prompt + 4 + + + + + + + + + {B81C8F9A-FE2C-4807-90BA-D34CB25D8CE6} + MvvmCross.Plugins.Accelerometer + + + {0E10E61C-78B8-437A-B044-6D1886F82ED9} + MvvmCross.Plugins.BarcodeScanner + + + + + ..\..\packages\MvvmCross.Binding.4.1.6\lib\win81\MvvmCross.Binding.dll + True + + + ..\..\packages\MvvmCross.Core.4.1.6\lib\win81\MvvmCross.Core.dll + True + + + ..\..\packages\MvvmCross.Binding.4.1.6\lib\win81\MvvmCross.Localization.dll + True + + + ..\..\packages\MvvmCross.Platform.4.1.6\lib\win81\MvvmCross.Platform.dll + True + + + ..\..\packages\MvvmCross.Platform.4.1.6\lib\win81\MvvmCross.Platform.WindowsCommon.dll + True + + + ..\..\packages\MvvmCross.Core.4.1.6\lib\win81\MvvmCross.WindowsCommon.dll + True + + + + + + + 12.0 + + + + \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/MvxStoreBarcodeScanner.cs b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/MvxStoreBarcodeScanner.cs new file mode 100644 index 00000000..ad31cafe --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/MvxStoreBarcodeScanner.cs @@ -0,0 +1,132 @@ +// (c) Copyright Cirrious. http://www.cirrious.com +// This source is subject to the Microsoft Public License (Ms-PL) +// Please see license.txt on http://opensource.org/licenses/ms-pl.html +// All other rights reserved. +// +// +// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com - Hire me - I'm worth it! +// Implemented - Michael Bogaerts, 3Way. http://www.3Way.be - I'm worth it 2 ;-)! + +using MvvmCross.Platform.Core; +using MvvmCross.Platform.Exceptions; +using System; +using System.Threading.Tasks; +using Windows.Devices.Enumeration; +using MvvmCross.Platform; + +namespace MvvmCross.Plugins.BarcodeScanner.WindowsStore +{ + public class MvxStoreBarcodeScanner : IMvxBarcodeScanner { + private MvxBarcodeScannerReading _lastReading; + + private bool _started; + private Windows.Devices.PointOfService.BarcodeScanner _barcodeScanner; + private Windows.Devices.PointOfService.ClaimedBarcodeScanner _claimedBarcodeScanner; + + public async void Start() { + if (_started) { + throw new MvxException("Barcodescanner already started"); + } + + if (await CreateScanner()) { + if (await ClaimScanner()) { + _started = true; + _claimedBarcodeScanner.ReleaseDeviceRequested += _claimedBarcodeScanner_ReleaseDeviceRequested; + _claimedBarcodeScanner.DataReceived += _claimedBarcodeScanner_DataReceived; + _claimedBarcodeScanner.IsDecodeDataEnabled = true; + if (await EnableScanner()) { + Mvx.Trace("Scanner Enabled"); + } + } + } + } + + private void _claimedBarcodeScanner_DataReceived(Windows.Devices.PointOfService.ClaimedBarcodeScanner sender, Windows.Devices.PointOfService.BarcodeScannerDataReceivedEventArgs args) { + var rawdata = Windows.Storage.Streams.DataReader.FromBuffer(args.Report.ScanData); + var barcodedata = Windows.Storage.Streams.DataReader.FromBuffer(args.Report.ScanDataLabel); + + // Remove the checksum + string strippedbc = barcodedata.ReadString(args.Report.ScanDataLabel.Length); + strippedbc = strippedbc.Remove(strippedbc.Length - 2); + // Trim the end + strippedbc = strippedbc.TrimEnd(); + + OnBarcodeScanned(args.Report.ScanDataType, rawdata.ReadString(args.Report.ScanData.Length), strippedbc); + } + + + protected virtual void OnBarcodeScanned(uint scanDataType, string rawData, string barcode) { + var symbology = Windows.Devices.PointOfService.BarcodeSymbologies.GetName(scanDataType); + _lastReading = new MvxBarcodeScannerReading(scanDataType, rawData, barcode, symbology); + ReadingAvailable?.Invoke(this, new MvxValueEventArgs(_lastReading)); + } + + private void _claimedBarcodeScanner_ReleaseDeviceRequested(object sender, Windows.Devices.PointOfService.ClaimedBarcodeScanner e) { + e.RetainDevice(); + } + + public void Stop() { + _started = false; + ReleaseScanner(); + } + + public MvxBarcodeScannerReading LastReading => _lastReading; + + public event EventHandler> ReadingAvailable; + + /// + /// Create a barcodescanner object + /// + /// true if system has a barcodescanner + public async Task CreateScanner() { + _barcodeScanner = await Windows.Devices.PointOfService.BarcodeScanner.GetDefaultAsync(); + + if (_barcodeScanner == null) { + DeviceInformationCollection col = await DeviceInformation.FindAllAsync(Windows.Devices.PointOfService.BarcodeScanner.GetDeviceSelector()); + if (col.Count > 0) { + _barcodeScanner = await Windows.Devices.PointOfService.BarcodeScanner.FromIdAsync(col[0].Id); + } + } + + return _barcodeScanner != null; + } + /// + /// Claim the barcode scanner + /// + /// true if claimed + private async Task ClaimScanner() { + if (_claimedBarcodeScanner != null) { + //Scanner was allready claimed + return true; + + } else { + // claim the barcode scanner + _claimedBarcodeScanner = await _barcodeScanner.ClaimScannerAsync(); + // enable the claimed barcode scanner + if (_claimedBarcodeScanner == null) { + return false; + } + } + return true; + } + + private async Task EnableScanner() { + if (_claimedBarcodeScanner == null) { + return false; + } else { + await _claimedBarcodeScanner.EnableAsync(); + return true; + } + } + + public void ReleaseScanner() { + if (_claimedBarcodeScanner != null) { + _claimedBarcodeScanner.DataReceived -= _claimedBarcodeScanner_DataReceived; + _claimedBarcodeScanner.ReleaseDeviceRequested -= _claimedBarcodeScanner_ReleaseDeviceRequested; + _claimedBarcodeScanner.Dispose(); + _claimedBarcodeScanner = null; + } + _barcodeScanner = null; + } + } +} \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/Plugin.cs b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/Plugin.cs new file mode 100644 index 00000000..444a60cd --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/Plugin.cs @@ -0,0 +1,23 @@ +// (c) Copyright Cirrious. http://www.cirrious.com +// This source is subject to the Microsoft Public License (Ms-PL) +// Please see license.txt on http://opensource.org/licenses/ms-pl.html +// All other rights reserved. +// +// +// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com - Hire me - I'm worth it! +// Implemented - Michael Bogaerts, 3Way. http://www.3Way.be - I'm worth it 2 ;-)! + +using MvvmCross.Platform; +using MvvmCross.Platform.Plugins; + +namespace MvvmCross.Plugins.BarcodeScanner.WindowsStore +{ + public class Plugin + : IMvxPlugin + { + public void Load() + { + Mvx.RegisterSingleton(new MvxStoreBarcodeScanner()); + } + } +} \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/Properties/AssemblyInfo.cs b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..4c7e9686 --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/Properties/AssemblyInfo.cs @@ -0,0 +1,28 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MvvmCross.Plugins.BarcodeScanner.WinRT")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("3Way")] +[assembly: AssemblyProduct("MvvmCross.Plugins.BarcodeScanner.WinRT")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("4.0.0.0")] +[assembly: AssemblyFileVersion("4.0.0.0")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/packages.config b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/packages.config new file mode 100644 index 00000000..2b5ffbb2 --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.WindowsStore/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/IMvxBarcodeScanner.cs b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/IMvxBarcodeScanner.cs new file mode 100644 index 00000000..4142e955 --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/IMvxBarcodeScanner.cs @@ -0,0 +1,21 @@ +// (c) Copyright Cirrious. http://www.cirrious.com +// This source is subject to the Microsoft Public License (Ms-PL) +// Please see license.txt on http://opensource.org/licenses/ms-pl.html +// All other rights reserved. +// +// +// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com - Hire me - I'm worth it! +// Implemented - Michael Bogaerts, 3Way. http://www.3Way.be - I'm worth it 2 ;-)! + +using System; +using MvvmCross.Platform.Core; + +namespace MvvmCross.Plugins.BarcodeScanner { + public interface IMvxBarcodeScanner { + void Start(); + void Stop(); + MvxBarcodeScannerReading LastReading { get; } + event EventHandler> ReadingAvailable; + } +} + diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.csproj b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.csproj new file mode 100644 index 00000000..75aaebe5 --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/MvvmCross.Plugins.BarcodeScanner.csproj @@ -0,0 +1,58 @@ + + + + + 10.0 + Debug + AnyCPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9} + Library + Properties + MvvmCross.Plugins.BarcodeScanner + MvvmCross.Plugins.BarcodeScanner + Profile259 + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + v4.5 + + + True + full + False + ..\..\bin\Debug\Mvx\Portable\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + True + ..\..\bin\Release\Mvx\Portable\ + TRACE + prompt + 4 + + + + + + + + + + ..\..\packages\MvvmCross.Platform.4.1.6\lib\portable-net45+win+wpa81+wp80\MvvmCross.Platform.dll + True + + + + + + + + \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/MvxBarcodeScannerReading.cs b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/MvxBarcodeScannerReading.cs new file mode 100644 index 00000000..22652c4d --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/MvxBarcodeScannerReading.cs @@ -0,0 +1,23 @@ +// (c) Copyright Cirrious. http://www.cirrious.com +// This source is subject to the Microsoft Public License (Ms-PL) +// Please see license.txt on http://opensource.org/licenses/ms-pl.html +// All other rights reserved. +// +// +// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com - Hire me - I'm worth it! +// Implemented - Michael Bogaerts, 3Way. http://www.3Way.be - I'm worth it 2 ;-)! + +namespace MvvmCross.Plugins.BarcodeScanner { + public class MvxBarcodeScannerReading { + public MvxBarcodeScannerReading(uint scanDataType, string rawData, string barcode, string symbology) { + ScanDataType = scanDataType; + RawData = rawData; + Barcode = barcode; + Symbology = symbology; + } + public string Barcode { get; private set; } + public string RawData { get; private set; } + public uint ScanDataType { get; private set; } + public string Symbology { get; private set; } + } +} \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/PluginLoader.cs b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/PluginLoader.cs new file mode 100644 index 00000000..e307f169 --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/PluginLoader.cs @@ -0,0 +1,25 @@ +// (c) Copyright Cirrious. http://www.cirrious.com +// This source is subject to the Microsoft Public License (Ms-PL) +// Please see license.txt on http://opensource.org/licenses/ms-pl.html +// All other rights reserved. +// +// +// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com - Hire me - I'm worth it! +// Implemented - Michael Bogaerts, 3Way. http://www.3Way.be - I'm worth it 2 ;-)! + +using MvvmCross.Platform; +using MvvmCross.Platform.Plugins; + +namespace MvvmCross.Plugins.BarcodeScanner { + public class PluginLoader + : IMvxPluginLoader + { + public static readonly PluginLoader Instance = new PluginLoader(); + + public void EnsureLoaded() + { + var manager = Mvx.Resolve(); + manager.EnsurePlatformAdaptionLoaded(); + } + } +} \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/Properties/AssemblyInfo.cs b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..0c828d2a --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/Properties/AssemblyInfo.cs @@ -0,0 +1,40 @@ +// +// (c) Copyright Cirrious. http://www.cirrious.com +// This source is subject to the Microsoft Public License (Ms-PL) +// Please see license.txt on http://opensource.org/licenses/ms-pl.html +// All other rights reserved. +// +// +// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com - Hire me - I'm worth it! +// Implemented - Michael Bogaerts, 3Way. http://www.3Way.be - I'm worth it 2 ;-)! + +using System.Reflection; +using System.Resources; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("MvvmCross.Plugins.BarcodeScanner")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("3Way")] +[assembly: AssemblyProduct("MvvmCross.Plugins.BarcodeScanner")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] + +[assembly: AssemblyVersion("4.0.0.0")] +[assembly: AssemblyFileVersion("4.0.0.0")] \ No newline at end of file diff --git a/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/packages.config b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/packages.config new file mode 100644 index 00000000..2928a1bf --- /dev/null +++ b/BarcodeScanner/MvvmCross.Plugins.BarcodeScanner/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/BarcodeScanner/Readme.md b/BarcodeScanner/Readme.md new file mode 100644 index 00000000..093e8578 --- /dev/null +++ b/BarcodeScanner/Readme.md @@ -0,0 +1,16 @@ +### BarcodeScanner + +The `BarcodeScanner` plugin provides access to a platforms BarcodeScanner using a singleton implementing the API: + + public interface IMvxBarcodeScanner + { + void Start(); + void Stop(); + bool Started { get; } + MvxBarcodeScannerReading LastReading { get; } + event EventHandler> ReadingAvailable; + } + +This plugin for now only available WindowsStore. + +Please note that this implementation is \ No newline at end of file diff --git a/MvvmCross.Plugins.sln b/MvvmCross.Plugins.sln index 436fba6c..9cdd6228 100644 --- a/MvvmCross.Plugins.sln +++ b/MvvmCross.Plugins.sln @@ -301,6 +301,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCross.Plugins.Sqlite.Wi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCross.Plugins.Location.Fused.Droid", "Location\MvvmCross.Plugins.Location.Fused.Droid\MvvmCross.Plugins.Location.Fused.Droid.csproj", "{6F1EEC6C-49B6-4710-AD52-8EBAEBBFEB85}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCross.Plugins.BarcodeScanner", "BarcodeScanner\MvvmCross.Plugins.BarcodeScanner\MvvmCross.Plugins.BarcodeScanner.csproj", "{0E10E61C-78B8-437A-B044-6D1886F82ED9}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BarcodeScanner", "BarcodeScanner", "{0CB0E660-E503-4ABC-ACA9-E1BB9C493BB8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCross.Plugins.BarcodeScanner.WindowsStore", "BarcodeScanner\MvvmCross.Plugins.BarcodeScanner.WindowsStore\MvvmCross.Plugins.BarcodeScanner.WindowsStore.csproj", "{6535F213-3EF5-4243-8F0E-9FFC97959662}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -2297,6 +2303,38 @@ Global {6F1EEC6C-49B6-4710-AD52-8EBAEBBFEB85}.Release|x64.Build.0 = Release|Any CPU {6F1EEC6C-49B6-4710-AD52-8EBAEBBFEB85}.Release|x86.ActiveCfg = Release|Any CPU {6F1EEC6C-49B6-4710-AD52-8EBAEBBFEB85}.Release|x86.Build.0 = Release|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Debug|ARM.ActiveCfg = Debug|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Debug|ARM.Build.0 = Debug|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Debug|x64.ActiveCfg = Debug|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Debug|x64.Build.0 = Debug|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Debug|x86.ActiveCfg = Debug|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Debug|x86.Build.0 = Debug|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Release|Any CPU.Build.0 = Release|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Release|ARM.ActiveCfg = Release|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Release|ARM.Build.0 = Release|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Release|x64.ActiveCfg = Release|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Release|x64.Build.0 = Release|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Release|x86.ActiveCfg = Release|Any CPU + {0E10E61C-78B8-437A-B044-6D1886F82ED9}.Release|x86.Build.0 = Release|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Debug|ARM.ActiveCfg = Debug|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Debug|ARM.Build.0 = Debug|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Debug|x64.ActiveCfg = Debug|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Debug|x64.Build.0 = Debug|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Debug|x86.ActiveCfg = Debug|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Debug|x86.Build.0 = Debug|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Release|Any CPU.Build.0 = Release|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Release|ARM.ActiveCfg = Release|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Release|ARM.Build.0 = Release|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Release|x64.ActiveCfg = Release|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Release|x64.Build.0 = Release|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Release|x86.ActiveCfg = Release|Any CPU + {6535F213-3EF5-4243-8F0E-9FFC97959662}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2426,5 +2464,7 @@ Global {3BD0462A-71C0-4240-A780-0C0BD284A0D5} = {E7C40E91-1D44-4CE7-A137-3C444738E94F} {E7CC2E25-7F05-42BC-9FF6-34A9A28D02C7} = {9B45C8EC-18B9-4A88-950E-8D8FF8FAA1DA} {6F1EEC6C-49B6-4710-AD52-8EBAEBBFEB85} = {B5BE527E-B554-4A0F-9627-62E0F2DD8889} + {0E10E61C-78B8-437A-B044-6D1886F82ED9} = {0CB0E660-E503-4ABC-ACA9-E1BB9C493BB8} + {6535F213-3EF5-4243-8F0E-9FFC97959662} = {0CB0E660-E503-4ABC-ACA9-E1BB9C493BB8} EndGlobalSection EndGlobal diff --git a/nuspec/BootstrapContent/BarcodeScannerPluginBootstrap.cs.pp b/nuspec/BootstrapContent/BarcodeScannerPluginBootstrap.cs.pp new file mode 100644 index 00000000..8bfaab25 --- /dev/null +++ b/nuspec/BootstrapContent/BarcodeScannerPluginBootstrap.cs.pp @@ -0,0 +1,9 @@ +using MvvmCross.Platform.Plugins; + +namespace $rootnamespace$.Bootstrap +{ + public class BarcodeScannerPluginBootstrap + : MvxPluginBootstrapAction + { + } +} \ No newline at end of file diff --git a/nuspec/MvvmCross.Plugin.BarcodeScanner.nuspec b/nuspec/MvvmCross.Plugin.BarcodeScanner.nuspec new file mode 100644 index 00000000..973c15e4 --- /dev/null +++ b/nuspec/MvvmCross.Plugin.BarcodeScanner.nuspec @@ -0,0 +1,81 @@ + + + + MvvmCross.Plugin.BarcodeScanner + 4.1.6 + MvvmCross - BarcodeScanner Plugin + MvvmCross + Michael Bogaerts + http://opensource.org/licenses/ms-pl.html + https://github.com/MvvmCross/MvvmCross-Plugins + false + MvvmCross is the .NET MVVM framework for cross-platform solutions, including Xamarin iOS, Xamarin Android, Xamarin Forms, Windows and Mac. + +This package contains the 'BarcodeScanner' plugin for MvvmCross + mvvm mvvmcross cross xamarin android ios forms monodroid monotouch xamarin.android xamarin.ios xamarin.forms wpf windows8 winrt net net45 netcore wp wpdev windowsphone windowsstore uwp plugin + http://i.imgur.com/BvdAtgT.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuspec/pack.ps1 b/nuspec/pack.ps1 index a777921b..a0a27464 100644 --- a/nuspec/pack.ps1 +++ b/nuspec/pack.ps1 @@ -11,6 +11,7 @@ Set-Alias nuget $targetNugetExe -Scope Global -Verbose del *.nupkg nuget pack MvvmCross.Plugin.Accelerometer.nuspec -Symbols +nuget pack MvvmCross.Plugin.BarcodeScanner.nuspec -Symbols nuget pack MvvmCross.Plugin.All.nuspec -Symbols nuget pack MvvmCross.Plugin.Bookmarks.nuspec -Symbols nuget pack MvvmCross.Plugin.Color.nuspec -Symbols