Example #1
0
        public void Run()
        {
            while (true)
            {
                Show();

                var selectionIndex = KLConsole.ReadInt("Select an item: ");

                var selection = MenuItems.FirstOrDefault(x => x.Key == selectionIndex);

                if (selection != null)
                {
                    KLConsole.Clear();

                    var reshowMenu = selection.Execute();

                    if (!reshowMenu)
                    {
                        break;
                    }

                    KLConsole.WriteLine();
                    KLConsole.ReadKey("Press any key to continue...");
                }
            }
        }
Example #2
0
        private void Show()
        {
            KLConsole.Clear();
            KLConsole.WriteLine();

            var key = 1;

            foreach (var menuItem in MenuItems.OrderBy(x => x.Order).ToList())
            {
                menuItem.Key = key++;
                KLConsole.WriteLine(string.Format("{0}) {1}", menuItem.Key, menuItem.Name));
            }

            KLConsole.WriteLine();
        }