91 lines
2.8 KiB
C#
91 lines
2.8 KiB
C#
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 string? _photoPath;
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
public int Id { get; set; }
|
|
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;
|
|
set
|
|
{
|
|
if (_photoBytes != value)
|
|
{
|
|
_photoBytes = value;
|
|
//_photo = null;
|
|
_photoPath = null;
|
|
//OnPropertyChanged(nameof(PhotoBytes));
|
|
//OnPropertyChanged(nameof(Photo));
|
|
OnPropertyChanged(nameof(PhotoPath));
|
|
}
|
|
}
|
|
}
|
|
//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 (_photoPath == null)
|
|
{
|
|
if (PhotoBytes != null && PhotoBytes.Length > 0)
|
|
{
|
|
_photoPath = ImageHelper.ResizeAndSaveImage(PhotoBytes, Id, 100);
|
|
}
|
|
else
|
|
{
|
|
_photoPath = "noimage.png";
|
|
}
|
|
}
|
|
return _photoPath;
|
|
}
|
|
}
|
|
|
|
protected void OnPropertyChanged(string name) =>
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
|
}
|
|
} |