Example #1
0
 public void PrintHighlightedElement(IConsoleProgram program, ConsoleColor highlightColor, ConsoleColor textColor)
 {
     ConsoleFormattingUtil.PushBackground(highlightColor);
     ConsoleFormattingUtil.PushForeground(textColor);
     Console.WriteLine($"\t{program?.Name}");
     ConsoleFormattingUtil.PopBackgorund();
     ConsoleFormattingUtil.PopForeground();
 }
Example #2
0
 public void PrintTitle(string title, ConsoleColor color)
 {
     _stringBuilder.Clear();
     for (int i = 0; i < Console.WindowWidth / 2 - title.Length / 2; i++)
     {
         _stringBuilder.Append(" ");
     }
     ConsoleFormattingUtil.PushForeground(color);
     Console.WriteLine(_stringBuilder + title);
     ConsoleFormattingUtil.PopForeground();
 }
Example #3
0
        public void PrintFooter(string footerString, ConsoleColor color)
        {
            ConsoleFormattingUtil.PushForeground(color);
            int spacesCount = Console.WindowWidth / 2 - footerString.Length / 2;

            for (int i = 0; i < spacesCount; i++)
            {
                footerString = footerString.Insert(0, " ");
            }
            ConsoleFormattingUtil.WriteOnBottomLine(footerString, 1);
            ConsoleFormattingUtil.PopForeground();
        }
Example #4
0
        private void StartSelectedItem(int index)
        {
            Console.Clear();
            _isMenuDrawn = false;
            try
            {
                _items[index].Start();
            }
            catch (Exception e)
            {
                Console.Clear();
                Console.WriteLine($"\"{_items[index]?.Name}\" crashed");
                ConsoleFormattingUtil.PushForeground(ConsoleColor.Red);
                ConsoleFormattingUtil.PopForeground();
                Console.WriteLine(JsonConvert.SerializeObject(e, Formatting.Indented));
            }

            Console.ReadKey();
        }