Пример #1
0
        /*
         *  Command function for CharButtonCommand
         *  Handles the interaction for each key press and for when the application is in predictive mode
         *  @param Object parameter passed in by the UI, the Key character for the button in this case
         */
        private void OnCharacterPress(object param)
        {
            var  paramString = param as string;
            char key         = paramString[0];

            switch (key)
            {
            case '*':
                OnBackspace();
                if (PredictiveModeChecked)
                {
                    GetCurrentPredictions();
                }
                else
                {
                    _currentViewChar = null;
                }
                break;

            case '1':
                _currentViewChar = null;
                break;

            case '#':
                if (PredictiveModeChecked && SelectedPrediction != null)
                {
                    SetSelectedWord();
                }
                OnCharacter(key);
                break;

            case '0':
                if (PredictiveModeChecked)
                {
                    CyclePredictionSelections();
                }
                else
                {
                    _currentViewChar = null;
                }

                break;

            default:
                OnCharacter(key);
                if (PredictiveModeChecked)
                {
                    GetCurrentPredictions();
                }

                break;
            }
        }
Пример #2
0
        /*
         *   Sequence of checks and functions for different stages of pressing a T9 Button
         */
        private void OnCharacter(char key)
        {
            // If the first character inputed or the current ViewChar has been nullified
            if (_currentViewChar == null)
            {
                _currentViewChar = new ViewChar(key, T9CharacterModel.T9CharDictionary[key].Length);
                AppendCurrChar();
                //Timer stuff
                _charStopWatch.Reset();
                _charStopWatch.Start();
                return;
            }
            // If pressing same character
            if (key == _currentViewChar.charKey)
            {
                _currentViewChar.currCharIndex++;
                _charStopWatch.Stop();
                if (_charStopWatch.ElapsedMilliseconds < _setCharTimeInterval)
                {
                    if (_currentViewChar.currCharIndex >= _currentViewChar.dictSize)
                    {
                        _currentViewChar = new ViewChar(key, T9CharacterModel.T9CharDictionary[key].Length);
                        AppendCurrChar();
                        _charStopWatch.Reset();
                        _charStopWatch.Start();
                    }
                    else
                    {
                        SwapLastWithCurrChar();
                        _charStopWatch.Reset();
                        _charStopWatch.Start();
                    }
                }
                else
                {
                    _currentViewChar = new ViewChar(key, T9CharacterModel.T9CharDictionary[key].Length);
                    AppendCurrChar();
                    _charStopWatch.Reset();
                    _charStopWatch.Start();
                }
                return;
            }

            // if new char pressed compared to last char
            _currentViewChar = new ViewChar(key, T9CharacterModel.T9CharDictionary[key].Length);
            AppendCurrChar();
            _charStopWatch.Reset();
            _charStopWatch.Start();
        }