DocScannerEditViewModel.cs 942 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Linq;
  2. using InABox.Core;
  3. using Xamarin.Forms;
  4. namespace PRS.Mobile
  5. {
  6. public class DocScannerEditViewModel : BindableObject
  7. {
  8. private DataEntryDocumentShell _document = new ();
  9. private readonly DocumentModel _imageModel;
  10. public DataEntryDocumentShell Document
  11. {
  12. get => _document;
  13. set
  14. {
  15. if (Equals(value, _document)) return;
  16. _document = value;
  17. _imageModel.Refresh(true);
  18. OnPropertyChanged();
  19. OnPropertyChanged(nameof(Image));
  20. }
  21. }
  22. public DocumentShell? Image => _imageModel.Items.FirstOrDefault();
  23. public DocScannerEditViewModel()
  24. {
  25. _imageModel = new DocumentModel(App.Data,
  26. () => new Filter<Document>(x => x.ID).IsEqualTo(Document.DocumentID)
  27. );
  28. }
  29. }
  30. }