Ejemplo n.º 1
0
        public void DrawMenu(ConsoleMenu menu)
        {
            ConsoleMenu test = menu;
            int depth = 0;
            while (test.InSubMenu) { test = test.MenuItems[test.CursorIndex]; depth++; }

            for (int i = 0; i < menu.MenuItems.Count; i++)
            {
                for (int j = 0; j <= depth; j++)
                {
                    int offset = 0;
                    if (j != 0) offset = menu.GetMenuAtDepth(j - 1).CursorIndex;

                    ConsoleMenu currentMenu = menu.GetMenuAtDepth(j);
                    int maxLength = currentMenu.MenuItems.Max(x => x.Heading.Length);

                    ConsoleMenu item = currentMenu.MenuItems[i - offset];
                    if (currentMenu.CursorIndex == i - offset) MenuPanel.Write(String.Format(" > {0," + maxLength + "}", item.Heading), ConsoleColor.Cyan);
                    else MenuPanel.Write(String.Format("   {0," + maxLength + "}", item.Heading), ConsoleColor.Gray);
                }
                MenuPanel.Write("\n", ConsoleColor.Blue);
            }
            Flush();
        }