private void textBox_KeyPress(object sender, KeyPressEventArgs e) { View.UpdateListBoxPosition(); string lastWord = WordProcessor.GetLastWordMatch(textBox).Value.ToLower(); if (char.IsWhiteSpace(e.KeyChar) || char.IsPunctuation(e.KeyChar) || e.KeyChar == '\n') { if (lastWord != "") { completion.Insert(lastWord); } } else { autoForm.ClearAndHide(); string nextWord = lastWord + e.KeyChar; if (nextWord != "") { promptsList = completion.GetMatches(nextWord, maxPrompts).Keys.ToList(); View.AdjustAndShowPrompts(promptsList); } } }
private void startButton_Click(object sender, EventArgs e) { IComplementarable completion = SetCompletionType(algComboBox.SelectedIndex); if (completion != null) { Dictionary <string, int> vocabularyWords = GetTxtVocabularyWords(); Dictionary <string, int> sourceWords = GetTxtSourceWords(); CompletionManager completionManager = new CompletionManager(completion, sortCB.Checked, vocabularyWords); if (sourceWords != null) { completionManager.Insert(sourceWords); } mainForm.Initialize(completionManager, (int)limitNum.Value); Close(); } else { string databasePath = GetDbPath(); if (databasePath != "") { CompletionManager completionManager = new CompletionManager(new DatabaseCompletion(databasePath, vocabularyCB.Checked), sortCB.Checked, null); mainForm.Initialize(completionManager, (int)limitNum.Value); Close(); } } }