コード例 #1
0
        public static void changeScreen(UserControl current, string next)
        {

            //tmp is set to the form that this control is on
            Form tmp = current.FindForm();
            tmp.Controls.Remove(current);
            UserControl ns = null;

            switch (next)
            {
                case "GameScreen":
                    ns = new GameScreen();
                    break;
                case "InstructionScreen":
                    ns = new InstructionScreen();
                    break;
                case "MenuScreen":
                    ns = new MenuScreen();
                    break;
                case "OptionScreen":
                    ns = new OptionScreen();
                    break;
                case "ScoreScreen":
                    ns = new ScoreScreen();
                    break;

            }

            ns.Size = new Size(controlWidth, controlHeight);
            ns.Location = startCentre;
            tmp.Controls.Add(ns);
            ns.Focus();
        }