Shuxia Ning
2025-01-08 687a3dfd095bc8c099b7fa6e65f0dc699fdc8f1d
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
using DevExpress.Utils.Extensions;
 
namespace Yw.WinFrmUI
{
    public partial class SelectHydroGradingPropTreeCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public SelectHydroGradingPropTreeCtrl()
        {
            InitializeComponent();
            this.simpleTreeViewCtrl1.ToolBarVisible = false;
            this.simpleTreeViewCtrl1.CloseSearchControl();
            this.simpleTreeViewCtrl1.ShowTreeLines = true;
            this.simpleTreeViewCtrl1.FocusedChangedEvent += SimpleTreeViewCtrl1_FocusedChangedEvent;
        }
 
 
        /// <summary>
        /// 选择属性改变事件
        /// </summary>
        public event Action<HydroGradingPropTreeViewModel> SelectedPropChangedEvent;
 
        //所有绑定列表
        private List<HydroGradingPropTreeViewModel> _allBindingList = null;
 
        /// <summary>
        /// 初始化数据
        /// </summary>
        public void InitialData()
        {
            _allBindingList = new List<HydroGradingPropTreeViewModel>();
            var dictCatalogList = HydroParterCatalogHelper.GetSimpleDict();
            dictCatalogList.ForEach(x =>
            {
                _allBindingList.Add(new HydroGradingPropTreeViewModel(x.Key, x.Value));
                var dictPropList = HydroParterPropHelper.GetDict(x.Key);
                dictPropList.ForEach(t =>
                {
                    _allBindingList.Add(new HydroGradingPropTreeViewModel(x.Key, t.Key, t.Value));
                });
            });
 
            var allTreeList = new List<SimpleTreeViewModel>();
            _allBindingList.ForEach(x =>
            {
                var treeModel = new SimpleTreeViewModel()
                {
                    Id = x.Id,
                    ParentId = x.ParentId,
                    Name = x.Name,
                    Tag = x
                };
                allTreeList.Add(treeModel);
            });
 
 
            this.simpleTreeViewCtrl1.SetBindingData(allTreeList);
            this.simpleTreeViewCtrl1.ExpandAll();
        }
 
        //聚焦节点改变
        private void SimpleTreeViewCtrl1_FocusedChangedEvent(SimpleTreeViewModel obj)
        {
            var vm = obj?.Tag as HydroGradingPropTreeViewModel;
            this.SelectedPropChangedEvent?.Invoke(vm);
        }
 
 
 
    }
}