Example #1
0
        static void Main(string[] args)
        {
            UI.DisplayMenu("MENU NAME");

            while (!UI.IsExit)
            {
                keyCommand command = UI.ReadKey();

                switch (command)
                {
                case keyCommand.Down:
                    UI.MoveDown();
                    break;

                case keyCommand.Up:
                    UI.MoveUp();
                    break;

                case keyCommand.Enter:
                {
                    UI.Enter();
                    switch (UI.GetCurrentElement())
                    {
                    case MenuItems.First:
                        RunPercentage();
                        break;

                    case MenuItems.Second:
                        RunPercentage();
                        break;

                    case MenuItems.Third:
                        RunPercentage();
                        break;

                    default:
                        RunPercentage();
                        break;
                    }
                    UI.ProcessFinished();
                }
                break;
                }
            }
            UI.ExitMenu();
        }
Example #2
0
        internal static keyCommand ReadKey()
        {
            keyCommand result = keyCommand.None;

            if (Console.KeyAvailable)
            {
                var command = Console.ReadKey(true);
                switch (command.Key)
                {
                case ConsoleKey.DownArrow:
                    if (currentLine < menuLength)
                    {
                        result = keyCommand.Down;
                    }
                    break;

                case ConsoleKey.UpArrow:
                    if (0 < currentLine)
                    {
                        result = keyCommand.Up;
                    }
                    break;

                case ConsoleKey.Enter:
                {
                    if (currentLine == menuLength)
                    {
                        isExit = true;
                    }
                    else
                    {
                        result = keyCommand.Enter;
                    }
                }
                break;
                }
            }
            return(result);
        }