Skip to content

Commit

Permalink
Merge branch 'main' into pr/135
Browse files Browse the repository at this point in the history
  • Loading branch information
Redth committed Oct 23, 2023
2 parents e46d335 + 20fe0f8 commit 0755b2c
Show file tree
Hide file tree
Showing 17 changed files with 910 additions and 97 deletions.
2 changes: 1 addition & 1 deletion BigIslandBarcode/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Grid
Grid.Row="0"
BackgroundColor="#aa000000">
<Label Grid.Row="2" Text="Top text..." HorizontalOptions="Center" VerticalOptions="Center" TextColor="White" />
<Label x:Name="ResultLabel" Grid.Row="2" Text="Top text..." HorizontalOptions="Center" VerticalOptions="Center" TextColor="White" />
</Grid>

<Grid
Expand Down
8 changes: 4 additions & 4 deletions BigIslandBarcode/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ protected void BarcodesDetected(object sender, BarcodeDetectionEventArgs e)
{
Dispatcher.Dispatch(() =>
{
// Update BarcodeGeneratorView
// Update BarcodeGeneratorView
barcodeGenerator.ClearValue(BarcodeGeneratorView.ValueProperty);
barcodeGenerator.Format = first.Format;
barcodeGenerator.Value = first.Value;

// Update Label
ResultLabel.Text = $"Barcodes: {first.Format} -> {first.Value}";
// Update Label
ResultLabel.Text = $"Barcodes: {first.Format} -> {first.Value}";
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The successor to ZXing.Net.Mobile: barcode scanning and generation for .NET MAUI

### Install ZXing.Net.MAUI

1. Install [ZXing.Net.MAUI](https://www.nuget.org/packages/ZXing.Net.Maui) NuGet package on your .NET MAUI application
1. Install [ZXing.Net.Maui.Controls](https://www.nuget.org/packages/ZXing.Net.Maui.Controls) NuGet package on your .NET MAUI application

1. Make sure to initialize the plugin first in your `MauiProgram.cs`, see below

Expand Down Expand Up @@ -59,7 +59,7 @@ For more information on permissions, see the [Microsoft Docs](https://docs.micro
### Using ZXing.Net.Maui

If you're using the controls from XAML, make sure to add the right XML namespace in the root of your file, e.g: `xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI"`
If you're using the controls from XAML, make sure to add the right XML namespace in the root of your file, e.g: `xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI.Controls"`

```xaml
<zxing:CameraBarcodeReaderView
Expand Down
5 changes: 5 additions & 0 deletions ZXing.Net.MAUI.Comet/HostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
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;
#else
global using NativePlatformCameraPreviewView = ZXing.Net.Maui.NativePlatformCameraPreviewView;
global using NativePlatformView = ZXing.Net.Maui.NativePlatformView;
global using NativePlatformImageView = ZXing.Net.Maui.NativePlatformImageView;
global using NativePlatformImage = ZXing.Net.Maui.NativePlatformImage;
#endif

using Microsoft.Extensions.DependencyInjection;
Expand Down
4 changes: 2 additions & 2 deletions ZXing.Net.MAUI.Comet/ZXing.Net.MAUI.Comet.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-maccatalyst;net7.0-ios</TargetFrameworks>
<TargetFrameworks>net7.0;net7.0-android;net7.0-maccatalyst;net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041</TargetFrameworks>
<PackageId>ZXing.Net.Maui.Comet</PackageId>
<Title>ZXing.Net.MAUI Barcode Scanner for .NET MAUI</Title>
Expand All @@ -19,7 +19,7 @@
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ZXing.Net" Version="0.16.8" />
<PackageReference Include="ZXing.Net" Version="0.16.9" />
<PackageReference Include="Clancey.Comet" Version="0.3.467-beta" />
</ItemGroup>
<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions ZXing.Net.MAUI.Controls/HostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
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;
#else
global using NativePlatformCameraPreviewView = ZXing.Net.Maui.NativePlatformCameraPreviewView;
global using NativePlatformView = ZXing.Net.Maui.NativePlatformView;
global using NativePlatformImageView = ZXing.Net.Maui.NativePlatformImageView;
global using NativePlatformImage = ZXing.Net.Maui.NativePlatformImage;
#endif

using Microsoft.Extensions.DependencyInjection;
Expand Down
4 changes: 2 additions & 2 deletions ZXing.Net.MAUI.Controls/ZXing.Net.MAUI.Controls.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-maccatalyst;net7.0-ios</TargetFrameworks>
<TargetFrameworks>net7.0;net7.0-android;net7.0-maccatalyst;net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041</TargetFrameworks>
<PackageId>ZXing.Net.Maui.Controls</PackageId>
<Title>ZXing.Net.MAUI Barcode Scanner for .NET MAUI</Title>
Expand All @@ -19,7 +19,7 @@
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ZXing.Net" Version="0.16.8" />
<PackageReference Include="ZXing.Net" Version="0.16.9" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZXing.Net.MAUI\ZXing.Net.MAUI.csproj" />
Expand Down
3 changes: 3 additions & 0 deletions ZXing.Net.MAUI/Apple/CameraManager.ios.maccatalyst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ public void UpdateCamera()
if (captureDevice == null)
captureDevice = AVCaptureDevice.GetDefaultDevice(AVMediaTypes.Video);

if (captureDevice is null)
return;

captureInput = new AVCaptureDeviceInput(captureDevice, out var err);

captureSession.AddInput(captureInput);
Expand Down
5 changes: 5 additions & 0 deletions ZXing.Net.MAUI/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
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;
#else
global using NativePlatformCameraPreviewView = ZXing.Net.Maui.NativePlatformCameraPreviewView;
global using NativePlatformView = ZXing.Net.Maui.NativePlatformView;
global using NativePlatformImageView = ZXing.Net.Maui.NativePlatformImageView;
global using NativePlatformImage = ZXing.Net.Maui.NativePlatformImage;
#endif
16 changes: 16 additions & 0 deletions ZXing.Net.MAUI/Net/BarcodeWriter.net.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Maui.Graphics;

namespace ZXing.Net.Maui
{
public class BarcodeWriter : BarcodeWriter<NativePlatformImage>
{
public Color ForegroundColor { get; set; }

public Color BackgroundColor { get; set; }
}
}
43 changes: 43 additions & 0 deletions ZXing.Net.MAUI/Net/CameraManager.net.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZXing.Net.Maui
{
internal partial class CameraManager
{
public NativePlatformCameraPreviewView CreateNativeView()
{
return new NativePlatformCameraPreviewView();
}

public void Connect()
=> LogUnsupported();

public void Disconnect()
=> LogUnsupported();

public void UpdateCamera()
=> LogUnsupported();

public void UpdateTorch(bool on)
=> LogUnsupported();

public void Focus(Microsoft.Maui.Graphics.Point point)
=> LogUnsupported();

public void AutoFocus()
=> LogUnsupported();

public void Dispose()
=> LogUnsupported();

void LogUnsupported()
=> Debug.WriteLine("Camera preview is not supported on this platform.");
}
}
24 changes: 24 additions & 0 deletions ZXing.Net.MAUI/Net/NativePlatformView.net.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZXing.Net.Maui
{
public class NativePlatformCameraPreviewView
{
}

public class NativePlatformImageView
{
}

public class NativePlatformView
{
}

public class NativePlatformImage
{
}
}
2 changes: 2 additions & 0 deletions ZXing.Net.MAUI/PixelBufferHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public record PixelBufferHolder
Java.Nio.ByteBuffer
#elif IOS || MACCATALYST
CoreVideo.CVPixelBuffer
#elif WINDOWS
Windows.Graphics.Imaging.SoftwareBitmap
#else
byte[]
#endif
Expand Down
Loading

0 comments on commit 0755b2c

Please sign in to comment.