public static ShellColorizer Set(ConsoleColor foregroundColor, ConsoleColor backgroundColor) { var colorizer = new ShellColorizer(Console.ForegroundColor, Console.BackgroundColor); SetCore(foregroundColor, backgroundColor); return(colorizer); }
public static void WriteKeyValue(string key, object value) { using (ShellColorizer.SetForeground(ConsoleColor.Black)) { Shell.Write((key + ":").PadRight(16)); } Shell.WriteLine(value); }
public static void Initialize(ShellOptions options) { if (IsInitialized) { return; } IsInitialized = true; Options = options; Console.OutputEncoding = Options.Encoding; ShellColorizer.Initialize(Options.DefaultForegroundColor, Options.DefaultBackgroundColor); ShellTextStyler.Initialize(); }
private static void Main() { Shell.Initialize(new ShellOptions { DefaultForegroundColor = ConsoleColor.DarkGray, DefaultBackgroundColor = ConsoleColor.Gray, PromptColor = ConsoleColor.Black, PromptQuestionColor = ConsoleColor.Red, PromptOptionColor = ConsoleColor.Magenta, }); Board lastBoard = null; do { Shell.Clear(); try { var options = CreateGameOptions(lastBoard?.Options); if (options == null) { return; } var codemaker = CreateCodemaker(options, lastBoard?.Codemaker); var codebreaker = CreateCodebreaker(options, lastBoard?.Codebreaker); var board = new Board(options, codemaker, codebreaker); board.Run(); lastBoard = board; } catch (Exception e) { using (ShellColorizer.Set(ConsoleColor.White, ConsoleColor.Red)) { Shell.WriteLine($"Error: {e.Message}"); } return; } } while (Shell.PromptBool("Play again?")); }
public static void Clear() { ShellColorizer.Clear(); }