예제 #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();
                }
            }
        }
예제 #2
0
        // Actions single or double click methods
        private void ButtonEntryFocused(LetterCell letterCell, int clickCount)
        {
            _focusedLetterCell = letterCell;
            _currentPlacedWord.ColourizeSelectedWordCells(Colours.Forground);

            if (clickCount == 1)
            {
                if (letterCell.PlacedWordGroup.PlacedWord1 != null)
                {
                    _currentPlacedWord = letterCell.PlacedWordGroup.PlacedWord1;
                    letterCell.PlacedWordGroup.PlacedWord1.ColourizeSelectedWordCells(Colours.Highlight);
                    letterCell.CellEntry.Focus();
                    _isPlacedWordSelected = true;
                }
            }
            else
            {
                if (letterCell.PlacedWordGroup.PlacedWord2 != null)
                {
                    _currentPlacedWord = letterCell.PlacedWordGroup.PlacedWord2;
                    letterCell.PlacedWordGroup.PlacedWord2.ColourizeSelectedWordCells(Colours.Highlight);
                    letterCell.CellEntry.Focus();
                    _isPlacedWordSelected = true;
                }
                else
                {
                    _isPlacedWordSelected = false;
                }
            }
        }
예제 #3
0
 // InitializeVarialbes
 private void ResetVariables()
 {
     _currentPlacedWord = new PlacedWord();
     _wordChecker       = new WordChecker();
     _focusedLetterCell = null;
     _score.Value       = 0;
     _newGame           = true;
 }
예제 #4
0
 // Determines if single or double click
 bool DoubleClick(LetterCell letterCell)
 {
     if (_buttonCount > 1)
     {
         //Your action for Double Click here
         ButtonEntryFocused(letterCell, 2);
     }
     else
     {
         //Your action for Single Click here
         ButtonEntryFocused(letterCell, 1);
     }
     _buttonCount = 0;
     return(false);
 }
예제 #5
0
 // Entry Letter Cell
 private void EntryFocused(LetterCell letterCell)
 {
 }