public void Run()
        {
            while (true)
            {
                if (background.BackColor != null)
                {
                    screenBuffer.Clear(background.FillChar,
                                       background.CharColor, background.BackColor.Value);
                }
                else
                {
                    screenBuffer.Clear(background.FillChar,
                                       background.CharColor, ConsoleColor.Black);
                }

                var controlsToDraw = Controls.OrderBy(c => c.ZIndex);
                foreach (Control control in controlsToDraw)
                {
                    if (control.Visible)
                    {
                        control.Draw(screenGraphics);
                    }
                }

                screenBuffer.Flush();

                var keyInfo = System.Console.ReadKey(true);
                if (focusedControl != null)
                {
                    focusedControl.DispatchKeyPress(keyInfo);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Ends the operation of drawing; builds a final picture on a screen.
        /// </summary>
        public override void End()
        {
            base.End();

            DrawTriangleBuffer();
            consoleBuffer.Flush();
        }
Esempio n. 3
0
        private static void Draw(IConsoleBuffer border, IConsoleBuffer board, IConsoleBuffer nextPiecePanel, IConsoleBuffer scorePanel, string lastCommand)
        {
            frame.Fill(ConsoleColor.DarkGray);

            for (var i = 0; i < PADDING; ++i)
            {
                var j = 2 * i;
                border.Stroke(
                    i, i,
                    border.Width - j, border.Height - j,
                    DoubleLight,
                    ConsoleColor.Gray);
            }

            board.Fill(ConsoleColor.Black);
            board.DrawPuzzle(0, 0, game);
            board.DrawPuzzle(game.CursorX, game.CursorY, game.Current);

            nextPiecePanel.Draw(0, 0, "Next", ConsoleColor.Black);
            nextPiecePanel.DrawPuzzle(2, 1, game.Next);

            var score = game.Score.ToString(CultureInfo.CurrentCulture);

            scorePanel.Draw(0, 0, $"Score", ConsoleColor.Black);
            scorePanel.Draw(2, 1, score, ConsoleColor.White);
            scorePanel.Draw(0, 2, lastCommand, ConsoleColor.Black);

            frame.Flush();
        }