MOBILE BugFix
This commit is contained in:
@@ -29,14 +29,14 @@ namespace WorkFlowCheck.MAUI
|
||||
_dbContext.Database.EnsureDeleted(); // Adatbázis törlése
|
||||
_dbContext.Database.EnsureCreated(); // Új adatbázis létrehozása
|
||||
|
||||
StartBackgroundTask();
|
||||
//StartBackgroundTask();
|
||||
MainPage = new AppShell();
|
||||
//MainPage = new NavigationPage(new MainPage(serviceProvider.GetRequiredService<IUserService>()));
|
||||
|
||||
}
|
||||
protected async override void OnResume()
|
||||
{
|
||||
StartBackgroundTask();
|
||||
//StartBackgroundTask();
|
||||
base.OnResume();
|
||||
var isLogged = await SecureStorage.Default.GetAsync("WFCUser");
|
||||
if (isLogged == null)
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace WorkFlowCheck.MAUI.Helper
|
||||
public static string ProgramVersion = "v1.1.030";
|
||||
|
||||
#if DEBUG
|
||||
public static string ApiBaseUrl = $"http://10.0.2.2:59027/";
|
||||
//public static string ApiBaseUrl = $"https://dev.wfcapi.nuvolar.hu/";
|
||||
//public static string ApiBaseUrl = $"http://10.0.2.2:59027/";
|
||||
public static string ApiBaseUrl = $"https://dev.wfcapi.nuvolar.hu/";
|
||||
public static string ApiKey = $"RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU=";
|
||||
|
||||
#endif
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
Source="{Binding Photo, Converter={StaticResource ByteArrayToImageSourceConverter}}" />
|
||||
<Button Text="📷" Grid.Column="1"
|
||||
VerticalOptions="Center"
|
||||
Command="{Binding BindingContext.CreatePhoto, Source={x:Reference CheckPointCheckListRows}}"
|
||||
Command="{Binding BindingContext.TakePhoto, Source={x:Reference CheckPointCheckListRows}}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -30,7 +30,7 @@ public partial class CheckListWorkPage : ContentPage
|
||||
}
|
||||
}
|
||||
public ObservableCollection<CheckListRowDTO> CheckListRows { get; set; } = new ObservableCollection<CheckListRowDTO>();
|
||||
public ICommand CreatePhoto { get; set; }
|
||||
public ICommand TakePhoto { get; set; }
|
||||
public ICommand SendCommand { get; set; }
|
||||
public ICommand SaveCommand { get; set; }
|
||||
|
||||
@@ -146,42 +146,40 @@ public partial class CheckListWorkPage : ContentPage
|
||||
base.OnAppearing();
|
||||
BindingContext = this;
|
||||
await SetInfo();
|
||||
CreatePhoto = new Command<CheckListRowDTO>(OnTakePhoto);
|
||||
TakePhoto = new Command<CheckListRowDTO>(OnTakePhoto);
|
||||
await LoadCheckPointCheckListRows();
|
||||
|
||||
}
|
||||
private async Task<byte[]> ResizePicture(FileResult? photo, int newWidth)
|
||||
{
|
||||
using var stream = await photo.OpenReadAsync();
|
||||
using var originalBitmap = SKBitmap.Decode(stream);
|
||||
|
||||
int newHeight = (int)(originalBitmap.Height * ((double)newWidth / originalBitmap.Width));
|
||||
|
||||
using var surface = SKSurface.Create(new SKImageInfo(newWidth, newHeight));
|
||||
using var canvas = surface.Canvas;
|
||||
|
||||
var sourceRect = new SKRect(0, 0, originalBitmap.Width, originalBitmap.Height);
|
||||
var destRect = new SKRect(0, 0, newWidth, newHeight);
|
||||
canvas.DrawBitmap(originalBitmap, sourceRect, destRect);
|
||||
|
||||
using var resizedImage = surface.Snapshot();
|
||||
using var data = resizedImage.Encode(SKEncodedImageFormat.Jpeg, 100);
|
||||
|
||||
return data.ToArray();
|
||||
}
|
||||
private async void OnTakePhoto(CheckListRowDTO checkListRowDTO)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (MediaPicker.IsCaptureSupported)
|
||||
{
|
||||
await OnSave();
|
||||
//await OnSave();
|
||||
var photo = await MediaPicker.CapturePhotoAsync();
|
||||
if (photo != null)
|
||||
{
|
||||
//using var stream = await photo.OpenReadAsync();
|
||||
//using var ms = new MemoryStream();
|
||||
//await stream.CopyToAsync(ms);
|
||||
//byte[] photoBytes = ms.ToArray();
|
||||
|
||||
using var stream = await photo.OpenReadAsync();
|
||||
using var originalBitmap = SKBitmap.Decode(stream);
|
||||
|
||||
int newWidth = 500;
|
||||
int newHeight = (int)(originalBitmap.Height * ((double)newWidth / originalBitmap.Width));
|
||||
|
||||
using var surface = SKSurface.Create(new SKImageInfo(newWidth, newHeight));
|
||||
using var canvas = surface.Canvas;
|
||||
|
||||
var sourceRect = new SKRect(0, 0, originalBitmap.Width, originalBitmap.Height);
|
||||
var destRect = new SKRect(0, 0, newWidth, newHeight);
|
||||
canvas.DrawBitmap(originalBitmap, sourceRect, destRect);
|
||||
|
||||
using var resizedImage = surface.Snapshot();
|
||||
using var data = resizedImage.Encode(SKEncodedImageFormat.Jpeg, 100);
|
||||
|
||||
checkListRowDTO.Photo = data.ToArray();
|
||||
checkListRowDTO.Photo = await ResizePicture(photo, 500);
|
||||
checkListRowDTO.Answer = "Igen";
|
||||
|
||||
await _checkListService.UpdateCheckListRow(checkListRowDTO);
|
||||
|
||||
Reference in New Issue
Block a user