From 9dba1b6adc0bbb4aa8cc531f4e6d822bf1a56be3 Mon Sep 17 00:00:00 2001 From: chenn <gu.beic@qq.com> Date: 星期五, 28 三月 2025 17:45:48 +0800 Subject: [PATCH] 添加例子 --- WinFrmUI/DPumpHydr.WinFrmUI.Volute/断面设计/ctrlSectionBundleInfo.cs | 767 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 621 insertions(+), 146 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 cceb647..83b7c4a 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,10 +5,12 @@ using System.Drawing; using System.IO; using System.Linq; +using System.Reflection; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; -using DPumpHydr.WinFrmUI.RLT.Controls; +using DPumpHydr.WinFrmUI.RLT.Controls; using DPumpHydr.WinFrmUI.Volute.ViewModel; namespace DPumpHydr.WinFrmUI.Volute @@ -23,63 +25,287 @@ InitializeComponent(); BuildAllTips(); BuildIcon(); + + //skyTextBox鏂潰y18.Click += (ss, ee) => + //{ + // HightLightSectCurve(8); + //}; + //skyTextBox鏂潰r18.Click += (ss, ee) => + //{ + // HightLightSectCurve(8); + //}; + //skyTextBox鏂潰H18.Click += (ss, ee) => + //{ + // HightLightSectCurve(8); + //}; + crownLabelVIII.DoubleClick += (ss, ee) => + { + HightLightSectCurve(8); + }; + + //skyTextBox鏂潰y17.Click += (ss, ee) => + //{ + // HightLightSectCurve(7); + //}; + //skyTextBox鏂潰r17.Click += (ss, ee) => + //{ + // HightLightSectCurve(7); + //}; + //skyTextBox鏂潰H17.Click += (ss, ee) => + //{ + // HightLightSectCurve(7); + //}; + crownLabelVII.DoubleClick += (ss, ee) => + { + HightLightSectCurve(7); + }; + + + //skyTextBox鏂潰y16.Click += (ss, ee) => + //{ + // HightLightSectCurve(6); + //}; + //skyTextBox鏂潰r16.Click += (ss, ee) => + //{ + // HightLightSectCurve(6); + //}; + //skyTextBox鏂潰H16.Click += (ss, ee) => + //{ + // HightLightSectCurve(6); + //}; + crownLabelVI.DoubleClick += (ss, ee) => + { + HightLightSectCurve(6); + }; + + //skyTextBox鏂潰y15.Click += (ss, ee) => + //{ + // HightLightSectCurve(5); + //}; + //skyTextBox鏂潰r15.Click += (ss, ee) => + //{ + // HightLightSectCurve(5); + //}; + //skyTextBox鏂潰H15.Click += (ss, ee) => + //{ + // HightLightSectCurve(5); + //}; + crownLabelV.DoubleClick += (ss, ee) => + { + HightLightSectCurve(5); + }; + + //skyTextBox鏂潰y14.Click += (ss, ee) => + //{ + // HightLightSectCurve(4); + //}; + //skyTextBox鏂潰r14.Click += (ss, ee) => + //{ + // HightLightSectCurve(4); + //}; + //skyTextBox鏂潰H14.Click += (ss, ee) => + //{ + // HightLightSectCurve(4); + //}; + crownLabelIV.DoubleClick += (ss, ee) => + { + HightLightSectCurve(4); + }; + + + //skyTextBox鏂潰y13.Click += (ss, ee) => + //{ + // HightLightSectCurve(3); + //}; + //skyTextBox鏂潰r13.Click += (ss, ee) => + //{ + // HightLightSectCurve(3); + //}; + //skyTextBox鏂潰H13.Click += (ss, ee) => + //{ + // HightLightSectCurve(3); + //}; + crownLabelIII.DoubleClick += (ss, ee) => + { + HightLightSectCurve(3); + }; + + + //skyTextBox鏂潰y12.Click += (ss, ee) => + //{ + // HightLightSectCurve(2); + //}; + //skyTextBox鏂潰r12.Click += (ss, ee) => + //{ + // HightLightSectCurve(2); + //}; + //skyTextBox鏂潰H12.Click += (ss, ee) => + //{ + // HightLightSectCurve(2); + //}; + crownLabelII.DoubleClick += (ss, ee) => + { + HightLightSectCurve(2); + }; + + //skyTextBox鏂潰y11.Click += (ss, ee) => + //{ + // HightLightSectCurve(1); + //}; + //skyTextBox鏂潰r11.Click += (ss, ee) => + //{ + // HightLightSectCurve(1); + //}; + //skyTextBox鏂潰H11.Click += (ss, ee) => + //{ + // HightLightSectCurve(1); + //}; + crownLabelI.DoubleClick += (ss, ee) => + { + HightLightSectCurve(1); + }; } - ViewModel.SectionBundleInfo _paras = null; + + ViewModel.SectionBundleInfo _sectionBundleInfo = null; ViewModel.HdrBaseInfo _hdrBaseInfo = null; ViewModel.GeomBaseInfo _geomBaseInfo = null; - public void InitialParas(HdrBaseInfo BaseInfo, GeomBaseInfo geom_info) + public void SetBindingData(ViewModel.SectionBundleInfo sectionBundle_info) { - this._hdrBaseInfo = BaseInfo; - this._geomBaseInfo = geom_info; + _sectionBundleInfo = sectionBundle_info; } - public void SetBindingData(ViewModel.SectionBundleInfo vm) + + /// <summary> + /// 鏄剧ず鐣岄潰 + /// </summary> + /// <param name="base_info">鍩烘湰鍙傛暟</param> + /// <param name="geom_info">鍩哄渾鍙傛暟</param> + /// <param name="step_direction">鍓嶈繘/鍚庨��</param> + /// <param name="isRefreshModel">鏄惁闇�瑕佽鐩栨柇闈㈠弬鏁�</param> + public void ShowPage( + ViewModel.HdrBaseInfo base_info, + ViewModel.GeomBaseInfo geom_info, + DPumpHydr.ViewModel.eWizardStepDiretion step_direction, bool isRefreshModel = false) { - this._paras = vm; - if (vm == null) + if (step_direction == DPumpHydr.ViewModel.eWizardStepDiretion.鍚庨��) { return; } - this.mTextBoxEdit铚楀骞冲潎閫熷害.Text = vm.V3.ToString(); + if (_hdrBaseInfo == null && _geomBaseInfo == null) + { + _hdrBaseInfo = base_info; + _geomBaseInfo = geom_info; + } + if (!isRefreshModel) + { + return; + } + if (_sectionBundleInfo == null) + { + this._hdrBaseInfo = base_info; + this._geomBaseInfo = geom_info; + _sectionBundleInfo = new ViewModel.SectionBundleInfo(); - if (_paras.ShapeType == eSectionShapeType.瀵圭О) + _sectionBundleInfo.BaseWidth = _geomBaseInfo.B3; + _sectionBundleInfo.BaseCircleRadius = _geomBaseInfo.D3 / 2; + + _sectionBundleInfo.ResetAllParas(_hdrBaseInfo, _geomBaseInfo); + } + else + { + if (Math.Abs(_sectionBundleInfo.BaseWidth - _geomBaseInfo.B3) < 1 && + Math.Abs(_sectionBundleInfo.BaseCircleRadius - _geomBaseInfo.D3 / 2) < 1) + { + + _sectionBundleInfo.BaseWidth = _geomBaseInfo.B3; + _sectionBundleInfo.BaseCircleRadius = _geomBaseInfo.D3 / 2; + if (_hdrBaseInfo.n != base_info.n || _hdrBaseInfo.Q != base_info.Q || _hdrBaseInfo.H != base_info.H || _hdrBaseInfo.IsSXB != base_info.IsSXB) + { + this._hdrBaseInfo = base_info; + this._geomBaseInfo = geom_info; + _sectionBundleInfo.InitialK3(this._hdrBaseInfo, this._geomBaseInfo); + RefreshAllSectPara(_sectionBundleInfo); + _sectionBundleInfo.RecalculateArea(this._hdrBaseInfo, this._geomBaseInfo); + + RefrehSectBundlePara(); + + + if (OnRefreshShape != null) + { + ViewModel.SectionBundleInfo paras = GetBindingData(out string error); + if (paras == null) + return; + //textBox鍓茶垖瑙掑害 + OnRefreshShape.Invoke(paras); + } + //RefreshShape(_sectionBundleInfo); + } + else + { + this._hdrBaseInfo = base_info; + this._geomBaseInfo = geom_info; + RefreshShape(_sectionBundleInfo); + } + + return; + } + } + + RefreshAllSectPara(_sectionBundleInfo); + + RefreshShape(_sectionBundleInfo); + } + private void pictureBoxRefreshK3_Click(object sender, EventArgs e) + { + _sectionBundleInfo.InitialK3(this._hdrBaseInfo, this._geomBaseInfo); + + RefreshAllSectPara(_sectionBundleInfo); + } + // + public void RefreshAllSectPara(ViewModel.SectionBundleInfo paras) + { + this._sectionBundleInfo = paras; + + this.textBoxK3.Text = _sectionBundleInfo.K3.ToString(); + this.textBoxV3.Text = _sectionBundleInfo.V3.ToString(); + + + RefrehSectBundlePara(); + if (_sectionBundleInfo.ShapeType == eSectionShapeType.瀵圭О) { RBtn鏂潰瀵圭О姊舰.Checked = true; RBtn涓嶅绉版褰�.Checked = false; RBtn鐭╁舰.Checked = false; } - if (_paras.ShapeType == eSectionShapeType.涓嶅绉�) + if (_sectionBundleInfo.ShapeType == eSectionShapeType.涓嶅绉�) { RBtn鏂潰瀵圭О姊舰.Checked = false; RBtn涓嶅绉版褰�.Checked = true; RBtn鐭╁舰.Checked = false; } - if (_paras.ShapeType == eSectionShapeType.鐭╁舰) + if (_sectionBundleInfo.ShapeType == eSectionShapeType.鐭╁舰) { RBtn鏂潰瀵圭О姊舰.Checked = false; RBtn涓嶅绉版褰�.Checked = false; RBtn鐭╁舰.Checked = true; } - - RefrehPara(); } - private void RefrehPara() + //鏀归潰绉� + public void RefreshSingleSectArea(int sectIndex, double area) { - for (var argument = 1; argument <= 8; argument++) - { - var controlnameGama1 = $"skyTextBox鏂潰y1{argument}"; - var controlnameRia1 = $"skyTextBox鏂潰r1{argument}"; - var controlname鏂潰闈㈢Н = $"skyTextBox鏂潰闈㈢Н{argument}"; - SkyTextBox controly1 = this.Controls.Find(controlnameGama1, true).FirstOrDefault() as SkyTextBox; - SkyTextBox controly2 = this.Controls.Find(controlnameRia1, true).FirstOrDefault() as SkyTextBox; - SkyTextBox control鏂潰闈㈢Н = this.Controls.Find(controlname鏂潰闈㈢Н, true).FirstOrDefault() as SkyTextBox; - if (controly1 != null) - controly1.Text = _paras.GaMa_Left[argument].ToString(); - if (controly2 != null) - controly2.Text = _paras.R_Left[argument].ToString(); - if (control鏂潰闈㈢Н != null) - control鏂潰闈㈢Н.Text = _paras.Area[argument].ToString(); - } + if (this._sectionBundleInfo == null) + return; + this._sectionBundleInfo.Area[sectIndex] = area; + this._sectionBundleInfo.CalcHeightByArea(_geomBaseInfo, sectIndex); + + RefrehSectBundlePara(); + + if (OnRefreshShape == null) + return; + OnRefreshShape.Invoke(_sectionBundleInfo); } + + + public ViewModel.SectionBundleInfo GetBindingData(out string error) { if (!Verify(out error)) @@ -87,70 +313,74 @@ return null; } error = null; - if (_paras == null) + if (_sectionBundleInfo == null) { - _paras = new ViewModel.SectionBundleInfo(); + _sectionBundleInfo = new ViewModel.SectionBundleInfo(); } if (RBtn鏂潰瀵圭О姊舰.Checked) { - _paras.ShapeType = eSectionShapeType.瀵圭О; + _sectionBundleInfo.ShapeType = eSectionShapeType.瀵圭О; } if (RBtn涓嶅绉版褰�.Checked) { - _paras.ShapeType = eSectionShapeType.涓嶅绉�; + _sectionBundleInfo.ShapeType = eSectionShapeType.涓嶅绉�; } if (RBtn鐭╁舰.Checked) { - _paras.ShapeType = eSectionShapeType.鐭╁舰; + _sectionBundleInfo.ShapeType = eSectionShapeType.鐭╁舰; } - _paras.V3 = Convert.ToDouble(this.mTextBoxEdit铚楀骞冲潎閫熷害.Text); + _sectionBundleInfo.V3 = Convert.ToDouble(this.textBoxV3.Text); for (var argument = 1; argument <= 8; argument++) - { + {//skyTextBox鏂潰H18 var controlname_y1 = $"skyTextBox鏂潰y1{argument}"; var controlname_r1 = $"skyTextBox鏂潰r1{argument}"; var controlname鏂潰闈㈢Н = $"skyTextBox鏂潰闈㈢Н{argument}"; + var controlnameh = $"skyTextBox鏂潰H1{argument}"; SkyTextBox controlY1 = this.Controls.Find(controlname_y1, true).FirstOrDefault() as SkyTextBox; SkyTextBox controlR1 = this.Controls.Find(controlname_r1, true).FirstOrDefault() as SkyTextBox; SkyTextBox control鏂潰闈㈢Н = this.Controls.Find(controlname鏂潰闈㈢Н, true).FirstOrDefault() as SkyTextBox; + SkyTextBox controlH = this.Controls.Find(controlnameh, true).FirstOrDefault() as SkyTextBox; if (controlY1 != null) { - _paras.GaMa_Left[argument] = Convert.ToDouble(controlY1.Text); - _paras.GaMa_Right[argument] = _paras.GaMa_Left[argument]; + _sectionBundleInfo.GaMa_Left[argument] = Convert.ToDouble(controlY1.Text); + _sectionBundleInfo.GaMa_Right[argument] = _sectionBundleInfo.GaMa_Left[argument]; } - + if (controlR1 != null) { - _paras.R_Left[argument] = Convert.ToDouble(controlR1.Text); - _paras.R_Right[argument] = _paras.R_Left[argument]; + _sectionBundleInfo.R_Left[argument] = Convert.ToDouble(controlR1.Text); + _sectionBundleInfo.R_Right[argument] = _sectionBundleInfo.R_Left[argument]; } - - if (control鏂潰闈㈢Н != null) - _paras.Area[argument] = Convert.ToDouble(control鏂潰闈㈢Н.Text); - } - - return _paras; + if (control鏂潰闈㈢Н != null) + _sectionBundleInfo.Area[argument] = Convert.ToDouble(control鏂潰闈㈢Н.Text); + + if (controlH != null) + _sectionBundleInfo.H[argument] = Convert.ToDouble(controlH.Text); + } + + + return _sectionBundleInfo; } public bool Verify(out string error) { error = ""; bool isOk = true; - if (string.IsNullOrEmpty(mTextBoxEdit铚楀骞冲潎閫熷害.Text) || double.Parse(mTextBoxEdit铚楀骞冲潎閫熷害.Text) == 0) + double v3 = 0; + if (string.IsNullOrEmpty(textBoxV3.Text) || !double.TryParse(textBoxV3.Text, out v3) || v3 <= 0.1) { error = "璇疯緭鍏ュ繀濉」锛�"; isOk = false; - mTextBoxEdit铚楀骞冲潎閫熷害.TrailingIcon = GlobalResource.GetTipTrailingIcon(); - skyLabel铚楀骞冲潎閫熷害.Visible = true; } - if (string.IsNullOrEmpty(skyTextBox鏂潰y18.Text) || double.Parse(skyTextBox鏂潰y18.Text) == 0) + if (string.IsNullOrEmpty(skyTextBox鏂潰y18.Text) || (!RBtn鐭╁舰.Checked && double.Parse(skyTextBox鏂潰y18.Text) == 0) || double.Parse(skyTextBox鏂潰y18.Text) < 0) { error = "璇疯緭鍏ュ繀濉」锛�"; isOk = false; - + } - if (string.IsNullOrEmpty(skyTextBox鏂潰r18.Text) || double.Parse(skyTextBox鏂潰r18.Text) == 0) + if (string.IsNullOrEmpty(skyTextBox鏂潰r18.Text) || (!RBtn鐭╁舰.Checked && double.Parse(skyTextBox鏂潰r18.Text) == 0) || double.Parse(skyTextBox鏂潰y18.Text) < 0) { error = "璇疯緭鍏ュ繀濉」锛�"; isOk = false; @@ -160,27 +390,27 @@ public bool IsParameterChange() { - if (double.Parse(mTextBoxEdit铚楀骞冲潎閫熷害.Text) != this._paras.V3) + if (double.Parse(textBoxV3.Text) != this._sectionBundleInfo.V3) { return true; } - if (RBtn鏂潰瀵圭О姊舰.Checked && this._paras.ShapeType == eSectionShapeType.瀵圭О) + if (RBtn鏂潰瀵圭О姊舰.Checked && this._sectionBundleInfo.ShapeType == eSectionShapeType.瀵圭О) { return true; } - if (RBtn涓嶅绉版褰�.Checked && this._paras.ShapeType == eSectionShapeType.涓嶅绉�) + if (RBtn涓嶅绉版褰�.Checked && this._sectionBundleInfo.ShapeType == eSectionShapeType.涓嶅绉�) { return true; } - if (RBtn鐭╁舰.Checked && this._paras.ShapeType == eSectionShapeType.鐭╁舰) + if (RBtn鐭╁舰.Checked && this._sectionBundleInfo.ShapeType == eSectionShapeType.鐭╁舰) { return true; } - if (double.Parse(skyTextBox鏂潰y18.Text) != this._paras.GaMa_Left[8]) + if (double.Parse(skyTextBox鏂潰y18.Text) != this._sectionBundleInfo.GaMa_Left[8]) { return true; } - if (double.Parse(skyTextBox鏂潰r18.Text) != this._paras.GaMa_Right[8]) + if (double.Parse(skyTextBox鏂潰r18.Text) != this._sectionBundleInfo.GaMa_Right[8]) { return true; } @@ -190,9 +420,6 @@ private void BuildIcon() { - //瀵硅瘽妗嗗墠缂�鍥剧墖 - mTextBoxEdit铚楀骞冲潎閫熷害.LeadingIcon = GlobalResource.GetLeadingIcon(); - //鏂潰褰㈢姸鍥剧墖 metroTile瀵圭О姊舰.BackgroundImage = GlobalResource.BuildImage("duichentixing.png", 97, 88); metroTile涓嶅绉版褰�.BackgroundImage = GlobalResource.BuildImage("buduichentixing.png", 97, 88); @@ -201,19 +428,17 @@ private void BuildAllTips() { - metroToolTip绗笁姝ユ彁绀�.SetToolTip(this.metroTile瀵圭О姊舰, "瀵圭О姊舰"); - metroToolTip绗笁姝ユ彁绀�.SetToolTip(this.metroTile涓嶅绉版褰�, "涓嶅绉版褰�"); - metroToolTip绗笁姝ユ彁绀�.SetToolTip(this.metroTile鐭╁舰, "鐭╁舰"); - metroToolTip绗笁姝ユ彁绀�.SetToolTip(this.mTextBoxEdit铚楀骞冲潎閫熷害, "娑蹭綋鍦ㄨ湕瀹ゅ唴娴佸姩\n鏃剁殑骞冲潎閫熷害"); - metroToolTip绗笁姝ユ彁绀�.SetToolTip(this.skyTextBox鏂潰y18, "y1 瑙i噴"); - metroToolTip绗笁姝ユ彁绀�.SetToolTip(this.skyTextBox鏂潰r18, "y2 瑙i噴"); + //metroToolTip鎻愮ず.SetToolTip(this.metroTile瀵圭О姊舰, "瀵圭О姊舰"); + //metroToolTip鎻愮ず.SetToolTip(this.metroTile涓嶅绉版褰�, "涓嶅绉版褰�"); + //metroToolTip鎻愮ず.SetToolTip(this.metroTile鐭╁舰, "鐭╁舰"); + //metroToolTip鎻愮ず.SetToolTip(this.skyTextBox鏂潰y18, "y1 瑙i噴"); + //metroToolTip鎻愮ず.SetToolTip(this.skyTextBox鏂潰r18, "y2 瑙i噴"); } 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) @@ -230,118 +455,176 @@ RBtn鐭╁舰.Checked = true; } - private void mTextBoxEdit铚楀骞冲潎閫熷害_Enter(object sender, EventArgs e) - { - skyLabel铚楀骞冲潎閫熷害.Visible = false; - mTextBoxEdit铚楀骞冲潎閫熷害.TrailingIcon = null; - } - private void mTextBoxEdit铚楀骞冲潎閫熷害_Leave(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(mTextBoxEdit铚楀骞冲潎閫熷害.Text) || double.Parse(mTextBoxEdit铚楀骞冲潎閫熷害.Text) == 0) - { - mTextBoxEdit铚楀骞冲潎閫熷害.Text = _paras.V3.ToString(); - } - } - 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铚楀骞冲潎閫熷害.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鏂潰y18.Text) + 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 = _paras.GaMa_Left[8].ToString(); - - break; + result = _sectionBundleInfo.GaMa_Left[index]; + skytextBox.Text = _sectionBundleInfo.GaMa_Left[index].ToString(); + }else if(result>45) + { + MessageBox.Show("璇疯緭鍏ュ皬浜�45搴︾殑瑙掑害"); + skytextBox.Text = _sectionBundleInfo.GaMa_Left[index].ToString(); + } + else + { + //var initialR = _sectionBundleInfo.CalInitialR(_hdrBaseInfo, _geomBaseInfo); + var height = _sectionBundleInfo.CalcHeight(_geomBaseInfo, index, result, _sectionBundleInfo.R_Left[index]); + var R = _sectionBundleInfo.CheckChamferR(height, index, result, _sectionBundleInfo.R_Left[index]); + SkyTextBox controlh1 = this.Controls.Find($"skyTextBox鏂潰H1{index}", true).FirstOrDefault() as SkyTextBox; + SkyTextBox controlr1 = this.Controls.Find($"skyTextBox鏂潰r1{index}", true).FirstOrDefault() as SkyTextBox; + controlh1.Text = height.ToString(); + controlr1.Text = R.ToString(); } } } private void skyTextBox鏂潰VIIIy2_TextChanged(object sender, EventArgs e) { - foreach (var s in skyTextBox鏂潰r18.Text) + 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 = _paras.GaMa_Right[8].ToString(); - //skyLabel鎻愮ずy2.Visible = true; - break; + skytextBox.Text = _sectionBundleInfo.GaMa_Right[index].ToString(); + } + if (string.IsNullOrEmpty(skytextBox.Text) || Convert.ToDouble(skytextBox.Text) == 0) + { + MessageBox.Show("r涓嶅悎鐞嗭紒璇烽噸鏂拌緭鍏�"); + } + double v = 0; + if (!double.TryParse(skytextBox.Text, out v)) + { + MessageBox.Show("璇疯緭鍏ユ暟瀛楁牸寮忥紒"); + return; + } + if (Convert.ToDouble(skytextBox.Text) != _sectionBundleInfo.R_Left[index]) + { + Judgment_R(index); + } + else + { + skytextBox.BackColor = Color.White; } } - } - private void skyTextBox鏂潰VIIIy1_Enter(object sender, EventArgs e) - { - + } - private void skyTextBox鏂潰VIIIy2_Enter(object sender, EventArgs e) + private bool Judgment_R(int index) { - //skyLabely2.Visible = false; + 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 (string.IsNullOrEmpty(controlr1.Text)) + return true; + if (string.IsNullOrEmpty(controlGaMa1.Text)) + return true; + if (string.IsNullOrEmpty(controlh1.Text)) + return true; + + if (RBtn鐭╁舰.Checked) + { + if (Convert.ToDouble(controlh1.Text) - Convert.ToDouble(controlr1.Text) < 1 || _sectionBundleInfo.BaseWidth - (Convert.ToDouble(controlr1.Text) * 2) < 1) + { + controlr1.BackColor = Color.OrangeRed; + MessageBox.Show("r涓嶅悎鐞嗭紒璇烽噸鏂拌緭鍏�"); + } + else + { + controlr1.BackColor = Color.White; + } + } + else + { + //鐩墠杩欎釜鍙娴嬪绉扮殑 //鑻ヤ笉瀵圭О鏇存崲鍗婂緞瑙掑害绛夊弬鏁伴噸鏂拌绠楀彟涓�杈箈 + var x = Math.Tan(Convert.ToDouble(controlGaMa1.Text) * Math.PI / 180) * Convert.ToDouble(controlh1.Text) + - (Math.Tan(Convert.ToDouble(controlGaMa1.Text) * Math.PI / 180) * Math.Tan(Convert.ToDouble(controlGaMa1.Text) / 2 * Math.PI / 180) * Convert.ToDouble(controlr1.Text)) + - (Math.Tan(Convert.ToDouble(controlGaMa1.Text) * Math.PI / 180) * Convert.ToDouble(controlr1.Text)) - Convert.ToDouble(controlr1.Text); + var c = _sectionBundleInfo.R_out / 1000; + var TopWidth = _sectionBundleInfo.BaseWidth + (2 * x); + var Slash = (Convert.ToDouble(controlh1.Text) - Convert.ToDouble(controlr1.Text) - (Math.Sin(Convert.ToDouble(controlGaMa1.Text) * Math.PI / 180) * Convert.ToDouble(controlr1.Text))) / Math.Cos(Convert.ToDouble(controlGaMa1.Text) * Math.PI / 180); + if ((!RBtn鐭╁舰.Checked && (TopWidth < c || Slash < c - 0.1))) // + { + controlr1.BackColor = Color.OrangeRed; + MessageBox.Show("r涓嶅悎鐞嗭紒璇烽噸鏂拌緭鍏�"); + } + else + { + controlr1.BackColor = Color.White; + } + } + + + return isreasonable; } + private void mBtn璁$畻鏂潰闈㈢Н_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(mTextBoxEdit铚楀骞冲潎閫熷害.Text) || mTextBoxEdit铚楀骞冲潎閫熷害.Text == "璇疯緭鍏ヨ湕瀹ゅ钩鍧囬�熷害") + double v3 = 0; + if (string.IsNullOrEmpty(textBoxV3.Text) || !double.TryParse(textBoxV3.Text, out v3) || v3 <= 0.1) { - skyLabel铚楀骞冲潎閫熷害.Visible = true; MessageBox.Show("璇峰厛杈撳叆铚楀骞冲潎閫熷害锛�"); return; } - if (_paras == null) + if (_sectionBundleInfo == null) { - _paras = new ViewModel.SectionBundleInfo(); + _sectionBundleInfo = new ViewModel.SectionBundleInfo(); } - double v3 = Convert.ToDouble(mTextBoxEdit铚楀骞冲潎閫熷害.Text); - _paras.V3 = v3; - _paras.CalcParaV3(this._hdrBaseInfo,this._geomBaseInfo, v3); - RefrehPara(); + _sectionBundleInfo.V3 = v3; + _sectionBundleInfo.RecalculateArea(this._hdrBaseInfo, this._geomBaseInfo); + + RefrehSectBundlePara(); + + + if (OnRefreshShape != null) + { + ViewModel.SectionBundleInfo paras = GetBindingData(out string error); + if (paras == null) + return; + //textBox鍓茶垖瑙掑害 + OnRefreshShape.Invoke(paras); + } + } private void mlBtn鏇存敼鏂潰瑙掑害_Click(object sender, EventArgs e) { - if (!RBtn鏂潰瀵圭О姊舰.Checked && !RBtn涓嶅绉版褰�.Checked && !RBtn鐭╁舰.Checked) - { - MessageBox.Show("璇峰厛閫夋嫨鏂潰绫诲瀷锛�"); - return; - } - if (string.IsNullOrEmpty(skyTextBox鏂潰y18.Text) || string.IsNullOrEmpty(skyTextBox鏂潰r18.Text)) - { - //skyLabel鎻愮ずy2.Visible = false; - //skyLabel鎻愮ずy1.Visible = false; - //skyLabely1.Visible = true; - //skyLabely2.Visible = true; - //MessageBox.Show("璇峰厛杈撳叆y1銆亂2锛�"); - return; - } + //if (!RBtn鏂潰瀵圭О姊舰.Checked && !RBtn涓嶅绉版褰�.Checked && !RBtn鐭╁舰.Checked) + //{ + // MessageBox.Show("璇峰厛閫夋嫨鏂潰绫诲瀷锛�"); + // return; + //} + //if (string.IsNullOrEmpty(skyTextBox鏂潰y18.Text) || string.IsNullOrEmpty(skyTextBox鏂潰r18.Text)) + //{ + // //skyLabel鎻愮ずy2.Visible = false; + // //skyLabel鎻愮ずy1.Visible = false; + // //skyLabely1.Visible = true; + // //skyLabely2.Visible = true; + // //MessageBox.Show("璇峰厛杈撳叆y1銆亂2锛�"); + // return; + //} } private void RBtn鏂潰瀵圭О姊舰_CheckedChanged(object sender) { if (RBtn鏂潰瀵圭О姊舰.Checked) { - skyTextBox鏂潰y18.Enabled = true; - skyTextBox鏂潰r18.Enabled = false; + RefrehSectBundlePara(); + RefreshShape(_sectionBundleInfo); + //skyTextBox鏂潰y18.Enabled = true; + //skyTextBox鏂潰r18.Enabled = false; } } @@ -349,20 +632,212 @@ { if (RBtn涓嶅绉版褰�.Checked) { - skyTextBox鏂潰y18.Enabled = true; - skyTextBox鏂潰r18.Enabled = true; + RefrehSectBundlePara(); + RefreshShape(_sectionBundleInfo); + //skyTextBox鏂潰y18.Enabled = true; + //skyTextBox鏂潰r18.Enabled = true; } } - public Action<ViewModel.SectionBundleInfo> OnRefreshShape = null; - private void materialButton1_Click(object sender, EventArgs e) + + + private void textBoxK3_TextChanged(object sender, EventArgs e) + { + double K3 = 0; + if (string.IsNullOrEmpty(textBoxK3.Text)) + return; + if (!double.TryParse(textBoxK3.Text, out K3)) + return; + if (K3 < 0.1) + return; + + var g = 9.81; + this.textBoxV3.Text = Math.Round(K3 * Math.Sqrt(2 * g * _hdrBaseInfo.H), 2).ToString(); + } + + public Func<ViewModel.SectionBundleInfo, List<int>> OnRefreshShape = null; + private void mBtn鏇存柊妯″瀷_Click(object sender, EventArgs e) { ViewModel.SectionBundleInfo paras = GetBindingData(out string error); if (paras == null) return; + + RefreshShape(paras); + + } + + private void RefreshShape(ViewModel.SectionBundleInfo paras) + { if (OnRefreshShape == null) return; - //paras.InitialAllParameters(this._hdrBaseInfo,this._geomBaseInfo); - OnRefreshShape.Invoke(paras); + var error_sects = OnRefreshShape.Invoke(paras); + + for (var sect_index = 1; sect_index <= 8; sect_index++) + { + var controlnameGama1 = $"skyTextBox鏂潰y1{sect_index}"; + var controlnameRia1 = $"skyTextBox鏂潰r1{sect_index}"; + var controlname鏂潰闈㈢Н = $"skyTextBox鏂潰闈㈢Н{sect_index}"; + var controlnameHeight = $"skyTextBox鏂潰H1{sect_index}"; + + SkyTextBox controly1 = this.Controls.Find(controlnameGama1, true).FirstOrDefault() as SkyTextBox; + SkyTextBox controly2 = this.Controls.Find(controlnameRia1, true).FirstOrDefault() as SkyTextBox; + SkyTextBox control鏂潰闈㈢Н = this.Controls.Find(controlname鏂潰闈㈢Н, true).FirstOrDefault() as SkyTextBox; + SkyTextBox controH1 = this.Controls.Find(controlnameHeight, true).FirstOrDefault() as SkyTextBox; + + + if (error_sects != null && error_sects.Contains(sect_index)) + { + controly1.BackColor = Color.OrangeRed; + controly2.BackColor = Color.OrangeRed; + control鏂潰闈㈢Н.BackColor = Color.OrangeRed; + controH1.BackColor = Color.OrangeRed; + } + else + { + controly1.BackColor = Color.White; + controly2.BackColor = Color.White; + control鏂潰闈㈢Н.BackColor = Color.White; + controH1.BackColor = Color.White; + } + } + } + public Action<int> OnHightLightSectCurve = null; + private void HightLightSectCurve(int sectIndex) + { + if (OnHightLightSectCurve != null) + OnHightLightSectCurve.Invoke(sectIndex); + } + + private void RefrehSectBundlePara() + { + for (var sect_index = 1; sect_index <= 8; sect_index++) + { + var controlnameGama1 = $"skyTextBox鏂潰y1{sect_index}"; + var controlnameRia1 = $"skyTextBox鏂潰r1{sect_index}"; + var controlname鏂潰闈㈢Н = $"skyTextBox鏂潰闈㈢Н{sect_index}"; + var controlnameHeight = $"skyTextBox鏂潰H1{sect_index}"; + + SkyTextBox controly1 = this.Controls.Find(controlnameGama1, true).FirstOrDefault() as SkyTextBox; + SkyTextBox controly2 = this.Controls.Find(controlnameRia1, true).FirstOrDefault() as SkyTextBox; + SkyTextBox control鏂潰闈㈢Н = this.Controls.Find(controlname鏂潰闈㈢Н, true).FirstOrDefault() as SkyTextBox; + SkyTextBox controH1 = this.Controls.Find(controlnameHeight, true).FirstOrDefault() as SkyTextBox; + + controly1.Enabled = true; + if (control鏂潰闈㈢Н != null) + control鏂潰闈㈢Н.Text = Math.Round(_sectionBundleInfo.Area[sect_index], 1).ToString(); + if (controH1 != null) + controH1.Text = Math.Round(_sectionBundleInfo.H[sect_index], 1).ToString(); + if (controly2 != null) + controly2.Text = Math.Round(_sectionBundleInfo.R_Left[sect_index], 1).ToString(); + if (controly1 != null) + controly1.Text = Math.Round(_sectionBundleInfo.GaMa_Left[sect_index], 1).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); + } + } + + private void skyTextBox鏂潰y11_Enter(object sender, EventArgs e) + { + if (sender is SkyTextBox skytextBox) + { + string lastChar = skytextBox.Name[skytextBox.Name.Length - 1].ToString(); + int index = Convert.ToInt32(lastChar); + HightLightSectCurve(index); + } + } + + private void btnNextStep_Click(object sender, EventArgs e) + { + NextStep(); + } + + private void RBtn鐭╁舰_CheckedChanged(object sender) + { + if (RBtn鐭╁舰.Checked) + { + if(_sectionBundleInfo.GaMa_Left.All(x => x == 0)) + { + for (var sect_index = 1; sect_index <= 8; sect_index++) + { + var controlnameGama1 = $"skyTextBox鏂潰y1{sect_index}"; + SkyTextBox controly1 = this.Controls.Find(controlnameGama1, true).FirstOrDefault() as SkyTextBox; + controly1.Enabled = false; + } + return; + } + //for (var sect_index = 1; sect_index <= 8; sect_index++) + //{ + // var controlnameGama1 = $"skyTextBox鏂潰y1{sect_index}"; + // SkyTextBox controly1 = this.Controls.Find(controlnameGama1, true).FirstOrDefault() as SkyTextBox; + // controly1.Text = "0"; + // controly1.Enabled = false; + //} + ViewModel.SectionBundleInfo Rec_sectionBundleInfo = _sectionBundleInfo.Copy(); + Rec_sectionBundleInfo.ShapeType = eSectionShapeType.鐭╁舰; + Rec_sectionBundleInfo.ResetAllParas(_hdrBaseInfo, _geomBaseInfo); + for (var sect_index = 1; sect_index <= 8; sect_index++) + { + var controlnameGama1 = $"skyTextBox鏂潰y1{sect_index}"; + var controlnameRia1 = $"skyTextBox鏂潰r1{sect_index}"; + var controlname鏂潰闈㈢Н = $"skyTextBox鏂潰闈㈢Н{sect_index}"; + var controlnameHeight = $"skyTextBox鏂潰H1{sect_index}"; + + SkyTextBox controly1 = this.Controls.Find(controlnameGama1, true).FirstOrDefault() as SkyTextBox; + SkyTextBox controly2 = this.Controls.Find(controlnameRia1, true).FirstOrDefault() as SkyTextBox; + SkyTextBox control鏂潰闈㈢Н = this.Controls.Find(controlname鏂潰闈㈢Н, true).FirstOrDefault() as SkyTextBox; + SkyTextBox controH1 = this.Controls.Find(controlnameHeight, true).FirstOrDefault() as SkyTextBox; + controly1.Enabled = false; + if (controly1 != null) + controly1.Text = Rec_sectionBundleInfo.GaMa_Left[sect_index].ToString(); + if (controly2 != null) + controly2.Text = Rec_sectionBundleInfo.R_Left[sect_index].ToString(); + if (control鏂潰闈㈢Н != null) + control鏂潰闈㈢Н.Text = Rec_sectionBundleInfo.Area[sect_index].ToString(); + if (controH1 != null) + controH1.Text = Rec_sectionBundleInfo.H[sect_index].ToString(); + } + RefreshShape(Rec_sectionBundleInfo); + } + } + + private void skyTextBox鏂潰H11_TextChanged(object sender, EventArgs e) + { + if (sender is SkyTextBox skytextBox) + { + string lastChar = skytextBox.Name[skytextBox.Name.Length - 1].ToString(); + int index = Convert.ToInt32(lastChar); + if (!double.TryParse(skytextBox.Text, out double resultH) && !string.IsNullOrEmpty(skytextBox.Text)) + { + resultH = _sectionBundleInfo.H[index]; + skytextBox.Text = _sectionBundleInfo.H[index].ToString(); + } + else + { + SkyTextBox controlGaMa1 = this.Controls.Find($"skyTextBox鏂潰y1{index}", true).FirstOrDefault() as SkyTextBox; + SkyTextBox controlr1 = this.Controls.Find($"skyTextBox鏂潰r1{index}", true).FirstOrDefault() as SkyTextBox; + if (!double.TryParse(controlGaMa1.Text, out double resultGame) && !string.IsNullOrEmpty(controlGaMa1.Text)) + { + resultH = _sectionBundleInfo.GaMa_Left[index]; + } + var R = _sectionBundleInfo.HCalR(_geomBaseInfo, index, resultGame, resultH); + R = _sectionBundleInfo.CheckChamferR(resultH, index, resultH, R); + skytextBox.Text = resultH.ToString(); + controlr1.Text = R.ToString(); + } + } } } } -- Gitblit v1.9.3