/// <summary> /// Populates the list of products that will actually be shown, using the current filters. /// </summary> public void PopulateProducts() { Products.RemoveAllChildren(); var search = _searchBar.Text.Trim().ToLowerInvariant(); foreach (var prototype in Owner.Market.Products) { // if no search or category // else if search // else if category and not search if ((search.Length == 0 && _category == null) || (search.Length != 0 && prototype.Name.ToLowerInvariant().Contains(search)) || (search.Length == 0 && _category != null && prototype.Category.Equals(_category))) { var button = new CargoProductRow(); button.Product = prototype; button.ProductName.Text = prototype.Name; button.PointCost.Text = prototype.PointCost.ToString(); button.Icon.Texture = prototype.Icon.Frame0(); button.MainButton.OnPressed += (args) => { OnItemSelected?.Invoke(args); }; Products.AddChild(button); } } }