private void Populate(string?search = null) { _lastSearch = search; ComponentItemList.ClearSelected(); ComponentItemList.Clear(); AddButton.Disabled = true; foreach (var component in _components) { if (!string.IsNullOrEmpty(search) && !component.Contains(search, StringComparison.InvariantCultureIgnoreCase)) { continue; } ComponentItemList.AddItem(component); } }
private void OnAddButtonPressed(BaseButton.ButtonEventArgs obj) { var selected = ComponentItemList.GetSelected().ToArray(); // Nothing to do here! if (selected.Length == 0) { return; } var comp = selected[0]; // This shouldn't really happen. if (comp.Text == null) { return; } AddComponentButtonPressed?.Invoke(new AddComponentButtonPressedEventArgs(comp.Text)); }
private void RefreshAddButton() { AddButton.Disabled = !ComponentItemList.GetSelected().Any(); }