12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 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<T> : DynamicGrid<T>, IDynamicItemsListGrid
- where T : BaseObject, new()
- {
- public List<T> Items { get; set; }
- public DynamicItemsListGrid() : this(new()) { }
- public DynamicItemsListGrid(List<T> 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<T> criteria, Columns<T> columns, ref SortOrder<T>? sort, Action<CoreTable?, Exception?> 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);
- }
- }
- }
- }
|