-
Notifications
You must be signed in to change notification settings - Fork 2
/
BarcodeClassicComponentPage.xaml.cs
54 lines (45 loc) · 1.4 KB
/
BarcodeClassicComponentPage.xaml.cs
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using ScanbotSDK.MAUI.Configurations;
using ScanbotSDK.MAUI.Constants;
using ScanbotSDK.MAUI.Models;
namespace ScanbotSDK.MAUI.Example.Pages
{
public partial class BarcodeClassicComponentPage : BaseComponentPage
{
public BarcodeClassicComponentPage()
{
InitializeComponent();
}
private void HandleScannerResults(BarcodeResultBundle result)
{
string text = string.Empty;
if (result?.Barcodes != null)
{
foreach (Barcode barcode in result.Barcodes)
{
text += $"{barcode.Text} ({barcode.Format.ToString().ToUpper()})\n";
}
}
MainThread.BeginInvokeOnMainThread(() =>
{
System.Diagnostics.Debug.WriteLine(text);
lblResult.Text = text;
});
}
protected override void OnAppearing()
{
base.OnAppearing();
// Start barcode detection manually
cameraView.StartDetection();
}
protected override void OnDisappearing()
{
base.OnDisappearing();
// Stop barcode detection manually
cameraView.StopDetection();
}
private void CameraView_OnOnBarcodeScanResult(BarcodeResultBundle result)
{
HandleScannerResults(result);
}
}
}