Bläddra i källkod

Merge branch 'frank' of http://192.168.100.242:3000/PRSDigital/inabox into frank

Frank van den Bos 1 år sedan
förälder
incheckning
f3a51ba0ad

+ 17 - 5
InABox.Core/Column.cs

@@ -119,23 +119,35 @@ namespace InABox.Core
         IColumns Add(IColumn column);
         IColumns Add<T>(Expression<Func<T, object?>> column);
         IColumns DefaultColumns(params ColumnType[] types);
-        
-        void SerializeBinary(CoreBinaryWriter writer);
-        void DeserializeBinary(CoreBinaryReader reader);
     }
 
     public enum ColumnType
     {
         ExcludeVisible,
+        /// <summary>
+        /// Do not include <see cref="Entity.ID"/> in the columns.
+        /// </summary>
         ExcludeID,
         IncludeOptional,
         IncludeForeignKeys,
+        /// <summary>
+        /// Include all columns that are accessible through entity links present in the root class.
+        /// </summary>
         IncludeLinked,
         IncludeAggregates,
         IncludeFormulae,
+        /// <summary>
+        /// Include any columns that are a <see cref="CustomProperty"/>.
+        /// </summary>
         IncludeUserProperties,
+        /// <summary>
+        /// Include all columns that are accessible through entity links, even nested ones.
+        /// </summary>
         IncludeNestedLinks,
         IncludeEditable,
+        /// <summary>
+        /// Add all columns found.
+        /// </summary>
         All
     }
 
@@ -371,7 +383,7 @@ namespace InABox.Core
             if (typeof(T).IsSubclassOf(typeof(Entity)) && !types.Contains(ColumnType.ExcludeID))
                 columns.Add(new Column<T>("ID"));
             
-            for  (int iCol=0; iCol<props.Count; iCol++)
+            for  (int iCol = 0; iCol < props.Count; iCol++)
             {
                 var prop = props[iCol];
                 var bOK = true;
@@ -464,7 +476,7 @@ namespace InABox.Core
 
                 if (bOK && !columns.Any(x => string.Equals(x.Property?.ToUpper(), prop.Name?.ToUpper())))
                 {
-                    if (bOK && prop.Editor is LookupEditor le)
+                    if (prop.Editor is LookupEditor le)
                     {
                         if (le.OtherColumns != null)
                         {

+ 1 - 1
inabox.scripting/FileReader/DelimitedFileReader.cs

@@ -53,7 +53,7 @@ namespace InABox.Scripting
                 x => x.Key,
                 x =>
                 {
-                    object? result = values[x.Value];
+                    object? result = x.Value < values.Length ? values[x.Value] : null;
                     return result;
                 });
         }

+ 0 - 3
inabox.wpf/DigitalForms/Designer/Controls/Fields/DFSignatureControl.cs

@@ -13,9 +13,6 @@ namespace InABox.DynamicGrid
 {
     public class DFSignatureControl : DynamicFormFieldControl<DFLayoutSignaturePad, DFLayoutSignaturePadProperties, byte[], byte[]?>
     {
-        
-        private DFLayoutEmbeddedMediaValue _value = null!;
-        
         private Grid Grid = null!; // Late-initialised
         private Image Image = null!; // Late-initialised
         private bool _isEmpty = true;

+ 2 - 2
inabox.wpf/DigitalForms/Designer/Controls/Fields/DFVideoControl.cs

@@ -28,9 +28,9 @@ namespace InABox.DynamicGrid
         private Image? _thumbnail;
         private Grid? _contentGrid;
         private Grid? _grid;
-        Point center;
+        /*Point center;
         int rotation = 90;
-        bool firstPlay = true;
+        bool firstPlay = true;*/
         private string _tempfilename = null!;
 
         byte[]? Data;

+ 1 - 1
inabox.wpf/DynamicGrid/BaseDynamicGrid.cs

@@ -174,7 +174,7 @@ namespace InABox.DynamicGrid
         public abstract void Refresh(bool reloadcolumns, bool reloaddata);
 
         public abstract void UpdateRow<TType>(CoreRow row, string column, TType value, bool refresh = true);
-        public abstract void UpdateRow<T, TType>(CoreRow row, Expression<Func<T, TType>> column, TType value, bool refresh = true);
+        public abstract void UpdateRow<TRow, TType>(CoreRow row, Expression<Func<TRow, TType>> column, TType value, bool refresh = true);
         
         protected abstract DynamicGridRowStyleSelector<T> GetRowStyleSelector();
 

+ 19 - 8
inabox.wpf/DynamicGrid/DynamicGridUtils.cs

@@ -12,6 +12,7 @@ using InABox.Core;
 using InABox.Wpf;
 using InABox.Core.Reports;
 using Syncfusion.Data.Extensions;
+using System.Diagnostics.CodeAnalysis;
 
 namespace InABox.DynamicGrid
 {
@@ -442,9 +443,9 @@ namespace InABox.DynamicGrid
 
         private static Dictionary<Type, Type[]> _dynamicGrids = new();
 
-        public static Type FindDynamicGrid(Type gridType, Type entityType)
+        public static bool TryFindDynamicGrid(Type gridType, Type entityType, [NotNullWhen(true)] out Type? grid)
         {
-            if(!_dynamicGrids.TryGetValue(gridType, out var grids))
+            if (!_dynamicGrids.TryGetValue(gridType, out var grids))
             {
                 grids = CoreUtils.TypeList(
                     AppDomain.CurrentDomain.GetAssemblies(),
@@ -457,7 +458,7 @@ namespace InABox.DynamicGrid
                 ).ToArray();
                 _dynamicGrids[gridType] = grids;
             }
-            grids = grids.Where(x=>x.IsSubclassOfRawGeneric(gridType)).ToArray();
+            grids = grids.Where(x => x.IsSubclassOfRawGeneric(gridType)).ToArray();
             var entityGrids = grids.Where(x =>
             {
                 var baseGrid = x.GetSuperclassDefinition(typeof(BaseDynamicGrid<>));
@@ -465,17 +466,27 @@ namespace InABox.DynamicGrid
             }).ToList();
 
             var defaults = entityGrids.Where(x => x.IsAssignableTo(typeof(IDefaultGrid))).ToList();
-            if(defaults.Count > 0)
+            if (defaults.Count > 0)
             {
-                if(defaults.Count > 1)
+                if (defaults.Count > 1)
                 {
                     Logger.Send(LogType.Information, ClientFactory.UserID, $"Error: {defaults.Count} IDefaultGrid derivations for {gridType.Name} of {entityType.Name}");
                 }
-                return defaults.First();
+                grid = defaults.First();
+                return true;
             }
 
-            return entityGrids.FirstOrDefault()
-                ?? gridType.MakeGenericType(entityType);
+            grid = entityGrids.FirstOrDefault();
+            return grid is not null;
+        }
+
+        public static Type FindDynamicGrid(Type gridType, Type entityType)
+        {
+            if(TryFindDynamicGrid(gridType, entityType, out var grid))
+            {
+                return grid;
+            }
+            return gridType.MakeGenericType(entityType);
         }
 
         public static Window CreateGridWindow(string title, BaseDynamicGrid dynamicGrid)