public static void SuggestionKeyHandler(KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Enter:
                string textToInsert   = SuggestionProvider.GetItem();
                int    lastWordLength = Utility.GetLastWord().Length;
                string textToAppend   = textToInsert.Substring(lastWordLength);
                int    select         = editor.SelectionStart;
                Utility.AppendText(editor, Coloring.GetColor(textToInsert), textToAppend);
                editor.SelectionStart = select + textToAppend.Length;
                Coloring.DoColoring();
                Utility.AppendText(editor, Color.Black, " ");
                editor.SelectionStart = editor.SelectionStart + 1;
                Utility.ClearSuggestionList();
                Utility.FocusEditor();
                break;

            case Keys.Escape:
                Utility.ClearSuggestionList();
                Utility.FocusEditor();
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        private void NrichTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                this.ListBoxPosition();
                switch (e.KeyChar)
                {
                case ((char)Keys.Back):
                    temp = temp.Remove(temp.Length - 1);
                    break;

                case ((char)Keys.Space):
                    temp = null;
                    suggestionBox.Items.Clear();
                    //this.ListBoxPosition();
                    break;

                default:
                    temp += e.KeyChar.ToString();
                    SuggestionProvider.GetSuggestion(temp);
                    //this.ListBoxPosition();
                    break;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 3
0
        private async void OnSearchSuggestionRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var deferral    = args.Request.GetDeferral();
            var suggestions = await SuggestionProvider.GetSuggestionsAsync(args.QueryText);

            args.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions);
            deferral.Complete();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var cityRepository = new FileCityRepository(@"C:\Users\matzoliv\dev\backend-coding-challenge\cities_canada-usa-big.tsv");

            var suggestionProvider = new SuggestionProvider(cityRepository, new CoveoBCC.Core.Searcher.NameSearcherFactory());

            var xs = suggestionProvider.GetSuggestions("west c", 20).ToList();
        }
Esempio n. 5
0
 public static void Init(RichTextBox editor, RichTextBox errorLog, ListBox suggestionBox)
 {
     Utility.Init(editor, errorLog, suggestionBox);
     KeyEventsHandler.Init(editor, errorLog, suggestionBox);
     TokenGenerator.InitBox(editor);
     Highlighter.Init(editor);
     SuggestionProvider.InitSuggestionProvider(new List <string>(), suggestionBox, editor);
     Coloring.InitColoring(editor);
     Helper.Init();
     MenuItemEvents.Init(editor);
 }
Esempio n. 6
0
        private void NrichTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            suggestionBox.Items.Clear();
            SuggestionProvider.GetSuggestion(Utility.GetLastWord());
            KeyEventsHandler.EditorKeyHandler(e);

            if (e.KeyCode == Keys.Enter)
            {
                if (BackgroundErrorTracer.IsBusy)
                {
                    BackgroundErrorTracer.CancelAsync();
                }
                else
                {
                    BackgroundErrorTracer.RunWorkerAsync();
                }
            }
        }
Esempio n. 7
0
 public RequiredArgumentBuilder <TSource, T> Suggests(SuggestionProvider <TSource> provider)
 {
     _suggestionsProvider = provider;
     return(This);
 }
Esempio n. 8
0
 private void Form1_Load(object sender, EventArgs e)
 {
     t = new Test(NrichTextBox);
     Logical.TokenGenerator.InitBox(this.NrichTextBox);
     SuggestionProvider.InitKeywordList(suggestionBox);
 }