private void SelectTaskSuggestion(ListMoveDirection direction) { Device.BeginInvokeOnMainThread(() => { // lock for collection manupulation lock (_autoCompleteTasksLock) { bool isAnySelected = Suggestions.Any(t => t.IsSelected); if (!isAnySelected) { // select the last item in the list Suggestions[Suggestions.Count - 1].IsSelected = true; } else if (Suggestions.Count > 1) { var selectedItem = Suggestions.First(t => t.IsSelected); int index = Suggestions.IndexOf(selectedItem); index = direction == ListMoveDirection.Next ? index + 1 : index - 1; if (index < 0) { index = Suggestions.Count - 1; } if (index > Suggestions.Count - 1) { index = 0; } selectedItem.IsSelected = false; selectedItem = Suggestions[index]; selectedItem.IsSelected = true; } } }); }
private void button1_Click(object sender, EventArgs e) { if (Suggestions?.Any() ?? false) { cmSuggestions.Show(button1, new Point(0, button1.Height)); } else { InvokeBuilder(sender); } }
private void UpdatePopup() { if (Popup != null) { if (Suggestions != null && Suggestions.Any()) { Popup.IsOpen = true; } else { Popup.IsOpen = false; } } }
void SetSuggestions() { if (!IsDropDownOpen) { return; } Suggestions.Clear(); var find = SelectedText == Text ? "" : SelectedText.CoalesceNullOrEmpty(Text) ?? ""; var ucFind = Regex.Replace(find, "[^A-Z]", ""); foreach (var suggestion in SuggestionList.Where(x => HasStr(x.Text, find))) { Suggestions.Add(suggestion); } if (!Suggestions.Any()) { Suggestions.Add(null); } SuggestedIndex = find == "" ? 0 : Suggestions.Indexes(str => str?.Text.StartsWith(Text, StringComparison.InvariantCultureIgnoreCase) ?? false).FirstOrDefault(); }