private void GameForm_Load(object sender, EventArgs e) { Cursor.Hide(); Form f = this.FindForm(); f.Controls.Remove(this); UserControl ns = null; ns = new Screens.MenuScreen(); f.Controls.Add(ns); ns.Location = new Point(f.Width / 2 - ns.Width / 2, (f.Height / 2 - ns.Height / 2) - 30); ns.Focus(); XmlRead(); }
public static void ChangeScreen(UserControl current, string next) { //f is set to the form that the current control is on Form f = current.FindForm(); if (next != "PauseScreen") { f.Controls.Remove(current); } UserControl ns = null; //switches screen switch (next) { case "MenuScreen": ns = new Screens.MenuScreen(); break; case "GameScreen": ns = new Screens.GameScreen(); break; case "HighScreen": ns = new Screens.HighScreen(); break; case "HowScreen": ns = new Screens.HowScreen(); break; case "EndScreen": ns = new Screens.EndScreen(); break; case "PauseScreen": ns = new Screens.PauseScreen(); break; } //centres on the screen ns.Location = new Point((f.Width - ns.Width) / 2, ((f.Height - ns.Height) / 2) - 30); f.Controls.Add(ns); ns.Focus(); }