Browse Source

Improved array value node popup on filter editor

Kenric Nugteren 6 months ago
parent
commit
19cfee041b

+ 6 - 0
inabox.wpf/DynamicGrid/Editors/FilterEditor/Nodes/ValueNodes/ArrayValueNode.cs

@@ -4,6 +4,8 @@ using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
+using InABox.Core;
+using netDxf.Tables;
 using Syncfusion.Windows.Shared;
 
 namespace InABox.DynamicGrid;
@@ -25,6 +27,10 @@ public class ArrayValueNode<TValueNode> : ValueNode where TValueNode : ValueNode
             {
                 list = objList.Cast<object?>().ToList();
             }
+            else if (value is ISubQuery)
+            {
+                list = new();
+            }
             else
             {
                 list = new List<object?> { value };

+ 1 - 1
inabox.wpf/DynamicGrid/Editors/FilterEditor/Nodes/ValueNodes/ArrayValueNodePopup.xaml

@@ -6,7 +6,7 @@
         xmlns:local="clr-namespace:InABox.DynamicGrid"
         xmlns:wpf="clr-namespace:InABox.Wpf"
         mc:Ignorable="d"
-        Title="Edit List" Height="450" Width="800">
+        Title="Edit List" Height="450" Width="800" WindowStartupLocation="CenterScreen">
     <Grid>
         <Grid.RowDefinitions>
             <RowDefinition Height="*"/>

+ 9 - 3
inabox.wpf/DynamicGrid/Editors/FilterEditor/Nodes/ValueNodes/ArrayValueNodePopup.xaml.cs

@@ -92,9 +92,8 @@ namespace InABox.DynamicGrid
             AddValue(null);
         }
 
-        public void AddValue(object? value)
+        public void AddValue(object? value, int? index = null)
         {
-
             var node = new TValueNode()
             {
                 Margin = new Thickness(0, 0, 5, 5)
@@ -124,7 +123,14 @@ namespace InABox.DynamicGrid
             {
                 RemoveNode(node);
             };
-            Nodes.Add(new(removeButton, node));
+            if(index is null || index.Value >= Nodes.Count)
+            {
+                Nodes.Add(new(removeButton, node));
+            }
+            else
+            {
+                Nodes.Insert(index.Value, new(removeButton, node));
+            }
 
             if (!bChanging)
             {