/// <summary> /// Changes which screen is currently displayed. /// </summary> /// <param name="Screen"></param> public static void Set_Active_Screen(VirtualScreen Screen) { /* Unregister the currently active screen */ if (ActiveScreen != null) { ActiveScreen.onUpdate -= ActiveScreen_onUpdate; } int i = Screens.IndexOf(Screen); ActiveScreenIndex = i; ActiveScreen.onUpdate += ActiveScreen_onUpdate; ActiveScreen.Update(); Print_Screen(Screen); }
/// <summary> /// Clears the console and then prints the entire contents of the given screen to it /// </summary> /// <param name="Screen"></param> private static void Print_Screen(VirtualScreen Screen) { /* Clear the console and print this screen */ Console.Clear(); Push_Cursor(); Push_CursorVisible(); Console.CursorVisible = false; foreach (TerminalText Text in Screen.Buffer) { Set_Cursor(Text.Position.X, Text.Position.Y); Terminal.Write(Text.Buffer); } Pop_Cursor(); Pop_CursorVisible(); // Set_Cursor(0, Console.BufferHeight-1); }
static Terminal() { var Screen = new VirtualScreen(); Set_Active_Screen(Screen); }