Esempio n. 1
0
        public int EnterMainLoop()
        {
            bool done = false;

            while (!done)
            {
                MenuRenderer.PrintNumbers(this, positionY, positionX);
                bool overflow = false;
                switch (Console.ReadKey().Key)
                {
                case ConsoleKey.Enter:
                    done = true;
                    break;

                case ConsoleKey.UpArrow:
                    overflow = numbers[currentDigit].Up();
                    CheckMax();
                    break;

                case ConsoleKey.DownArrow:
                    overflow = numbers[currentDigit].Down();
                    CheckMax();
                    break;

                case ConsoleKey.LeftArrow:
                    if (currentDigit < numbers.Count - 1)
                    {
                        currentDigit++;
                    }
                    break;

                case ConsoleKey.RightArrow:
                    if (currentDigit > 0)
                    {
                        currentDigit--;
                    }
                    break;
                }
            }

            return(GetCurrentValue());
        }
Esempio n. 2
0
 public void Print()
 {
     if (!scrollable)
     {
         MenuRenderer.PrintMenu(this);
     }
     else if (menuItems.Count() < maxShown)
     {
         MenuRenderer.PrintMenu(this);
     }
     else
     {
         Menu croped = new Menu(firstRow, columnStart, title, style, width: columnWidth);
         if (top > 0)
         {
             croped.AddItem(new MenuItem(@"………", Alignment.Centered));
         }
         else
         {
             croped.AddItem(menuItems[0]);
         }
         for (int i = top + 1; i < end; i++)
         {
             croped.AddItem(menuItems[i]);
         }
         if (end < menuItems.Count - 1)
         {
             croped.AddItem(new MenuItem("………", Alignment.Centered));
         }
         else
         {
             croped.AddItem(menuItems[end]);
         }
         MenuRenderer.PrintMenu(croped);
     }
 }