yangyin
2025-02-21 e15fa3fb9193f6635b7f4ddec526c061a8ee03ed
WinFrmUI/DPumpHydr.WinFrmUI.Volute/¶ÏÃæÉè¼Æ/ctrlSectionBundleInfo.cs
@@ -168,22 +168,34 @@
        ViewModel.SectionBundleInfo _sectionBundleInfo = null;
        ViewModel.HdrBaseInfo _hdrBaseInfo = null;
        ViewModel.GeomBaseInfo _geomBaseInfo = null;
        public void SetBindingData(ViewModel.SectionBundleInfo sectionBundle_info)
        {
            _sectionBundleInfo= sectionBundle_info;
        }
        public void ShowPage(
            ViewModel.HdrBaseInfo base_info,
            ViewModel.GeomBaseInfo geom_info,
            DPumpHydr.ViewModel.eWizardStepDiretion step_direction)
            DPumpHydr.ViewModel.eWizardStepDiretion step_direction, bool isRefreshModel = true)
        {
            if (step_direction == DPumpHydr.ViewModel.eWizardStepDiretion.后退)
            {
                return;
            }
            this._hdrBaseInfo = base_info;
            this._geomBaseInfo = geom_info;
            if(_hdrBaseInfo == null && _geomBaseInfo == null)
            {
                _hdrBaseInfo = base_info;
                _geomBaseInfo = geom_info;
            }
            if (isRefreshModel == false)
            {
                return;
            }
            if (_sectionBundleInfo == null)
            {
                this._hdrBaseInfo = base_info;
                this._geomBaseInfo = geom_info;
                _sectionBundleInfo = new ViewModel.SectionBundleInfo();
                _sectionBundleInfo.BaseWidth = _geomBaseInfo.B3;
@@ -193,18 +205,47 @@
            }
            else
            {
                if (Math.Abs(_sectionBundleInfo.BaseWidth - _geomBaseInfo.B3) < 1 ||
                    Math.Abs(_sectionBundleInfo.BaseCircleRadius - _geomBaseInfo.D3 / 2) < 1)
                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);
        }
@@ -222,6 +263,8 @@
            this.textBoxK3.Text = _sectionBundleInfo.K3.ToString();
            this.textBoxV3.Text = _sectionBundleInfo.V3.ToString();
            RefrehSectBundlePara();
            if (_sectionBundleInfo.ShapeType == eSectionShapeType.对称)
            {
                RBtn断面对称梯形.Checked = true;
@@ -240,8 +283,6 @@
                RBtn不对称梯形.Checked = false;
                RBtn矩形.Checked = true;
            }
            RefrehSectBundlePara();
        }
        //改面积
        public void RefreshSingleSectArea(int sectIndex, double area)
@@ -287,13 +328,15 @@
            _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)
                {
                    _sectionBundleInfo.GaMa_Left[argument] = Convert.ToDouble(controlY1.Text);
@@ -308,6 +351,8 @@
                if (control断面面积 != null)
                    _sectionBundleInfo.Area[argument] = Convert.ToDouble(control断面面积.Text);
                if (controlH != null)
                    _sectionBundleInfo.H[argument] = Convert.ToDouble(controlH.Text);
            }
@@ -323,13 +368,13 @@
                error = "请输入必填项!";
                isOk = false;
            }
            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;
@@ -454,15 +499,38 @@
            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)
            if (RBtn矩形.Checked)
            {
                controlr1.BackColor = Color.OrangeRed;
                MessageBox.Show("r不合理!请重新输入");
                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
            {
                controlr1.BackColor = Color.White;
                //目前这个只检测对称的 //若不对称更换半径角度等参数重新计算另一边x
                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)) || Convert.ToDouble(controlr1.Text) == 0)
                {
                    controlr1.BackColor = Color.OrangeRed;
                    MessageBox.Show("r不合理!请重新输入");
                }
                else
                {
                    controlr1.BackColor = Color.White;
                }
            }
            return isreasonable;
        }
@@ -482,7 +550,7 @@
                _sectionBundleInfo = new ViewModel.SectionBundleInfo();
            }
            _sectionBundleInfo.V3 = v3;
            _sectionBundleInfo.CalcParaV3(this._hdrBaseInfo, this._geomBaseInfo);
            _sectionBundleInfo.RecalculateArea(this._hdrBaseInfo, this._geomBaseInfo);
            RefrehSectBundlePara();
@@ -520,7 +588,9 @@
        {
            if (RBtn断面对称梯形.Checked)
            {
                skyTextBox断面y18.Enabled = true;
                RefrehSectBundlePara();
                RefreshShape(_sectionBundleInfo);
                //skyTextBox断面y18.Enabled = true;
                //skyTextBox断面r18.Enabled = false;
            }
        }
@@ -529,7 +599,9 @@
        {
            if (RBtn不对称梯形.Checked)
            {
                skyTextBox断面y18.Enabled = true;
                RefrehSectBundlePara();
                RefreshShape(_sectionBundleInfo);
                //skyTextBox断面y18.Enabled = true;
                //skyTextBox断面r18.Enabled = true;
            }
        }
@@ -616,6 +688,7 @@
                SkyTextBox control断面面积 = this.Controls.Find(controlname断面面积, true).FirstOrDefault() as SkyTextBox;
                SkyTextBox controH1 = this.Controls.Find(controlnameHeight, true).FirstOrDefault() as SkyTextBox;
                controly1.Enabled = true;
                if (controly1 != null)
                    controly1.Text = _sectionBundleInfo.GaMa_Left[sect_index].ToString();
                if (controly2 != null)
@@ -652,5 +725,49 @@
                HightLightSectCurve(index);
            }
        }
        private void btnNextStep_Click(object sender, EventArgs e)
        {
            NextStep();
        }
        private void RBtn矩形_CheckedChanged(object sender)
        {
            if (RBtn矩形.Checked)
            {
                //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);
            }
        }
    }
}