lixiaojun
2024-10-18 82dfff29bca77a1e11459fb7a69f729a09f4345c
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
using DevExpress.Utils.Layout;
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Forms;
using Yw.WinFrmUI;
 
namespace Yw.WinFrmUI
{
    public partial class SetWaterboxCalcuPrefixListCtrl : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPage<SetHydroCalcuPrefixViewModel>
    {
        public SetWaterboxCalcuPrefixListCtrl()
        {
            InitializeComponent();
        }
 
        /// <summary>
        /// 查看水箱事件
        /// </summary>
        public event Action<Yw.Model.HydroWaterboxInfo> ViewWaterboxEvent;
 
        /// <summary>
        /// 页面状态发生改变
        /// </summary>
        public event Action PageStateChangedEvent;
 
        private SetHydroCalcuPrefixViewModel _vm = null;
        private List<SetWaterboxCalcuPrefixCtrl> _allCalcuPrefixCtrlList = null;
 
        /// <summary>
        /// 初始化页面
        /// </summary>
        public void InitialPage(SetHydroCalcuPrefixViewModel vm)
        {
            _vm = vm;
            InitialControls();
        }
 
        //初始化控件
        private void InitialControls()
        {
            if (_vm == null)
            {
                return;
            }
            if (_allCalcuPrefixCtrlList == null)
            {
                _allCalcuPrefixCtrlList = new List<SetWaterboxCalcuPrefixCtrl>();
                this.tabPanelCore.Columns.Add(new TablePanelColumn(TablePanelEntityStyle.Relative, 55F));
                if (_vm.HydroInfo.Waterboxs != null && _vm.HydroInfo.Waterboxs.Count > 0)
                {
                    for (int i = 0; i < _vm.HydroInfo.Waterboxs.Count; i++)
                    {
                        this.tabPanelCore.Rows.Add(new TablePanelRow(TablePanelEntityStyle.AutoSize, 150F));
                        var ctrl = new SetWaterboxCalcuPrefixCtrl();
                        ctrl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                        ctrl.ViewEvent += (waterbox) =>
                        {
                            if (waterbox == null)
                            {
                                return;
                            }
                            this.ViewWaterboxEvent?.Invoke(waterbox);
                        };
                        _allCalcuPrefixCtrlList.Add(ctrl);
                        this.tabPanelCore.Controls.Add(ctrl);
                        this.tabPanelCore.SetCell(ctrl, i, 0);
                    }
                    this.tabPanelCore.Rows.Add(new TablePanelRow(TablePanelEntityStyle.AutoSize, 150F));
                }
            }
            if (_vm.HydroInfo.Waterboxs != null && _vm.HydroInfo.Waterboxs.Count == _allCalcuPrefixCtrlList.Count)
            {
                for (int i = 0; i < _allCalcuPrefixCtrlList.Count; i++)
                {
                    _allCalcuPrefixCtrlList[i].SetBindingData(_vm.HydroInfo.Waterboxs[i]);
                }
            }
        }
 
        //更新页面
        private void UpdatePage()
        {
            if (_allCalcuPrefixCtrlList == null)
            {
                return;
            }
            _allCalcuPrefixCtrlList.ForEach(x => x.UpdateBindingData());
        }
 
 
        /// <summary>
        /// 允许上一步
        /// </summary>
        public bool AllowPrev
        {
            get
            {
                if (_vm == null)
                {
                    return false;
                }
                if (_vm.FirstPage == this)
                {
                    return false;
                }
                return true;
            }
        }
 
        /// <summary>
        /// 允许上一步
        /// </summary>
        public bool AllowNext
        {
            get
            {
                if (_vm == null)
                {
                    return false;
                }
                if (_vm.LastPage == this)
                {
                    return false;
                }
                return true;
            }
        }
 
        /// <summary>
        /// 允许取消
        /// </summary>
        public bool AllowCancel
        {
            get { return true; }
        }
 
        /// <summary>
        /// 允许完成
        /// </summary>
        public bool AllowComplete
        {
            get { return true; }
        }
 
 
        /// <summary>
        /// 能否上一步
        /// </summary>
        public bool CanPrev()
        {
            return true;
        }
 
        /// <summary>
        /// 能否下一步
        /// </summary>
        public bool CanNext()
        {
            UpdatePage();
            return true;
        }
 
        /// <summary>
        /// 能否取消
        /// </summary>
        public bool CanCancel()
        {
            return true;
        }
 
        /// <summary>
        /// 能否完成
        /// </summary>
        public bool CanComplete()
        {
            UpdatePage();
            return true;
        }
 
 
    }
}