コード例 #1
0
        // Incriment cell focus to next available cell or defocus
        private void LetterCell_TextChanged(CustomEntry entry, TextChangedEventArgs e)
        {
            // Check if the character is not empty
            if (!IsCellEmpty(e))
            {
                return;
            }

            // Check if word is complete and correct - if so, defocus and dehighlight
            if (_wordChecker.IsWordCorrect())
            {
                // Update Score
                UpdateScoring();

                if (_focusedLetterCell != null)
                {
                    DeFocusCell();
                    _isPlacedWordSelected = false;
                }
            }
            else
            {
                // Exit if _focusedLetterCell is null
                if (!IsFocusedLetterCellNull())
                {
                    return;
                }

                // Exit if placed word is not selected
                if (!IsFocusedLetterCellNull())
                {
                    return;
                }

                // Change Entry focus to next cell in word
                // Return next cell position
                var nextCellPos = _currentPlacedWord.IncrimentCellPos(_focusedLetterCell.Pos);

                if (nextCellPos != null)
                {
                    // Clear character when selected
                    var letterCell = CrosswordViewModel.Instance().DisplayBoard[nextCellPos.Item2][nextCellPos.Item1];
                    if (letterCell.LetterIn != Char.MinValue)
                    {
                        letterCell.LetterIn = Char.MinValue;
                    }
                    _focusedLetterCell = letterCell;
                }
                else
                {
                    DeFocusCell();
                    _isPlacedWordSelected = false;
                }

                if (nextCellPos != null)
                {
                    CrosswordViewModel.Instance().DisplayBoard[nextCellPos.Item2][nextCellPos.Item1].CellEntry.Focus();
                }
            }
        }