Пример #1
0
 public virtual void Run()
 {
     ItemPosition.Reset();
     Console.Clear();
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine("\n  " + Title);
     foreach (Menuitem item in MenuItems)
     {
         item.Y = ItemPosition.Y += 3;
         item.Draw();
     }
 }
Пример #2
0
 public override void Run()
 {
     ItemPosition.Reset();
     Console.Clear();
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine("\n  " + Title + " : " + session.ToString());
     foreach (Menuitem item in MenuItems)
     {
         item.Y = ItemPosition.Y += 3;
         item.Draw();
     }
 }
Пример #3
0
        public override void Run()
        {
            Console.Clear();
            ItemPosition.Reset();
            ItemPosition.Y = 6;

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\n  " + Title);
            Console.WriteLine(Hall.ShowInfo());


            foreach (Menuitem item in MenuItems)
            {
                item.Y = ItemPosition.Y += 3;
                item.Draw();
            }
        }
Пример #4
0
        public void Start()
        {
            while (true)
            {
                ItemPosition.Reset();
                activeMenu.Run();
                Console.Title = activeMenu.Path;
                for (int i = 0; i < activeMenu.Items.Count; i++)
                {
                    if (i == index)
                    {
                        activeMenu.Items[i].IsHover = true;
                        activeMenu.Items[i].Draw();
                    }
                    else
                    {
                        activeMenu.Items[i].IsHover = false;
                        activeMenu.Items[i].Draw();
                    }
                }

                ConsoleKey key = Console.ReadKey(true).Key;

                switch (key)
                {
                case ConsoleKey.UpArrow:
                {
                    if (index == 0)
                    {
                        index = activeMenu.Items.Count - 1;
                    }
                    else
                    {
                        index--;
                    }
                    break;
                }

                case ConsoleKey.DownArrow:
                {
                    if (index == activeMenu.Items.Count - 1)
                    {
                        index = 0;
                    }
                    else
                    {
                        index++;
                    }
                    break;
                }

                case ConsoleKey.Enter:
                {
                    if (activeMenu.Items.Count > 0)
                    {
                        var item = activeMenu.Items[index];
                        if (activeMenu.Items[index] is Folder)
                        {
                            indexHistory.Push(index);
                            index = 0;
                            history.Push(activeMenu);
                            item.Action?.Invoke();
                        }
                        else
                        {
                            item.Action?.Invoke();
                        }
                    }
                }
                break;

                case ConsoleKey.Backspace:
                {
                    if (history.Count > 0)
                    {
                        Console.Clear();
                        back();
                    }
                }
                break;

                case ConsoleKey.Escape:
                {
                    Process.GetCurrentProcess().Kill();
                }
                break;
                }
            }
        }
Пример #5
0
        public void Start()
        {
            while (true)
            {
                ItemPosition.Reset();
                activeMenu.Run();
                for (int i = 0; i < activeMenu.MenuItems.Count; i++)
                {
                    if (i == index)
                    {
                        activeMenu.MenuItems[i].Index   = i;
                        activeMenu.MenuItems[i].IsHover = true;
                        activeMenu.MenuItems[i].Draw();
                    }
                    else
                    {
                        activeMenu.MenuItems[i].Index   = i;
                        activeMenu.MenuItems[i].IsHover = false;
                        activeMenu.MenuItems[i].Draw();
                    }
                }

                ConsoleKey key = Console.ReadKey().Key;

                switch (key)
                {
                case ConsoleKey.UpArrow:
                {
                    if (index == 0)
                    {
                        index = activeMenu.MenuItems.Count - 1;
                    }
                    else
                    {
                        index--;
                    }
                    break;
                }

                case ConsoleKey.DownArrow:
                {
                    if (index == activeMenu.MenuItems.Count - 1)
                    {
                        index = 0;
                    }
                    else
                    {
                        index++;
                    }
                    break;
                }

                case ConsoleKey.Enter:
                {
                    var item = activeMenu.MenuItems[index];
                    if (item.LinkMenu != null)
                    {
                        Console.Clear();
                        index = 0;
                        indexHistory.Push(item.Index);
                        history.Push(activeMenu);
                        activeMenu = item.LinkMenu;
                        activeMenu.Run();
                    }
                    else
                    {
                        Console.Clear();
                        //index = 0;
                        if (item.Index > 0)
                        {
                            indexHistory.Push(item.Index);
                        }
                        item.Action?.Invoke();
                    }
                }
                break;
                }
            }
        }