This project is read-only.
Project Description
ConsoleMenuUI exists to make it easier for developers to build a simple menu interface for a .NET console application. Written in C#, ConsoleMenuUI provides a simple fluent interface for declaring menu options and handles user response to menu choices to drive actions.

In the following code sample, you can see how the ConsoleMenu object is instantiated and used. Menu items are added via AddMenuOption, which takes an Action and a description string. The DrawMenu method will write the menu options to the screen and execute the action that corresponds to the selected menu item.

using ConsoleMenuUI.Lib;

namespace ConsoleMenuUI.ConsoleTest
    class Program
        static void Main(string[] args)
            var cm = new ConsoleMenu()
                .AddMenuChoice(() => Console.WriteLine("This is option 1"),
                              "Option 1")
                .AddMenuChoice(() => Console.WriteLine("I'm watching a movie."),
                    "Print what you are doing")
                .AddMenuChoice(() => TestSomething(),"Run TestSomething");
            cm.ConsoleMenuOptions.EscapeKeyBahavior = EscapeKeyBehavior.PressTwiceToExit;

        static void TestSomething()
            string s = "This is a test.";
            Console.WriteLine("The string \"{0}\" has {1} characters",s,s.Length);

When the above code is run, it will print the following to the screen:

  1 - Option 1
  2 - Print what you are doing
  3 - Run TestSomething

  0 - Exit

Last edited Oct 18, 2010 at 3:25 AM by bmccormack, version 2