Advertisement
MaoChessy

Task 10

Oct 24th, 2020
131
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.  
  33.                     case "Set background":
  34.                         Console.Clear();
  35.                         Console.WriteLine("1 - Черный\n2-зелёный\n3-серый");
  36.                         switch (Convert.ToInt32(Console.ReadLine()))
  37.                         {
  38.                             case 1:
  39.                                 Console.BackgroundColor = ConsoleColor.Black;
  40.                                 break;
  41.                             case 2:
  42.                                 Console.BackgroundColor = ConsoleColor.DarkGreen;
  43.                                 break;
  44.                             case 3:
  45.                                 Console.BackgroundColor = ConsoleColor.DarkGray;
  46.                                 break;
  47.                         }
  48.                         break;
  49.  
  50.                     case "Set foreground":
  51.                         Console.Clear();
  52.                         Console.WriteLine("1 - белый\n2-синий\n3-фиолетовый");
  53.                         switch (Convert.ToInt32(Console.ReadLine()))
  54.                         {
  55.                             case 1:
  56.                                 Console.ForegroundColor = ConsoleColor.White;
  57.                                 break;
  58.                             case 2:
  59.                                 Console.ForegroundColor = ConsoleColor.Blue;
  60.                                 break;
  61.                             case 3:
  62.                                 Console.ForegroundColor = ConsoleColor.Magenta;
  63.                                 break;
  64.                         }
  65.                         defaultForeground = Console.ForegroundColor;
  66.                         break;
  67.  
  68.                     case "Set message":
  69.                         Console.Clear();
  70.                         message = Console.ReadLine();
  71.                         break;
  72.  
  73.                     case "Show message":
  74.                         Console.WriteLine(message);
  75.                         break;
  76.  
  77.                     case "Set Cursor":
  78.                         Console.Clear();
  79.                         Console.Write("Введите величину отступа с левого края - ");
  80.                         x = Convert.ToInt32(Console.ReadLine());
  81.                         Console.Write("Введите величину отступа с верхнего края - ");
  82.                         y = Convert.ToInt32(Console.ReadLine());
  83.                         break;
  84.  
  85.                     default:
  86.                         Console.WriteLine("Неизвестная команда");
  87.                         break;
  88.                 }
  89.                 if (isOpen)
  90.                 {
  91.                     Console.ReadKey();
  92.                     Console.Clear();
  93.                 }
  94.             }
  95.         }
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement