Exemple #1
0
        public void FreeStringDemo()
        {
            cHandler.Reset();
            IntXYPair textPosition = new IntXYPair(30, 10);

            cHandler.SetFreeString("Hello", new FreeString("Hello World!", textPosition, Color.Black, Color.Green));
            cHandler.SetBorder("DialogBorder", new Border(18, 9, 25, 3));
            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");
                cHandler.PrintAllBorders();
                cHandler.PrintAllFreeStrings();
                var input = Console.ReadKey(true);
                switch (input.Key)
                {
                case ConsoleKey.Escape:
                    exit = true;
                    break;

                case ConsoleKey.UpArrow:
                    cHandler.MoveFreeString("Hello", 0, -1);
                    cHandler.MoveBorder("DialogBorder", 0, -1);
                    break;

                case ConsoleKey.DownArrow:
                    cHandler.MoveFreeString("Hello", 0, 1);
                    cHandler.MoveBorder("DialogBorder", 0, 1);
                    break;

                case ConsoleKey.LeftArrow:
                    cHandler.MoveFreeString("Hello", -1, 0);
                    cHandler.MoveBorder("DialogBorder", -1, 0);
                    break;

                case ConsoleKey.RightArrow:
                    cHandler.MoveFreeString("Hello", 1, 0);
                    cHandler.MoveBorder("DialogBorder", 1, 0);
                    break;

                case ConsoleKey.Q:
                    cHandler.ChangeFreeStringAlignment("Hello", Alignment.Left);
                    break;

                case ConsoleKey.W:
                    cHandler.ChangeFreeStringAlignment("Hello", Alignment.Center);
                    break;

                case ConsoleKey.E:
                    cHandler.ChangeFreeStringAlignment("Hello", Alignment.Right);
                    break;
                }
            }
        }