QR-Code Scanner
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Jugenddienst_Stunden.Models {
|
|||||||
|
|
||||||
private static readonly string BaseAddress = "http://hours.dauni.mine.nu:81";
|
private static readonly string BaseAddress = "http://hours.dauni.mine.nu:81";
|
||||||
//private static readonly string apiKey = "MTQzfEFlMVRjQXdZMnI4RmpxZ0FSY3A0VEN2bVZYVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //Christine
|
//private static readonly string apiKey = "MTQzfEFlMVRjQXdZMnI4RmpxZ0FSY3A0VEN2bVZYVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //Christine
|
||||||
private static readonly string apiKey = "MTU0fGpkQUNYTGkvcjMvVk4rNkMyK0dDQkJmMkFwVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //Damian
|
public static string apiKey = "MTU0fGpkQUNYTGkvcjMvVk4rNkMyK0dDQkJmMkFwVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //Damian
|
||||||
private static readonly string requestUrl = $"{BaseAddress}/appapi?hours";
|
private static readonly string requestUrl = $"{BaseAddress}/appapi?hours";
|
||||||
|
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
|||||||
@@ -57,5 +57,6 @@ namespace Jugenddienst_Stunden.ViewModels {
|
|||||||
OnPropertyChanged(nameof(Hours));
|
OnPropertyChanged(nameof(Hours));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,64 @@
|
|||||||
using ZXing;
|
using Microsoft.Maui.Controls;
|
||||||
using ZXing.Net.Maui.Controls;
|
using System.Collections.Generic;
|
||||||
|
using ZXing.Net.Maui;
|
||||||
|
|
||||||
namespace Jugenddienst_Stunden.Views;
|
namespace Jugenddienst_Stunden.Views;
|
||||||
|
|
||||||
public partial class AboutPage : ContentPage
|
public partial class AboutPage : ContentPage {
|
||||||
{
|
|
||||||
public AboutPage()
|
private DateTime _lastDetectionTime;
|
||||||
{
|
private readonly TimeSpan _detectionInterval = TimeSpan.FromSeconds(3);
|
||||||
|
|
||||||
|
public AboutPage() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
barcodeScannerView.Options = new ZXing.Net.Maui.BarcodeReaderOptions {
|
barcodeScannerView.Options = new ZXing.Net.Maui.BarcodeReaderOptions {
|
||||||
Formats = ZXing.Net.Maui.BarcodeFormat.QrCode,
|
Formats = ZXing.Net.Maui.BarcodeFormat.QrCode,
|
||||||
AutoRotate = true,
|
AutoRotate = true,
|
||||||
Multiple = false
|
Multiple = false
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BarcodesDetected(object sender, ZXing.Net.Maui.BarcodeDetectionEventArgs e) {
|
private void BarcodesDetected(object sender, ZXing.Net.Maui.BarcodeDetectionEventArgs e) {
|
||||||
var first = e.Results?.FirstOrDefault();
|
//var first = e.Results?.FirstOrDefault();
|
||||||
if (first is null) {
|
|
||||||
return;
|
var currentTime = DateTime.Now;
|
||||||
}
|
if ((currentTime - _lastDetectionTime) > _detectionInterval) {
|
||||||
Dispatcher.DispatchAsync(async () => {
|
_lastDetectionTime = currentTime;
|
||||||
await DisplayAlert("Scan-Ergebnis", $"Barcode: {first.Value}", "OK");
|
foreach (var barcode in e.Results) {
|
||||||
|
MainThread.InvokeOnMainThreadAsync(() => {
|
||||||
|
DisplayAlert("Barcode erkannt", $"Barcode: {barcode.Format} - {barcode.Value}", "OK");
|
||||||
|
Models.Stunde.apiKey = barcode.Value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (first is null) {
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
//Dispatcher.DispatchAsync(async () => {
|
||||||
|
// await DisplayAlert("Scan-Ergebnis", $"Barcode: {first.Value}", "OK");
|
||||||
|
//});
|
||||||
|
//MainThread.InvokeOnMainThreadAsync(() => {
|
||||||
|
// DisplayAlert("Barcode erkannt", $"Barcode: {first.Format} - {first.Value}", "OK");
|
||||||
|
// Models.Stunde.apiKey = first.Value;
|
||||||
|
//});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDisappearing() {
|
||||||
|
base.OnDisappearing();
|
||||||
|
barcodeScannerView.CameraLocation = CameraLocation.Front;
|
||||||
|
barcodeScannerView.IsDetecting = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnAppearing() {
|
||||||
|
base.OnAppearing();
|
||||||
|
|
||||||
|
barcodeScannerView.IsDetecting = true;
|
||||||
|
barcodeScannerView.CameraLocation = CameraLocation.Rear;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,11 +20,11 @@
|
|||||||
<Label Text="Überstunden Jahr:" Grid.Row="4" />
|
<Label Text="Überstunden Jahr:" Grid.Row="4" />
|
||||||
|
|
||||||
|
|
||||||
<Label BackgroundColor="AliceBlue" Grid.Row="0" Grid.Column="1" Text="{Binding Nominal}" />
|
<Label BackgroundColor="AliceBlue" Grid.Row="0" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Nominal}" />
|
||||||
<Label BackgroundColor="AliceBlue" Grid.Row="1" Grid.Column="1" Text="{Binding ZeitDone}" />
|
<Label BackgroundColor="AliceBlue" Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding ZeitDone}" />
|
||||||
<Label BackgroundColor="AliceBlue" Grid.Row="2" Grid.Column="1" Text="{Binding ZeitCalculated}" />
|
<Label BackgroundColor="AliceBlue" Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding ZeitCalculated}" />
|
||||||
<Label BackgroundColor="AliceBlue" Grid.Row="3" Grid.Column="1" Text="{Binding OvertimeMonth}" />
|
<Label BackgroundColor="AliceBlue" Grid.Row="3" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding OvertimeMonth}" />
|
||||||
<Label BackgroundColor="AliceBlue" Grid.Row="4" Grid.Column="1" Text="{Binding Overtime}" />
|
<Label BackgroundColor="AliceBlue" Grid.Row="4" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Overtime}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
Reference in New Issue
Block a user