12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using InABox.Core;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.CodeAnalysis.CSharp.Syntax;
- using Syncfusion.Windows.Tools.Controls;
- namespace InABox.DynamicGrid
- {
- public interface IDynamicItemsListGrid : IDynamicGrid
- {
- IList Items { get; set; }
-
-
- }
-
- public class DynamicItemsListGrid<T> : DynamicGrid<T>, IDynamicItemsListGrid
- where T : BaseObject, new()
- {
-
- private List<T> _items = new List<T>();
- public List<T> Items
- {
- get => _items;
- set => _items = value;
- }
- IList IDynamicItemsListGrid.Items
- {
- get => _items;
- set => _items = value as List<T> ?? new List<T>();
- }
- protected override void Init()
- {
- }
- protected override void DoReconfigure(FluentList<DynamicGridOption> options)
- {
-
- }
- public override void DeleteItems(params CoreRow[] rows)
- {
- foreach (var row in rows.OrderByDescending(x => x.Index))
- {
- Items.RemoveAt(_recordmap[row].Index);
- }
- }
- public 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(columns);
- result.LoadRows(Items);
- action.Invoke(result, null);
- }
- public override void SaveItem(T item)
- {
- if (!Items.Contains(item))
- {
- Items.Add(item);
- }
- }
- }
- }
|