A user asked how to use the dewitcher Menu.
It's very easy to use, don't worry =)

using System;
using System.Collections.Generic;
using sys = Cosmos.System;

// Use "menu" as the static dewitcher.Core.Menu class
using menu = dewitcher.Console.Menu;

namespace YourOS
{
    public class Kernel : sys.Kernel
    {
        protected override void BeforeRun()
        {
            Console.WriteLine("Press any key to start");
            Console.ReadKey();
        }

        protected override void Run()
        {
            // Initialize the menu
            menu.Reset();

            // Create a new category: catTest
            menu.Category catTest = new menu.Category("Test");
            catTest.AddEntry(new TestCommand());

            // Create a new category: catHello
            menu.Category catHello = new menu.Category("Hello");
            catHello.AddEntry(new HelloWorld());

            // Add the categories to the menu
            menu.AddCategory(catTest);
            menu.AddCategory(catHello);

            // Show the menu
            menu.Show();
        }
    }

    #region Entries

    // A test entry
    public class TestCommand : menu.Entry
    {
        public TestCommand() { this.text = "Test Command"; }
        public override void Execute()
        {
            // Place the code that should be executed here
        }
    }

    // A hello world entry
    public class HelloWorld : menu.Entry
    {
        public HelloWorld() { this.text = "Hello World!"; }
        public override void Execute()
        {
            // Place the code that should be executed here
        }
    }

    #endregion
}

Last edited Mar 22, 2013 at 11:04 PM by SplittyDev, version 2

Comments

No comments yet.