using System; using System.Collections.Generic; using System.Linq; using System.Windows.Media.Imaging; using Comal.Classes; using InABox.Core; using InABox.DynamicGrid; using InABox.WPF; namespace PRSDesktop { public class DailyReportFavouriteGrid : DynamicGrid { public DailyReportFavouriteGrid() { Options.Clear(); MasterColumns.Clear(); MasterColumns.Add(new DynamicGridColumn { ColumnName = "Title", Width = 0 }); MasterColumns.Add(new DynamicGridColumn { ColumnName = "JobNumber", Width = 100, Alignment = Alignment.MiddleCenter }); MasterColumns.Add(new DynamicGridColumn { ColumnName = "ITPCode", Width = 100, Caption = "ITP", Alignment = Alignment.MiddleCenter }); MasterColumns.Add(new DynamicGridColumn { ColumnName = "ActivityName", Width = 0, Caption = "Activity" }); ActionColumns.Add(new DynamicActionColumn(PRSDesktop.Resources.delete.AsBitmapImage(), DeleteClick) { Position = DynamicActionColumnPosition.Start }); } public List Items { get; set; } private bool DeleteClick(CoreRow? arg) { if (arg == null) return false; DeleteItems(arg); return true; } protected override void DeleteItems(params CoreRow[] rows) { foreach (var row in rows.OrderByDescending(x => x.Index)) { var item = Items[row.Index]; Items.Remove(item); } } protected override AssignmentFavourite LoadItem(CoreRow row) { return row.ToObject(); } protected override void Reload(Filters criteria, Columns columns, ref SortOrder? sort, Action action) { var result = new CoreTable(); result.LoadColumns(typeof(AssignmentFavourite)); result.LoadRows(Items); action.Invoke(result, null); } protected override void SaveItem(AssignmentFavourite item) { } } }