Exemple #1
0
        static void Main(string[] args)
        {
            ConsoleMenu menu    = new ConsoleMenu();
            ConsoleMenu subMenu = new ConsoleMenu();

            subMenu.AddCommand("Do nothing", (sm) =>
            {
                Console.WriteLine("nothing done");
                Console.ReadKey();
            });
            subMenu.AddCommand("Do something else", (sm) =>
            {
                Console.WriteLine("still not doing jack shit");
                Console.ReadKey();
            });
            menu.AddSubMenu("Action 1: submenu", subMenu);
            menu.AddCommand("You may prefer action 2", (m) =>
            {
                Console.WriteLine("Action 2 Called");
                Console.ReadKey();
            });
            menu.AddCommand("Exit", (m) =>
            {
                m.Exit();
            });

            // navigate the menu with arrow keys and select with enter or use number as shortcut
            menu.Show();
        }
Exemple #2
0
        public void TestCountConsoleMenu()
        {
            var menu = new ConsoleMenu();
            var i    = 0;

            menu.AddCommand("Nothing", () => i = 1);
            Assert.AreEqual(menu.Count, 1);
        }