tangxu
2024-12-29 f7ec23b2fe6e8e48bbb32b8c9321b64529622406
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
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.Threading.Tasks;
using System.Windows.Forms;
using DPumpHydr.WinFrmUI.Volute.ViewModel;
using static System.Runtime.InteropServices.JavaScript.JSType;
 
namespace DPumpHydr.WinFrmUI.Volute
{
    public partial class ctrlSetOutflowParas : ParasInfoBaseCtrl
    {
        public ctrlSetOutflowParas()
        {
            InitializeComponent();
 
            BuildAllTips();
        }
        eOutflowStyle _stype = eOutflowStyle.未知;
        public Func<OtuflowParas, bool> OnRefreshShape3D = null;
        public Func<OtuflowParas, bool> OnRefreshShape2D = null;
        ViewModel.OtuflowParas _outflowParas = null;
 
        //控件
        SetOutflowParasCtrl1 _sidelineExitControl = null;
        SetOutflowParasCtrl2 _sideCurveExitControl = null;
        public void SetOutflowStyle(eOutflowStyle style)
        {
            if (_stype == style)
                return;
 
            _stype = style;
 
            panel.Controls.Clear();
            switch (_stype)
            {
                case eOutflowStyle.中心出口_垂直法兰面流出:
                    metroTile扩散管形状.BackgroundImage = GlobalResource.BuildImage("Central-exit.png", 878, 238);
 
                    if (_sidelineExitControl == null)
                    {
                        _sidelineExitControl = new SetOutflowParasCtrl1();
                        _sidelineExitControl.OnChangeParas += (para) =>
                        {
                            if(OnRefreshShape2D != null)
                            OnRefreshShape2D(para);
                        };
                        _sidelineExitControl.Dock = DockStyle.Top;
                    }
                    _sidelineExitControl.SetA_state(false); 
                    panel.Controls.Add(_sidelineExitControl);
                    return;
                case eOutflowStyle.侧面出口_曲线连接:
                    metroTile扩散管形状.BackgroundImage = GlobalResource.BuildImage("Side-exit-curve.png", 878, 238);
                    if (_sidelineExitControl == null)
                    {
                        _sidelineExitControl = new SetOutflowParasCtrl1();
                        _sidelineExitControl.OnChangeParas += (para) =>
                        {
                            if (OnRefreshShape2D != null)
                                OnRefreshShape2D(para);
                        };
                        _sidelineExitControl.Dock = DockStyle.Top;
                    }
 
                    _sidelineExitControl.SetA_state(true);
                    panel.Controls.Add(_sidelineExitControl);
                    return;
                case eOutflowStyle.侧面出口_直线连接:
                    metroTile扩散管形状.BackgroundImage = GlobalResource.BuildImage("Side-exit-straight-line.png", 878, 238);
 
                    if (_sideCurveExitControl == null)
                        _sideCurveExitControl = new SetOutflowParasCtrl2();
                    _sideCurveExitControl.Dock = DockStyle.Top;
                    panel.Controls.Add(_sideCurveExitControl);
                    return;
                default:
                    throw new ArgumentException("Invalid control type");
            }
        }
 
        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 = 10;
            if (_stype == eOutflowStyle.侧面出口_直线连接)
            {
                _sideCurveExitControl.SetBindingData(_outflowParas);
            }
            else
            {
                _sidelineExitControl.IsInvokeAble = false;
                _sidelineExitControl.SetBindingData(_outflowParas);
                _sidelineExitControl.IsInvokeAble = 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()
        {
            OnRefreshShape3D(_outflowParas);
        }
 
 
 
        private void mBtn更新模型_Click(object sender, EventArgs e)
        {
            string error;
            OnRefreshShape3D(GetBindingData(out error));
        }
    }
}