| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 | 
							- using Avalonia.Controls;
 
- using InABox.Avalonia.Platform;
 
- namespace InABox.Avalonia
 
- {
 
-     
 
-     public abstract class MobileDocumentSource
 
-     {
 
-         public abstract Task<MobileDocument> From(TopLevel window);
 
-     }
 
-     
 
-     public abstract class MobileDocumentSource<TOptions> : MobileDocumentSource 
 
-         where TOptions : class, IMobileDocumentOptions, new()
 
-     {
 
-         public TOptions Options { get; set; }
 
-         protected MobileDocumentSource(TOptions options)
 
-         {
 
-             Options = options;
 
-         }
 
-         
 
-         protected abstract Task<bool> IsEnabled();
 
-         
 
-         // protected async Task<bool> IsEnabled<TPermission>()
 
-         //     where TPermission : Permissions.BasePermission, new()
 
-         // {
 
-         //     var status = await Permissions.CheckStatusAsync<TPermission>();
 
-         //     if (status != PermissionStatus.Granted && status != PermissionStatus.Restricted)
 
-         //         status = await Permissions.RequestAsync<TPermission>();
 
-         //     return status == PermissionStatus.Granted;
 
-         // }
 
-         
 
-         protected abstract Task<ImageFile?> Capture(TopLevel window);
 
-         
 
-         public override async Task<MobileDocument> From(TopLevel window)
 
-         {
 
-             var result = new MobileDocument();
 
-             if (await IsEnabled())
 
-             {
 
-                 try
 
-                 {
 
-                     var file = await Capture(window);
 
-                     if (file?.Data != null)
 
-                     {
 
-                         result.FileName = Path.GetFileName(file.FileName);
 
-                         result.Data = file.Data; 
 
-                         //file.OriginalFilename ?? file.Path);
 
-                         //await using (var stream = await file.OpenReadAsync())
 
-                         //{
 
-                         //    BinaryReader br = new BinaryReader(file.Stream);
 
-                         //    result.Data = br.ReadBytes((int)file.Stream.Length);
 
-                         //}
 
-                     }
 
-                     ApplyOptions(result);
 
-                 }
 
-                 // catch (FeatureNotSupportedException fnsEx)
 
-                 // {
 
-                 //     MobileLogging.Log(fnsEx, "Capture(FNS)");
 
-                 //     MobileDialog.ShowMessage("This operation is not Supported on this Device!");
 
-                 // }
 
-                 // catch (PermissionException pEx)
 
-                 // {
 
-                 //     MobileLogging.Log(pEx, "Capture(PERM)");
 
-                 //     MobileDialog.ShowMessage("This operation is not Permitted on this Device!");
 
-                 // }
 
-                 catch (Exception ex)
 
-                 {
 
-                     MobileLogging.Log(ex, "Capture(ERR)");
 
-                     MobileDialog.ShowMessage($"Oops! Something went wrong!\n{ex.Message}");
 
-                 }
 
-             }
 
-             return result;
 
-         }
 
-         protected abstract void ApplyOptions(MobileDocument document);
 
-     }
 
- }
 
 
  |