private SKColor[,] GetColorOverrideMatrix(List <Tuple <SKRectI, SKColor> > spec) { SKColor[,] result = null; if (TableCellData.Count > 0 && TableCellData[0].Count > 0) { int number_of_rows = TableCellData.Count; if (DisplayHeaderRow) { number_of_rows++; } int number_of_columns = TableCellData[0].Count; //Initialize the result matrix fo empty colors result = new SKColor[number_of_rows, number_of_columns]; for (int r = 0; r < number_of_rows; r++) { for (int c = 0; c < number_of_columns; c++) { result[r, c] = SKColor.Empty; } } //Now fill it with the appropriate colors for (int i = 0; i < spec.Count; i++) { var this_tuple = spec[i]; var this_rect = this_tuple.Item1; var this_color = this_tuple.Item2; for (int r = 0; r < this_rect.Height; r++) { var row_coord = this_rect.Top + r; for (int c = 0; c < this_rect.Width; c++) { var col_coord = this_rect.Left + c; if (row_coord >= 0 && col_coord >= 0 && row_coord < result.GetLength(0) && col_coord < result.GetLength(1)) { result[row_coord, col_coord] = this_color; } } } } } return(result); }