Пример #1
0
        public void DemoMainPage()
        {
            //setup
            Menu <int> mainMenu = new Menu <int>(46, 19, 28);

            mainMenu.AddItem("FreeString", 0);
            mainMenu.AddItem("FreeStringBundle", 1);
            mainMenu.AddItem("Border", 2);
            mainMenu.AddItem("Image", 3);
            mainMenu.AddItem("Canvas", 4);
            mainMenu.AddItem("Menu", 5);
            mainMenu.AddItem("ScrollableMenu", 6);
            mainMenu.AddItem("Numbers", 7);
            mainMenu.AddItem("Exit", 8);

            bool exit        = false;
            bool needRefresh = true;

            while (!exit)
            {
                if (needRefresh)
                {
                    cHandler.Reset();
                    cHandler.SetCanvas("Logo", new Canvas(90, 35, 15, 0));
                    cHandler.DrawToCanvas("Logo", "ConsoleGameEngineDemo_Logo", new IntXYPair(0, 0));
                    cHandler.SetBorder("HomeMenuBorder", new Border(45, 18, 30, 11));

                    Console.Clear();
                    cHandler.PrintAllCanvas();
                    cHandler.PrintAllBorders();
                    needRefresh = false;
                }
                mainMenu.Print();
                var input = Console.ReadKey(true);
                switch (input.Key)
                {
                case ConsoleKey.Escape:
                    exit = true;
                    break;

                case ConsoleKey.UpArrow:
                    mainMenu.Up();
                    break;

                case ConsoleKey.DownArrow:
                    mainMenu.Down();
                    break;

                case ConsoleKey.Enter:
                    switch (mainMenu.GetReturn())
                    {
                    case 0:
                        FreeStringDemo();
                        needRefresh = true;
                        break;

                    case 1:
                        FreeStringBundleDemo();
                        needRefresh = true;
                        break;

                    case 2:
                        BorderDemo();
                        needRefresh = true;
                        break;

                    case 3:
                        ImageDemo();
                        needRefresh = true;
                        break;

                    case 4:
                        CanvasDemo();
                        needRefresh = true;
                        break;

                    case 5:
                        MenuDemo();
                        needRefresh = true;
                        break;

                    case 6:
                        ScrollableMenuDemo();
                        needRefresh = true;
                        break;

                    case 7:
                        NumberDemo();
                        needRefresh = true;
                        break;

                    case 8:
                        exit = true;
                        break;
                    }

                    break;
                }
            }
            mainMenu.Print();
        }