using Ion.Sdk.Ici;
using Ion.Sdk.Idi;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;

namespace Ion.Sdk.DemoApp.Components
{
    public abstract class AutoSequenceGroupFileLoader : FileLoader<AutoSequenceGroup>
    {

        #region -=Loader implementations=-

        public class Atmpx : AutoSequenceGroupFileLoader
        {
            public override string CommandName { get; } = "Open";
            public override string OpenDialogFilter { get; } = "atmpx|*.atmpx";
            public override async Task<AutoSequenceGroup> Load(string filenameWithPath)
            {
                using (var atmpx = Channel.Atmpx.Open(filenameWithPath))
                {
                    atmpx.Use(Progress);
                    var info = (await atmpx.GetAutoSequenceGroups()).FirstOrDefault();
                    var group = await atmpx.DownloadAutoSequenceGroup(info);
                    return group;
                }
            }
        }

        #endregion
    }
}
