/// <summary>
        /// The display grid.
        /// </summary>
        /// <param name="grid">
        /// The game grid.
        /// </param>
        public void DisplayGrid(IMinesweeperGrid grid)
        {
            if (this.isRealView)
            {
                var sb = new StringBuilder();

                for (var i = 0; i < grid.Rows; i++)
                {
                    for (var j = 0; j < grid.Cols; j++)
                    {
                        if (grid.IsCellRevealed(i, j))
                        {
                            if (grid.HasCellBomb(i, j))
                            {
                                sb.Append("*");
                            }
                            else if (grid.NeighborMinesCount(i, j) == 0)
                            {
                                sb.Append(" ");
                            }
                            else
                            {
                                sb.Append(grid.NeighborMinesCount(i, j).ToString());
                            }
                        }
                        else if (grid.IsCellProtected(i, j))
                        {
                            sb.Append("~");
                        }
                        else
                        {
                            sb.Append('▒');
                        }
                    }
                }

                if (this.gridBox == null)
                {
                    this.gridBox = new ConsoleBox<ConsoleColor>(
                        10,
                        10,
                        grid.Rows + 1,
                        grid.Cols + 1,
                        ConsoleColor.Cyan,
                        ConsoleColor.DarkRed,
                        sb.ToString());
                    this.consoleWrpView.Clear();
                    ConsolePrinter.PrintGrid(
                        this.consoleWrpView,
                        this.gridBox,
                        this.OpenCellEvent,
                        this.ProtectCellEvent);
                }

                this.gridBox.Text = sb.ToString();
                ConsolePrinter.Print(this.consoleWrpView, this.gridBox);
            }
        }
        /// <summary>
        /// The update cell button.
        /// </summary>
        /// <param name="grid">
        /// The game grid.
        /// </param>
        /// <param name="button">
        /// The button.
        /// </param>
        private void UpdateCellButton(IMinesweeperGrid grid, WpfMinesweeperButton button)
        {
            var i = button.Row;
            var j = button.Col;

            var color = new System.Windows.Media.Color();

            if (grid.IsCellProtected(i, j))
            {
                button.Background = this.images[1];
            }
            else if (grid.IsCellRevealed(i, j))
            {
                button.ClearValue(Control.BackgroundProperty);
                button.Background = new SolidColorBrush(Colors.LightGray);

                if (grid.HasCellBomb(i, j))
                {
                    button.Background = this.images[0];
                }
                else
                {
                    switch (grid.NeighborMinesCount(i, j))
                    {
                        case 1:
                            color = Colors.Blue;
                            break;
                        case 2:
                            color = Colors.Green;
                            break;
                        case 3:
                            color = Colors.Red;
                            break;
                        case 4:
                            color = Colors.Indigo;
                            break;
                        case 5:
                            color = Colors.DarkSlateGray;
                            break;
                        case 6:
                            color = Colors.DarkRed;
                            break;
                        case 7:
                            color = Colors.DarkBlue;
                            break;
                        case 8:
                            color = Colors.Black;
                            break;
                    }

                    if (grid.NeighborMinesCount(i, j) != 0)
                    {
                        button.Content = grid.NeighborMinesCount(i, j).ToString();
                        button.Foreground = new SolidColorBrush(color);
                    }
                }

                button.IsHitTestVisible = false;
            }
            else
            {
                button.Background = new SolidColorBrush(Colors.AliceBlue);

                button.Content = string.Empty;
            }
        }