Ejemplo n.º 1
0
        public void ScrollableMenuDemo()
        {
            cHandler.Reset();
            Console.Clear();
            ScrollableMenu <int> menu = new ScrollableMenu <int>(30, 10, 20, 10, Color.Green, Color.Black);

            for (int i = 1; i <= 30; i++)
            {
                menu.AddItem($"{i}", i);
            }
            menu.AddItem("Exit", 0);

            FreeStringBundle guide = new FreeStringBundle(5, 20, 30);

            guide.Add("This menu contains 30 numbered items and an exit button");
            guide.Add("Q | LeftAlign, W | CenterAlign, E | RightAlign");
            bool exit = false;

            while (!exit)
            {
                guide.Print();
                menu.Print();
                ConsoleKey switcher = Console.ReadKey().Key;
                switch (switcher)
                {
                case ConsoleKey.Enter:
                    if (menu.GetReturn() == 0)
                    {
                        exit = true;
                    }
                    break;

                case ConsoleKey.UpArrow:
                    if (!menu.AtTop())
                    {
                        Console.Clear();
                        menu.Up();
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (!menu.AtBottem())
                    {
                        Console.Clear();
                        menu.Down();
                    }
                    break;

                case ConsoleKey.Q:
                    menu.LeftAlign();
                    Console.Clear();
                    break;

                case ConsoleKey.W:
                    menu.CenterAlign();
                    Console.Clear();
                    break;

                case ConsoleKey.E:
                    menu.RightAlign();
                    Console.Clear();
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public void FreeStringBundleDemo()
        {
            FreeStringBundle fsBundle = new FreeStringBundle(30, 5, 50, Color.Black, Color.Green, Alignment.Center);
            Border           border   = new Border(fsBundle.GetPositionX() - 1
                                                   , fsBundle.GetPositionY() - 1, fsBundle.GetMaxTextLength() + 2, 10);

            fsBundle.Add("FirstLine");
            fsBundle.Add("This Line exceed the 20 character limit and will be warped to next line.");
            fsBundle.Add("Third Imput but in fourth line");
            fsBundle.Add("This Line Has Exactly 50 characters.##############");
            fsBundle.Add("This Line Has Exactly 49 characters.#############");
            fsBundle.Add("This Line Has Exactly 51 characters.###############");

            bool exit = false;

            while (!exit)
            {
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Clear();
                Console.SetCursorPosition(10, 20);
                Console.Write("Q | LeftAlign, W | CenterAlign, E | RightAlign");
                border.Print();
                fsBundle.Print();
                var input = Console.ReadKey(true);
                switch (input.Key)
                {
                case ConsoleKey.Escape:
                    exit = true;
                    break;

                case ConsoleKey.LeftArrow:
                    fsBundle.Move(-1, 0);
                    border.Move(-1, 0);
                    break;

                case ConsoleKey.UpArrow:
                    fsBundle.Move(0, -1);
                    border.Move(0, -1);
                    break;

                case ConsoleKey.RightArrow:
                    fsBundle.Move(1, 0);
                    border.Move(1, 0);
                    break;

                case ConsoleKey.DownArrow:
                    fsBundle.Move(0, 1);
                    border.Move(0, 1);
                    break;

                case ConsoleKey.Q:
                    fsBundle.LeftAlign();
                    break;

                case ConsoleKey.W:
                    fsBundle.CenterAlign();
                    break;

                case ConsoleKey.E:
                    fsBundle.RightAlign();
                    break;
                }
            }
        }