예제 #1
0
파일: FormPool.cs 프로젝트: corefan/yad2
        static FormPool()
        {
            UIManageable form = null;

            form = new MainMenuForm();
            InitMainMenu(form);
        }
예제 #2
0
파일: FormPool.cs 프로젝트: corefan/yad2
        /// <summary>
        /// Inits form into proper form - set groupbox name
        /// </summary>
        /// <param name="form"></param>
        /// <param name="initInto"></param>
        /// <returns></returns>
        public static UIManageable InitForm(UIManageable form, Views initInto)
        {
            switch (initInto)
            {
            case Views.MainMenuForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.LoginForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.RegistrationForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.OptionsForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.ChatForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.UserInfoForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.ChooseGameForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.CreateGameForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.WaitingForPlayersForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.PauseForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.GameMenuForm:
                ((MainMenuForm)form).SwitchToTab(initInto);
                break;

            case Views.GameForm:
                break;

            default:
                break;
            }
            return(form);
        }
예제 #3
0
파일: UIManager.cs 프로젝트: corefan/yad2
 private void ThreadStartFunction()
 {
     actualForm = FormPool.GetForm(Views.MainMenuForm);
     //reset handler
     actualForm.MenuOptionChange -= menuEventHandler;
     actualForm.MenuOptionChange += menuEventHandler;
     actualForm.MessageBoxShow   -= messageBoxEventHandler;
     actualForm.MessageBoxShow   += messageBoxEventHandler;
     actualForm.Show();
 }
예제 #4
0
파일: FormPool.cs 프로젝트: corefan/yad2
 private static void InitMainMenu(UIManageable form)
 {
     pool.Add(Views.MainMenuForm, form);
     pool.Add(Views.LoginForm, form);
     pool.Add(Views.RegistrationForm, form);
     pool.Add(Views.OptionsForm, form);
     pool.Add(Views.ChatForm, form);
     pool.Add(Views.UserInfoForm, form);
     pool.Add(Views.ChooseGameForm, form);
     pool.Add(Views.CreateGameForm, form);
     pool.Add(Views.WaitingForPlayersForm, form);
     pool.Add(Views.PauseForm, form);
     pool.Add(Views.GameMenuForm, form);
 }
예제 #5
0
파일: FormPool.cs 프로젝트: corefan/yad2
        public static UIManageable GetForm(Views view)
        {
            UIManageable form = null;

            if (pool.ContainsKey(view))
            {
                form = pool[view];

                if (form.IsDisposed)
                {
                    pool.Remove(view);
                }
                else
                {
                    form = InitForm(form, view);
                    return(form);
                }
            }

            switch (view)
            {
            case Views.MainMenuForm:
            case Views.LoginForm:
            case Views.RegistrationForm:
            case Views.OptionsForm:
            case Views.ChatForm:
            case Views.UserInfoForm:
            case Views.ChooseGameForm:
            case Views.CreateGameForm:
            case Views.WaitingForPlayersForm:
            case Views.PauseForm:
            case Views.GameMenuForm:
                form = new MainMenuForm();
                form.Hide();
                InitMainMenu(form);
                break;

            case Views.GameForm:
                form = new GameForm();
                pool.Add(view, form);
                break;

            default:
                break;
            }
            return(form);
        }
예제 #6
0
파일: UIManager.cs 프로젝트: corefan/yad2
        private void switchView(Views viewToSwitch, bool hideLast, bool modal)
        {
            if (hideLast)
            {
                actualForm.Hide();
            }

            actualView = viewToSwitch;
            actualForm = FormPool.GetForm(viewToSwitch);

            //reset handler
            actualForm.MenuOptionChange -= menuEventHandler;
            actualForm.MenuOptionChange += menuEventHandler;
            actualForm.MessageBoxShow   -= messageBoxEventHandler;
            actualForm.MessageBoxShow   += messageBoxEventHandler;


            if (actualForm.InvokeRequired)
            {
                actualForm.Invoke(new TopMostEventHandler(SetFormTopMost), new object[] { actualForm, modal });
            }
            else
            {
                SetFormTopMost(actualForm, modal);
            }

            if (actualForm.Visible == false)
            {
                if (actualForm.InvokeRequired)
                {
                    actualForm.Invoke(new FormShowEventHandler(actualForm.Show), new object[] { mainForm });
                }
                else
                {
                    actualForm.Show(mainForm);
                }
            }
        }