tangxu
2025-01-13 4f7cb65b079d88d5a829688b24d26d5145c5df47
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text; 
using System.Windows.Forms;
using DPumpHydr.WinFrmUI.Volute.ViewModel; 
 
namespace DPumpHydr.WinFrmUI.Volute
{
    public partial class ctrlSetOutflowParas : ParasInfoBaseCtrl
    {
        public ctrlSetOutflowParas()
        {
            InitializeComponent();
 
            BuildAllTips();
 
            this.ctrlSection910Posi1.OnMoveSectPosi += (sect_index, posi)=>
            {
                if(this.OnMoveSectPosi != null)
                {
                    OnMoveSectPosi.Invoke(sect_index, posi);
                }
            }; 
        }
        
        public Func<ViewModel.OtuflowParas, ViewModel.OtuflowParasCalcReponse> OnRefreshShape3D = null;
        public Func<ViewModel.OtuflowParas, ViewModel.OtuflowParasCalcReponse> OnRefreshShape2D = null;
        ViewModel.OtuflowParas _outflowParas = null;
 
        //控件
        SetOutflowParasCtrl1 _sidelineExitControl = null;
        SetOutflowParasCtrl2 _sideCurveExitControl = null;
 
        eOutflowStyle _stype = eOutflowStyle.未知;
        public eOutflowStyle CurrentOutflowStyle
        {
            get
            {
                return _stype;
            }
        }
        public void SetOutflowStyle(eOutflowStyle style)
        {
            if (_stype == style)
                return;
 
            _stype = style;
 
            tabPage1.Controls.Clear();
            switch (_stype)
            {
                case eOutflowStyle.中心出口_垂直法兰面流出:
                    metroTile扩散管形状.BackgroundImage = GlobalResource.BuildImage("Central-exit.png", 878, 238);
 
                    if (_sidelineExitControl == null)
                    {
                        _sidelineExitControl = new SetOutflowParasCtrl1() { Name = "SetOutflowParasCtrl1" };
                        _sidelineExitControl.OnRefreshShape += (para) =>
                        {
                            if (OnRefreshShape2D != null)
                                return OnRefreshShape2D(para);
                            else
                                return null;
                        };
                        _sidelineExitControl.Dock = DockStyle.Top;
                    }
                    _sidelineExitControl.SetA_state(false);
                    tabPage1.Controls.Add(_sidelineExitControl);
                    return;
                case eOutflowStyle.侧面出口_曲线连接:
                    metroTile扩散管形状.BackgroundImage = GlobalResource.BuildImage("Side-exit-curve.png", 878, 238);
                    if (_sidelineExitControl == null)
                    {
                        _sidelineExitControl = new SetOutflowParasCtrl1() { Name= "SetOutflowParasCtrl1" };
                        _sidelineExitControl.OnRefreshShape += (para) =>
                        {
                            if (OnRefreshShape2D != null)
                                return OnRefreshShape2D(para);
                            else
                                return null;
                        };
                        _sidelineExitControl.Dock = DockStyle.Top;
                    }
 
                    _sidelineExitControl.SetA_state(true);
                    tabPage1.Controls.Add(_sidelineExitControl);
                    return;
                case eOutflowStyle.侧面出口_直线连接:
                    metroTile扩散管形状.BackgroundImage = GlobalResource.BuildImage("Side-exit-straight-line.png", 878, 238);
 
                    if (_sideCurveExitControl == null)
                    {
                        _sideCurveExitControl = new SetOutflowParasCtrl2() { Name = "SetOutflowParasCtrl2" };
                        _sideCurveExitControl.OnRefreshShape += (para) =>
                        {
                            if (OnRefreshShape2D != null)
                                return OnRefreshShape2D(para);
                            else
                                return null;
                        };
                        _sideCurveExitControl.Dock = DockStyle.Top;
                    }
 
                    tabPage1.Controls.Add(_sideCurveExitControl);
                    return;
                default:
                    throw new ArgumentException("Invalid control type");
            }
        }
        public void SetBindingData(
            eOutflowStyle style,
            ViewModel.HdrBaseInfo hdrBaseInfo,
            ViewModel.GeomBaseInfo geomBaseInfo,
            ViewModel.SectionBundleInfo sectionBundleInfo)
        {
            if(_outflowParas == null)
            {
                InitialParas(style, hdrBaseInfo, geomBaseInfo, sectionBundleInfo);
            }
            else
            {
                if (_stype == style)
                    return;
                if(_stype == eOutflowStyle.侧面出口_直线连接)
                {
                    if(style != eOutflowStyle.侧面出口_直线连接)
                    {
                        InitialParas(style, hdrBaseInfo, geomBaseInfo, sectionBundleInfo);
                    }
                    else
                    {
                        SetOutflowStyle(style);
                    }
                }
                else
                {
                    if (style == eOutflowStyle.侧面出口_直线连接)
                    {
                        InitialParas(style, hdrBaseInfo, geomBaseInfo, sectionBundleInfo);
                    }
                    else
                    {
                        SetOutflowStyle(style);
                    }
                }
         
            }
        }
        public void InitialParas(
            eOutflowStyle style,
            ViewModel.HdrBaseInfo hdrBaseInfo,
            ViewModel.GeomBaseInfo geomBaseInfo,
            ViewModel.SectionBundleInfo sectionBundleInfo)
        {
            SetOutflowStyle(style);
            //出口直径标准化
            double outer_dia = 4.5 * Math.Pow(hdrBaseInfo.Q / 3600 / hdrBaseInfo.n, 1 / 3.0) * 1000;
            double height = 10 * (int)((geomBaseInfo.D3 * 1.3 + sectionBundleInfo.H[8] + 15) / 10);
 
            double a = 0;
            if (style == eOutflowStyle.中心出口_垂直法兰面流出)
            {
                a = 0;
            }
            else
            {
                a = (int)((geomBaseInfo.D3 + sectionBundleInfo.H[8]) / 2);
            }
 
            _outflowParas = new OtuflowParas();
            _outflowParas.Offset = a;
            _outflowParas.Heigh = height;
            _outflowParas.H1 = 5;
            _outflowParas.H2 = 5;
            _outflowParas.Dia = GetStdDia(outer_dia);
            _outflowParas.Septalradius = 2;
            if (_stype == eOutflowStyle.侧面出口_直线连接)
            {
                _sideCurveExitControl.SetBindingData(_outflowParas);
            }
            else
            {
                _sidelineExitControl.InitialParas(hdrBaseInfo, geomBaseInfo, sectionBundleInfo);
                _sidelineExitControl.IsInvokeRefreshShapeAble = false;
                _sidelineExitControl.SetBindingData(_outflowParas);
                _sidelineExitControl.IsInvokeRefreshShapeAble = true;
            }
        }
 
        private static double GetStdDia(double mm)
        {
            var iFlangeCodeList = new int[] {10,15,20,25,32,
                        40,50,65,80,100,
                        125,150,200,250,300,
                        350,400,450,500,600,
                        700,800,900,1000,1200,
                        1400,1600,1800,2000,5000,100000};
 
            for (int i = 0; i < iFlangeCodeList.Count() - 1; i++)
            {
                if (mm < iFlangeCodeList[i])
                    return iFlangeCodeList[i];
            }
 
 
            return iFlangeCodeList.Last();
        }
        //
        public ViewModel.OtuflowParas GetBindingData(out string error)
        {
            error = "";
            if (_stype == eOutflowStyle.侧面出口_直线连接)
            {
                _outflowParas = _sideCurveExitControl.GetBindingData(out error);
            }
            else
            {
                _outflowParas = _sidelineExitControl.GetBindingData(out error);
            }
 
            return _outflowParas;
        }
 
        public void SetBindingData(eOutflowStyle style, ViewModel.OtuflowParas paras)
        {
            SetOutflowStyle(style);
            if (_stype == eOutflowStyle.侧面出口_直线连接)
            {
                _sideCurveExitControl.SetBindingData(_outflowParas);
            }
            else
            {
                _sidelineExitControl.SetBindingData(_outflowParas);
            }
 
 
        }
 
 
 
 
        private void BuildAllTips()
        {
            metroToolTip第六步提示.SetToolTip(this.metroTile扩散管形状, "断面图");
        }
 
        public void ShowPage(DPumpHydr.ViewModel.eWizardStepDiretion step_direction)
        {
 
            if (step_direction == DPumpHydr.ViewModel.eWizardStepDiretion.前进)
            {
                var resp = OnRefreshShape3D(_outflowParas);
                if (resp != null)
                {
                    if (_stype == eOutflowStyle.侧面出口_直线连接)
                    {
                        _sideCurveExitControl.SetBindingData(resp);
                    }
                    else
                    {
                        _sidelineExitControl.SetBindingData(resp);
                    }
                }
            }
            else
            {
 
            }
        }
 
 
 
        private void mBtn更新模型_Click(object sender, EventArgs e)
        {
            string error;
            var resp = OnRefreshShape3D(GetBindingData(out error));
            if (resp != null)
            {
                if (_stype == eOutflowStyle.侧面出口_直线连接)
                {
                    _sideCurveExitControl.SetBindingData(resp);
                }
                else
                {
                    _sidelineExitControl.SetBindingData(resp);
                }
            }
        }
        public Action<int, double> OnMoveSectPosi = null;
        internal void SetSect9Posi(double sect9Posi)
        {
            ctrlSection910Posi1.SetSect9Posi(sect9Posi);
        }
        internal void SetSect10Posi(double sect9Posi)
        {
            ctrlSection910Posi1.SetSect10Posi(sect9Posi);
        }
    }
}