Advertisement
MaoChessy

Task 10 - fix

Oct 24th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace C_sharp_Light
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string message = "Сообщение не установлено";
  10.             int x, y;
  11.             x = 0;
  12.             y = 8;
  13.             bool isOpen = true;
  14.             ConsoleColor defaultForeground = ConsoleColor.White;
  15.  
  16.             while (isOpen)
  17.             {
  18.                 Console.SetCursorPosition(0, 0);
  19.  
  20.                 Console.ForegroundColor = ConsoleColor.Red;
  21.                 Console.WriteLine("Команды:\nExit - выход\nSet background - установить задний цвет\nSet foreground - Установить цвет шрифта\n" +
  22.                     "Set message - установить сообщение для вывода\nShow message - вывести сообщение\nSet Cursor - установить позицию курсора по умолчанию для ввода команд");
  23.                 Console.ForegroundColor = defaultForeground;
  24.  
  25.                 Console.SetCursorPosition(x, y);
  26.  
  27.                 switch (Console.ReadLine())
  28.                 {
  29.                     case "Exit":
  30.                         isOpen = false;
  31.                         break;
  32.                     case "Set background":
  33.                         Console.Clear();
  34.                         Console.WriteLine("1 - Черный\n2-зелёный\n3-серый");
  35.                         switch (Convert.ToInt32(Console.ReadLine()))
  36.                         {
  37.                             case 1:
  38.                                 Console.BackgroundColor = ConsoleColor.Black;
  39.                                 break;
  40.                             case 2:
  41.                                 Console.BackgroundColor = ConsoleColor.DarkGreen;
  42.                                 break;
  43.                             case 3:
  44.                                 Console.BackgroundColor = ConsoleColor.DarkGray;
  45.                                 break;
  46.                         }
  47.                         break;
  48.                     case "Set foreground":
  49.                         Console.Clear();
  50.                         Console.WriteLine("1 - белый\n2-синий\n3-фиолетовый");
  51.                         switch (Convert.ToInt32(Console.ReadLine()))
  52.                         {
  53.                             case 1:
  54.                                 Console.ForegroundColor = ConsoleColor.White;
  55.                                 break;
  56.                             case 2:
  57.                                 Console.ForegroundColor = ConsoleColor.Blue;
  58.                                 break;
  59.                             case 3:
  60.                                 Console.ForegroundColor = ConsoleColor.Magenta;
  61.                                 break;
  62.                         }
  63.                         defaultForeground = Console.ForegroundColor;
  64.                         break;
  65.                     case "Set message":
  66.                         Console.Clear();
  67.                         message = Console.ReadLine();
  68.                         break;
  69.                     case "Show message":
  70.                         Console.WriteLine(message);
  71.                         break;
  72.                     case "Set Cursor":
  73.                         Console.Clear();
  74.                         Console.Write("Введите величину отступа с левого края - ");
  75.                         x = Convert.ToInt32(Console.ReadLine());
  76.                         Console.Write("Введите величину отступа с верхнего края - ");
  77.                         y = Convert.ToInt32(Console.ReadLine());
  78.                         break;
  79.                     default:
  80.                         Console.WriteLine("Неизвестная команда");
  81.                         break;
  82.                 }
  83.                 if (isOpen)
  84.                 {
  85.                     Console.ReadKey();
  86.                     Console.Clear();
  87.                 }
  88.             }
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement