Ejemplo n.º 1
0
        public static void TestRendering()
        {
            con.SetForegroundColour(ForestGreen);
            con.Write("Starting...\n");
            con.Write(Console.In.GetType());
            con.Write('\n');
            con.Flush();
            var view = Test.CreateView(con);

            con.UseNewScreenBuffer();
            if (_render)
            {
                view.Render();
            }
            while (_running)
            {
                if (_errorUntil > DateTime.Now.Ticks)
                {
                    con.SetForegroundColour(_errorColour);
                    int i = 0;
                    foreach (var s in _errorDisplay)
                    {
                        con.SetCurrentPos(con.Height - _errorDisplay.Length + i++, 2);
                        con.Write(s);
                    }
                }
                if (!string.IsNullOrEmpty(_currentInput))
                {
                    con.SetCurrentPos(con.Height, 1);
                    con.SetForegroundColour(Lime);
                    con.Write('>');
                    con.SetForegroundColour(White);
                    con.Write(_currentInput);
                    con.Write(' ');
                    con.SetCurrentPos(con.Height + (1 + _currentCursor) / con.Width - (1 + _currentInput.Length) / con.Width, (_currentCursor + 1) % con.Width + 1);
                    if (DateTime.Now.Ticks % 10_000_000 < 5000000)
                    {
                        con.Write('_');
                    }
                }
                con.Flush();
                Thread.Sleep(32);
            }

            con.UseMainScreenBuffer();
            con.Write("Program closing...\n");
            con.Flush();
            Thread.Sleep(200);
        }