コード例 #1
0
 /// <summary>
 /// Clear the selection of cells
 /// </summary>
 public void DeselectAllCells()
 {
     foreach (var cell in selectedCells)
     {
         cell.IsHighlighted = false;
     }
     selectedCells.Clear();
     lastSelectedCell = null;
 }
コード例 #2
0
 /// <summary>
 /// Toggle the selection of the given cell
 /// </summary>
 /// <param name="cell">Cell to toggle selection of</param>
 public void ToggleCell(CellViewModel cell)
 {
     if (cell.IsHighlighted)
     {
         DeselectCell(cell);
     }
     else
     {
         SelectCell(cell, true);
     }
 }
コード例 #3
0
        /// <summary>
        /// Deselect the given cell
        /// </summary>
        /// <param name="cell">Cell to deselect</param>
        public void DeselectCell(CellViewModel cell)
        {
            selectedCells.Remove(cell);
            cell.IsHighlighted = false;

            // If the deselected cell was also the most recently selected one, choose the next most recently selected cell as the new most recent one
            if (lastSelectedCell == cell)
            {
                lastSelectedCell = selectedCells.Count > 0 ? selectedCells[selectedCells.Count - 1] : null;
            }
        }
コード例 #4
0
        /// <summary>
        /// Select the given cell
        /// </summary>
        /// <param name="cell">Cell to select</param>
        /// <param name="add">If true, cell is added to selection, otherwise, it replaces the current selection</param>
        public void SelectCell(CellViewModel cell, bool add = false)
        {
            if (!add)
            {
                DeselectAllCells();
            }

            lastSelectedCell = cell;

            if (!cell.IsHighlighted)
            {
                cell.IsHighlighted = true;
                selectedCells.Add(cell);
            }
        }
コード例 #5
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public SudokuPuzzleViewModel()
 {
     for (int y = 0; y < numDigits; y++)
     {
         for (int x = 0; x < numDigits; x++)
         {
             var cell = new CellViewModel()
             {
                 Column        = x,
                 Row           = y,
                 Digit         = 0,
                 IsLockedDigit = false,
             };
             Cells.Add(cell);
         }
     }
 }