diff --git a/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListRowCS.cs b/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListRowCS.cs new file mode 100644 index 0000000..87756c7 --- /dev/null +++ b/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListRowCS.cs @@ -0,0 +1,66 @@ +using System.ComponentModel; +using WorkFlowCheck.Common.DTO; + +namespace WorkFlowCheck.MAUI.Pages.CheckList +{ + public class CheckListRowCS : INotifyPropertyChanged + { + private byte[] _photoBytes; + private ImageSource? _photo; + + 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; + OnPropertyChanged(nameof(PhotoBytes)); + OnPropertyChanged(nameof(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; + } + } + + protected void OnPropertyChanged(string name) => + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); + } +} \ No newline at end of file diff --git a/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml b/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml index a348a5e..e477a95 100644 --- a/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml +++ b/src/WorkFlowCheck.MAUI/Pages/CheckList/CheckListWorkPage.xaml @@ -48,7 +48,7 @@