/// <summary> /// Remove an existing screen /// </summary> /// <param name="screen">Screen object to remove</param> /// <returns>If operation was successful</returns> public bool RemoveScreen(Screen screen) { if (screen != null && screens.Count > 1) { screen.UnloadContent(); return screens.Remove(screen); } return false; }
/// <summary> /// Add as screen to the screen list /// </summary> /// <param name="screen">Screen to add</param> /// <returns>If operation was successful</returns> public bool AddScreen(Screen screen) { if (screen == null) return false; screen.ScreenManager = this; screen.LoadContent(); screens.Add(screen); return true; }
/// <summary> /// Remove an existing screen /// </summary> /// <param name="screen">Screen object to remove</param> /// <returns>If operation was successful</returns> public bool RemoveScreen(Screen screen) { if (screen != null && screens.Count > 1) { screen.UnloadContent(); screens.Remove(screen); screens[screens.Count - 1].Reload(); screens[screens.Count - 1].SetStatus(ScreenStatus.Visible); return true; } return false; }
/// <summary> /// Show a screen /// </summary> /// <param name="screen">Screen to show</param> /// <returns>If operation was successful</returns> public bool ShowScreen(Screen screen) { //Find if screen exists. If not, add it if (!screens.Contains(screen)) AddScreen(screen); //Find out where the screen exists in the array int foundAtIndex = -1; for (int i = 0; i < screens.Count; i++) { if (screens[i] == screen) { foundAtIndex = i; break; } } //if screen isn't found, error out if (foundAtIndex == -1) return false; //disable all non-relevant screens for (int i = 0; i < foundAtIndex; i++) { if (screens[foundAtIndex].Status == ScreenStatus.Overlay && i == foundAtIndex - 1) //overlay screens can have 1 screen visible underneath them screens[i].SetStatus(ScreenStatus.Visible); else screens[i].SetStatus(ScreenStatus.Disabled); } if (screens[foundAtIndex].Status != ScreenStatus.Overlay) screens[foundAtIndex].SetStatus(ScreenStatus.Visible); return true; }