duheng
2024-05-13 8223887b96c33e509f8706d4a0d2548386af6c0d
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
using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;
 
namespace IStation.WinFrmUI.Curve
{
    public partial class SetCoordinateAllDlg : DevExpress.XtraEditors.XtraForm
    {
 
        public event Action<Model.CurveCoordinateParas> OnChangedCoord = null;
 
        private Model.CurveCoordinateParas _coordinateParas = null;
        public Model.CurveCoordinateParas CoordinateParas { get { return _coordinateParas; } set { _coordinateParas = value; } }
 
        Unit.eUnitQ _unitQ = Unit.eUnitQ.M3H;
        public Unit.eUnitQ UnitQ
        {
            get { return _unitQ; }
            set { _unitQ = value; }
        }
 
        Unit.eUnitH _unitH = Unit.eUnitH.M;
        public Unit.eUnitH UnitH
        {
            get { return _unitH; }
            set { _unitH = value; }
        }
 
        public SetCoordinateAllDlg()
        {
            InitializeComponent();
        }
 
        private void LoadWindow(object sender, EventArgs e)
        {
            if (_coordinateParas == null)
                return;
 
            //流量刻度间隔数
            textGridNumberX.Text = _coordinateParas.GridNumberX.ToString();
            textGridNumberY.Text = _coordinateParas.GridNumberY.ToString();
            textGridNumberX.Enabled = true;
 
            if (_unitQ != Unit.eUnitQ.M3H)
            {
                textCoordSpaceQ.Text = Unit.UnitQHelper.Convert(_unitQ, Unit.eUnitQ.M3H, _coordinateParas.CoordSpaceQ).ToString("0.00");
                textMinDispQ.Text = Unit.UnitQHelper.Convert(_unitQ, Unit.eUnitQ.M3H, _coordinateParas.CoordMinQ).ToString("0.00");
            }
            else
            {
                textCoordSpaceQ.Text = _coordinateParas.CoordSpaceQ.ToString();
                textMinDispQ.Text = _coordinateParas.CoordMinQ.ToString();
            }
 
            textStartLineNoH.Text = _coordinateParas.StartLineNoH.ToString();
            textEndLineNoH.Text = _coordinateParas.EndLineNoH.ToString();
            if (_unitH != Unit.eUnitH.M)
            {
                textMaxDispH.Text = Unit.UnitHHelper.Convert(_unitH, Unit.eUnitH.M, (_coordinateParas.CoordMinH + _coordinateParas.EndLineNoH * _coordinateParas.CoordSpaceH)).ToString("0.00");
                textCoordSpaceH.Text = Unit.UnitHHelper.Convert(_unitH, Unit.eUnitH.M, _coordinateParas.CoordSpaceH).ToString("0.00");
            }
            else
            {
 
                textMaxDispH.Text = (_coordinateParas.CoordMinH + _coordinateParas.EndLineNoH * _coordinateParas.CoordSpaceH).ToString();
                textCoordSpaceH.Text = _coordinateParas.CoordSpaceH.ToString();
            }
 
 
            textEndLineNoE.Text = _coordinateParas.EndLineNoE.ToString();
            textStartLineNoE.Text = _coordinateParas.StartLineNoE.ToString();
            textCoordSpaceE.Text = _coordinateParas.CoordSpaceE.ToString();
            textMaxDispE.Text = (_coordinateParas.CoordMinE + _coordinateParas.EndLineNoE * _coordinateParas.CoordSpaceE).ToString();
 
            double minP = _coordinateParas.CoordMinP + _coordinateParas.StartLineNoP * _coordinateParas.CoordSpaceP;
            if (minP < 0.001)
                minP = 0;
            textMinDispP.Text = minP.ToString();
            textStartLineNoP.Text = _coordinateParas.StartLineNoP.ToString();
            textEndLineNoP.Text = _coordinateParas.EndLineNoP.ToString();
            textCoordSpaceP.Text = _coordinateParas.CoordSpaceP.ToString();
 
 
        }
 
 
        private void btnSet_Click(object sender, EventArgs e)
        {
            if (_coordinateParas == null)
                return;
 
            if (!double.TryParse(textCoordSpaceQ.Text, out double space))
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            if (space < 0.1)
            {
                XtraMessageBox.Show("刻度值过小,请重新调整");
                return;
            }
 
            if (!int.TryParse(textGridNumberX.Text, out int num))
            {
                XtraMessageBox.Show("扬程刻度数请输入合理值");
                return;
            }
            _coordinateParas.GridNumberX = num;
 
            if (!int.TryParse(textGridNumberY.Text, out num))
            {
                XtraMessageBox.Show("扬程刻度数请输入合理值");
                return;
            }
            _coordinateParas.GridNumberY = num;
 
            double.TryParse(textMinDispQ.Text, out double CoordMinQ);
 
            if (_unitQ != Unit.eUnitQ.M3H)
            {
                _coordinateParas.CoordMinQ = Unit.UnitQHelper.Convert(_unitQ, Unit.eUnitQ.M3H, CoordMinQ);
                _coordinateParas.CoordSpaceQ = Unit.UnitQHelper.Convert(_unitQ, Unit.eUnitQ.M3H, space);
            }
            else
            {
                _coordinateParas.CoordMinQ = CoordMinQ;
                _coordinateParas.CoordSpaceQ = space;
            }
 
 
            if (!int.TryParse(textStartLineNoH.Text, out int start))
            {
                XtraMessageBox.Show("扬程刻度数请输入合理值");
                return;
            }
            if (!int.TryParse(textEndLineNoH.Text, out int end))
            {
                XtraMessageBox.Show("扬程刻度数请输入合理值");
                return;
            }
            if (start >= end - 1)
            {
                XtraMessageBox.Show("扬程刻度设置不合理");
                return;
            }
            if (!double.TryParse(textCoordSpaceH.Text, out space))
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            if (space < 0.1)
            {
                XtraMessageBox.Show("刻度值过小,请重新调整");
                return;
            }
            if (!double.TryParse(textMaxDispH.Text, out double maxValue))
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
 
            if (_unitH != Unit.eUnitH.M)
            {
                _coordinateParas.StartLineNoH = start;
                _coordinateParas.EndLineNoH = end;
                _coordinateParas.CoordSpaceH = Unit.UnitHHelper.Convert(_unitH, Unit.eUnitH.M, space);
                _coordinateParas.CoordMinH = Unit.UnitHHelper.Convert(_unitH, Unit.eUnitH.M, maxValue - _coordinateParas.EndLineNoH * space);
            }
            else
            {
                _coordinateParas.StartLineNoH = start;
                _coordinateParas.EndLineNoH = end;
                _coordinateParas.CoordSpaceH = space;
                _coordinateParas.CoordMinH = maxValue - _coordinateParas.EndLineNoH * space;
            }
 
 
            if (!int.TryParse(textEndLineNoE.Text, out end))
            {
                XtraMessageBox.Show("效率刻度数请输入合理值");
                return;
            }
            if (!int.TryParse(textStartLineNoE.Text, out start))
            {
                XtraMessageBox.Show("效率刻度数请输入合理值");
                return;
            }
            if (start >= end - 1)
            {
                XtraMessageBox.Show("效率刻度设置不合理");
                return;
            }
            if (!double.TryParse(textCoordSpaceE.Text, out space))
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            if (space < 0.1)
            {
                XtraMessageBox.Show("刻度值过小,请重新调整");
                return;
            }
            if (!double.TryParse(textMaxDispE.Text, out maxValue))
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            _coordinateParas.CoordSpaceE = space;
            _coordinateParas.StartLineNoE = start;
            _coordinateParas.EndLineNoE = end;
            _coordinateParas.CoordMinE = maxValue - _coordinateParas.EndLineNoE * _coordinateParas.CoordSpaceE;
 
 
 
            if (!int.TryParse(textStartLineNoP.Text, out start))
            {
                XtraMessageBox.Show("功率刻度数请输入合理值");
                return;
            }
            if (!int.TryParse(textEndLineNoP.Text, out end))
            {
                XtraMessageBox.Show("功率刻度数请输入合理值");
                return;
            }
            if (start >= end - 1)
            {
                XtraMessageBox.Show("功率刻度设置不合理");
                return;
            }
            if (!double.TryParse(textCoordSpaceP.Text, out space))
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            if (space < 0.01)
            {
                XtraMessageBox.Show("刻度值过小,请重新调整");
                return;
            }
            if (!double.TryParse(textMinDispP.Text, out double minValue))
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            _coordinateParas.StartLineNoP = start;
            _coordinateParas.EndLineNoP = end;
            _coordinateParas.CoordSpaceP = space;
            _coordinateParas.CoordMinP = minValue - _coordinateParas.StartLineNoP * _coordinateParas.CoordSpaceP;
 
            if (OnChangedCoord != null)
            {
                OnChangedCoord(_coordinateParas);
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
 
    }
}