tangxu
2024-11-02 399c534c415062b08ee5a00fb2c36608f4b3c7ff
WinFrmUI/DPumpHydr.WinFrmUI.Volute/MainViewPage_StepInfo.cs
@@ -1,5 +1,4 @@

using System;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
@@ -10,6 +9,14 @@
{
    public partial class MainViewPage  
    {
        //
        ctrlHdrBaseInfo _ctrlHdrBaseInfo = null;
        ctrlGeomBaseInfo _ctrlGeomBaseInfo = null;
        ctrlSectionBaseInfo _ctrlSectionBaseInfo = null;
        ctrlSectionShapeInfo18 _ctrlSectionShapeInfo18 = null;
        ctrlSetOutflowStyle _ctrlSetOutflowStyle = null;
        ctrlSetOutflowDim _ctrlSetOutflowDim = null;
        //基础信息
        private readonly string Group_Name_Base_Info = "BaseInfo";
        private readonly int Group_ID_Base_Info = -1;//组ID
@@ -30,11 +37,12 @@
        private long Step_ID_Outflow_Style = 31;
        private long Step_ID_Outflow_Dim = 32;
        //
        private List<DPumpHydr.WinFrmUI.Volute.TreeStepNode> _allStepNodes = null;
         
        private long _currentStepID = 0;
        /// <summary>
        /// 下一步
        /// </summary>
@@ -52,71 +60,216 @@
        {
            return GoPrevStepCore();
        }
        ViewModel.HdrBaseInfo _hdrBaseInfo = null;
        ViewModel.GeomBaseInfo _geomBaseInfo = null;
        ViewModel.SectionBaseInfo _sectionBaseInfo = null;
        ViewModel.SectionShapePara _sectionShapePara = null;
        DPumpHydr.WinFrmUI.Volute.TreeStepNode next_step = null;
        int _currentSectIndex;
        /// <summary>
        /// 下一步核心
        /// </summary>
        /// <returns></returns>
        private bool GoNextStepCore()
        {
            var next_step = (from x in _allStepNodes
                             where x.ID > _currentStepID
                             orderby x.ID
                             select x).FirstOrDefault();
            if (next_step == null)
                return false;
            if (_currentStepID != Step_ID_Section18_Dim || _currentSectIndex>8 || _currentSectIndex<=1)
            {
                _currentSectIndex = 9;
                next_step = (from x in _allStepNodes
                                 where x.ID > _currentStepID
                                 orderby x.ID
                                 select x).FirstOrDefault();
                if (next_step == null)
                    return false;
            }
            //第一步进行下一步点击
            if(_currentStepID == Step_ID_Hdr_Base_Info)
            {
                string error_info;
                var hdrBaseInfo = _ctrlHdrBaseInfo.GetBindingData(out error_info);
                if(hdrBaseInfo == null)
                {
                    MessageBox.Show(error_info);
                    return false;
                }
                hdrBaseInfo.CalcNs();
                _hdrBaseInfo = hdrBaseInfo;
                if(_geomBaseInfo == null)
                {
                    _geomBaseInfo = new ViewModel.GeomBaseInfo();
                }
                _geomBaseInfo.Calc(_hdrBaseInfo);
            }
            //第二步进行下一步点击
            if (_currentStepID == Step_ID_Geom_Base_Info)
            {
                string error_info;
                var geomBaseInfo = _ctrlGeomBaseInfo.GetBindingData(out error_info);
                if (geomBaseInfo == null)
                {
                    MessageBox.Show(error_info);
                    return false;
                }
                _geomBaseInfo = geomBaseInfo;
                if(_sectionBaseInfo == null)
                {
                    _sectionBaseInfo = new ViewModel.SectionBaseInfo();
                }
                _sectionBaseInfo.CalcV3(_hdrBaseInfo, _geomBaseInfo);
                _sectionBaseInfo.CalcArea(_hdrBaseInfo, _geomBaseInfo, _sectionBaseInfo.V3);
                _sectionBaseInfo.IntialShapeType(_hdrBaseInfo, _geomBaseInfo, _sectionBaseInfo.ShapeType);
            }
            //第三步进行下一步点击
            if (_currentStepID == Step_ID_Section18_Base)
            {
                string error_info;
                var sectionBaseInfo = _ctrlSectionBaseInfo.GetBindingData(out error_info);
                if (sectionBaseInfo == null)
                {
                    MessageBox.Show(error_info);
                    return false;
                }
                _sectionBaseInfo = sectionBaseInfo;
                _sectionBaseInfo.InitialAllParameters(_hdrBaseInfo, _geomBaseInfo);
                _currentSectIndex--;
                if (_sectionShapePara == null)
                {
                    _sectionShapePara = new ViewModel.SectionShapePara();
                }
                _sectionShapePara.Initialparameters(_currentSectIndex, _sectionBaseInfo);
            }
            //1-8断面进行下一步点击
            if (_currentStepID == Step_ID_Section18_Dim)
            {
                string error_info;
                var sectionShapeInfo18 = _ctrlSectionShapeInfo18.GetBindingData(out error_info);
                if (sectionShapeInfo18 == null)
                {
                    MessageBox.Show(error_info);
                    return false;
                }
                _sectionShapePara = sectionShapeInfo18;
                _sectionShapePara.CalcHeightByArea(_sectionBaseInfo.ShapeType);
                _sectionBaseInfo.EditSingleShape(_sectionShapePara, _currentSectIndex);
                if(_currentSectIndex != 9)
                {
                    _currentSectIndex--;
                }
                _sectionShapePara.Initialparameters(_currentSectIndex, _sectionBaseInfo);
            }
            SetParasCtrl(next_step.ID);
 
            return true;
        }
        /// <summary>
        /// 上一步核心
        /// </summary>
        /// <returns></returns>
        private bool GoPrevStepCore()
        {
        {
            //bool IsChanges = true;
            //if (_currentStepID == Step_ID_Section18_Base && _ctrlSectionBaseInfo.IsParameterChange())
            //{
            //    IsChanges = false;
            //}
            //if(IsChanges)
            //{
            //    DialogResult result = MessageBox.Show("已经修改过的数据需要保存吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            //    if (result == DialogResult.OK)
            //    {
            //        string error_info = "";
            //        var hdrBaseInfo = _ctrlSectionBaseInfo.GetBindingData(out error_info);
            //        if (hdrBaseInfo == null)
            //        {
            //            MessageBox.Show(error_info);
            //            return false;
            //        }
            //    }
            //}
            if (_currentStepID == Step_ID_Hdr_Base_Info)
                return false;
            if(_currentStepID == Step_ID_Section18_Dim && _currentSectIndex >=1 &&_currentSectIndex < 8)
            {
                _currentSectIndex++;
                _sectionShapePara.Initialparameters(_currentSectIndex, _sectionBaseInfo);
                SetParasCtrl(Step_ID_Section18_Dim);
                return true;
            }
            if(_currentStepID == Step_ID_Outflow_Style)
            {
                _currentSectIndex = 1;
                _sectionShapePara.Initialparameters(_currentSectIndex, _sectionBaseInfo);
            }
            var prev_step = (from x in _allStepNodes
                             where x.ID < _currentStepID
                             orderby x.ID
                             select x).LastOrDefault();
                                where x.ID < _currentStepID
                                orderby x.ID
                                select x).LastOrDefault();
            if (prev_step == null)
                return false;
            SetParasCtrl(prev_step.ID);
                SetParasCtrl(prev_step.ID);
            return true;
        }
        /// <summary>
        /// 生成第几步控件
        /// </summary>
        /// <param name="step_id"></param>
        private void SetParasCtrl(long step_id)
        {   
            //第一步
            if (step_id == Step_ID_Hdr_Base_Info)
            {
                if (_ctrlHdrBaseInfo == null)
                    _ctrlHdrBaseInfo = new ctrlHdrBaseInfo();
              //  dockPanel2.Controls.Clear();
               // dockPanel2.Controls.Add(_ctrlHdrBaseInfo);
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlHdrBaseInfo);
                _ctrlHdrBaseInfo.SetBindingData(_hdrBaseInfo);
            }
            //第二步
            if (step_id == Step_ID_Geom_Base_Info)
            {
                if (_ctrlGeomBaseInfo == null)
                {
                    _ctrlGeomBaseInfo = new ctrlGeomBaseInfo();
              //  dockPanel2.Controls.Clear();
              //  dockPanel2.Controls.Add(_ctrlGeomBaseInfo);
                    _ctrlGeomBaseInfo.Name = "ctrlGeomBaseInfo";
                    _ctrlGeomBaseInfo.Dock = DockStyle.Right;
                }
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlGeomBaseInfo);
                _ctrlGeomBaseInfo.SetBindingData(_geomBaseInfo);
            }
            //第三步
            if (step_id == Step_ID_Section18_Base)
            {
                if (_ctrlSectionBaseInfo == null)
                    _ctrlSectionBaseInfo = new  ctrlSectionBaseInfo();
              //  dockPanel2.Controls.Clear();
              //  dockPanel2.Controls.Add(_ctrlSectionBaseInfo);
                {
                    _ctrlSectionBaseInfo = new ctrlSectionBaseInfo();
                    _ctrlSectionBaseInfo.Name = "ctrlSectionBaseInfo";
                    _ctrlSectionBaseInfo.Dock = DockStyle.Right;
                }
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlSectionBaseInfo);
                _ctrlSectionBaseInfo.SetBindingData(_sectionBaseInfo);
            }
            //第四步
            if (step_id == Step_ID_Section18_Dim)
            {
                if (_ctrlSectionShapeInfo18 == null)
                {
                    _ctrlSectionShapeInfo18 = new ctrlSectionShapeInfo18();
              //  dockPanel2.Controls.Clear();
              //  dockPanel2.Controls.Add(_ctrlSectionShapeInfo18);
                    _ctrlSectionShapeInfo18.Name = "ctrlSectionShapeInfo18";
                    _ctrlSectionShapeInfo18.Dock = DockStyle.Right;
                }
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlSectionShapeInfo18);
                _ctrlSectionShapeInfo18.SetBindingData(_sectionShapePara);
            }
@@ -124,17 +277,25 @@
            if(step_id == Step_ID_Outflow_Style)
            {
                if (_ctrlSetOutflowStyle == null)
                {
                    _ctrlSetOutflowStyle = new ctrlSetOutflowStyle();
              //  dockPanel2.Controls.Clear();
               // dockPanel2.Controls.Add(_ctrlSetOutflowStyle);
                    _ctrlSetOutflowStyle.Name = "ctrlSetOutflowStyle";
                    _ctrlSetOutflowStyle.Dock = DockStyle.Right;
                }
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlSetOutflowStyle);
            }
            if (step_id == Step_ID_Outflow_Dim)
            {
                if (_ctrlSetOutflowDim == null)
                {
                    _ctrlSetOutflowDim = new ctrlSetOutflowDim();
               // dockPanel2.Controls.Clear();
               // dockPanel2.Controls.Add(_ctrlSetOutflowDim);
                    _ctrlSetOutflowDim.Name = "ctrlSetOutflowDim";
                    _ctrlSetOutflowDim.Dock = DockStyle.Right;
                }
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlSetOutflowDim);
            }
@@ -143,8 +304,31 @@
            this._currentStepID = step_id;
        }
        
        /// <summary>
        /// 蜗壳参数导出
        /// </summary>
        public void VoluteDeriveArgument()
        {
            if(_sectionBaseInfo == null )
            {
                MessageBox.Show("您还没有完成定义参数!请定义完成后在进行导出!(至少完成第三步)");
                return;
            }
            if(_currentStepID <= 21)
            {
                DialogResult result = MessageBox.Show("确定不进行后续断面参数的调整,使用初始计算后的参数吗?","提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.Cancel)
                {
                    return;
                }
            }
            ViewModel.SectionShapePara VoluteArgument = new ViewModel.SectionShapePara();
            string json = VoluteArgument.DeriveArgument(_sectionBaseInfo);
            string filePath = Path.Combine(@"C:\Users\THL\Desktop", $"蜗壳参数.json");
            File.WriteAllText(filePath, json);
        }
        #region 初始化步骤列表
        /// <summary>
@@ -252,9 +436,6 @@
            #endregion
            #region 出水体
            var stepGroup_出水体 = new DPumpHydr.WinFrmUI.Volute.TreeStepNode()
@@ -301,6 +482,23 @@
            #endregion
            ViewModel.HdrBaseInfo hdrBaseInfo = new ViewModel.HdrBaseInfo();
            hdrBaseInfo.Q = 200;
            hdrBaseInfo.H = 50;
            hdrBaseInfo.n = 2900;
            hdrBaseInfo.D2 = 220;
            hdrBaseInfo.B2 = 20;
            if (_ctrlHdrBaseInfo == null)
            {
                _ctrlHdrBaseInfo = new ctrlHdrBaseInfo();
                _ctrlHdrBaseInfo.Name = "ctrlHdrBaseInfo";
                _ctrlHdrBaseInfo.Dock = DockStyle.Right;
                _ctrlHdrBaseInfo.SetBindingData(hdrBaseInfo);
            }
            //this.panelParas.Controls.Clear();//不能清理
            this.panelParas.Controls.Add(_ctrlHdrBaseInfo);
            this._currentStepID = Step_ID_Hdr_Base_Info;
            //this.stepTreeListCtrl.SetStepSource(_allStepNodes, 1);
        }