From 809cab44fa1cbea94d84c42cce94a35cc49ce5ad Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期一, 13 一月 2025 14:01:45 +0800 Subject: [PATCH] 断面总参数页圆半径 添加验证变色 --- WinFrmUI/DPumpHydr.WinFrmUI.Volute/断面设计/ctrlSectionBundleInfo.cs | 170 +++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 129 insertions(+), 41 deletions(-) diff --git "a/WinFrmUI/DPumpHydr.WinFrmUI.Volute/\346\226\255\351\235\242\350\256\276\350\256\241/ctrlSectionBundleInfo.cs" "b/WinFrmUI/DPumpHydr.WinFrmUI.Volute/\346\226\255\351\235\242\350\256\276\350\256\241/ctrlSectionBundleInfo.cs" index a09238c..f468870 100644 --- "a/WinFrmUI/DPumpHydr.WinFrmUI.Volute/\346\226\255\351\235\242\350\256\276\350\256\241/ctrlSectionBundleInfo.cs" +++ "b/WinFrmUI/DPumpHydr.WinFrmUI.Volute/\346\226\255\351\235\242\350\256\276\350\256\241/ctrlSectionBundleInfo.cs" @@ -5,6 +5,7 @@ using System.Drawing; using System.IO; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -24,110 +25,142 @@ BuildAllTips(); BuildIcon(); - skyTextBox鏂潰y18.Click += (ss,ee)=> { + skyTextBox鏂潰y18.Click += (ss, ee) => + { HightLightSectCurve(8); }; - skyTextBox鏂潰r18.Click += (ss, ee) => { + skyTextBox鏂潰r18.Click += (ss, ee) => + { HightLightSectCurve(8); }; - skyTextBox鏂潰H18.Click += (ss, ee) => { + skyTextBox鏂潰H18.Click += (ss, ee) => + { HightLightSectCurve(8); }; - crownLabelVIII.DoubleClick += (ss, ee) => { + crownLabelVIII.DoubleClick += (ss, ee) => + { HightLightSectCurve(8); }; - skyTextBox鏂潰y17.Click += (ss, ee) => { + skyTextBox鏂潰y17.Click += (ss, ee) => + { HightLightSectCurve(7); }; - skyTextBox鏂潰r17.Click += (ss, ee) => { + skyTextBox鏂潰r17.Click += (ss, ee) => + { HightLightSectCurve(7); }; - skyTextBox鏂潰H17.Click += (ss, ee) => { + skyTextBox鏂潰H17.Click += (ss, ee) => + { HightLightSectCurve(7); }; - crownLabelVII.DoubleClick += (ss, ee) => { + crownLabelVII.DoubleClick += (ss, ee) => + { HightLightSectCurve(7); }; - skyTextBox鏂潰y16.Click += (ss, ee) => { + skyTextBox鏂潰y16.Click += (ss, ee) => + { HightLightSectCurve(6); }; - skyTextBox鏂潰r16.Click += (ss, ee) => { + skyTextBox鏂潰r16.Click += (ss, ee) => + { HightLightSectCurve(6); }; - skyTextBox鏂潰H16.Click += (ss, ee) => { + skyTextBox鏂潰H16.Click += (ss, ee) => + { HightLightSectCurve(6); }; - crownLabelVI.DoubleClick += (ss, ee) => { + crownLabelVI.DoubleClick += (ss, ee) => + { HightLightSectCurve(6); }; - skyTextBox鏂潰y15.Click += (ss, ee) => { + skyTextBox鏂潰y15.Click += (ss, ee) => + { HightLightSectCurve(5); }; - skyTextBox鏂潰r15.Click += (ss, ee) => { + skyTextBox鏂潰r15.Click += (ss, ee) => + { HightLightSectCurve(5); }; - skyTextBox鏂潰H15.Click += (ss, ee) => { + skyTextBox鏂潰H15.Click += (ss, ee) => + { HightLightSectCurve(5); }; - crownLabelV.DoubleClick += (ss, ee) => { + crownLabelV.DoubleClick += (ss, ee) => + { HightLightSectCurve(5); }; - skyTextBox鏂潰y14.Click += (ss, ee) => { + skyTextBox鏂潰y14.Click += (ss, ee) => + { HightLightSectCurve(4); }; - skyTextBox鏂潰r14.Click += (ss, ee) => { + skyTextBox鏂潰r14.Click += (ss, ee) => + { HightLightSectCurve(4); }; - skyTextBox鏂潰H14.Click += (ss, ee) => { + skyTextBox鏂潰H14.Click += (ss, ee) => + { HightLightSectCurve(4); }; - crownLabelIV.DoubleClick += (ss, ee) => { + crownLabelIV.DoubleClick += (ss, ee) => + { HightLightSectCurve(4); }; - skyTextBox鏂潰y13.Click += (ss, ee) => { + skyTextBox鏂潰y13.Click += (ss, ee) => + { HightLightSectCurve(3); }; - skyTextBox鏂潰r13.Click += (ss, ee) => { + skyTextBox鏂潰r13.Click += (ss, ee) => + { HightLightSectCurve(3); }; - skyTextBox鏂潰H13.Click += (ss, ee) => { + skyTextBox鏂潰H13.Click += (ss, ee) => + { HightLightSectCurve(3); }; - crownLabelIII.DoubleClick += (ss, ee) => { + crownLabelIII.DoubleClick += (ss, ee) => + { HightLightSectCurve(3); }; - skyTextBox鏂潰y12.Click += (ss, ee) => { + skyTextBox鏂潰y12.Click += (ss, ee) => + { HightLightSectCurve(2); }; - skyTextBox鏂潰r12.Click += (ss, ee) => { + skyTextBox鏂潰r12.Click += (ss, ee) => + { HightLightSectCurve(2); }; - skyTextBox鏂潰H12.Click += (ss, ee) => { + skyTextBox鏂潰H12.Click += (ss, ee) => + { HightLightSectCurve(2); }; - crownLabelII.DoubleClick += (ss, ee) => { + crownLabelII.DoubleClick += (ss, ee) => + { HightLightSectCurve(2); }; - skyTextBox鏂潰y11.Click += (ss, ee) => { + skyTextBox鏂潰y11.Click += (ss, ee) => + { HightLightSectCurve(1); }; - skyTextBox鏂潰r11.Click += (ss, ee) => { + skyTextBox鏂潰r11.Click += (ss, ee) => + { HightLightSectCurve(1); }; - skyTextBox鏂潰H11.Click += (ss, ee) => { + skyTextBox鏂潰H11.Click += (ss, ee) => + { HightLightSectCurve(1); }; - crownLabelI.DoubleClick += (ss, ee) => { + crownLabelI.DoubleClick += (ss, ee) => + { HightLightSectCurve(1); }; } @@ -159,7 +192,7 @@ } else { - if(Math.Abs(_sectionBundleInfo.BaseWidth - _geomBaseInfo.B3)<1 || + if (Math.Abs(_sectionBundleInfo.BaseWidth - _geomBaseInfo.B3) < 1 || Math.Abs(_sectionBundleInfo.BaseCircleRadius - _geomBaseInfo.D3 / 2) < 1) { _sectionBundleInfo.BaseWidth = _geomBaseInfo.B3; @@ -172,7 +205,7 @@ RefreshAllSectPara(_sectionBundleInfo); - RefreshShape(_sectionBundleInfo); + RefreshShape(_sectionBundleInfo); } private void pictureBoxRefreshK3_Click(object sender, EventArgs e) { @@ -225,7 +258,7 @@ } - + public ViewModel.SectionBundleInfo GetBindingData(out string error) { if (!Verify(out error)) @@ -376,22 +409,61 @@ private void skyTextBox鏂潰VIIIy1_TextChanged(object sender, EventArgs e) { + if (sender is SkyTextBox skytextBox) { - if (!double.TryParse(skyTextBox鏂潰y18.Text, out double result) && !string.IsNullOrEmpty(skyTextBox鏂潰y18.Text)) + string lastChar = skytextBox.Name[skytextBox.Name.Length - 1].ToString(); + int index = Convert.ToInt32(lastChar); + if (!double.TryParse(skytextBox.Text, out double result) && !string.IsNullOrEmpty(skytextBox.Text)) { - skyTextBox鏂潰y18.Text = _sectionBundleInfo.GaMa_Left[8].ToString(); + skytextBox.Text = _sectionBundleInfo.GaMa_Left[index].ToString(); } } } private void skyTextBox鏂潰VIIIy2_TextChanged(object sender, EventArgs e) { + if (sender is SkyTextBox skytextBox) { - if (!double.TryParse(skyTextBox鏂潰r18.Text, out double result) && !string.IsNullOrEmpty(skyTextBox鏂潰r18.Text)) + string lastChar = skytextBox.Name[skytextBox.Name.Length - 1].ToString(); + int index = Convert.ToInt32(lastChar); + if (!double.TryParse(skytextBox.Text, out double result) && !string.IsNullOrEmpty(skytextBox.Text)) { - skyTextBox鏂潰r18.Text = _sectionBundleInfo.GaMa_Right[8].ToString(); + skytextBox.Text = _sectionBundleInfo.GaMa_Right[index].ToString(); + } + if (string.IsNullOrEmpty(skytextBox.Text)) + { + MessageBox.Show("r涓嶅悎鐞嗭紒璇烽噸鏂拌緭鍏�"); + } + + if (Convert.ToDouble(skytextBox.Text) != _sectionBundleInfo.R_Left[index]) + { + Judgment_R(index); + } + else + { + skytextBox.BackColor = Color.White; } } + + } + + public bool Judgment_R(int index) + { + bool isreasonable = true; + SkyTextBox controlr1 = this.Controls.Find($"skyTextBox鏂潰r1{index}", true).FirstOrDefault() as SkyTextBox; + SkyTextBox controlGaMa1 = this.Controls.Find($"skyTextBox鏂潰y1{index}", true).FirstOrDefault() as SkyTextBox; + SkyTextBox controlh1 = this.Controls.Find($"skyTextBox鏂潰H1{index}", true).FirstOrDefault() as SkyTextBox; + if (Convert.ToDouble(controlr1.Text) * (1 + Math.Sin(Convert.ToDouble(controlGaMa1.Text) * Math.PI / 180)) > Convert.ToDouble(controlh1.Text)|| Convert.ToDouble(controlr1.Text) == 0) + { + controlr1.BackColor = Color.OrangeRed; + MessageBox.Show("r涓嶅悎鐞嗭紒璇烽噸鏂拌緭鍏�"); + } + else + { + controlr1.BackColor = Color.White; + } + + return isreasonable; } @@ -476,7 +548,7 @@ this.textBoxV3.Text = Math.Round(K3 * Math.Sqrt(2 * g * _hdrBaseInfo.Q), 2).ToString(); } - public Func<ViewModel.SectionBundleInfo,List<int>> OnRefreshShape = null; + public Func<ViewModel.SectionBundleInfo, List<int>> OnRefreshShape = null; private void mBtn鏇存柊妯″瀷_Click(object sender, EventArgs e) { ViewModel.SectionBundleInfo paras = GetBindingData(out string error); @@ -525,7 +597,7 @@ public Action<int> OnHightLightSectCurve = null; private void HightLightSectCurve(int sectIndex) { - if(OnHightLightSectCurve != null) + if (OnHightLightSectCurve != null) OnHightLightSectCurve.Invoke(sectIndex); } @@ -553,5 +625,21 @@ controH1.Text = _sectionBundleInfo.H[sect_index].ToString(); } } + + private void skyTextBox鏂潰r17_TextChanged(object sender, EventArgs e) + { + if (!double.TryParse(skyTextBox鏂潰r17.Text, out double result) && !string.IsNullOrEmpty(skyTextBox鏂潰r17.Text)) + { + skyTextBox鏂潰r17.Text = _sectionBundleInfo.GaMa_Right[7].ToString(); + } + if (string.IsNullOrEmpty(skyTextBox鏂潰r17.Text)) + { + MessageBox.Show("r涓嶅悎鐞嗭紒璇烽噸鏂拌緭鍏�"); + } + if (Convert.ToDouble(skyTextBox鏂潰r17.Text) != _sectionBundleInfo.R_Left[7]) + { + Judgment_R(7); + } + } } } -- Gitblit v1.9.3