Example #1
0
        public void input(int pos, Imenu menu)
        {
            var          k         = Console.ReadKey();
            int          CurPos    = pos;
            Imenu        PrevMenu  = menu;
            infinateMenu InfiMatch = new infinateMenu("Match");

            while (k.KeyChar != 'q')
            {
                if (k.Key == ConsoleKey.UpArrow)
                {
                    pos--;
                    if (0 <= pos)
                    {
                        print(pos, CurPos, menu);
                    }
                    else
                    {
                        pos = 0;
                    }
                }
                if (k.Key == ConsoleKey.DownArrow)
                {
                    pos++;

                    if (menu.menulist.Count > pos)
                    {
                        print(pos, CurPos, menu);
                    }
                    else
                    {
                        pos = menu.menulist.Count - 1;
                    }
                }
                if (k.Key == ConsoleKey.Enter)
                {
                    PrevMenu = menu;
                    menu     = menu.menulist[pos];
                    if (menu.GetType() == InfiMatch.GetType())
                    {
                        menu.menulist = new List <Imenu>();
                        for (int i = 1; i <= 6; i++)
                        {
                            menu.menulist.Add(new infinateMenu(i.ToString()));
                        }
                    }
                    CurPos = pos;
                    pos    = 0;
                    print(pos, CurPos, menu);
                }
                if (k.Key == ConsoleKey.Backspace)
                {
                    menu = PrevMenu;
                    print(pos, CurPos, PrevMenu);
                }
                k = Console.ReadKey();
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            Console.Clear();
            Menu     selector = new Menu();
            MenuItem menu     = new MenuItem("fancymenu");

            menu.add(new MenuItem("Punkt1"));
            menu.add(new MenuItem("Punkt2"));
            menu.add(new MenuItem("Punkt3"));
            MenuItem under = new MenuItem("Menu1");

            under.add(new MenuItem("nasdon"));
            under.add(new MenuItem("nasifd"));
            menu.add(under);
            infinateMenu infi = new infinateMenu("infinate");


            menu.add(infi);
            selector.Start(menu);
        }