示例#1
0
        public static ShellColorizer Set(ConsoleColor foregroundColor, ConsoleColor backgroundColor)
        {
            var colorizer = new ShellColorizer(Console.ForegroundColor, Console.BackgroundColor);

            SetCore(foregroundColor, backgroundColor);
            return(colorizer);
        }
示例#2
0
 public static void WriteKeyValue(string key, object value)
 {
     using (ShellColorizer.SetForeground(ConsoleColor.Black))
     {
         Shell.Write((key + ":").PadRight(16));
     }
     Shell.WriteLine(value);
 }
示例#3
0
        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();
        }
示例#4
0
        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?"));
        }
示例#5
0
 public static void Clear()
 {
     ShellColorizer.Clear();
 }