MobileDocument.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Avalonia.Controls;
  2. using Syncfusion.Pdf;
  3. using Syncfusion.Pdf.Graphics;
  4. namespace InABox.Avalonia
  5. {
  6. public class MobileDocument
  7. {
  8. public string FileName { get; set; }
  9. public byte[] Data { get; set; }
  10. public MobileDocument()
  11. {
  12. FileName = "";
  13. Data = new byte[] { };
  14. }
  15. public MobileDocument(string filename, byte[] data)
  16. {
  17. FileName = filename;
  18. Data = data;
  19. }
  20. public static async Task<MobileDocument> From<TSource, TOptions>(TopLevel window, TSource source)
  21. where TSource : MobileDocumentSource
  22. where TOptions : MobileDocumentOptions<TSource>
  23. {
  24. var result = await source.From(window);
  25. return result;
  26. }
  27. public static async Task<MobileDocument> From<T>(TopLevel? window, MobileDocumentOptions<T> options) where T : MobileDocumentSource
  28. {
  29. if (window == null)
  30. throw new Exception("Window is null");
  31. var source = (T)Activator.CreateInstance(typeof(T), new object[] { options });
  32. var result = await source.From(window);
  33. return result;
  34. }
  35. }
  36. }