using Avalonia.Controls;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;

namespace InABox.Avalonia
{
    public class MobileDocument
    {
        public string FileName { get; set; }
        public byte[] Data { get; set; }

        public MobileDocument()
        {
            FileName = "";
            Data = new byte[] { };
        }
        
        public MobileDocument(string filename, byte[] data)
        {
            FileName = filename;
            Data = data;
        }
        
        
        public static async Task<MobileDocument> From<TSource, TOptions>(TopLevel window, TSource source) 
            where TSource : MobileDocumentSource
            where TOptions : MobileDocumentOptions<TSource>
        {
            var result = await source.From(window);
            return result;
        }
        
        public static async Task<MobileDocument> From<T>(TopLevel? window, MobileDocumentOptions<T> options) where T : MobileDocumentSource
        {
            if (window == null)
                throw new Exception("Window is null");
            var source = (T)Activator.CreateInstance(typeof(T), new object[] { options });
            var result = await source.From(window);
            return result;
        }
        
    }
}