using InABox.Core; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace InABox.DynamicGrid { public interface IDynamicItemsListGrid { } public class DynamicItemsListGrid : DynamicGrid, IDynamicItemsListGrid where T : BaseObject, new() { public List Items { get; set; } public DynamicItemsListGrid() : this(new()) { } public DynamicItemsListGrid(List items) : base() { Items = items; } protected override void DeleteItems(params CoreRow[] rows) { foreach (var row in rows.OrderByDescending(x => x.Index)) { Items.RemoveAt(_recordmap[row].Index); } } protected override T LoadItem(CoreRow row) { return Items[_recordmap[row].Index]; } protected override void Reload(Filters criteria, Columns columns, ref SortOrder? sort, Action action) { var result = new CoreTable(); result.LoadColumns(typeof(T)); result.LoadRows(Items); action.Invoke(result, null); } public override void SaveItem(T item) { if (!Items.Contains(item)) { Items.Add(item); } } } }