From 15bbd62b0b24b72c717ae91ab45348a2083ad04e Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期五, 10 十月 2025 08:58:18 +0800
Subject: [PATCH] 优化bug;

---
 Plugin.SeqEditor/SeqEditor.xaml.cs |   64 ++++++++++++++++++++++++++++++--
 1 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/Plugin.SeqEditor/SeqEditor.xaml.cs b/Plugin.SeqEditor/SeqEditor.xaml.cs
index a6d4213..7bef44c 100644
--- a/Plugin.SeqEditor/SeqEditor.xaml.cs
+++ b/Plugin.SeqEditor/SeqEditor.xaml.cs
@@ -1,9 +1,12 @@
 using HMI.Base;
 using HMI.UI;
 using Panuon.WPF.UI;
+using Plugin.SeqEditor.Entity;
 using Plugin.SeqEditor.Util;
 using Plugin.SeqEditor.ViewModel;
+using System.Web.UI.WebControls;
 using System.Windows;
+using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Input;
 
@@ -74,14 +77,67 @@
 
     private void TreeListView_SizeChanged(object sender, SizeChangedEventArgs e)
     {
-        var treeListView = sender as TreeListView;
-        var columns = treeListView.Columns;
-        var width = treeListView.ActualWidth;
+        //var treeListView = sender as TreeListView;
+        //var columns = treeListView.Columns;
+        //var width = treeListView.ActualWidth;
 
-        columns[0].Width = columns[0].Width + (width - columns[0].Width - columns[1].Width - columns[2].Width - columns[3].Width);
+        //columns[0].Width = columns[0].Width + (width - columns[0].Width - columns[1].Width - columns[2].Width - columns[3].Width);
+
         //foreach (var col in columns) { 
         //    col.Width = 
         //}
     }
+
+    public void HandleStatus(ItemContainerGenerator cg, StepUI step, bool status)
+    {
+        DependencyObject dObject = cg.ContainerFromItem(step);
+        if (status == true)
+        {
+            if (dObject is TreeViewItem item)
+            {
+                if (step.Children != null && step.Children.Count > 0)
+                {
+                    if (item.IsExpanded != status)
+                    {
+                        item.IsExpanded = status;
+                        item.UpdateLayout();
+                    }
+                    foreach (var child in step.Children)
+                    {
+                        HandleStatus(item.ItemContainerGenerator, child, status);
+                    }
+                }
+            }
+        }
+        else
+        {
+            if (dObject is TreeViewItem item)
+            {
+                if (step.Children != null && step.Children.Count > 0)
+                {
+                    foreach (var child in step.Children)
+                    {
+                        HandleStatus(item.ItemContainerGenerator, child, status);
+                    }
+                    item.IsExpanded = status;
+                }
+            }
+        }
+    }
+
+    public bool expandAll = false;
+    private void Button_Click(object sender, RoutedEventArgs e)
+    {
+        treeList.UpdateLayout();
+        foreach (var item in treeList.Items)
+        {
+            if (item is StepUI step)
+            {
+                HandleStatus(treeList.ItemContainerGenerator, step, !expandAll);
+            }
+        }
+        expandAll = !expandAll;
+        //treeAll.Content = expandAll ? "一键收起" : "一键展开";
+    }
 }
 

--
Gitblit v1.9.1