Advertisement
Nausa

UImenu

Nov 19th, 2017
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.17 KB | None | 0 0
  1.  public static void UImenu(string[] Text1, out int Choise, string oglav)
  2.         {
  3.             Choise = 0;
  4. //Выбор
  5.             bool helperUI = true;
  6. //булевая переменная для вайла
  7.             int menPoint = 1;
  8. //изначальный пункт меню
  9.             while (helperUI)
  10.             {
  11.                 Output(Text1, menPoint, oglav);
  12. //вывод меню
  13.                 ConsoleKeyInfo navigation = new ConsoleKeyInfo();
  14.                 navigation = Console.ReadKey();
  15. //считываем с клавиатуры
  16.                 switch (navigation.Key.ToString())
  17.                 {
  18. //если S Двигаемся вниз, если W - вниз,При F мы выходим из меню, и возвращаем наш выбор который можно вставить в Switch-case(if-else)
  19.                     case ("S"):
  20.                         menPoint++;
  21.                         if (menPoint >= Text1.Length)
  22.                         {
  23.                             menPoint = Text1.Length - 1;
  24.                         }
  25.                         break;
  26.                     case ("W"):
  27.                         menPoint--;
  28.                         if (menPoint <= 0)
  29.                         {
  30.                             menPoint = 0;
  31.                         }
  32.                         break;
  33.                     case ("F"):
  34.                         Choise = menPoint + 1;
  35.                         helperUI = false;
  36.                         break;
  37.                 }
  38.             }
  39.             Console.Clear();
  40.         }
  41.  
  42.         static void Output(string[] Text2, int Menupoint, string oglav)
  43.         {
  44.             Console.Clear();
  45.             Console.WriteLine(oglav);
  46.             for (int count = 0; count < Text2.Length; count++)
  47.             {
  48.                 if (count == Menupoint)
  49.                 {
  50.                     Console.Write("- ");
  51.                 }
  52.                 else
  53.                 {
  54.                     Console.Write("  ");
  55.                 }
  56.                 Console.Write(Text2[count] + "\n");
  57.             }
  58.             Console.WriteLine("\n\n\nНавигация - W/S,выбор - F");
  59.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement