using System.Windows;

namespace Zerolauncher.dialog
{
    class EditMemberDialog 
    {
        static BaseDialog? baseDialog;
        static EditMember? editControl;

        public static int? member;

        public static void CreateDailog(int? memberId)
        {
            if (editControl != null || baseDialog != null)
            {
                return;
            }
            member = memberId;
            editControl = new EditMember();
            baseDialog = new BaseDialog(editControl);
            baseDialog.ShowDialog();
            baseDialog = null;
            editControl = null;
            member = null;
        }

        public static void Close()
        {
            if (baseDialog != null) 
            {
                baseDialog.Close();
            }
        }

    }

    class EditTeamDialog
    {
        static BaseDialog? baseDialog;
        static EditTeamControl? editControl;


        public static bool CreateDailog(string? oldTeamName=null)
        {
            if (editControl != null || baseDialog != null)
            {
                return false;
            }
            if (oldTeamName != null)
            {
                editControl = new EditTeamControl(true);
                editControl.edit_name.Text = oldTeamName;
            }
            else
            {
                editControl = new EditTeamControl(false);
                editControl.btn_del.Visibility = Visibility.Hidden;
            }
            baseDialog = new BaseDialog(editControl);
            baseDialog.ShowDialog();
            baseDialog = null;
            editControl = null;
            return true;
        }

        public static void Close()
        {
            if (baseDialog != null)
            {
                baseDialog.Close();
            }
        }
    }

    class AddMemebersDialog
    {
        static BaseDialog? baseDialog;
        static UseAccDataTextAdd? editControl;

        public static void CreateDailog()
        {
            if (editControl != null || baseDialog != null)
            {
                return;
            }
            editControl = new UseAccDataTextAdd();
            baseDialog = new BaseDialog(editControl);
            baseDialog.ShowDialog();
            baseDialog = null;
            editControl = null;
        }

        public static void Close()
        {
            if (baseDialog != null)
            {
                baseDialog.Close();
            }
        }

    }

    class UpdateDialog
    {
        static BaseDialog? baseDialog;
        public static DownloadControl1? editControl;
        public static bool ui_enale = false;

        public static void CreateDailog()
        {
            if (editControl != null || baseDialog != null)
            {
                return;
            }
            editControl = new DownloadControl1();
            baseDialog = new BaseDialog(editControl);
            ui_enale = true;
            baseDialog.ShowDialog();
            ui_enale = false;
            baseDialog = null;
            editControl = null;
        }

        public static void Close()
        {
            if (baseDialog != null)
            {
                baseDialog.Close();
            }
        }
    }
}
