12345678910111213141516171819202122232425262728293031323334 |
- using System;
- using System.Linq.Expressions;
- using System.Windows.Media.Imaging;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.WPF;
- namespace PRSDesktop
- {
- public class DynamicCheckColumn<T> : DynamicImageColumn
- {
- private readonly BitmapImage Disabled = Resources.tick.AsGrayScale().AsBitmapImage();
- private readonly BitmapImage Enabled = Resources.tick.AsBitmapImage();
- private readonly BitmapImage Header;
- private readonly Expression<Func<T, bool>> Property;
- public DynamicCheckColumn(BitmapImage header, Expression<Func<T, bool>> property) : base(r => null)
- {
- Header = header;
- Property = property;
- Image = GetImage;
- Action = null;
- }
- private BitmapImage GetImage(CoreRow? row)
- {
- if (row == null)
- return Header;
- var Checked = row.Get(Property).Equals(true);
- return Checked ? Enabled : Disabled;
- }
- }
- }
|