public static void Alert(string alertMessage, int ms = 1000) { // Get position of the cursor before and after the alert. Int2 cursorPosition = Int2Utils.GetConsoleCursor(); Console.WriteLine(); Int2 newLinePosition = Int2Utils.GetConsoleCursor(); // Get the actual color of the console and switch with the red color. ConsoleColor actualColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; // Write the alert message and reset the color. Console.Write(alertMessage); Console.ForegroundColor = actualColor; // Show the alert during a certain amount of time. Thread.Sleep(ms); // Remove the text alert. newLinePosition.SetConsoleCursor(); for (int i = 0; i < alertMessage.Length; ++i) { Console.Write(" "); } cursorPosition.SetConsoleCursor(); }
public static string ReadCancel() { Int2 cursorPosition = Int2Utils.GetConsoleCursor(); string input = Console.ReadLine(); cursorPosition.SetConsoleCursor(); if (input != null) { for (int i = 0; i < input.Length; ++i) { Console.Write(" "); } } cursorPosition.SetConsoleCursor(); return(input); }
public void Clear() { if (Writed) { _Position.SetConsoleCursor(); System.Console.Write(' '); Writed = false; } }
public Int2 Write(IGenericPair <int, int> position) { System.Console.ForegroundColor = _Color; Clear(); _Position = ((Int2)position).Max(0); _Position.SetConsoleCursor(); System.Console.Write(Char); Writed = true; return(Int2Utils.GetConsoleCursor()); }
private Int2 WriteMethod(IGenericPair <int, int> position, Action <string> value) { System.Console.ForegroundColor = _Color; Clear(); _Position = ((Int2)position).Max(0); _Position.SetConsoleCursor(); value(Text); Writed = true; return(Int2Utils.GetConsoleCursor()); }
public void Clear() { if (Writed) { _Position.SetConsoleCursor(); for (int i = 0; i < Text.Length; ++i) { System.Console.Write(' '); } Writed = false; } }
public virtual Int2 Write(IGenericPair <int, int> position) { Clear(); _Position = ((Int2)position).Max(0); _Position.SetConsoleCursor(); SetColor(); for (int i = 0; i < Text.Count; ++i) { Int2 lastPosition = Text[i].ConsoleObjectGroup[0].Write(); for (int j = 1; j < Text[i].ConsoleObjectGroup.Count; ++j) { lastPosition = Text[i].ConsoleObjectGroup[j].Write(lastPosition); } if (i < Text.Count - 1) { ConsoleUtils.SetCursorPosition(position.x, System.Console.CursorTop + 1); } } Writed = true; return(Int2Utils.GetConsoleCursor()); }
public static void Alert(ColoredText alertMessage, int ms = 1000) { // Get position of the cursor before and after the alert. Int2 cursorPosition = Int2Utils.GetConsoleCursor(); Console.WriteLine(); Int2 newLinePosition = Int2Utils.GetConsoleCursor(); // Write the alert message. alertMessage.WriteAndResetColor(); // Show the alert during a certain amount of time. Thread.Sleep(ms); // Remove the text alert. newLinePosition.SetConsoleCursor(); for (int i = 0; i < alertMessage.Text.Length; ++i) { Console.Write(" "); } cursorPosition.SetConsoleCursor(); }
public override void InsertValue(int x, int y, T value) { Container[x, y] = value; int size = LargerSizeInColumn(x); if (size > _ColumnSize[x]) { _ColumnSize[x] = size; if (Writed) { Write(Position); } } else { if (Writed) { Int2 position = Int2Utils.GetConsoleCursor(); WriteContent(x, y); position.SetConsoleCursor(); } } }