Elvileg jó, meg a mentés is.

This commit is contained in:
2025-07-02 19:38:33 +02:00
parent 7f3562fb73
commit a646258837
6 changed files with 122 additions and 28 deletions
@@ -1,23 +1,27 @@
using System.ComponentModel;
using SkiaSharp;
using System.ComponentModel;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.Helper;
namespace WorkFlowCheck.MAUI.Pages.CheckList
{
public class CheckListRowCS : INotifyPropertyChanged
{
private byte[] _photoBytes;
private ImageSource? _photo;
//private ImageSource? _photo;
private string? _photoPath;
public event PropertyChangedEventHandler PropertyChanged;
public int Id { get; set; }
public string AnswerType { get; set; } = null!;
public string AnswerType { get; set; } = null!;
public int RowIndex { get; set; }
public string OperationDescription { get; set; } = null!;
public string GroupName { get; set; } = null!;
public string Answer { get; set; } = null!;
public bool? AnswerYes { get; set; } = null!;
public bool? AnswerNo { get; set; } = null!;
public byte[] PhotoBytes
{
get => _photoBytes;
@@ -26,37 +30,58 @@ namespace WorkFlowCheck.MAUI.Pages.CheckList
if (_photoBytes != value)
{
_photoBytes = value;
_photo = null;
OnPropertyChanged(nameof(PhotoBytes));
OnPropertyChanged(nameof(Photo));
//_photo = null;
_photoPath = null;
//OnPropertyChanged(nameof(PhotoBytes));
//OnPropertyChanged(nameof(Photo));
OnPropertyChanged(nameof(PhotoPath));
}
}
}
public ImageSource Photo
//public ImageSource Photo
//{
// get
// {
// if (_photo == null)
// {
// if (PhotoBytes != null && PhotoBytes.Length > 0)
// {
// try
// {
// var bytesCopy = PhotoBytes.ToArray();
// _photo = ImageSource.FromStream(() => new MemoryStream(bytesCopy));
// }
// catch
// {
// _photo = ImageSource.FromFile("noimage.png");
// }
// }
// else
// {
// _photo = ImageSource.FromFile("noimage.png");
// }
// }
// return _photo;
// }
//}
public string PhotoPath
{
get
{
if (_photo == null)
if (_photoPath == null)
{
if (PhotoBytes != null && PhotoBytes.Length > 0)
{
try
{
var bytesCopy = PhotoBytes.ToArray();
_photo = ImageSource.FromStream(() => new MemoryStream(bytesCopy));
}
catch
{
_photo = ImageSource.FromFile("noimage.png");
}
_photoPath = ImageHelper.ResizeAndSaveImage(PhotoBytes, Id, 100);
}
else
{
_photo = ImageSource.FromFile("noimage.png");
_photoPath = "noimage.png";
}
}
return _photo;
return _photoPath;
}
}
@@ -130,12 +130,12 @@
<Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="1" />
<Grid Grid.Column="2" ColumnDefinitions="Auto,Auto" VerticalOptions="Center">
<Image Grid.Column="0"
WidthRequest="95"
HeightRequest="120"
WidthRequest="65"
HeightRequest="90"
Aspect="AspectFill"
Margin="0,0,10,0"
VerticalOptions="Center"
Source="{Binding Photo}" >
Source="{Binding PhotoPath}" >
</Image>
<Button Text="📷" Grid.Column="1"
VerticalOptions="Center"
@@ -182,7 +182,7 @@ public partial class CheckListWorkPage : ContentPage
{
if (MediaPicker.IsCaptureSupported)
{
await OnSave(false);
//await OnSave(false);
var photo = await MediaPicker.CapturePhotoAsync();
if (photo != null)
{
@@ -196,7 +196,7 @@ public partial class CheckListWorkPage : ContentPage
checkListRowDTO.Answer = "Igen";
await _checkListService.UpdateCheckListRow(checkListRowDTO, true);
await LoadCheckPointCheckListRows();
//await LoadCheckPointCheckListRows();
}
}
}