| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using InABox.Core;
- using Syncfusion.UI.Xaml.Grid;
- using Image = System.Windows.Controls.Image;
- using Label = System.Windows.Controls.Label;
- namespace InABox.DynamicGrid
- {
- public abstract class DynamicActionColumn : DynamicColumnBase
- {
- public DynamicActionColumnPosition Position { get; set; } = DynamicActionColumnPosition.End;
- public delegate bool ActionDelegate(CoreRow? row);
- public delegate FrameworkElement? ActionColumnToolTip(DynamicActionColumn column, CoreRow? row);
- public ActionDelegate? Action { get; set; }
- public ActionColumnToolTip? ToolTip { get; set; }
- public Func<IDynamicGridSummary?>? GetSummary = null;
- public Func<IDynamicGridColumnFilter?>? GetFilter = null;
-
- public Func<CoreRow[]?, ContextMenu?>? ContextMenu { get; set; }
-
- public string HeaderText { get; set; } = " ";
- public bool VerticalHeader { get; set; }
- public int Width { get; set; } = 0;
- 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, double? maxWidth = null, double? maxHeight = null)
- {
- if (image == null)
- return null;
- var result = new Border
- {
- Background = new SolidColorBrush(Colors.LightYellow),
- BorderBrush = new SolidColorBrush(Colors.Gray),
- BorderThickness = new Thickness(0.75)
- };
- var imageControl = new Image
- {
- Source = image,
- Stretch = Stretch.Uniform
- };
- if (maxWidth.HasValue)
- {
- imageControl.MaxWidth = maxWidth.Value;
- }
- if (maxHeight.HasValue)
- {
- imageControl.MaxHeight = maxHeight.Value;
- }
- result.Child = imageControl;
- return result;
- }
- public abstract object? Data(CoreRow? row);
- public IDynamicGridSummary? Summary() => GetSummary?.Invoke();
- }
- }
|