ranee

досье

Aug 10th, 2020 (edited)
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Diagnostics.CodeAnalysis;
  5. using System.Dynamic;
  6. using System.Globalization;
  7. using System.Linq;
  8. using System.Runtime.Serialization;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. using System.IO;
  13. namespace CSLight
  14. {
  15.     class Program
  16.     {
  17.         private static int index = 0;
  18.         static void Main(string[] args)
  19.         {
  20.             //int index = 0;
  21.             string[] menu = { "1. Добавить досье.", "2. Вывести досье.", "3. Удалить досье.", "4. Поиск по фамилии.", "5. Выход." };
  22.             Console.CursorVisible = false;
  23.             while(true)
  24.             {
  25.                 string selectMenuItems = DrawMenu(menu);
  26.                 if(selectMenuItems == "1. Добавить досье.")
  27.                 {
  28.                     Console.Clear();
  29.                     Console.WriteLine("Привет!");
  30.                     //Console.Read();
  31.                 }
  32.                 else if(selectMenuItems == "2. Вывести досье.")
  33.                 {
  34.  
  35.                 }
  36.                 else if (selectMenuItems == "3. Удалить досье.")
  37.                 {
  38.  
  39.                 }
  40.                 else if (selectMenuItems == "4. Поиск по фамилии.")
  41.                 {
  42.  
  43.                 }
  44.                 else if (selectMenuItems == "5. Выход.")
  45.                 {
  46.                     break;
  47.                 }
  48.             }
  49.         }
  50.         static string DrawMenu(string[] items)
  51.         {
  52.            
  53.             for (int i = 0; i < items.Length; i++)
  54.             {
  55.                 if (i == index)
  56.                 {
  57.                     Console.BackgroundColor = ConsoleColor.Gray;
  58.                     Console.ForegroundColor = ConsoleColor.Black;
  59.                     Console.WriteLine(items[i]);
  60.                 }
  61.                 else
  62.                 {
  63.                     Console.WriteLine(items[i]);
  64.                 }
  65.                 Console.ResetColor();
  66.             }
  67.             ConsoleKeyInfo ckey = Console.ReadKey();
  68.             if (ckey.Key == ConsoleKey.DownArrow)
  69.             {
  70.                 if (index == items.Length - 1)
  71.                 {
  72.                     index = 0;
  73.                 }
  74.                 else
  75.                 {
  76.                     index++;
  77.                 }
  78.             }
  79.             else if (ckey.Key == ConsoleKey.UpArrow)
  80.             {
  81.                 if (index <= 0)
  82.                 {
  83.                     index = items.Length - 1;
  84.                 }
  85.                 else
  86.                 {
  87.                     index--;
  88.                 }
  89.             }
  90.             else if (ckey.Key == ConsoleKey.Enter)
  91.             {
  92.                 return items[index];
  93.             }
  94.             else
  95.             {
  96.                 Console.Clear();
  97.             }
  98.             Console.Clear();
  99.             return "";
  100.         }
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment