Git Product home page Git Product logo

console.menu's Introduction

Console.Menu

CSharp console menu allows you to quickly and easily organize a complex menu.

Features

Navigation

Imgur

Dynamic

Imgur

Input

Imgur

Confirm

Imgur

Program

using Nim.Console;
using System;
using System.Text;

namespace MenuTest
{
    class Program
    {
        static Menu Menu;

        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.Default;

            Menu = new Menu
            (
                "Main",
                new[]
                {
                    new Menu.Item("Static", new[]
                    {
                        new Menu.Item("Sub-0", Print),
                        new Menu.Item("Sub-1", Print),
                        new Menu.Item("Sub-2", Print),
                        new Menu.Item("Sub-3", Print)
                    }),
                    new Menu.Item("Dynamic", Generate),
                    new Menu.InputItem("Input Test", "Please input you name", InputTest),
                    new Menu.Item("Confirm", Print){ ActionIfConfirmed = true },
                    new Menu.Item("Exit", Exit),
                }
            );

            Menu.Main.MaxColumns = 1;
            
            Menu.WriteLine("Use ←↑↓→ for navigation.");
            Menu.WriteLine("Press Esc for return to main menu.");
            Menu.WriteLine("Press Backspace for return to parent menu.");
            Menu.WriteLine("Press Del for clear log.");

            Menu.Begin();
        }

        static void Print()
        {
            Menu.WriteLine("Selected: " + Menu.Selected.Name);
        }
        
        static void Generate()
        {
            if (Menu.Selected.Items.Count > 0)
            {
                return;
            }


            for (var i = 0; i < 50; ++i)
            {
                var sub = new Menu.Item("Dynamic - " + i, Print);
                

                Menu.Selected.Add(sub);
            }
        }

        static void InputTest(string str)
        {
            var inp = Menu.Selected as Menu.InputItem;

            Menu.WriteLine("You wrote: " + inp.Value);
        }

        static void Exit()
        {
            Menu.Close();
        }
    }
}

Imgur

console.menu's People

Contributors

mburtsev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.