-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCameraPage.xaml.cs
More file actions
38 lines (33 loc) · 921 Bytes
/
CameraPage.xaml.cs
File metadata and controls
38 lines (33 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using ZXing.Net.Maui.Controls;
using ZXing.Net.Maui;
namespace Manta;
public partial class CameraPage : ContentPage
{
public CameraPage()
{
InitializeComponent();
CameraBarcodeScannerView.Options = new BarcodeReaderOptions
{
Formats = BarcodeFormats.TwoDimensional,
AutoRotate = true,
Multiple = false,
TryInverted = true
};
}
private TaskCompletionSource<BarcodeResult[]> ScanTCS = new();
public Task<BarcodeResult[]> WaitForResultAsync()
{
return ScanTCS.Task;
}
private void OnBarcodesDetected(object sender, BarcodeDetectionEventArgs e)
{
var barcode = e.Results.FirstOrDefault()?.Value;
if (barcode is not null)
{
MainThread.BeginInvokeOnMainThread(() =>
{
ScanTCS.TrySetResult(e.Results);
});
}
}
}