Ejemplo n.º 1
0
        private bool KeyboardHook_ArrowKeysPressed(bool up)
        {
            if (suggestions == null)
            {
                return(false);
            }
            if (suggestions.Count == 0)
            {
                return(false);
            }

            if (up)
            {
                selectedIdx--;
                if (selectedIdx < 0)
                {
                    selectedIdx = 0;
                }
            }
            else
            {
                selectedIdx++;
                if (selectedIdx >= suggestions.Count)
                {
                    selectedIdx = suggestions.Count - 1;
                }
            }

            SuggestionsChanged?.Invoke(suggestions, selectedIdx);

            return(true);
        }
Ejemplo n.º 2
0
        private void KeyboardHook_WordActionHappened(KeyboardHook.WordAction action)
        {
            if (action == KeyboardHook.WordAction.WordCompleted)
            {
                if (current.Length == 0)
                {
                    return;
                }

                string word = current.ToString();
                current.Clear();

                if (KeyboardHook.Language == 1026)
                {
                    bgWords.UpdateWord(word);
                }
                else if (KeyboardHook.Language == 1033)
                {
                    enWords.UpdateWord(word);
                }
            }
            else if (action == KeyboardHook.WordAction.WordTerminated)
            {
                current.Clear();
            }

            suggestions = null;
            selectedIdx = 0;
            SuggestionsChanged?.Invoke(suggestions, selectedIdx);
        }
 /// <summary>
 /// Update the fixed set of options from which to generate suggestions.
 /// </summary>
 /// <param name="options">The complete collection of possible options.</param>
 public void SetOptions(IReadOnlyList <string> options)
 {
     if (!_options.SequenceEqual(options))
     {
         _options = options;
         SuggestionsChanged?.Invoke();
     }
 }
Ejemplo n.º 4
0
        private async void GetSuggestionsAndUpdateResultsAsync(string currentValue, bool isFocused)
        {
            if (_cancelSource != null)
            {
                _cancelSource.Cancel();
            }
            _cancelSource = new CancellationTokenSource();

            try
            {
                _results = await GetSuggestionsAsync(currentValue, isFocused, _cancelSource.Token).ConfigureAwait(false);

                SuggestionsChanged?.Invoke();
            }
            catch (OperationCanceledException)
            {
                // Do nothing
            }
        }
Ejemplo n.º 5
0
        private void UpdateSuggestions()
        {
            if (current.Length == 0)
            {
                SuggestionsChanged?.Invoke(null, 0);
                return;
            }
            string prefix = current.ToString();

            if (KeyboardHook.Language == 1026)
            {
                suggestions = bgWords.GetSuggestions(prefix);
            }
            else if (KeyboardHook.Language == 1033)
            {
                suggestions = enWords.GetSuggestions(prefix);
            }
            selectedIdx = 0;

            SuggestionsChanged?.Invoke(suggestions, selectedIdx);
        }
Ejemplo n.º 6
0
 public void FireSuggestionsChangedEvent()
 {
     SuggestionsChanged?.Invoke();
 }