Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ArduinoMenu
- {
- class Program
- {
- private static char arrow = (char)16;
- private static string[] menuItems = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10" };
- private static int maxItems = 5;
- private static int currentLine = 0;
- private static bool exit = false;
- static void Main(string[] args)
- {
- while (!exit)
- {
- Console.Clear();
- for (int i = 0; i < maxItems; i++)
- {
- string currentMenuItem = menuItems[i];
- if (i == currentLine)
- Console.WriteLine(arrow + currentMenuItem);
- else
- Console.WriteLine(" " + currentMenuItem);
- }
- var key = Console.ReadKey().Key;
- if (key == ConsoleKey.UpArrow && currentLine > 0)
- {
- currentLine--;
- }
- else if (key == ConsoleKey.DownArrow && currentLine < maxItems - 1)
- {
- currentLine++;
- }
- if (key == ConsoleKey.Enter)
- {
- Console.Title = "You selected: " + menuItems[currentLine];
- }
- if (key == ConsoleKey.Escape)
- {
- exit = true;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement