Browse Source

Added delegates for action columns to improve naming of auto generated methods

Kenric Nugteren 1 year ago
parent
commit
8ec83d525e

+ 15 - 9
inabox.wpf/DynamicGrid/Columns/DynamicActionColumn.cs

@@ -9,14 +9,16 @@ using Label = System.Windows.Controls.Label;
 
 namespace InABox.DynamicGrid
 {
-
     public abstract class DynamicActionColumn : DynamicColumnBase
     {
         public DynamicActionColumnPosition Position { get; set; }
-        
-        public Func<CoreRow?, bool>? Action { get; set; }
 
-        public Func<DynamicActionColumn, CoreRow?, FrameworkElement?>? ToolTip { get; set; }
+        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 string[] SelectedFilters { get; set; }
         public string[] Filters { get; set; }
@@ -79,11 +81,13 @@ namespace InABox.DynamicGrid
 
     public class DynamicTextColumn : DynamicActionColumn
     {
-        public Func<CoreRow?, String> Text { get; private set; }
+        public delegate string GetTextDelegate(CoreRow? row);
+
+        public GetTextDelegate Text { get; private set; }
         
         public Alignment Alignment { get; set; }
         
-        public DynamicTextColumn(Func<CoreRow?, String?> text, Func<CoreRow?, bool>? action = null)
+        public DynamicTextColumn(GetTextDelegate text, ActionDelegate? action = null)
         {
             Alignment = Alignment.MiddleCenter;
             Text = text;
@@ -96,20 +100,22 @@ namespace InABox.DynamicGrid
     
     public class DynamicImageColumn : DynamicActionColumn
     {
-        public DynamicImageColumn(Func<CoreRow?, BitmapImage?> image, Func<CoreRow?, bool>? action = null)
+        public delegate BitmapImage? GetImageDelegate(CoreRow? row);
+
+        public DynamicImageColumn(GetImageDelegate image, ActionDelegate? action = null)
         {
             Image = image;
             Action = action;
             VerticalHeader = true;
         }
 
-        public DynamicImageColumn(BitmapImage image, Func<CoreRow?, bool>? action = null)
+        public DynamicImageColumn(BitmapImage image, ActionDelegate? action = null)
         {
             Image = r => image;
             Action = action;
         }
 
-        public Func<CoreRow?, BitmapImage?> Image { get; protected set; }
+        public GetImageDelegate Image { get; protected set; }
 
         
         public bool AllowHeaderClick { get; set; }

+ 3 - 3
inabox.wpf/DynamicGrid/Columns/DynamicTickColumn.cs

@@ -9,14 +9,14 @@ namespace InABox.DynamicGrid
 {
     public class DynamicTickColumn<T, P> : DynamicImageColumn where T : BaseObject, new() where P : struct
     {
-        private readonly BitmapImage? Data =Wpf.Resources.tick.AsBitmapImage();
+        private readonly BitmapImage? Data = Wpf.Resources.tick.AsBitmapImage();
 
         private readonly BitmapImage? Header;
         private readonly BitmapImage? NoData;
         private readonly Expression<Func<T, P>> Property;
 
         public DynamicTickColumn(Expression<Func<T, P>> property, BitmapImage? header, BitmapImage? data, BitmapImage? nodata,
-            Func<CoreRow, bool>? action = null) : base(r => null, action)
+            ActionDelegate? action = null) : base(r => null, action)
         {
             Header = header;
             Data = data;
@@ -37,7 +37,7 @@ namespace InABox.DynamicGrid
             return false;
         }
 
-        private BitmapImage? GetImage(CoreRow row)
+        private BitmapImage? GetImage(CoreRow? row)
         {
             if (row == null)
                 return Header;