tangxu
2024-12-27 9cc5bf68aaab46f33f2b00f8dcef0ab52ced0c41
WinFrmUI/DPumpHydr.WinFrmUI.Volute/MainViewPage_StepInfo.cs
@@ -1,41 +1,22 @@

using System;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Text;
using System.Linq;
using System.Linq;
namespace DPumpHydr.WinFrmUI.Volute
{
    public partial class MainViewPage
    public partial class MainViewPage
    {
        //基础信息
        private readonly string Group_Name_Base_Info = "BaseInfo";
        private readonly int Group_ID_Base_Info = -1;//组ID
        private long Step_ID_Hdr_Base_Info = 12;
        private long Step_ID_Geom_Base_Info = 13;
        //步骤控件
        StepTreeDockPanel _stepTreeDockPanel = null;
        //断面设计(1-8)
        private readonly string Group_Name_Section18 = "Section18";
        private readonly int Group_ID_Section18 = -2;
        private long Step_ID_Section18_Base = 20;//基本信息
        private long Step_ID_Section18_Dim = 21;//详细页面
        //出水设计
        private readonly string Group_Name_Outflow = "Outflow";
        private readonly int Group_ID_Outflow  = -3;
        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>
@@ -53,133 +34,328 @@
        {
            return GoPrevStepCore();
        }
        ViewModel.HdrBaseInfo _hdrBaseInfo = null;
        /// <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)
            var currentStepID = this._stepTreeDockPanel.CurrentStepID;
            if (SaveStepParas(currentStepID) == false)
            {
                return false;
            if(_currentStepID == Step_ID_Hdr_Base_Info)
            }
            //
            var next_step_id = this._stepTreeDockPanel.NextStepID;
            if (next_step_id > 0)
            {
                this.SetParasCtrl(next_step_id);
                //
                this._stepTreeDockPanel.SetFocusedNode(next_step_id);
            }
            return true;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="stepID"></param>
        /// <returns></returns>
        protected bool SaveStepParas(long stepID)
        {
            #region 获取当前页面参数
            //第一步
            if (stepID == this._stepTreeDockPanel.Step_ID_Hdr_Base_Info)
            {
                string error_info;
                var hdrBaseInfo = _ctrlHdrBaseInfo.GetBindingData(out error_info);
                if(hdrBaseInfo == null)
                if (hdrBaseInfo == null)
                {
                    MessageBox.Show(error_info);
                    return false;
                }
                hdrBaseInfo.CalcNs();
                _hdrBaseInfo = hdrBaseInfo;
                if (_geomBaseInfo == null)
                {
                    _geomBaseInfo = new ViewModel.GeomBaseInfo();
                }
                _geomBaseInfo.Calc(_hdrBaseInfo);
                return true;
            }
            SetParasCtrl(next_step.ID);
            //第二步
            if (stepID == this._stepTreeDockPanel.Step_ID_Geom_Base_Info)
            {
                if (_ctrlGeomBaseInfo == null)
                    return false;
                string error_info;
                var geomBaseInfo = _ctrlGeomBaseInfo.GetBindingData(out error_info);
                if (geomBaseInfo == null)
                {
                    MessageBox.Show(error_info);
                    return false;
                }
                _geomBaseInfo = geomBaseInfo;
                if (_sectionBundleInfo == null)
                {
                    _sectionBundleInfo = new ViewModel.SectionBundleInfo();
                }
                var v3 = ViewModel.SectionBundleInfo.CalcV3(_hdrBaseInfo, _geomBaseInfo);
                _sectionBundleInfo.ResetAllParas(_hdrBaseInfo, _geomBaseInfo, v3);
                return true;
            }
            //第三步
            if (stepID == this._stepTreeDockPanel.Step_ID_Section18_Full)
            {
                string error_info;
                var sectionBaseInfo = _ctrlSectionBundleInfo.GetBindingData(out error_info);
                if (sectionBaseInfo == null)
                {
                    MessageBox.Show(error_info);
                    return false;
                }
                _sectionBundleInfo = sectionBaseInfo;
                //_sectionBundleInfo.ResetAllParas(_hdrBaseInfo, _geomBaseInfo);
                //ViewModel.SectionShapePara _sectionShapePara = null;
                //if (_sectionShapePara == null)
                //{
                //    _sectionShapePara = new ViewModel.SectionShapePara();
                //}
                //_sectionShapePara.Initialparameters(_currentSectIndex, _sectionBaseInfo);
                return true;
            }
            //1-8断面进行下一步点击
            if (stepID == this._stepTreeDockPanel.Step_ID_Section18_Grp)
            {
                //string error_info;
                //var sectionShapeInfo18 = _ctrlSectionShapeInfo18.GetBindingData(out error_info);
                //if (sectionShapeInfo18 == null)
                //{
                //    MessageBox.Show(error_info);
                //    return false;
                //}
                //if (!sectionShapeInfo18.Verify(out error_info))
                //{
                //    MessageBox.Show(error_info);
                //    return false;
                //}
                //_sectionShapePara = sectionShapeInfo18;
                //_sectionShapePara.CalcHeightByArea(_sectionBaseInfo.ShapeType);
                //_sectionBaseInfo.EditSingleShape(_sectionShapePara, _currentSectIndex);
                //if (_currentSectIndex != 9)
                //{
                //    _currentSectIndex--;
                //}
                //_sectionShapePara.Initialparameters(_currentSectIndex, _sectionBaseInfo);
                return true;
            }
            #endregion
            return true;
        }
        /// <summary>
        /// 上一步核心
        /// </summary>
        /// <returns></returns>
        private bool GoPrevStepCore()
        {
            if (_currentStepID == Step_ID_Hdr_Base_Info)
            var currentStepID = this._stepTreeDockPanel.CurrentStepID;
            ParasInfoBaseCtrl paras_ctrl = GetParasCtrl(currentStepID);
            if(paras_ctrl != null && paras_ctrl.IsChangesParas())
            {
                DialogResult result = MessageBox.Show("已经修改过的数据需要保存吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.OK)
                {
                    if (SaveStepParas(currentStepID) == false )
                    {
                        return false;
                    }
                }
            }
            var prev_step_id = this._stepTreeDockPanel.PrevStepID;
            if (prev_step_id == 0)
                return false;
            var prev_step = (from x in _allStepNodes
                             where x.ID < _currentStepID
                             orderby x.ID
                             select x).LastOrDefault();
            if (prev_step == null)
                return false;
            SetParasCtrl(prev_step.ID);
            this.SetParasCtrl(prev_step_id);
            //
            this._stepTreeDockPanel.SetFocusedNode(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 (step_id == this._stepTreeDockPanel.Step_ID_Hdr_Base_Info)
            {
                if (_ctrlHdrBaseInfo == null)
                {
                    _ctrlHdrBaseInfo = new ctrlHdrBaseInfo();
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlHdrBaseInfo);
                    _ctrlHdrBaseInfo.Name = "ctrlHdrBaseInfo";
                }
                _ctrlHdrBaseInfo.SetBindingData(_hdrBaseInfo);
                AddStepParaCtrl(_ctrlHdrBaseInfo);
                this._sectAreaDockPanel.Visible = false;
            }
            if (step_id == Step_ID_Geom_Base_Info)
            //第二步
            if (step_id == this._stepTreeDockPanel.Step_ID_Geom_Base_Info)
            {
                if (_ctrlGeomBaseInfo == null)
                {
                    _ctrlGeomBaseInfo = new ctrlGeomBaseInfo();
                    _ctrlGeomBaseInfo.Name = "ctrlGeomBaseInfo";
                    _ctrlGeomBaseInfo.Dock = DockStyle.Right;
                }
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlGeomBaseInfo);
                _ctrlGeomBaseInfo.SetBindingData(_geomBaseInfo);
                AddStepParaCtrl(_ctrlGeomBaseInfo);
                this._sectAreaDockPanel.Visible = false;
            }
            if (step_id == Step_ID_Section18_Base)
            //第三步 断面总览
            if (step_id == this._stepTreeDockPanel.Step_ID_Section18_Full)
            {
                if (_ctrlSectionBaseInfo == null)
                if (_ctrlSectionBundleInfo == null)
                {
                    _ctrlSectionBaseInfo = new ctrlSectionBaseInfo();
                    _ctrlSectionBaseInfo.Name = "ctrlSectionBaseInfo";
                    _ctrlSectionBaseInfo.Dock = DockStyle.Right;
                    _ctrlSectionBundleInfo = new ctrlSectionBundleInfo();
                    _ctrlSectionBundleInfo.Name = "ctrlSectionBaseInfo";
                    _ctrlSectionBundleInfo.OnRefreshShape += RefreshSectShapeWhole18;
                }
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlSectionBaseInfo);
                AddStepParaCtrl(_ctrlSectionBundleInfo);
                _ctrlSectionBundleInfo.InitialParas(_hdrBaseInfo, _geomBaseInfo);
                _ctrlSectionBundleInfo.SetBindingData(_sectionBundleInfo);
                RefreshSectShapeWhole18(_sectionBundleInfo);
                this._sectAreaDockPanel.RefreshControl();
                this._sectAreaDockPanel.Visible = true;
            }
            if (step_id == Step_ID_Section18_Dim)
            //第四步 1-8断面
            if (step_id > this._stepTreeDockPanel.Step_ID_Section18_Grp &&
                step_id <= this._stepTreeDockPanel.Step_ID_Section18_Grp + 8)
            {
                if (_sectionBundleInfo == null)
                    return;
                if (_ctrlSectionShapeInfo18 == null)
                {
                    _ctrlSectionShapeInfo18 = new ctrlSectionShapeInfo18();
                    _ctrlSectionShapeInfo18.Name = "ctrlSectionShapeInfo18";
                    _ctrlSectionShapeInfo18.Dock = DockStyle.Right;
                    _ctrlSectionShapeInfo18.OnRefreshShape += RefreshSectShapeSingle18;
                }
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlSectionShapeInfo18);
                AddStepParaCtrl(_ctrlSectionShapeInfo18);
                var sect_index = 9 + this._stepTreeDockPanel.Step_ID_Section18_Grp - step_id;
                var shape_info = _sectionBundleInfo.ToSectionShapePara((int)sect_index);
                RefreshSectShapeSingle18(shape_info);
                _ctrlSectionShapeInfo18.SetBindingData(shape_info);
                this._sectAreaDockPanel.RefreshControl();
                this._sectAreaDockPanel.Visible = true;
            }
            if(step_id == Step_ID_Outflow_Style)
            //出水面类型选择
            if (step_id == this._stepTreeDockPanel.Step_ID_Outflow_Type)
            {
                if (_ctrlSetOutflowStyle == null)
                {
                    _ctrlSetOutflowStyle = new 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)
                if (_ctrlSetOutflowType == null)
                {
                    _ctrlSetOutflowDim = new ctrlSetOutflowDim();
                    _ctrlSetOutflowDim.Name = "ctrlSetOutflowDim";
                    _ctrlSetOutflowDim.Dock = DockStyle.Right;
                    _ctrlSetOutflowType = new ctrlSetOutflowType();
                    _ctrlSetOutflowType.Name = "ctrlSetOutflowDim";
                }
                this.panelParas.Controls.Clear();
                this.panelParas.Controls.Add(_ctrlSetOutflowDim);
                this._sectAreaDockPanel.Visible = true;
                this._sectAreaDockPanel.RefreshControl();
                AddStepParaCtrl(_ctrlSetOutflowType);
            }
            //出水面参数
            if (step_id == this._stepTreeDockPanel.Step_ID_Outflow_Style)
            {
                _outflowType = _ctrlSetOutflowType.GetBindingData();
                if (_ctrlSetOutflowStyle == null)
                {
                    _ctrlSetOutflowStyle = new ctrlSetOutflowParas();
                    _ctrlSetOutflowStyle.Name = "ctrlSetOutflowStyle";
                    _ctrlSetOutflowStyle.OnRefreshShape += CreateWaterBody;
                    _ctrlSetOutflowStyle.InitialParas(_outflowType, _hdrBaseInfo, _geomBaseInfo, _sectionBundleInfo);
                }
                _ctrlSetOutflowStyle.SetOutflowStyle(_outflowType);
                _ctrlSetOutflowStyle.ShowPage();
                this._sectAreaDockPanel.RefreshControl();
                this._sectAreaDockPanel.Visible = true;
                AddStepParaCtrl(_ctrlSetOutflowStyle);
                string error = "";
                _otuflowParas = _ctrlSetOutflowStyle.GetBindingData(out error);
            }
            if (step_id == this._stepTreeDockPanel.Step_ID_jiahout)
            {
                this._occDesign3dCtrl.CreateOutletBody3d();
            }
            this._currentStepID = step_id;
        }
        /// <summary>
        /// 获取当前步骤的参数控制控件
        /// </summary>
        /// <param name="step_id"></param>
        private DPumpHydr.WinFrmUI.Volute.ParasInfoBaseCtrl GetParasCtrl(long step_id)
        {
            if (step_id == this._stepTreeDockPanel.Step_ID_Hdr_Base_Info)
            {
                return _ctrlHdrBaseInfo;
            }
            //第二步
            if (step_id == this._stepTreeDockPanel.Step_ID_Geom_Base_Info)
            {
                return _ctrlGeomBaseInfo;
            }
            //第三步
            if (step_id == this._stepTreeDockPanel.Step_ID_Section18_Full)
            {
                return _ctrlSectionBundleInfo;
            }
            //1-8断面进行下一步点击
            if (step_id >= this._stepTreeDockPanel.Step_ID_Section18_Grp && 
                step_id>= this._stepTreeDockPanel.Step_ID_Section18_Grp+8)
            {
                return _ctrlSectionShapeInfo18;
            }
            return null;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctrl"></param>
        private void AddStepParaCtrl(ParasInfoBaseCtrl ctrl)
        {
            this._parasDockPanel.Controls.Clear();
            ctrl.Dock = DockStyle.Fill;
            this._parasDockPanel.Controls.Add(ctrl);
        }
        #region 初始化步骤列表
        /// <summary>
@@ -187,152 +363,6 @@
        /// </summary>
        private void InitialStepNodes()
        {
            _allStepNodes = new List<DPumpHydr.WinFrmUI.Volute.TreeStepNode>();
            #region 基础信息/几何参数
            var stepGroup_BaseInfo = new DPumpHydr.WinFrmUI.Volute.TreeStepNode();
            stepGroup_BaseInfo.AllowSelect = false;
            stepGroup_BaseInfo.Group = Group_Name_Base_Info;
            stepGroup_BaseInfo.Caption = "基础信息";
            stepGroup_BaseInfo.Name = Group_Name_Base_Info;
            stepGroup_BaseInfo.ID = Group_ID_Base_Info;
            stepGroup_BaseInfo.ParentID = 0;
            _allStepNodes.Add(stepGroup_BaseInfo);
            var step欢迎使用 = new DPumpHydr.WinFrmUI.Volute.TreeStepNode();
            step欢迎使用.AllowSelect = true;
            step欢迎使用.Group = Group_Name_Base_Info;
            step欢迎使用.Caption = "欢迎使用";
            step欢迎使用.Name = "StepHelp";
            step欢迎使用.ID = 1;
            step欢迎使用.ParentID = Group_ID_Base_Info;
            _allStepNodes.Add(step欢迎使用);
            var step基础信息 = new DPumpHydr.WinFrmUI.Volute.TreeStepNode()
            {
                ProgressState = WinFrmUI.Volute.TreeStepNode.eProgressState.未完成,
                DataState = WinFrmUI.Volute.TreeStepNode.eDataState.未知
            };
            step基础信息.AllowSelect = true;
            step基础信息.Group = Group_Name_Base_Info;
            step基础信息.Caption = "第一步:基础信息";
            step基础信息.Name = "StepHydParas";
            step基础信息.ID = Step_ID_Hdr_Base_Info;
            step基础信息.ParentID = Group_ID_Base_Info;
            _allStepNodes.Add(step基础信息);
            var step几何参数 = new DPumpHydr.WinFrmUI.Volute.TreeStepNode()
            {
                ProgressState = WinFrmUI.Volute.TreeStepNode.eProgressState.未完成,
                DataState = WinFrmUI.Volute.TreeStepNode.eDataState.未知
            };
            step几何参数.AllowSelect = true;
            step几何参数.Group = Group_Name_Base_Info;
            step几何参数.Caption = "第二步:几何参数";
            step几何参数.Name = "StepGeomParas";
            step几何参数.ID = Step_ID_Geom_Base_Info;
            step几何参数.ParentID = Group_ID_Base_Info;
            _allStepNodes.Add(step几何参数);
            #endregion
            #region 断面设计(1-8)
            var stepGroup_CoverPlate = new DPumpHydr.WinFrmUI.Volute.TreeStepNode()
            {
                ProgressState = WinFrmUI.Volute.TreeStepNode.eProgressState.未完成,
                DataState = WinFrmUI.Volute.TreeStepNode.eDataState.未知
            };
            stepGroup_CoverPlate.AllowSelect = false;
            stepGroup_CoverPlate.Caption = "断面设计";
            stepGroup_CoverPlate.Name = Group_Name_Section18;
            stepGroup_CoverPlate.ID = Group_ID_Section18;
            stepGroup_CoverPlate.ParentID = 0;
            _allStepNodes.Add(stepGroup_CoverPlate);
            var step断面基本信息 = new DPumpHydr.WinFrmUI.Volute.TreeStepNode()
            {
                ProgressState = WinFrmUI.Volute.TreeStepNode.eProgressState.未完成,
                DataState = WinFrmUI.Volute.TreeStepNode.eDataState.未知
            };
            step断面基本信息.AllowSelect = true;
            step断面基本信息.Caption = string.Format("{0}:{1}", GetTranslateString("第三步"), GetTranslateString("零件材料"));
            step断面基本信息.Name = "SectBaseInfo18";
            step断面基本信息.ID = Step_ID_Section18_Base;
            step断面基本信息.Group = "断面信息";
            step断面基本信息.ParentID = Group_ID_Section18;
            _allStepNodes.Add(step断面基本信息);
                var stepSetct18 = new DPumpHydr.WinFrmUI.Volute.TreeStepNode()
                {
                    ProgressState = WinFrmUI.Volute.TreeStepNode.eProgressState.未完成,
                    DataState = WinFrmUI.Volute.TreeStepNode.eDataState.未知
                };
                stepSetct18.AllowSelect = true;
                stepSetct18.Caption =  "第四步: 第1-8断面" ;
            stepSetct18.Name = "TreeStepNode" + Step_ID_Section18_Dim;
            stepSetct18.ID = Step_ID_Section18_Dim  ;
                stepSetct18.Group = "盖板连接";
                stepSetct18.ParentID = Group_ID_Section18;
                _allStepNodes.Add(stepSetct18);
            #endregion
            #region 出水体
            var stepGroup_出水体 = new DPumpHydr.WinFrmUI.Volute.TreeStepNode()
            {
                ProgressState = WinFrmUI.Volute.TreeStepNode.eProgressState.未完成,
                DataState = WinFrmUI.Volute.TreeStepNode.eDataState.未知
            };
            stepGroup_出水体.AllowSelect = false;
            stepGroup_出水体.Caption = "出水体设计";
            stepGroup_出水体.Name = Group_Name_Outflow;
            stepGroup_出水体.ID = Group_ID_Outflow;
            stepGroup_出水体.ParentID = 0;
            _allStepNodes.Add(stepGroup_出水体);
            var step出水体类型 = new DPumpHydr.WinFrmUI.Volute.TreeStepNode()
            {
                ProgressState = WinFrmUI.Volute.TreeStepNode.eProgressState.未完成,
                DataState = WinFrmUI.Volute.TreeStepNode.eDataState.未知
            };
            step出水体类型.AllowSelect = true;
            step出水体类型.Caption = "第五步:出水体类型";
            step出水体类型.Name = "TreeStepNode"+ Step_ID_Outflow_Style;
            step出水体类型.ID = Step_ID_Outflow_Style;
            step出水体类型.Group = Group_Name_Outflow;
            step出水体类型.ParentID = Group_ID_Outflow;
            _allStepNodes.Add(step出水体类型);
            var step出水体尺寸 = new DPumpHydr.WinFrmUI.Volute.TreeStepNode()
            {
                ProgressState = WinFrmUI.Volute.TreeStepNode.eProgressState.未完成,
                DataState = WinFrmUI.Volute.TreeStepNode.eDataState.未知
            };
            step出水体尺寸.AllowSelect = true;
            step出水体尺寸.Caption = "第六步:出水体尺寸";
            step出水体尺寸.Name = "TreeStepNode"+ Step_ID_Outflow_Dim;
            step出水体尺寸.ID = Step_ID_Outflow_Dim;
            step出水体尺寸.Group = Group_Name_Outflow;
            step出水体尺寸.ParentID = Group_ID_Outflow;
            _allStepNodes.Add(step出水体尺寸);
            #endregion
            ViewModel.HdrBaseInfo hdrBaseInfo = new ViewModel.HdrBaseInfo();
            hdrBaseInfo.Q = 200;
            hdrBaseInfo.H = 50;
@@ -347,10 +377,11 @@
                _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);
            this.AddStepParaCtrl(_ctrlHdrBaseInfo);
            //
            this._stepTreeDockPanel.InitialStepNodes();
        }
        #endregion