using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using InABox.Core; namespace InABox.DynamicGrid { public class DynamicActionColumn : DynamicColumnBase { public DynamicActionColumn(Func image, Func? action = null) { Image = image; Action = action; } public DynamicActionColumn(BitmapImage image, Func? action = null) { Image = r => image; Action = action; } public Func Image { get; protected set; } public Func? Action { get; protected set; } public Func? ToolTip { get; set; } public DynamicActionColumnPosition Position { get; set; } public string[] SelectedFilters { get; set; } public string[] Filters { get; set; } public Func FilterRecord { get; set; } public bool AllowHeaderClick { get; set; } public Func ContextMenu { get; set; } public object Tag { get; set; } public string HeaderText { get; set; } public int Width { get; set; } protected override void Init() { base.Init(); Width = 0; HeaderText = " "; AllowHeaderClick = false; Filters = null; FilterRecord = null; Position = DynamicActionColumnPosition.End; } public FrameworkElement? TextToolTip(string text) { if (string.IsNullOrWhiteSpace(text)) return null; var border = new Border { BorderBrush = new SolidColorBrush(Colors.Gray), BorderThickness = new Thickness(0.75), CornerRadius = new CornerRadius(5), Background = new SolidColorBrush(Colors.LightYellow), Padding = new Thickness(5), Child = new Label { Content = text } }; return border; } public FrameworkElement? ImageToolTip(BitmapImage image) { if (image == null) return null; var result = new Border { Background = new SolidColorBrush(Colors.LightYellow), BorderBrush = new SolidColorBrush(Colors.Gray), BorderThickness = new Thickness(0.75) }; result.Child = new Image { Source = image }; return result; } } }