forked from Redth/ZXing.Net.Mobile
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
302 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace ZXing.Net.Mobile.Forms.GTK | ||
{ | ||
public class Platform | ||
{ | ||
public static void Init () | ||
{ | ||
ZXing.Net.Mobile.Forms.GTK.ZXingBarcodeImageViewRenderer.Init(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
ZXing.Net.Mobile.Forms/ZXingBarcodeImageViewRenderer.gtk.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using Xamarin.Forms; | ||
using Xamarin.Forms.Platform.GTK; | ||
using ZXing.Net.Mobile.Forms; | ||
using ZXing.Net.Mobile.Forms.GTK; | ||
using ZXing.Net.Mobile.GTK; | ||
using Image = Gtk.Image; | ||
|
||
[assembly:ExportRenderer(typeof(ZXingBarcodeImageView), typeof(ZXingBarcodeImageViewRenderer))] | ||
namespace ZXing.Net.Mobile.Forms.GTK | ||
{ | ||
public class ZXingBarcodeImageViewRenderer : ViewRenderer<ZXingBarcodeImageView, Image> | ||
{ | ||
public static void Init() | ||
{ | ||
var temp = DateTime.Now; | ||
} | ||
|
||
ZXingBarcodeImageView formsView; | ||
Image gtkImage; | ||
|
||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) | ||
{ | ||
// in GTK there are a way to many properties that are changed compared to other platforms | ||
if (e.PropertyName == ZXingBarcodeImageView.BarcodeValueProperty.PropertyName || | ||
e.PropertyName == ZXingBarcodeImageView.BarcodeFormatProperty.PropertyName || | ||
e.PropertyName == ZXingBarcodeImageView.BarcodeOptionsProperty.PropertyName) | ||
{ | ||
Regenerate(); | ||
} | ||
|
||
base.OnElementPropertyChanged(sender, e); | ||
} | ||
|
||
protected override void OnElementChanged(ElementChangedEventArgs<ZXingBarcodeImageView> e) | ||
{ | ||
formsView = Element; | ||
|
||
if (gtkImage == null) | ||
{ | ||
gtkImage = new Image(); | ||
|
||
base.SetNativeControl(gtkImage); | ||
} | ||
|
||
Regenerate(); | ||
|
||
base.OnElementChanged(e); | ||
} | ||
|
||
void Regenerate () | ||
{ | ||
if (formsView != null && formsView.BarcodeValue != null) | ||
{ | ||
var writer = new BarcodeWriter(); | ||
|
||
if (formsView != null && formsView.BarcodeOptions != null) | ||
writer.Options = formsView.BarcodeOptions; | ||
if (formsView != null && formsView.BarcodeFormat != null) | ||
writer.Format = formsView.BarcodeFormat; | ||
|
||
var value = formsView != null ? formsView.BarcodeValue : string.Empty; | ||
|
||
Device.BeginInvokeOnMainThread(() => | ||
{ | ||
var pixBuf = writer.Write(value); | ||
gtkImage.Pixbuf = pixBuf; | ||
}); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Gdk; | ||
|
||
namespace ZXing.Net.Mobile.GTK | ||
{ | ||
public class BarcodeWriter : BarcodeWriter<Pixbuf>, IBarcodeWriter | ||
{ | ||
public BarcodeWriter() | ||
{ | ||
Renderer = new BitmapRenderer(); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Cairo; | ||
using Gdk; | ||
using ZXing.Common; | ||
using ZXing.Rendering; | ||
|
||
namespace ZXing.Net.Mobile.GTK | ||
{ | ||
public class BitmapRenderer : IBarcodeRenderer<Pixbuf> | ||
{ | ||
public Pixbuf Render(BitMatrix matrix, BarcodeFormat format, string content) | ||
{ | ||
var black = new Cairo.Color(0, 0, 0); | ||
var white = new Cairo.Color(1, 1, 1); | ||
using (var surface = new ImageSurface(Format.RGB24, matrix.Width, matrix.Height)) | ||
{ | ||
using (var cr = new Context(surface)) | ||
{ | ||
for (var x = 0; x < matrix.Width; x++) | ||
{ | ||
for (var y = 0; y < matrix.Height; y++) | ||
{ | ||
SetSourceColor(cr, matrix[x, y] ? black : white); | ||
cr.MoveTo(x, y); | ||
cr.LineTo(x + 1, y); | ||
cr.Stroke(); | ||
} | ||
} | ||
|
||
const int onlyBitsPerSampleValueSupportedByGdk = 8; | ||
return new Pixbuf(surface.Data, | ||
Colorspace.Rgb, | ||
true, | ||
onlyBitsPerSampleValueSupportedByGdk, | ||
matrix.Width, | ||
matrix.Height, | ||
surface.Stride); | ||
} | ||
} | ||
} | ||
|
||
private void SetSourceColor(Context context, Cairo.Color color) | ||
{ | ||
context.SetSourceRGB(color.R, color.G, color.B); | ||
} | ||
|
||
public Pixbuf Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options) | ||
{ | ||
return Render(matrix, format, content); | ||
} | ||
} | ||
} | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<configuration> | ||
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/> | ||
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/> | ||
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/> | ||
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/> | ||
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/> | ||
<dllmap os="linux" dll="libX11" target="libX11.so.6"/> | ||
<dllmap os="linux" dll="libXi" target="libXi.so.6"/> | ||
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/> | ||
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/> | ||
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" /> | ||
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" /> | ||
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" /> | ||
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" /> | ||
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" /> | ||
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/> | ||
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/> | ||
<!-- XQuartz compatibility (X11 on Mac) --> | ||
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/> | ||
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/> | ||
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/> | ||
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/> | ||
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/> | ||
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/opentk/opentk |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/mono/gtk-sharp |
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
ZXing.Net.Mobile/GTK/Libs/gtk-sharp/gtk-sharp-2.0/atk-sharp.dll.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<configuration> | ||
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.12.0/lib/libgobject-2.0.0.dylib"/> | ||
<dllmap dll="libatk-1.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.12.0/lib/libatk-1.0.0.dylib"/> | ||
</configuration> |
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
ZXing.Net.Mobile/GTK/Libs/gtk-sharp/gtk-sharp-2.0/gdk-sharp.dll.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<configuration> | ||
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.0.dylib"/> | ||
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.0.dylib"/> | ||
<dllmap dll="libgdk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdk-quartz-2.0.0.dylib"/> | ||
<dllmap dll="libgdk_pixbuf-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdk_pixbuf-2.0.0.dylib"/> | ||
</configuration> |
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
ZXing.Net.Mobile/GTK/Libs/gtk-sharp/gtk-sharp-2.0/glade-sharp.dll.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<configuration> | ||
<dllmap dll="libglade-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglade-2.0.0.dylib"/> | ||
</configuration> |
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
ZXing.Net.Mobile/GTK/Libs/gtk-sharp/gtk-sharp-2.0/glib-sharp.dll.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<configuration> | ||
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.0.dylib"/> | ||
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.0.dylib"/> | ||
<dllmap dll="libgthread-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgthread-2.0.0.dylib"/> | ||
</configuration> |
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
ZXing.Net.Mobile/GTK/Libs/gtk-sharp/gtk-sharp-2.0/gtk-dotnet.dll.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<configuration> | ||
<dllmap dll="libgdk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdk-quartz-2.0.0.dylib"/> | ||
</configuration> |
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
ZXing.Net.Mobile/GTK/Libs/gtk-sharp/gtk-sharp-2.0/gtk-sharp.dll.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<configuration> | ||
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.0.dylib"/> | ||
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.0.dylib"/> | ||
<dllmap dll="libatk-1.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libatk-1.0.0.dylib"/> | ||
<dllmap dll="libgtk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgtk-quartz-2.0.0.dylib"/> | ||
<dllmap dll="libgdk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdk-quartz-2.0.0.dylib"/> | ||
</configuration> |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
ZXing.Net.Mobile/GTK/Libs/gtk-sharp/gtk-sharp-2.0/pango-sharp.dll.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<configuration> | ||
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.0.dylib"/> | ||
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.0.dylib"/> | ||
<dllmap dll="libpango-1.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libpango-1.0.0.dylib"/> | ||
<dllmap dll="libpangocairo-1.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libpangocairo-1.0.0.dylib"/> | ||
</configuration> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/mono/webkit-sharp |
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
ZXing.Net.Mobile/GTK/Libs/webkit-sharp/webkit-sharp.dll.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<configuration> | ||
<dllmap dll="webkit-1.0" target="libwebkitgtk-1.0.0.dylib"/> | ||
<dllmap dll="webkit-1.0" os="linux" target="libwebkitgtk-1.0.so.0"/> | ||
<dllmap dll="webkit-1.0" os="windows" target="libwebkitgtk-1.0-0.dll"/> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace ZXing.Mobile | ||
{ | ||
public partial class MobileBarcodeScanner : MobileBarcodeScannerBase | ||
{ | ||
var ex = new NotSupportedException("MobileBarcodeScanner is unsupported on this platform."); | ||
|
||
Task<Result> PlatformScan(MobileBarcodeScanningOptions options) | ||
=> throw ex; | ||
|
||
void PlatformScanContinuously(MobileBarcodeScanningOptions options, Action<Result> scanHandler) | ||
=> throw ex; | ||
|
||
void PlatformCancel() | ||
=> throw ex; | ||
|
||
void PlatformAutoFocus() | ||
=> throw ex; | ||
|
||
void PlatformTorch(bool on) | ||
=> throw ex; | ||
|
||
void PlatformToggleTorch() | ||
=> throw ex; | ||
|
||
void PlatformPauseAnalysis() | ||
=> throw ex; | ||
|
||
void PlatformResumeAnalysis() | ||
=> throw ex; | ||
|
||
bool PlatformIsTorchOn | ||
=> throw ex; | ||
} | ||
} |
Oops, something went wrong.