yangyin
2024-10-23 7fa5235e0368153db3a9e97a1e92042177ce3075
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
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 static System.Runtime.InteropServices.JavaScript.JSType;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
 
namespace DPumpHydr.WinFrmUI.Volute 
{
    /// <summary>
    /// 断面基本信息(形状等)
    /// </summary>
    public partial class ctrlSectionBaseInfo : UserControl
    {
        public ctrlSectionBaseInfo()
        {
            InitializeComponent();
            BuildAllTips();
            BuildIcon();
        }
        ViewModel.SectionBaseInfo _paras = null;
        public void SetBindingData(ViewModel.SectionBaseInfo vm)
        {
            this._paras = vm;
            if (vm == null)
            {
                return;
            }
            this.mTextBoxEdit蜗室平均速度.Text = vm.V3.ToString();
            //this.skyTextBox断面VIIIy1.Text = vm.GaMa1.ToString();
            //this.skyTextBox断面VIIIy2.Text = vm.GaMa2.ToString();
            if (_paras.ShapeType == 0)
            {
                RBtn断面对称梯形.Checked = true;
                RBtn不对称梯形.Checked = false;
                RBtn矩形.Checked = false ;
            }
            if (_paras.ShapeType == 1)
            {
                RBtn断面对称梯形.Checked = false;
                RBtn不对称梯形.Checked = true;
                RBtn矩形.Checked = false;
            }
            if (_paras.ShapeType == 2)
            {
                RBtn断面对称梯形.Checked = false;
                RBtn不对称梯形.Checked = false;
                RBtn矩形.Checked = true;
            }
 
        }   
        public ViewModel.SectionBaseInfo GetBindingData(out string error)
        {
            if (!Verify(out error))
            {
                return null;
            }
            error = null;
            if (_paras == null)
            {
                _paras = new ViewModel.SectionBaseInfo();
            }
            _paras.V3 = Convert.ToDouble(this.mTextBoxEdit蜗室平均速度.Text);
            //_paras.GaMa1 = Convert.ToDouble(this.skyTextBox断面VIIIy1.Text);
            //_paras.GaMa2 = Convert.ToDouble(this.skyTextBox断面VIIIy2.Text);
            if (RBtn断面对称梯形.Checked)
            {
                _paras.ShapeType = 0;
            }
            if (RBtn不对称梯形.Checked)
            {
                _paras.ShapeType = 1;
            }
            if (RBtn矩形.Checked)
            {
                _paras.ShapeType = 2;
            }
            return _paras;
        }
        public bool Verify(out string error)
        {
            error = "";
            bool isOk = true;
            if (string.IsNullOrEmpty(mTextBoxEdit蜗室平均速度.Text) || mTextBoxEdit蜗室平均速度.Text == "请输入" || double.Parse(mTextBoxEdit蜗室平均速度.Text) == 0)
            {
                error = "请输入必填项!";
                isOk = false;
                mTextBoxEdit蜗室平均速度.TrailingIcon = GlobalResource.GetTipTrailingIcon();
                skyLabel蜗室平均速度.Visible = true;
            }
            if (string.IsNullOrEmpty(skyTextBox断面VIIIy1.Text) || double.Parse(skyTextBox断面VIIIy1.Text) == 0)
            {
                error = "请输入必填项!";
                isOk = false;
                skyLabel提示y2.Visible = false;
                skyLabely2.Visible = true;
            }
            if (string.IsNullOrEmpty(skyTextBox断面VIIIy2.Text) || double.Parse(skyTextBox断面VIIIy2.Text) == 0)
            {
                error = "请输入必填项!";
                isOk = false;
                skyLabel提示y1.Visible = false;
                skyLabely1.Visible = true;
            }
            return isOk;
        }
 
        private void BuildIcon()
        {
            //对话框前缀图片
            mTextBoxEdit蜗室平均速度.LeadingIcon = GlobalResource.GetLeadingIcon();
 
            //断面形状图片
            metroTile对称梯形.BackgroundImage = GlobalResource.BuildImage("duichentixing.png",97,88);
            metroTile不对称梯形.BackgroundImage = GlobalResource.BuildImage("buduichentixing.png", 97, 88);
            metroTile矩形.BackgroundImage = GlobalResource.BuildImage("juxing.png", 97, 88);
        }
 
        private void BuildAllTips()
        {
            metroToolTip第三步提示.SetToolTip(this.metroTile对称梯形, "对称梯形");
            metroToolTip第三步提示.SetToolTip(this.metroTile不对称梯形, "不对称梯形");
            metroToolTip第三步提示.SetToolTip(this.metroTile矩形, "矩形");
            metroToolTip第三步提示.SetToolTip(this.mTextBoxEdit蜗室平均速度, "液体在蜗室内流动\n时的平均速度");
            metroToolTip第三步提示.SetToolTip(this.skyTextBox断面VIIIy1, "y1 解释");
            metroToolTip第三步提示.SetToolTip(this.skyTextBox断面VIIIy2, "y2 解释");
        }
        private void metroTile断面形状1_Click(object sender, EventArgs e)
        {
            RBtn断面对称梯形.Checked = true;
            RBtn不对称梯形.Checked = false;
            RBtn矩形.Checked = false;
 
        }
 
        private void metroTile断面形状2_Click(object sender, EventArgs e)
        {
            RBtn断面对称梯形.Checked = false;
            RBtn不对称梯形.Checked = true;
            RBtn矩形.Checked = false;
        }
 
        private void metroTile断面形状3_Click(object sender, EventArgs e)
        {
            RBtn断面对称梯形.Checked = false;
            RBtn不对称梯形.Checked = false;
            RBtn矩形.Checked = true;
        }
 
        private void mTextBoxEdit蜗室平均速度_Enter(object sender, EventArgs e)
        {
            skyLabel蜗室平均速度.Visible = false;
            mTextBoxEdit蜗室平均速度.TrailingIcon = null;
            if (mTextBoxEdit蜗室平均速度.Text == "请输入")
            {
                mTextBoxEdit蜗室平均速度.Text = "";
            }
        }
 
        private void mTextBoxEdit蜗室平均速度_Leave(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(mTextBoxEdit蜗室平均速度.Text) || double.Parse(mTextBoxEdit蜗室平均速度.Text) == 0)
            {
                mTextBoxEdit蜗室平均速度.Text = "请输入";
            }
        }
 
        private void mTextBoxEdit蜗室平均速度_TextChanged(object sender, EventArgs e)
        {
            foreach (var s in mTextBoxEdit蜗室平均速度.Text)
            {
                if (!double.TryParse(mTextBoxEdit蜗室平均速度.Text, out double result) && !string.IsNullOrEmpty(mTextBoxEdit蜗室平均速度.Text) && mTextBoxEdit蜗室平均速度.Text != "请输入")
                {
                    mTextBoxEdit蜗室平均速度.UseAccent = true;
                    mTextBoxEdit蜗室平均速度.ShowAssistiveText = true;
                    mTextBoxEdit蜗室平均速度.Text = "";
                    break;
                }
                else
                {
                    mTextBoxEdit蜗室平均速度.ShowAssistiveText = false;
                    mTextBoxEdit蜗室平均速度.UseAccent = false;
                }
            }
        }
 
 
        private void skyTextBox断面VIIIy1_TextChanged(object sender, EventArgs e)
        {
            foreach (var s in skyTextBox断面VIIIy1.Text)
            {
                if (!double.TryParse(skyTextBox断面VIIIy1.Text, out double result) && !string.IsNullOrEmpty(skyTextBox断面VIIIy1.Text))
                {
                    skyTextBox断面VIIIy1.Text = "";
                    skyLabel提示y1.Visible = true;
                    break;
                }
            }
        }
 
        private void skyTextBox断面VIIIy2_TextChanged(object sender, EventArgs e)
        {
            foreach (var s in skyTextBox断面VIIIy2.Text)
            {
                if (!double.TryParse(skyTextBox断面VIIIy2.Text, out double result) && !string.IsNullOrEmpty(skyTextBox断面VIIIy2.Text))
                {
                    skyTextBox断面VIIIy2.Text = "";
                    skyLabel提示y2.Visible = true;
                    break;
                }
            }
        }
        private void skyTextBox断面VIIIy1_Enter(object sender, EventArgs e)
        {
            skyLabely1.Visible = false;
        }
 
        private void skyTextBox断面VIIIy2_Enter(object sender, EventArgs e)
        {
            skyLabely2.Visible = false;
        }
 
 
        private void mBtn计算断面面积_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(mTextBoxEdit蜗室平均速度.Text) || mTextBoxEdit蜗室平均速度.Text != "请输入蜗室平均速度")
            {
                skyLabel蜗室平均速度.Visible = true;
                MessageBox.Show("请先输入蜗室平均速度!");
                return;
            }
        }
 
        private void mlBtn更改断面角度_Click(object sender, EventArgs e)
        {
            if (!RBtn断面对称梯形.Checked && !RBtn不对称梯形.Checked && !RBtn矩形.Checked)
            {
                MessageBox.Show("请先选择断面类型!");
                return;
            }
            if (string.IsNullOrEmpty(skyTextBox断面VIIIy1.Text) || string.IsNullOrEmpty(skyTextBox断面VIIIy2.Text))
            {
                skyLabel提示y2.Visible = false;
                skyLabel提示y1.Visible = false;
                skyLabely1.Visible = true;
                skyLabely2.Visible = true;
                MessageBox.Show("请先输入y1、y2!");
                return;
            }
        }
 
 
        
    }
}