duheng
2024-03-26 11c7908bcc2ca699e88b7a0a17bc32e45521c349
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
using DevExpress.XtraEditors;
using System;
 
namespace IStation.WinFrmUI.Basic
{
    public partial class SetSingleCoordLxpEDlg : DevExpress.XtraEditors.XtraForm
    {
        public event ChangeLxpCoordHandler OnChangedCoord = null;
 
        private Eventech.Model.LxpCoordinateParas CoordinateParas = null;
 
        public SetSingleCoordLxpEDlg()
        {
            InitializeComponent();
        }
 
        private void LoadWindow(object sender, EventArgs e)
        {
        }
 
        public void SetBindingData(Eventech.Model.LxpCoordinateParas coord)
        {
            this.CoordinateParas = coord;
            if (CoordinateParas == null)
                return;
 
            comboBoxType.Properties.Items.Add("刻度数,最大最小值");
            comboBoxType.Properties.Items.Add("刻度数,间隔量,最小值");
            comboBoxType.Properties.Items.Add("间隔量,最大最小值");
            comboBoxType.SelectedIndex = 2;
 
 
 
            //if (type == Eventech.Model.eAxisType.P)
            //{
            //    labelMin.Text = "最小功率";
            //    labelMax.Text = "最大功率";
            //    checkBox1.Text = "从底部开始";
            //    //labelSpace.Text = "流量/刻度";
            //    textStart.Text = CoordinateParas.StartLineNoP.ToString();
            //    textNumber.Text = (CoordinateParas.EndLineNoP - CoordinateParas.StartLineNoP + 1).ToString();
            //    textMin.Text = Math.Round((CoordinateParas.CoordMinP + CoordinateParas.StartLineNoP
            //        * CoordinateParas.CoordSpaceP),3).ToString();
            //    textMax.Text = Math.Round((CoordinateParas.CoordMinP + CoordinateParas.EndLineNoP
            //        * CoordinateParas.CoordSpaceP), 3).ToString();
            //    textSpace.Text = CoordinateParas.CoordSpaceP.ToString();
            //}
            //if (type == Eventech.Model.eAxisType.E)
            //{
            labelMin.Text = "最小效率";
            labelMax.Text = "最大效率";
            checkBox1.Text = "从底部开始";
            //labelSpace.Text = "流量/刻度";
            textStart.Text = CoordinateParas.StartLineNoE.ToString();
            textNumber.Text = (CoordinateParas.EndLineNoE - CoordinateParas.StartLineNoE + 1).ToString();
            textMin.Text = Math.Round((CoordinateParas.CoordMinE + CoordinateParas.StartLineNoE
                * CoordinateParas.CoordSpaceE), 3).ToString();
            textMax.Text = Math.Round((CoordinateParas.CoordMinE + CoordinateParas.EndLineNoE
                * CoordinateParas.CoordSpaceE), 3).ToString();
            textSpace.Text = CoordinateParas.CoordSpaceE.ToString();
            //}
            //if (type == Eventech.Model.eAxisType.NPSH)
            //{
            //    labelMin.Text = "最小汽蚀";
            //    labelMax.Text = "最大汽蚀";
            //    checkBox1.Text = "从底部开始";
            //    //labelSpace.Text = "流量/刻度";
            //    textStart.Text = CoordinateParas.StartLineNoNPSH.ToString();
            //    textNumber.Text = (CoordinateParas.EndLineNoNPSH - CoordinateParas.StartLineNoNPSH + 1).ToString();
            //    textMin.Text = Math.Round((CoordinateParas.CoordMinNPSH + CoordinateParas.StartLineNoNPSH
            //        * CoordinateParas.CoordSpaceNPSH), 3).ToString();
            //    textMax.Text = Math.Round((CoordinateParas.CoordMinNPSH + CoordinateParas.EndLineNoNPSH
            //        * CoordinateParas.CoordSpaceNPSH), 3).ToString();
            //    textSpace.Text = CoordinateParas.CoordSpaceNPSH.ToString();
            //}
 
        }
 
        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void btnSet_Click(object sender, EventArgs e)
        {
            if (OnChangedCoord == null || CoordinateParas == null)
                return;
 
            double space = 0;
            int num = 0;
            int start = 0;
            double minValue = 0;
            double maxValue = 0;
            if (!double.TryParse(textSpace.Text, out space))
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            if (space < 0.001)
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
 
            if (!int.TryParse(textNumber.Text, out num))
            {
                XtraMessageBox.Show("刻度数请输入合理值");
                return;
            }
            if (num < 3)
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            if (!int.TryParse(textStart.Text, out start))
            {
                XtraMessageBox.Show("刻度数请输入合理值");
                return;
            }
            if (!double.TryParse(textMin.Text, out minValue))
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            if (!double.TryParse(textMax.Text, out maxValue))
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            if (maxValue < minValue)
            {
                XtraMessageBox.Show("请输入合理值");
                return;
            }
            switch (comboBoxType.Text)
            {
                case "刻度数,最大最小值":
                    space = Math.Round((maxValue - minValue + 0.001) / (num - 1), 3);
                    textSpace.Text = space.ToString();
                    break;
                case "刻度数,间隔量,最小值":
                    maxValue = minValue + space * (num - 1);
                    textMax.Text = maxValue.ToString();
                    break;
                case "间隔量,最大最小值":
                    num = (int)((maxValue - minValue + 0.001) / space) + 1;
                    textNumber.Text = num.ToString();
                    break;
            }
 
 
            //if (axisType == Eventech.Model.eAxisType.P)
            //{
            //    CoordinateParas.StartLineNoP = start;
            //    CoordinateParas.EndLineNoP = start + num - 1;
            //    CoordinateParas.CoordSpaceP = space;
            //    CoordinateParas.CoordMinP = minValue - CoordinateParas.StartLineNoP * CoordinateParas.CoordSpaceP;
            //}
            //else if (axisType == Eventech.Model.eAxisType.E)
            {
                CoordinateParas.StartLineNoE = start;
                CoordinateParas.EndLineNoE = start + num - 1;
                CoordinateParas.CoordSpaceE = space;
                CoordinateParas.CoordMinE = minValue - CoordinateParas.StartLineNoE * CoordinateParas.CoordSpaceE;
            }
            //else if (axisType == Eventech.Model.eAxisType.NPSH)
            //{
            //    CoordinateParas.StartLineNoNPSH = start;
            //    CoordinateParas.EndLineNoNPSH = start + num - 1;
            //    CoordinateParas.CoordSpaceNPSH = space;
            //    CoordinateParas.CoordMinNPSH = minValue - CoordinateParas.StartLineNoNPSH * CoordinateParas.CoordSpaceNPSH;
            //}
 
            //
            OnChangedCoord(this, new LxpCoordEventArgs(CoordinateParas));
        }
 
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            textStart.Enabled = !checkBox1.Checked;
            if (checkBox1.Checked)
            {
                textStart.Text = "0";
            }
        }
 
        private void comboBoxType_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBoxType.Text)
            {
                case "刻度数,最大最小值":
                    labelNumber.Visible = true;
                    textNumber.Visible = true;
 
                    labelMin.Visible = true;
                    textMin.Visible = true;
 
                    labelMax.Visible = true;
                    textMax.Visible = true;
 
                    labelSpace.Visible = false;
                    textSpace.Visible = false;
                    break;
                case "刻度数,间隔量,最小值":
                    labelNumber.Visible = true;
                    textNumber.Visible = true;
 
                    labelMin.Visible = true;
                    textMin.Visible = true;
 
                    labelMax.Visible = false;
                    textMax.Visible = false;
 
                    labelSpace.Visible = true;
                    textSpace.Visible = true;
                    break;
                case "间隔量,最大最小值":
                    labelNumber.Visible = false;
                    textNumber.Visible = false;
 
                    labelMin.Visible = true;
                    textMin.Visible = true;
 
                    labelMax.Visible = true;
                    textMax.Visible = true;
 
                    labelSpace.Visible = true;
                    textSpace.Visible = true;
 
                    break;
 
            }
 
 
        }
 
 
    }
}