BalloonsPop.GraphicUserInterface.MainWindowController.PrintField C# (CSharp) Method

PrintField() public method

Introduces updates on the view bases on the provided IBalloon two-dimensional array.
public PrintField ( IBalloon matrix ) : void
matrix IBalloon The array which is used as a blueprint for introducing changes to the view.
return void
        public void PrintField(IBalloon[,] matrix)
        {
            var rowsCount = matrix.GetLength(0);
            var colsCount = matrix.GetLength(1);

            if (this.balloons == null)
            {
                this.InitializeBalloonImageMatrix(rowsCount, colsCount);
            }

            for (int row = 0; row < rowsCount; row++)
            {
                for (int col = 0; col < colsCount; col++)
                {
                    var colorNumber = matrix[row, col].IsPopped ? 0 : matrix[row, col].Number;
                    var sourcePath = string.Format(this.Resources.ImagePathTemplate, this.Resources.Colors[colorNumber]);
                    this.balloons[row, col].SetSource(sourcePath);
                }
            }

            this.Window.UserMoves = 3.ToString();
        }