DigitalFormEmbeddedImage.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Threading.Tasks;
  3. using Comal.Classes;
  4. using InABox.Configuration;
  5. using InABox.Core;
  6. using InABox.Mobile;
  7. namespace PRS.Mobile
  8. {
  9. public class DigitalFormEmbeddedImage : DigitalFormEmbeddedMedia<DFLayoutEmbeddedImage, DFLayoutEmbeddedImageProperties, Guid>
  10. {
  11. protected override bool IsVideo => false;
  12. protected override bool DisableLibrary => Definition.Properties.DisableLibrary;
  13. protected override bool Secure => Definition.Properties.Secure;
  14. protected override bool Required => Definition.Properties.Required;
  15. public DigitalFormEmbeddedImage() : base()
  16. {
  17. AddButton(Xamarin.Forms.ImageSource.FromFile("rotate"),RotateImage);
  18. }
  19. private void RotateImage()
  20. {
  21. _value.Thumbnail = MobileUtils.ImageTools.RotateImage(_value.Thumbnail, 90F, 100);
  22. _value.Data = MobileUtils.ImageTools.RotateImage(_value.Data, 90F, 100);
  23. UpdateUI();
  24. }
  25. protected override Task<MobileDocument> CaptureMedia()
  26. {
  27. return MobileDocument.From<MobileDocumentCameraSource>(PhotoUtils.CreateCameraOptions());
  28. }
  29. protected override Task<MobileDocument> SelectMedia()
  30. {
  31. return MobileDocument.From<MobileDocumentPhotoLibrarySource>(PhotoUtils.CreatePhotoLibraryOptions());
  32. }
  33. protected override Guid GetValue() => _value.ID;
  34. protected override void SetValue(Guid value) => _value.ID = value;
  35. protected override byte[] CreateThumbnail(byte[] data, int maxwidth = 256, int maxheight=256)
  36. {
  37. return MobileUtils.ImageTools.CreateThumbnail(data, maxwidth, maxheight);
  38. }
  39. }
  40. }