alielie
2026-04-16 1afe548ac40cc7f975917ef9bf2e156595cf81f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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;
 
namespace Plugin.SeqEditor;
 
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class SeqEditor : PluginControl
{
    public SeqEditor()
    {
        InitializeComponent();
        CbFilter.ItemsSource = (IEnumerable<MultiComboBoxData>)
            new MultiComboBoxDataConverter().Convert(FilterTypeData.ItemSource,
            null, null, null
            );
    }
 
    public override void InitFinish()
    {
        this.DataContext = new SeqEditorViewModel(this, log);
    }
 
    public void BackgroundAction(Action action, string message)
    {
        new MaskWindow((WindowX)Window.GetWindow(this),
                  (win) =>
                  {
                      action?.Invoke();
                  }
                  ).Info(message);
    }
 
    /// <summary>
    /// Ê÷Êý¾Ýչʾ¹ýÂË
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void CollectionViewSource_Filter(object sender, FilterEventArgs e)
    {
        if (e.Item is TreeItemData data)
        {
            e.Accepted = data.IsVisible;
        }
    }
 
    // <summary>
    /// Ê÷Õ¹¿ª/¹Ø±Õʼþ
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void treeDataGrid_ExpandedChange(object sender, bool e)
    {
        //CollectionViewSource cvs = this.Resources["TreeGridFilter"] as CollectionViewSource;
        //cvs?.View.Refresh();
    }
 
    private void treeDataGrid_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
    {
        e.Handled = false;
    }
 
    private void Expander_PreviewMouseDown(object sender, MouseButtonEventArgs e)
    {
        e.Handled = false;
    }
 
    private void TreeListView_SizeChanged(object sender, SizeChangedEventArgs e)
    {
        //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);
 
        //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 ? "Ò»¼üÊÕÆð" : "Ò»¼üÕ¹¿ª";
    }
}