ScanModule.xaml.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Comal.Classes;
  7. using InABox.Core;
  8. using InABox.Mobile;
  9. using Xamarin.Forms;
  10. using Xamarin.Forms.Xaml;
  11. namespace PRS.Mobile.Modules.Scans
  12. {
  13. [XamlCompilation(XamlCompilationOptions.Compile)]
  14. public partial class ScanModule
  15. {
  16. private ScanModel _scans;
  17. public ScanModule()
  18. {
  19. _scans = new ScanModel(App.Data,
  20. () => new Filter<Scan>(x => x.Employee.ID).IsEqualTo(App.Data.Me.ID)
  21. .And(x => x.Processed).IsEqualTo(false)
  22. ) { FileName = "scans.data" };
  23. InitializeComponent();
  24. RefreshData(false, true);
  25. }
  26. private void RefreshData(bool force, bool async)
  27. {
  28. if (async)
  29. _scans.Refresh(force, () => Device.BeginInvokeOnMainThread(RefreshScreen));
  30. else
  31. {
  32. _scans.Refresh(force);
  33. RefreshScreen();
  34. }
  35. }
  36. private void RefreshScreen()
  37. {
  38. _documents.ItemsSource = null;
  39. _documents.ItemsSource = _scans;
  40. }
  41. private async void TakePhoto_Clicked(object sender, EventArgs e)
  42. {
  43. await _documents.AddImage<MobileDocumentCameraSource,ScanShell>(
  44. true, (shell) => shell.EmployeeID = App.Data.Me.ID);
  45. }
  46. private async void BrowseLibrary_Clicked(object sender, EventArgs e)
  47. {
  48. await _documents.AddImage<MobileDocumentLibrarySource,ScanShell>(
  49. true, (shell) => shell.EmployeeID = App.Data.Me.ID);
  50. }
  51. }
  52. }