using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Windows.Media.Imaging; using Comal.Classes; using InABox.Core; using InABox.DynamicGrid; using InABox.WPF; namespace PRSDesktop; public class DailyReportFavouriteGrid : DynamicGrid { protected override void Init() { ActionColumns.Add(new DynamicImageColumn(PRSDesktop.Resources.delete.AsBitmapImage(), DeleteClick) { Position = DynamicActionColumnPosition.Start }); } protected override void DoReconfigure(DynamicGridOptions options) { options.Clear(); } public List Items { get; set; } private bool DeleteClick(CoreRow? arg) { if (arg == null) return false; DeleteItems(arg); return true; } public override void DeleteItems(params CoreRow[] rows) { foreach (var row in rows.OrderByDescending(x => x.Index)) { var item = Items[row.Index]; Items.Remove(item); } } public override AssignmentFavourite LoadItem(CoreRow row) { return row.ToObject(); } protected override void Reload( Filters criteria, Columns columns, ref SortOrder? sort, CancellationToken token, Action action) { var result = new CoreTable(); result.LoadColumns(typeof(AssignmentFavourite)); result.LoadRows(Items); action.Invoke(result, null); } public override void SaveItem(AssignmentFavourite item) { } }