diff --git a/BigIslandBarcode/BigIslandBarcode.csproj b/BigIslandBarcode/BigIslandBarcode.csproj
index 0e373eb..b1a752a 100644
--- a/BigIslandBarcode/BigIslandBarcode.csproj
+++ b/BigIslandBarcode/BigIslandBarcode.csproj
@@ -46,6 +46,7 @@
+
diff --git a/BigIslandBarcode/MainPage.xaml b/BigIslandBarcode/MainPage.xaml
index bb357b5..42d5db3 100644
--- a/BigIslandBarcode/MainPage.xaml
+++ b/BigIslandBarcode/MainPage.xaml
@@ -1,6 +1,6 @@
diff --git a/BigIslandBarcode/MauiProgram.cs b/BigIslandBarcode/MauiProgram.cs
index b21db78..1e9cfa8 100644
--- a/BigIslandBarcode/MauiProgram.cs
+++ b/BigIslandBarcode/MauiProgram.cs
@@ -4,6 +4,7 @@
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.LifecycleEvents;
using ZXing.Net.Maui;
+using ZXing.Net.Maui.Controls;
#if ANDROID
[assembly: Android.App.UsesPermission(Android.Manifest.Permission.Camera)]
diff --git a/ZXing.Net.MAUI.Comet/Controls.cs b/ZXing.Net.MAUI.Comet/Controls.cs
new file mode 100644
index 0000000..4ca2e09
--- /dev/null
+++ b/ZXing.Net.MAUI.Comet/Controls.cs
@@ -0,0 +1,6 @@
+using Comet;
+using ZXing.Net.Maui;
+
+[assembly: CometGenerate(typeof(ICameraBarcodeReaderView), nameof(ICameraBarcodeReaderView.BarcodesDetected))]
+[assembly: CometGenerate(typeof(ICameraView), nameof(ICameraView.CameraLocation))]
+[assembly: CometGenerate(typeof(IBarcodeGeneratorView), nameof(IBarcodeGeneratorView.Value), nameof(IBarcodeGeneratorView.Format), Skip = new[] { $"{nameof(IBarcodeGeneratorView.ForegroundColor)}:{EnvironmentKeys.Colors.Color}" })]
\ No newline at end of file
diff --git a/ZXing.Net.MAUI.Comet/HostBuilderExtensions.cs b/ZXing.Net.MAUI.Comet/HostBuilderExtensions.cs
new file mode 100644
index 0000000..6ed11d6
--- /dev/null
+++ b/ZXing.Net.MAUI.Comet/HostBuilderExtensions.cs
@@ -0,0 +1,59 @@
+#if IOS || MACCATALYST
+global using NativePlatformCameraPreviewView = global::UIKit.UIView;
+global using NativePlatformView = global::UIKit.UIView;
+global using NativePlatformImageView = global::UIKit.UIImageView;
+global using NativePlatformImage = global::UIKit.UIImage;
+#elif ANDROID
+global using NativePlatformCameraPreviewView = global::AndroidX.Camera.View.PreviewView;
+global using NativePlatformView = global::Android.Views.View;
+global using NativePlatformImageView = global::Android.Widget.ImageView;
+global using NativePlatformImage = global::Android.Graphics.Bitmap;
+#elif WINDOWS
+global using NativePlatformCameraPreviewView = global::Microsoft.UI.Xaml.FrameworkElement;
+global using NativePlatformView = global::Microsoft.UI.Xaml.FrameworkElement;
+global using NativePlatformImageView = global::Microsoft.UI.Xaml.Controls.Image;
+global using NativePlatformImage = global::Microsoft.UI.Xaml.Media.Imaging.WriteableBitmap;
+#endif
+
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Maui.Hosting;
+using Microsoft.Maui;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+namespace ZXing.Net.Maui
+{
+ public static class MauiHostBuilderExtensions
+ {
+ public static MauiAppBuilder UseBarcodeReader(this MauiAppBuilder builder)
+ {
+ builder.ConfigureMauiHandlers(handlers =>
+ {
+ handlers.AddHandler(typeof(CameraView), typeof(CameraViewHandler));
+ handlers.AddHandler(typeof(CameraBarcodeReaderView), typeof(CameraBarcodeReaderViewHandler));
+ handlers.AddHandler(typeof(BarcodeGeneratorView), typeof(BarcodeGeneratorViewHandler));
+ });
+
+ builder.Services.AddTransient();
+
+ return builder;
+ }
+
+ public static MauiAppBuilder UseBarcodeReader(this MauiAppBuilder builder) where TBarcodeReader : class, Readers.IBarcodeReader
+ {
+ builder.ConfigureMauiHandlers(handlers =>
+ {
+ handlers.AddHandler(typeof(CameraView), typeof(CameraViewHandler));
+ handlers.AddHandler(typeof(CameraBarcodeReaderView), typeof(CameraBarcodeReaderViewHandler));
+ handlers.AddHandler(typeof(BarcodeGeneratorView), typeof(BarcodeGeneratorViewHandler));
+ });
+
+ builder.Services.AddTransient();
+
+ return builder;
+ }
+
+ }
+}
diff --git a/ZXing.Net.MAUI.Comet/ZXing.Net.MAUI.Comet.csproj b/ZXing.Net.MAUI.Comet/ZXing.Net.MAUI.Comet.csproj
new file mode 100644
index 0000000..687c084
--- /dev/null
+++ b/ZXing.Net.MAUI.Comet/ZXing.Net.MAUI.Comet.csproj
@@ -0,0 +1,28 @@
+
+
+ net6.0-android;net6.0-maccatalyst;net6.0-ios
+ $(TargetFrameworks);net6.0-windows10.0.19041
+ ZXing.Net.Maui.Comet
+ ZXing.Net.MAUI Barcode Scanner for .NET MAUI
+ Redth
+ True
+ True
+ true
+ false
+ Copyright © Redth
+ https://github.com/redth/BigIslandBarcoding
+ MIT
+ https://github.com/redth/BigIslandBarcoding
+ $(PackageVersion)
+ true
+ portable
+ Library
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ZXing.Net.MAUI/Controls/BarcodeGeneratorView.cs b/ZXing.Net.MAUI.Controls/Controls/BarcodeGeneratorView.cs
similarity index 100%
rename from ZXing.Net.MAUI/Controls/BarcodeGeneratorView.cs
rename to ZXing.Net.MAUI.Controls/Controls/BarcodeGeneratorView.cs
diff --git a/ZXing.Net.MAUI/Controls/CameraBarcodeReaderView.cs b/ZXing.Net.MAUI.Controls/Controls/CameraBarcodeReaderView.cs
similarity index 78%
rename from ZXing.Net.MAUI/Controls/CameraBarcodeReaderView.cs
rename to ZXing.Net.MAUI.Controls/Controls/CameraBarcodeReaderView.cs
index 0a822ee..86b8b94 100644
--- a/ZXing.Net.MAUI/Controls/CameraBarcodeReaderView.cs
+++ b/ZXing.Net.MAUI.Controls/Controls/CameraBarcodeReaderView.cs
@@ -15,24 +15,8 @@ public partial class CameraBarcodeReaderView : View, ICameraBarcodeReaderView
public event EventHandler BarcodesDetected;
public event EventHandler FrameReady;
- protected override void OnHandlerChanging(HandlerChangingEventArgs args)
- {
- base.OnHandlerChanging(args);
- if (args.OldHandler is CameraBarcodeReaderViewHandler oldHandler)
- {
- oldHandler.BarcodesDetected -= Handler_BarcodesDetected;
- oldHandler.FrameReady -= Handler_FrameReady;
- }
-
- if (args.NewHandler is CameraBarcodeReaderViewHandler newHandler)
- {
- newHandler.BarcodesDetected += Handler_BarcodesDetected;
- newHandler.FrameReady += Handler_FrameReady;
- }
- }
-
- void Handler_BarcodesDetected(object sender, BarcodeDetectionEventArgs e)
- => BarcodesDetected?.Invoke(this, e);
+ void ICameraBarcodeReaderView.BarcodesDetected(BarcodeDetectionEventArgs e) => BarcodesDetected?.Invoke(this, e);
+ void ICameraFrameAnalyzer.FrameReady(ZXing.Net.Maui.CameraFrameBufferEventArgs e) => FrameReady?.Invoke(this, e);
public static readonly BindableProperty OptionsProperty =
BindableProperty.Create(nameof(Options), typeof(BarcodeReaderOptions), typeof(CameraBarcodeReaderView), defaultValueCreator: bindableObj => new BarcodeReaderOptions());
diff --git a/ZXing.Net.MAUI/Controls/CameraView.cs b/ZXing.Net.MAUI.Controls/Controls/CameraView.cs
similarity index 74%
rename from ZXing.Net.MAUI/Controls/CameraView.cs
rename to ZXing.Net.MAUI.Controls/Controls/CameraView.cs
index 316d8df..724d38d 100644
--- a/ZXing.Net.MAUI/Controls/CameraView.cs
+++ b/ZXing.Net.MAUI.Controls/Controls/CameraView.cs
@@ -9,17 +9,7 @@ public partial class CameraView : View, ICameraView
{
public event EventHandler FrameReady;
- protected override void OnHandlerChanging(HandlerChangingEventArgs args)
- {
- base.OnHandlerChanging(args);
- if (args.OldHandler is CameraViewHandler oldHandler)
- oldHandler.FrameReady -= Handler_FrameReady;
-
- if (args.NewHandler is CameraViewHandler newHandler)
- newHandler.FrameReady += Handler_FrameReady;
- }
-
- void Handler_FrameReady(object sender, CameraFrameBufferEventArgs e)
+ void ICameraFrameAnalyzer.FrameReady(CameraFrameBufferEventArgs e)
=> FrameReady?.Invoke(this, e);
public static readonly BindableProperty IsTorchOnProperty =
diff --git a/ZXing.Net.MAUI/HostBuilderExtensions.cs b/ZXing.Net.MAUI.Controls/HostBuilderExtensions.cs
similarity index 98%
rename from ZXing.Net.MAUI/HostBuilderExtensions.cs
rename to ZXing.Net.MAUI.Controls/HostBuilderExtensions.cs
index d9d7d65..f63fa29 100644
--- a/ZXing.Net.MAUI/HostBuilderExtensions.cs
+++ b/ZXing.Net.MAUI.Controls/HostBuilderExtensions.cs
@@ -25,7 +25,7 @@
using System.Threading.Tasks;
using ZXing.Net.Maui.Controls;
-namespace ZXing.Net.Maui
+namespace ZXing.Net.Maui.Controls
{
public static class CameraViewExtensions
{
diff --git a/ZXing.Net.MAUI.Controls/ZXing.Net.MAUI.Controls.csproj b/ZXing.Net.MAUI.Controls/ZXing.Net.MAUI.Controls.csproj
new file mode 100644
index 0000000..ab94116
--- /dev/null
+++ b/ZXing.Net.MAUI.Controls/ZXing.Net.MAUI.Controls.csproj
@@ -0,0 +1,27 @@
+
+
+ net6.0-android;net6.0-maccatalyst;net6.0-ios
+ $(TargetFrameworks);net6.0-windows10.0.19041
+ ZXing.Net.Maui.Controls
+ ZXing.Net.MAUI Barcode Scanner for .NET MAUI
+ Redth
+ True
+ True
+ true
+ false
+ Copyright © Redth
+ https://github.com/redth/BigIslandBarcoding
+ MIT
+ https://github.com/redth/BigIslandBarcoding
+ $(PackageVersion)
+ true
+ portable
+ Library
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ZXing.Net.MAUI.sln b/ZXing.Net.MAUI.sln
index c2c556a..29622e5 100644
--- a/ZXing.Net.MAUI.sln
+++ b/ZXing.Net.MAUI.sln
@@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZXing.Net.MAUI", "ZXing.Net
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BigIslandBarcode", "BigIslandBarcode\BigIslandBarcode.csproj", "{D3EBA600-16E4-4C91-A9E9-CC600FA2B481}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZXing.Net.MAUI.Controls", "ZXing.Net.MAUI.Controls\ZXing.Net.MAUI.Controls.csproj", "{F7911DCB-5278-4CE9-A934-48089F92162A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -22,6 +24,10 @@ Global
{D3EBA600-16E4-4C91-A9E9-CC600FA2B481}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{D3EBA600-16E4-4C91-A9E9-CC600FA2B481}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3EBA600-16E4-4C91-A9E9-CC600FA2B481}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F7911DCB-5278-4CE9-A934-48089F92162A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F7911DCB-5278-4CE9-A934-48089F92162A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F7911DCB-5278-4CE9-A934-48089F92162A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F7911DCB-5278-4CE9-A934-48089F92162A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ZXing.Net.MAUI/GlobalUsings.cs b/ZXing.Net.MAUI/GlobalUsings.cs
new file mode 100644
index 0000000..dc3628a
--- /dev/null
+++ b/ZXing.Net.MAUI/GlobalUsings.cs
@@ -0,0 +1,16 @@
+#if IOS || MACCATALYST
+global using NativePlatformCameraPreviewView = global::UIKit.UIView;
+global using NativePlatformView = global::UIKit.UIView;
+global using NativePlatformImageView = global::UIKit.UIImageView;
+global using NativePlatformImage = global::UIKit.UIImage;
+#elif ANDROID
+global using NativePlatformCameraPreviewView = global::AndroidX.Camera.View.PreviewView;
+global using NativePlatformView = global::Android.Views.View;
+global using NativePlatformImageView = global::Android.Widget.ImageView;
+global using NativePlatformImage = global::Android.Graphics.Bitmap;
+#elif WINDOWS
+global using NativePlatformCameraPreviewView = global::Microsoft.UI.Xaml.FrameworkElement;
+global using NativePlatformView = global::Microsoft.UI.Xaml.FrameworkElement;
+global using NativePlatformImageView = global::Microsoft.UI.Xaml.Controls.Image;
+global using NativePlatformImage = global::Microsoft.UI.Xaml.Media.Imaging.WriteableBitmap;
+#endif
\ No newline at end of file
diff --git a/ZXing.Net.MAUI/ICameraBarcodeReaderView.cs b/ZXing.Net.MAUI/ICameraBarcodeReaderView.cs
index 2d2c761..fd746a3 100644
--- a/ZXing.Net.MAUI/ICameraBarcodeReaderView.cs
+++ b/ZXing.Net.MAUI/ICameraBarcodeReaderView.cs
@@ -9,7 +9,7 @@ public interface ICameraBarcodeReaderView : ICameraView
{
BarcodeReaderOptions Options { get; }
- event EventHandler BarcodesDetected;
+ void BarcodesDetected(BarcodeDetectionEventArgs args);
bool IsDetecting { get; set; }
}
diff --git a/ZXing.Net.MAUI/ICameraView.cs b/ZXing.Net.MAUI/ICameraView.cs
index fc46789..e9b2ecf 100644
--- a/ZXing.Net.MAUI/ICameraView.cs
+++ b/ZXing.Net.MAUI/ICameraView.cs
@@ -7,7 +7,7 @@ namespace ZXing.Net.Maui
{
public interface ICameraFrameAnalyzer
{
- event EventHandler FrameReady;
+ void FrameReady(CameraFrameBufferEventArgs args);
}
public interface ICameraView : IView, ICameraFrameAnalyzer