MobileDocumentCameraSource.cs 725 B

12345678910111213141516171819202122
  1. using Avalonia.Controls;
  2. using Microsoft.Maui.ApplicationModel;
  3. using Microsoft.Maui.Storage;
  4. using InABox.Avalonia.Platform;
  5. namespace InABox.Avalonia
  6. {
  7. public class MobileDocumentCameraSource : MobileImageSource<MobileDocumentCameraSource, MobileDocumentCameraOptions>
  8. {
  9. public MobileDocumentCameraSource(MobileDocumentCameraOptions options) : base(options)
  10. {
  11. }
  12. protected override async Task<bool> IsEnabled()
  13. => await IsEnabled<Permissions.Camera>();
  14. protected override async Task<ImageFile> Capture(TopLevel window)
  15. => await PlatformTools.ImageTools.CapturePhotoAsync(window, Options.Compression, Options.Constraints);
  16. }
  17. }