using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Windows.Media.Imaging; using InABox.Core; using InABox.WPF; namespace InABox.DynamicGrid; public class DynamicTickColumn : DynamicImageColumn where T : BaseObject, new() where P : struct { private readonly BitmapImage? Data = Wpf.Resources.tick.AsBitmapImage(); private readonly BitmapImage? Header; private readonly BitmapImage? NoData; private readonly Expression> Property; public DynamicTickColumn(Expression> property, BitmapImage? header, BitmapImage? data, BitmapImage? nodata, ActionDelegate? action = null) : base(r => null, action) { Header = header; Data = data; NoData = nodata; Property = property; Image = GetImage; GetFilter = () => new StaticColumnFilter(HasData, [ new("(Blank)", false), new("(Not Blank)", true) ]); } private BitmapImage? GetImage(CoreRow? row) { if (row == null) return Header; return HasData(row) ? Data : NoData; } private bool HasData(CoreRow row) { var value = row.Get(Property); return !value.Equals(default(P)); } }