private void showAutoCompleteList() { StringUtils.WordInfo currentWordInfo = getCurrentWord(textBoxAutoComplete); if (!currentWordInfo.IsValid) { return; } string currentWord = currentWordInfo.Word.ToLower(); string pureCurrentWord = currentWord.StartsWith(Constants.GitLabLabelPrefix) ? currentWord.Substring(Constants.GitLabLabelPrefix.Length) : currentWord; object[] objects = _users? .Where(user => user.Name.ToLower().Contains(pureCurrentWord) || user.Username.ToLower().Contains(pureCurrentWord)) .Cast <object>() .ToArray() ?? Array.Empty <object>(); hideAutoCompleteList(); if (currentWord == String.Empty || objects.Length == 0) { return; } ListBox listBox = createListBox(); fillListBox(listBox, objects); resizeListBox(listBox, objects); createPopupWindow(listBox); showPopupWindow(); _listBoxAutoComplete = listBox; Focus(); }
private void applyAutoCompleteListSelection() { StringUtils.WordInfo currentWordInfo = getCurrentWord(textBoxAutoComplete); if (_listBoxAutoComplete.SelectedItem == null || !currentWordInfo.IsValid) { return; } string substitutionWord = Constants.GitLabLabelPrefix + ((User)(_listBoxAutoComplete.SelectedItem)).Username; textBoxAutoComplete.Text = StringUtils.ReplaceWord(textBoxAutoComplete.Text, currentWordInfo, substitutionWord); textBoxAutoComplete.SelectionStart = currentWordInfo.Start + substitutionWord.Length; }
private void showPopupWindow() { StringUtils.WordInfo currentWordInfo = getCurrentWord(textBoxAutoComplete); if (!currentWordInfo.IsValid) { return; } Point position = textBoxAutoComplete.GetPositionFromCharIndex(currentWordInfo.Start); Point pt = PointToScreen(new Point(position.X, position.Y + textBoxAutoComplete.Height)); _popupWindow.Show(pt); }