yangyin
2025-01-13 36616eb44dc36a4e6e3e7a7540310cb850218ea9
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System;
using DPumpHydr.WinFrmUI.RLT.Controls;
using DPumpHydr.WinFrmUI.RLT.Docking.Crown;
using DPumpHydr.WinFrmUI.Base;
using System.Linq;
using System.Windows.Forms;
 
namespace DPumpHydr.WinFrmUI.Volute
{
    public partial class StepTreeDockPanel : CrownToolWindow
    {
        //基础信息
        private readonly string Group_Name_Base_Info = "BaseInfo";
        private readonly int Group_ID_Base_Info = -1;//组ID
        public readonly long Step_ID_Introduce = 11;
        public readonly long Step_ID_Hdr_Base_Info = 12; 
 
 
        //断面设计(1-8)
        private readonly string Group_Name_Section18 = "Section18";
        private readonly int Group_ID_Section18 = -2;
        public readonly long Step_ID_Section18_Full = 20;//详细信息
        public readonly long Step_ID_Section18_Grp = 21;// 1-8组
 
 
        //出水设计
        private readonly string Group_Name_Outflow = "Outflow";
        private readonly int Group_ID_Outflow = -3;
        public readonly long Step_ID_Outflow_Paras = 32;
        public readonly long Step_ID_Outflow_Type = 31;
        public readonly long Step_ID_jiahout = 33;
 
        //
        private List<DPumpHydr.WinFrmUI.Base.StepTreeNodePara> _allStepNodes = null;
        /// <summary>
        /// 步骤节点选择改变前后事件
        /// </summary>
        public event Func<StepTreeNodePara, StepTreeNodePara, bool> BeforeSelectedNodeChangedEvent;
        public event Func<StepTreeNodePara, StepTreeNodePara, bool> AfterSelectedNodeChangedEvent;
 
 
        public long PrevStepID
        {
            get
            {
                var prev_step = (from x in _allStepNodes
                             where x.ID<_currentStepID && x.AllowSelect
                                 orderby x.ID
                             select x).LastOrDefault();
                if (prev_step == null)
                    return 0;
                else 
                    return prev_step.ID;
            }
        }
        public long NextStepID
        {
            get
            {
                var next_step = (from x in _allStepNodes
                                 where x.ID > _currentStepID && x.AllowSelect
                                 orderby x.ID
                                 select x).FirstOrDefault();
                if (next_step == null)
                    return 0;
                else
                    return next_step.ID;
            }
        }
        private long _currentStepID = 0;
        public long CurrentStepID {
            get { return _currentStepID; }
        }
 
        public StepTreeDockPanel()
        {
            InitializeComponent();
 
            this.SerializationKey = "StepTreeDockPanel";
            //BackColor = System.Drawing.Color.Transparent;
            this.stepTreeCtrl1.BeforeSelectedNodeChangedEvent += (arg1, arg2) =>
            {
                if (arg1 == null)
                    return false ;
                if (BeforeSelectedNodeChangedEvent != null)
                {
                    return BeforeSelectedNodeChangedEvent(arg1, arg2);
                }
 
                return true; 
            };
 
            this.stepTreeCtrl1.AfterSelectedNodeChangedEvent += (arg1, arg2) =>
            {
                if (arg1 == null || arg2 == null)
                    return true ;
                if (AfterSelectedNodeChangedEvent != null)
                {
                    if( AfterSelectedNodeChangedEvent(arg1, arg2))
                    {
                        this.stepTreeCtrl1.SetFocusedNode(arg2.ID);
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                this.stepTreeCtrl1.SetFocusedNode(arg2.ID);
                return true; 
            };
        }
 
 
        /// <summary>
        /// 
        /// </summary>
        public void InitialStepNodes()
        {
            _allStepNodes = new List<DPumpHydr.WinFrmUI.Base.StepTreeNodePara>();
 
            #region 基础信息/几何参数
            var stepGroup_BaseInfo = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara();
            stepGroup_BaseInfo.AllowSelect = false; 
            stepGroup_BaseInfo.Caption = "基础信息";
            stepGroup_BaseInfo.Name = Group_Name_Base_Info;
            stepGroup_BaseInfo.ID = Group_ID_Base_Info;
            stepGroup_BaseInfo.ParentID = 0;
            _allStepNodes.Add(stepGroup_BaseInfo);
 
            var step欢迎使用 = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara();
            step欢迎使用.AllowSelect = false ; 
            step欢迎使用.Caption = "欢迎使用";
            step欢迎使用.Name = "StepHelp";
            step欢迎使用.ID = Step_ID_Introduce;
            step欢迎使用.ParentID = Group_ID_Base_Info;
            step欢迎使用.SpecImage = DPumpHydr.WinFrmUI.Volute.Properties.Resources.Smile16;
            _allStepNodes.Add(step欢迎使用);
 
 
            var step基础信息 = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara()
            {
                ProgressState = WinFrmUI.Base.StepTreeNodePara.eProgressState.未完成,
                DataState = WinFrmUI.Base.StepTreeNodePara.eDataState.未知
            };
            step基础信息.AllowSelect = true; 
            step基础信息.Caption = "第一步:基础信息";
            step基础信息.Name = "StepHydParas";
            step基础信息.ID = Step_ID_Hdr_Base_Info;
            step基础信息.ParentID = Group_ID_Base_Info;
            _allStepNodes.Add(step基础信息);
 
 
            #endregion
 
 
            #region 断面设计(1-8)
 
            var stepGroup_CoverPlate = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara()
            {
                ProgressState = WinFrmUI.Base.StepTreeNodePara.eProgressState.未完成,
                DataState = WinFrmUI.Base.StepTreeNodePara.eDataState.未知
            };
            stepGroup_CoverPlate.AllowSelect = false;
            stepGroup_CoverPlate.Caption = "断面设计";
            stepGroup_CoverPlate.Name = Group_Name_Section18;
            stepGroup_CoverPlate.ID = Group_ID_Section18;
            stepGroup_CoverPlate.ParentID = 0;
            _allStepNodes.Add(stepGroup_CoverPlate);
 
 
            var step断面基本信息 = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara()
            {
                ProgressState = WinFrmUI.Base.StepTreeNodePara.eProgressState.未完成,
                DataState = WinFrmUI.Base.StepTreeNodePara.eDataState.未知
            };
            step断面基本信息.AllowSelect = true   ;
            step断面基本信息.Caption = string.Format("{0}:{1}",
                GetTranslateString("第二步"),
                GetTranslateString("断面信息"));
            step断面基本信息.Name = "SectBaseInfo18";
            step断面基本信息.ID = Step_ID_Section18_Full; 
            step断面基本信息.ParentID = Group_ID_Section18;
            _allStepNodes.Add(step断面基本信息);
 
 
            var stepSetct18 = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara()
            {
                ProgressState = WinFrmUI.Base.StepTreeNodePara.eProgressState.未完成,
                DataState = WinFrmUI.Base.StepTreeNodePara.eDataState.未知
            };
            stepSetct18.AllowSelect = false ;
            stepSetct18.Caption = "第三步: 第1-8断面";
            stepSetct18.Name = "TreeStepNode" + Step_ID_Section18_Grp;
            stepSetct18.ID = Step_ID_Section18_Grp; 
            stepSetct18.ParentID = Group_ID_Section18;
            stepSetct18.SpecImage = DPumpHydr.WinFrmUI.Volute.Properties.Resources.Sect16;
            _allStepNodes.Add(stepSetct18);
 
            for(int i = 8; i >= 1; i--)
            {
                var stepSetct0 = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara()
                {
                    ProgressState = WinFrmUI.Base.StepTreeNodePara.eProgressState.未完成,
                    DataState = WinFrmUI.Base.StepTreeNodePara.eDataState.未知
                };
                stepSetct0.AllowSelect = true;
                stepSetct0.Caption = string.Format("第{0}断面",i);
                stepSetct0.Name = "TreeStepNodeSect" + i;
                stepSetct0.ID = Step_ID_Section18_Grp + (9-i); 
                stepSetct0.ParentID = Step_ID_Section18_Grp;
                _allStepNodes.Add(stepSetct0);
            }
            #endregion
 
 
            #region 出水体
 
            var stepGroup_出水体 = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara()
            {
                ProgressState = WinFrmUI.Base.StepTreeNodePara.eProgressState.未完成,
                DataState = WinFrmUI.Base.StepTreeNodePara.eDataState.未知
            };
            stepGroup_出水体.AllowSelect = false;
            stepGroup_出水体.Caption = "出水体设计";
            stepGroup_出水体.Name = Group_Name_Outflow;
            stepGroup_出水体.ID = Group_ID_Outflow;
            stepGroup_出水体.ParentID = 0;
            _allStepNodes.Add(stepGroup_出水体);
 
 
 
            var step出水体尺寸 = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara()
            {
                ProgressState = WinFrmUI.Base.StepTreeNodePara.eProgressState.未完成,
                DataState = WinFrmUI.Base.StepTreeNodePara.eDataState.未知
            };
            step出水体尺寸.AllowSelect = true;
            step出水体尺寸.Caption = " 第四步:出水体类型";
            step出水体尺寸.Name = "TreeStepNode" + Step_ID_Outflow_Type;
            step出水体尺寸.ID = Step_ID_Outflow_Type;
            step出水体尺寸.ParentID = Group_ID_Outflow;
            _allStepNodes.Add(step出水体尺寸);
 
 
 
 
            var step出水体类型 = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara()
            {
                ProgressState = WinFrmUI.Base.StepTreeNodePara.eProgressState.未完成,
                DataState = WinFrmUI.Base.StepTreeNodePara.eDataState.未知
            };
            step出水体类型.AllowSelect = true;
            step出水体类型.Caption = "第五步:出水体尺寸";
            step出水体类型.Name = "TreeStepNode" + Step_ID_Outflow_Paras;
            step出水体类型.ID = Step_ID_Outflow_Paras; 
            step出水体类型.ParentID = Group_ID_Outflow;
            _allStepNodes.Add(step出水体类型);
 
            
            var step加厚 = new DPumpHydr.WinFrmUI.Base.StepTreeNodePara()
            {
                ProgressState = WinFrmUI.Base.StepTreeNodePara.eProgressState.未完成,
                DataState = WinFrmUI.Base.StepTreeNodePara.eDataState.未知
            };
            step加厚.AllowSelect = true;
            step加厚.Caption = "第六步:水体加厚";
            step加厚.Name = "TreeStepNode" + Step_ID_jiahout;
            step加厚.ID = Step_ID_jiahout;
            step加厚.ParentID = Group_ID_Outflow;
            _allStepNodes.Add(step加厚);
 
 
            #endregion
 
 
            //
            this._currentStepID = Step_ID_Hdr_Base_Info;
            this.stepTreeCtrl1.SetStepSource(_allStepNodes, Step_ID_Hdr_Base_Info);
        }
 
 
 
        public void SetFocusedNode(long StepNodeID)
        {
            this._currentStepID = StepNodeID;
            this.stepTreeCtrl1.SetFocusedNode(StepNodeID);
        }
        public void SetStepSource(List<StepTreeNodePara> steps, long ID)
        {
            if(ID > 0)
            {
                this._currentStepID = ID;
                this.stepTreeCtrl1.SetStepSource(steps, ID);
            }
            else
            {
                this.stepTreeCtrl1.SetStepSource(steps, this._currentStepID);
            }
        }
 
 
 
        
        private string GetTranslateString(string text)
        {
            return text;
        }
 
    }
 
}