duheng
2024-03-26 11c7908bcc2ca699e88b7a0a17bc32e45521c349
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
using DevExpress.XtraEditors;
using System;
using System.ComponentModel;
using System.Linq;
 
namespace IStation.WinFrmUI.Basic
{
    /// <summary>
    /// 
    /// </summary>
    public partial class PumpMgrListCtrl : XtraUserControl
    {
        public PumpMgrListCtrl()
        {
            InitializeComponent();
            this.treeList1.InitialMultiColSettings();
            this.treeList1.SelectImageList = ImageLib.Lib;
            this.layoutControl1.SetupLayoutControl();
        }
 
        public class CurrentViewModel : Model.Product<Model.Pump>
        {
            public CurrentViewModel() { }
            public CurrentViewModel(Model.Product<Model.Pump> rhs) : base(rhs)
            {
                if (rhs.RatedParas != null)
                {
                    this.Qr = rhs.RatedParas.Qr;
                    this.Hr = rhs.RatedParas.Hr;
                    this.Nr = rhs.RatedParas.Nr;
                    this.Pr = rhs.RatedParas.Pr;
                    this.Er = rhs.RatedParas.Er;
                    this.NPSHr = rhs.RatedParas.NPSHr;
                    this.StNumr = rhs.RatedParas.StNumr;
                    this.Ic = rhs.RatedParas.Ic;
                    this.Oc = rhs.RatedParas.Oc;
                    this.IOd = rhs.RatedParas.IOd;
                    this.IsBp = rhs.RatedParas.IsBp ? "是" : "否";
                    this.IsSxp = rhs.RatedParas.IsSxp ? "是" : "否";
                }
            }
            public double Qr { get; set; }
            public double Hr { get; set; }
            public double Nr { get; set; }
            public double Pr { get; set; }
            public double Er { get; set; }
            public double NPSHr { get; set; }
            public int StNumr { get; set; }
            public double? Ic { get; set; }
            public double? Oc { get; set; }
            public double? IOd { get; set; }
            public string IsBp { get; set; }
            public string IsSxp { get; set; }
            public int ImageIndex { get; set; } = ImageLib.Pump;
        }
 
        /// <summary>
        /// 聚焦改变事件
        /// </summary> 
        public event Action<Model.Product<Model.Pump>> FocusedChangedEvent;
 
        private BindingList<CurrentViewModel> _allBindingList = null;//所有绑定列表
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void Clear()
        {
            _allBindingList = new BindingList<CurrentViewModel>();
            this.currentViewModelBindingSource.DataSource = _allBindingList;
            this.FocusedChangedEvent?.Invoke(null);
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData()
        {
            WaitFrmHelper.ShowWaitForm("正在加载数据...");
            _allBindingList = new BindingList<CurrentViewModel>();
 
            var pumps = new BLL.Product().GetAllPump();
            if (pumps != null && pumps.Any())
            {
                foreach (var pump in pumps)
                {
                    var vm = new CurrentViewModel(pump);
                    _allBindingList.Add(vm);
                }
            }
 
            this.currentViewModelBindingSource.DataSource = _allBindingList;
            this.treeList1.BestFitColumns();
            this.treeList1.FocusedNode = this.treeList1.Nodes.FirstOrDefault();
            WaitFrmHelper.HideWaitForm();
        }
 
 
        //聚焦改变
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            var vm = this.treeList1.GetCurrentViewModel(_allBindingList);
            if (vm == null)
                return;
 
            this.FocusedChangedEvent?.Invoke(vm);
        }
 
 
    }
 
}