using System.Windows;

namespace ReAct_PME.WPF_FrameWork
{
    /// <summary>
    /// Choix de la fenêtre à ouvrir.
    /// </summary>
    public enum CustomWindowToOpen
    {

    }

    /// <summary>
    /// L'interface pour l'utilisation de l'ouverture de fenêtres depuis une VM
    /// </summary>
    public interface IShowWindowService
    {
        void OpenWindow(CustomWindowToOpen windowCible, object itemCible);
        void OpenWindow(CustomWindowToOpen windowCible);
        bool? OpenWindowModal(CustomWindowToOpen windowCible, object itemCible, object itemContext);
        bool? OpenWindowModal(CustomWindowToOpen windowCible, object itemCible);
        bool? OpenWindowModal(CustomWindowToOpen windowCible);
        void CloseWindow();
    }

    /// <summary>
    /// Classe implementant IShowWindowService
    /// </summary>
    public class ShowWindowService : IShowWindowService
    {
        private Window? _windowOpened;

        #region Méthodes publiques (génériques)
        public void OpenWindow(CustomWindowToOpen windowCible, object itemCible)
        {
            object? window = WindowCible(windowCible, itemCible);
            _windowOpened = (Window)window!; 
            ((Window)window!).Show();
        }
        public void OpenWindow(CustomWindowToOpen windowCible)
        {
            object? window = WindowCible(windowCible);
            _windowOpened = (Window)window!; 
            ((Window)window!).Show();
        }
        public bool? OpenWindowModal(CustomWindowToOpen windowCible, object itemCible, object itemContext)
        {
            object? window = WindowCible(windowCible, itemCible, itemContext);
            _windowOpened = (Window)window!;
            return ((Window)window!).ShowDialog();
        }
        public bool? OpenWindowModal(CustomWindowToOpen windowCible, object itemCible)
        {
            object? window = WindowCible(windowCible, itemCible);
            _windowOpened = (Window)window!;
            return ((Window)window!).ShowDialog();
        }
        public bool? OpenWindowModal(CustomWindowToOpen windowCible)
        {
            object? window = WindowCible(windowCible);
            _windowOpened = (Window)window!;
            return ((Window)window!).ShowDialog();
        }
        public void CloseWindow()
        {
            _windowOpened!.Close();
        }
        #endregion

        #region Méthodes privées (à customiser)
        private object? WindowCible(CustomWindowToOpen windowCible, object itemCible, object itemContext)
        {
            Window? o = null;
            /*
            switch (windowCible)
            {
                // Création Cours
                case CustomWindowToOpen.DT_ACTION_Detail_View:
                    o = new DT_ACTION_Detail_View(itemContext, true);
                    break;

                // Création Module
                case CustomWindowToOpen.DT_ACTION_Liste_View:
                    o = new DT_ACTION_Liste_View(itemContext, true);
                    break;
            }
            */
            return o;
        }
        private object? WindowCible(CustomWindowToOpen windowCible, object itemCible)
        {
            Window? o = null;
            /*
            switch (windowCible)
            {



            }
            */
            return o;
            
        }
        private object? WindowCible(CustomWindowToOpen windowCible)
        {
            Window? o = null;
            /*
            switch (windowCible)
            {


            }
            */
            return o;
        }
        #endregion
    }
}
