123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using InABox.Clients;
- using InABox.Core;
- namespace InABox.DynamicGrid
- {
- public class FormControlGrid<T> : DynamicGrid<T> where T : DFLayoutControl, new()
- {
- public FormControlGrid()
- {
- Items = new List<T>();
- }
- protected override void Init()
- {
- }
- protected override void DoReconfigure(DynamicGridOptions options)
- {
- options.RecordCount = true;
- }
- public List<T> Items { get; set; }
- public override void DeleteItems(params CoreRow[] rows)
- {
- var items = new List<DFLayoutControl>();
- foreach (var row in rows)
- items.Add(Items[row.Index]);
- Items.RemoveAll(x => items.Contains(x));
- }
- public override T LoadItem(CoreRow row)
- {
- return Items[row.Index];
- }
- protected override void Reload(
- Filters<T> criteria, Columns<T> columns, ref SortOrder<T>? sort,
- CancellationToken token, Action<CoreTable?, Exception?> action)
- {
- var table = new CoreTable();
- table.LoadColumns(typeof(T));
- table.LoadRows(Items.OrderBy(x => x.Sequence));
- action?.Invoke(table, null);
- }
- public override void SaveItem(T item)
- {
- if (!Items.Contains(item))
- Items.Add(item);
- }
- }
- }
|