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 "TutorialScreen": ns = new tutorialScreen(); break; case "TitleScreen": ns = new titleScreen(); break; case "EndScreen": ns = new endScreen(); break; } ns.Size = new Size(controlWidth, controlHeight); ns.Location = startCentre; tmp.Controls.Add(ns); ns.Focus(); }
public startupForm() { InitializeComponent(); this.WindowState = FormWindowState.Maximized; titleScreen mm = new titleScreen(); // set the menu to display centre screen based on screen size defaults mm.Size = new Size(screenControl.controlWidth, screenControl.controlHeight); mm.Location = screenControl.startCentre; // add main menu screen to form this.Controls.Add(mm); }