Explorar el Código

Added "Parent" to Logikal Group Import
Tweaked Product Group Tree Expand / Collapse behaviour
Added DecimalPlaces to DoubleEdit

frankvandenbos hace 2 meses
padre
commit
a35f6341e3

+ 18 - 0
InABox.Core/CoreTreeNodes.cs

@@ -143,6 +143,14 @@ namespace InABox.Core
             }
         }
         
+        public int Depth()
+        {
+            var result = 0;
+            foreach (var child in Children)
+                result = Math.Max(result, child.Depth());
+            return 1 + result;
+        }
+        
     }
 
     public class CoreTreeNodes<TKey>
@@ -231,6 +239,16 @@ namespace InABox.Core
         {
             ColumnChanged?.Invoke(node, column);
         }
+
+        public int Depth()
+        {
+            var result = 0;
+            var roots = Nodes.Where(x => Equals(DefaultKey, x.Parent));
+            foreach (var root in roots)
+                result = Math.Max(result, root.Depth());
+            return result;
+        }
+        
     }
 
 }

+ 1 - 0
InABox.Integration/Base/Product/IIntegrationGroup.cs

@@ -2,5 +2,6 @@ namespace InABox.Integration
 {
     public interface IIntegrationGroup : IIntegrationItem
     {
+        string Parent { get; set; }
     }
 }

+ 49 - 3
inabox.wpf/DynamicGrid/UIComponent/DynamicGridTreeUIComponent.cs

@@ -294,6 +294,14 @@ public class DynamicGridTreeUIComponent<T, TKey> : IDynamicGridUIComponent<T>, I
         });
 
         _tree.SizeChanged += _tree_SizeChanged;
+        _tree.NodeCollapsed += (sender, args) =>
+        {
+            ResizeColumns(_tree, _tree.Width - 2, _tree.Height - 2);
+        };
+        _tree.NodeExpanded += (sender, args) =>
+        {
+            ResizeColumns(_tree, _tree.Width - 2, _tree.Height - 2);
+        };
     }
 
     private System.Windows.Controls.ScrollChangedEventHandler? _summaryScrollChangedHandler;
@@ -1441,6 +1449,40 @@ public class DynamicGridTreeUIComponent<T, TKey> : IDynamicGridUIComponent<T>, I
         ResizeColumns(_tree, _tree.ActualWidth - 2, _tree.ActualHeight - 2);
     }
 
+    // public void GetExpandedTreeDepth(TreeNode node, ref int depth)
+    // {
+    //     if (node == null || node.ChildNodes == null || node.ChildNodes.Count == 0)
+    //         return;
+    //     
+    //     depth++;
+    //     if (!node.IsExpanded)
+    //         return;
+    //     
+    //     int maxChildDepth = 0;
+    //     foreach (var child in node.ChildNodes)
+    //     {
+    //         int childdepth = 0;
+    //         GetExpandedTreeDepth(child, ref childdepth);
+    //         maxChildDepth = Math.Max(maxChildDepth, childdepth);
+    //     }
+    //     
+    //     depth += maxChildDepth;
+    //
+    // }
+    //
+    // private double ExpanderWidth(double columnwidth)
+    // {
+    //     var depth = 0;
+    //     var children = _tree.View.Nodes.Where(x => x.ParentNode == null && x.HasChildNodes);
+    //     foreach (var child in children)
+    //     {
+    //         var childdepth = 0;
+    //         GetExpandedTreeDepth(child, ref childdepth);
+    //         depth = Math.Max(depth, childdepth);
+    //     }
+    //     return depth * columnwidth;
+    // }
+
     private void ResizeColumns(SfTreeGrid grid, double width, double height)
     {
         if (Parent.Data == null || width <= 0)
@@ -1448,12 +1490,16 @@ public class DynamicGridTreeUIComponent<T, TKey> : IDynamicGridUIComponent<T>, I
 
         grid.Dispatcher.BeginInvoke(() =>
         {
-            foreach (var (index, size) in this.CalculateColumnSizes(width))
+            var expander = 0; //ExpanderWidth(18.0);
+            var sizes = this.CalculateColumnSizes(width, false);
+            foreach (var (index, size) in sizes)
             {
                 var colSize = Math.Max(0.0F, size);
-                _tree.Columns[index].Width = colSize;
+                _tree.Columns[index].Width = colSize.IsEffectivelyEqual(0.0) ? double.NaN : colSize;
+                _tree.Columns[index].ColumnSizer = colSize.IsEffectivelyEqual(0.0) ? TreeColumnSizer.Star : TreeColumnSizer.None;
             }
-
+            _tree.TreeGridColumnSizer.Refresh();
+            
             RebuildSummaryRow();
         });
     }

+ 5 - 5
inabox.wpf/DynamicGrid/UIComponent/IDynamicGridGridUIComponent.cs

@@ -24,7 +24,7 @@ public interface IDynamicGridGridUIComponent
 
 internal static class DynamicGridGridUIComponentExtension
 {
-    public static Dictionary<int, double> CalculateColumnSizes(this IDynamicGridGridUIComponent component, double width)
+    public static Dictionary<int, double> CalculateColumnSizes(this IDynamicGridGridUIComponent component, double width, bool manualautosize = true)
     {
         var fAvailWidth = width - (SystemParameters.VerticalScrollBarWidth);
         
@@ -49,7 +49,7 @@ internal static class DynamicGridGridUIComponentExtension
             {
                 colWidths[i] = dxc.Width;
                 if (dxc.Width != 0)
-                    fCurWidth += Math.Max(0.0F, dxc.Width);
+                    fCurWidth += Math.Max(0.0F, colWidths[i]);
                 else
                     NumAutoCols++;
             }
@@ -57,7 +57,7 @@ internal static class DynamicGridGridUIComponentExtension
             {
                 colWidths[i] = dtc.Width;
                 if (dtc.Width != 0)
-                    fCurWidth += Math.Max(0.0F, dtc.Width);
+                    fCurWidth += Math.Max(0.0F, colWidths[i]);
                 else
                     NumAutoCols++;
             }
@@ -65,13 +65,13 @@ internal static class DynamicGridGridUIComponentExtension
             {
                 colWidths[i] = dgc.Width;
                 if (dgc.Width != 0)
-                    fCurWidth += Math.Max(0.0F, dgc.Width);
+                    fCurWidth += Math.Max(0.0F, colWidths[i]);
                 else
                     NumAutoCols++;
             }
         }
 
-        if (NumAutoCols > 0)
+        if (manualautosize && NumAutoCols > 0)
         {
             var fAutoWidth = (fAvailWidth - fCurWidth) / NumAutoCols;
             if (fAutoWidth < 100)

+ 10 - 3
inabox.wpf/Editors/DoubleEdit.xaml.cs

@@ -8,15 +8,22 @@ namespace InABox.WPF
     /// </summary>
     public partial class DoubleEdit : ThemableWindow
     {
-        public DoubleEdit(string title, double min, double max, double value)
+        public DoubleEdit(string title, double min, double max, int decimals, double value)
         {
             InitializeComponent();
             Title = title;
             Value = value;
+            Editor.NumberDecimalDigits = decimals;
             Editor.MinValue = min;
             Editor.MaxValue = max;
         }
 
+        public int DecimalPlaces
+        {
+            get => Editor.NumberDecimalDigits;
+            set => Editor.NumberDecimalDigits = value;
+        }
+        
         public double Value
         {
             get => Editor.Value.HasValue ? Editor.Value.Value : 0;
@@ -47,9 +54,9 @@ namespace InABox.WPF
             Close();
         }
 
-        public static bool Execute(string title, double min, double max, ref double value)
+        public static bool Execute(string title, double min, double max, int decimals, ref double value)
         {
-            var edit = new DoubleEdit(title, min, max, value);
+            var edit = new DoubleEdit(title, min, max, decimals, value);
             if (edit.ShowDialog() == true)
             {
                 value = edit.Value;