Exemple #1
0
        /// <summary>
        /// Updates the column collection to match the row collection in the specific cell.
        /// </summary>
        /// <param name="reference">The cell reference.</param>
        private void UpdateReferences(GridReference reference)
        {
            var col = this.Columns[reference.ColumnIndex].Cells[reference.RowIndex];
            var row = this.Rows[reference.RowIndex].Cells[reference.ColumnIndex];

            if (row.Known && col.Known)
            {
                // If they are both known, then blow up if they are different
                if (row.Black != col.Black)
                {
                    throw new Exception($"Two known cells in rows and cols have different values: ({reference.RowIndex},{reference.ColumnIndex})");
                }

                return;
            }
            else if (!row.Known && !col.Known)
            {
                // If neither are known then no changes to make
                return;
            }

            if (col.Known)
            {
                // Column is known, so set the row value
                row.Black = col.Black;
            }
            else
            {
                col.Black = row.Black;
            }
        }
Exemple #2
0
 /// <summary>
 /// Sets the cell at the specified index to be black.
 /// </summary>
 /// <param name="reference">The cell reference.</param>
 public void SetCellBlack(GridReference reference)
 {
     this.ValidateIndices(reference.RowIndex, reference.ColumnIndex);
     this.Rows[reference.RowIndex].SetCellBlack(reference);
     this.UpdateReferences(reference);
 }
Exemple #3
0
 /// <summary>
 /// Sets the cell at the specified index to be black.
 /// </summary>
 /// <param name="reference">The cell reference.</param>
 public void SetCellBlack(GridReference reference)
 {
     this.Cells[reference.ColumnIndex].Black = true;
 }