示例#1
0
        public static int MultipleChoice(bool canCancel, params string[] options)
        {
            int optionsPerLine = options.Length;

            int currentSelection = 0;

            ConsoleKey keymenu;

            do
            {
                Clear();
                Game.TittlePage();
                for (int i = 0; i < options.Length; i++)
                {
                    if (i == currentSelection)
                    {
                        ForegroundColor = ConsoleColor.Red;
                    }

                    WriteLine("\t\t\t\t\t" + options[i]);
                    ResetColor();
                }

                keymenu = ReadKey(true).Key;

                switch (keymenu)
                {
                case ConsoleKey.UpArrow:
                {
                    if (currentSelection > 0)
                    {
                        currentSelection--;
                    }
                    break;
                }

                case ConsoleKey.DownArrow:
                {
                    if (currentSelection < optionsPerLine - 1)
                    {
                        currentSelection++;
                    }
                    break;
                }

                case ConsoleKey.Escape:
                {
                    if (canCancel)
                    {
                        return(-1);
                    }
                    break;
                }
                }
            } while (keymenu != ConsoleKey.Enter);

            return(currentSelection);
        }