protected override void OnTextChanged(EventArgs e) { base.OnTextChanged(e); if (changeKeyEnter) { changeKeyEnter = false; } else { if (this.Focused) { Point cp; GetCaretPos(out cp); var results = SplitText.GetSplitText(Text, new List <string> { " ", Environment.NewLine }, SelectionStart); var resultCursor = results.Where(x => x.IsCursor).FirstOrDefault(); List <string> lstTemp = new List <string>(); combobox.SetBounds(cp.X, cp.Y, 150, 50); if (resultCursor != null && resultCursor.Word != "") { lstTemp = dictionary.Where(n => n.ToUpper().Contains(resultCursor.Word.ToUpper())) .Select(r => r) .OrderBy(x => x.StartsWith(resultCursor.Word) ? 0 : 1) .ThenBy(x => x.ToUpper().StartsWith(resultCursor.Word.ToUpper()) ? 0 : 1) .ThenBy(x => x.IndexOf(resultCursor.Word)) .ThenBy(x => x.ToUpper().IndexOf(resultCursor.Word.ToUpper())) .ThenBy(x => x) .ToList(); //var TempFilteredList = dictionary.Where(n => n.ToUpper().Contains(GetLastString(Text).ToUpper())).Select(r => r); } combobox.DataSource = lstTemp; if (lstTemp.Count != 0) { combobox.DroppedDown = true; } else { combobox.DroppedDown = false; } } } }
private void SetAutoComplete(string word) { Point cp; GetCaretPos(out cp); var results = SplitText.GetSplitText(word, new List <string> { " ", Environment.NewLine }, SelectionStart); var resultCursor = results.Where(x => x.IsCursor).FirstOrDefault(); List <string> lstTemp = new List <string>(); combobox.SetBounds(cp.X, cp.Y, 150, 50); if (resultCursor != null && resultCursor.Word != "") { lstTemp = dictionary.Where(n => n.ToUpper().Contains(resultCursor.Word.ToUpper())) .Select(r => r) .OrderBy(x => x.StartsWith(resultCursor.Word) ? 0 : 1) .ThenBy(x => x.ToUpper().StartsWith(resultCursor.Word.ToUpper()) ? 0 : 1) .ThenBy(x => x.IndexOf(resultCursor.Word)) .ThenBy(x => x.ToUpper().IndexOf(resultCursor.Word.ToUpper())) .ThenBy(x => x) .ToList(); //var TempFilteredList = dictionary.Where(n => n.ToUpper().Contains(GetLastString(Text).ToUpper())).Select(r => r); } combobox.DataSource = lstTemp; if (lstTemp.Count != 0) { combobox.DroppedDown = true; } else { combobox.DroppedDown = false; } }
private void SetText() { var results = SplitText.GetSplitText(Text, new List <string> { " ", Environment.NewLine }, SelectionStart); var resultCursor = results.Where(x => x.IsCursor).FirstOrDefault(); if (resultCursor != null) { resultCursor.Word = combobox.SelectedItem.ToString(); } var newSelectIndex = 0; var newText = ""; var find = false; foreach (var rs in results) { if (!find) { if (!rs.IsCursor) { newSelectIndex = newSelectIndex + rs.Word.Length + rs.Conjuction.Length; } else { find = true; newSelectIndex = newSelectIndex + rs.Word.Length; } } newText = newText + rs.Word + rs.Conjuction; } Text = newText; Select(newSelectIndex, 0); Focus(); combobox.DroppedDown = false; }
public List <SplitResult> GetListWord() { return(SplitText.GetSplitText(Text, new List <string> { " ", Environment.NewLine }, SelectionStart)); }