using InABox.Wpf;
using System;
using System.Windows;
using InABox.Core;

namespace InABox.DynamicGrid
{
    /// <summary>
    ///     Interaction logic for DynamicImportList.xaml
    /// </summary>
    public partial class DynamicImportList : ThemableWindow
    {
        public DynamicImportList(Type entitytype, Guid entityid, bool canImport = true)
        {
            InitializeComponent();
            Imports.EntityType = entitytype;
            Imports.EntityID = entityid;
            Imports.OnImportItem += o => { return OnImportItem != null ? OnImportItem.Invoke(o) : true; };
            Imports.OnCustomiseImport += (o, e) => { OnCustomiseImport?.Invoke(o, e); };
            Imports.OnSave += (sender, entity) => OnSave?.Invoke(sender, entity);
            Imports.OnLoad += (sender, type, fields, id) => OnLoad(sender, type, fields, id);
            Imports.CanImport = canImport;
            Imports.Refresh(true, true);
        }

        public event OnImportItem OnImportItem;

        public event OnCustomiseImport OnCustomiseImport;

        public event ImportSaveEvent OnSave;

        public event ImportLoadEvent OnLoad;

    }
}