using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; using DPumpHydr.WinFrmUI.Volute.ViewModel; namespace DPumpHydr.WinFrmUI.Volute { public partial class ctrlSetOutflowParas : ParasInfoBaseCtrl { public ctrlSetOutflowParas() { InitializeComponent(); BuildAllTips(); this.ctrlSection910Posi1.OnMoveSectPosi += (sect_index, posi)=> { if(this.OnMoveSectPosi != null) { OnMoveSectPosi.Invoke(sect_index, posi); } }; } public Func OnRefreshShape3D = null; public Func OnRefreshShape2D = null; ViewModel.OtuflowParas _outflowParas = null; //控件 SetOutflowParasCtrl1 _sidelineExitControl = null; SetOutflowParasCtrl2 _sideCurveExitControl = null; eOutflowStyle _stype = eOutflowStyle.未知; public eOutflowStyle CurrentOutflowStyle { get { return _stype; } } public void SetOutflowStyle(eOutflowStyle style) { if (_stype == style) return; _stype = style; tabPage1.Controls.Clear(); switch (_stype) { case eOutflowStyle.中心出口_垂直法兰面流出: metroTile扩散管形状.BackgroundImage = GlobalResource.BuildImage("Central-exit.png", 878, 238); if (_sidelineExitControl == null) { _sidelineExitControl = new SetOutflowParasCtrl1() { Name = "SetOutflowParasCtrl1" }; _sidelineExitControl.OnRefreshShape += (para) => { if (OnRefreshShape2D != null) return OnRefreshShape2D(para); else return null; }; _sidelineExitControl.Dock = DockStyle.Top; } _sidelineExitControl.SetA_state(false); tabPage1.Controls.Add(_sidelineExitControl); return; case eOutflowStyle.侧面出口_曲线连接: metroTile扩散管形状.BackgroundImage = GlobalResource.BuildImage("Side-exit-curve.png", 878, 238); if (_sidelineExitControl == null) { _sidelineExitControl = new SetOutflowParasCtrl1() { Name= "SetOutflowParasCtrl1" }; _sidelineExitControl.OnRefreshShape += (para) => { if (OnRefreshShape2D != null) return OnRefreshShape2D(para); else return null; }; _sidelineExitControl.Dock = DockStyle.Top; } _sidelineExitControl.SetA_state(true); tabPage1.Controls.Add(_sidelineExitControl); return; case eOutflowStyle.侧面出口_直线连接: metroTile扩散管形状.BackgroundImage = GlobalResource.BuildImage("Side-exit-straight-line.png", 878, 238); if (_sideCurveExitControl == null) { _sideCurveExitControl = new SetOutflowParasCtrl2() { Name = "SetOutflowParasCtrl2" }; _sideCurveExitControl.OnRefreshShape += (para) => { if (OnRefreshShape2D != null) return OnRefreshShape2D(para); else return null; }; _sideCurveExitControl.Dock = DockStyle.Top; } tabPage1.Controls.Add(_sideCurveExitControl); return; default: throw new ArgumentException("Invalid control type"); } } public void SetBindingData( eOutflowStyle style, ViewModel.HdrBaseInfo hdrBaseInfo, ViewModel.GeomBaseInfo geomBaseInfo, ViewModel.SectionBundleInfo sectionBundleInfo) { if(_outflowParas == null) { InitialParas(style, hdrBaseInfo, geomBaseInfo, sectionBundleInfo); } else { if (_stype == style) return; if(_stype == eOutflowStyle.侧面出口_直线连接) { if(style != eOutflowStyle.侧面出口_直线连接) { InitialParas(style, hdrBaseInfo, geomBaseInfo, sectionBundleInfo); } else { SetOutflowStyle(style); } } else { if (style == eOutflowStyle.侧面出口_直线连接) { InitialParas(style, hdrBaseInfo, geomBaseInfo, sectionBundleInfo); } else { SetOutflowStyle(style); } } } } public void InitialParas( eOutflowStyle style, ViewModel.HdrBaseInfo hdrBaseInfo, ViewModel.GeomBaseInfo geomBaseInfo, ViewModel.SectionBundleInfo sectionBundleInfo) { SetOutflowStyle(style); //出口直径标准化 double outer_dia = 4.5 * Math.Pow(hdrBaseInfo.Q / 3600 / hdrBaseInfo.n, 1 / 3.0) * 1000; double height = 10 * (int)((geomBaseInfo.D3 * 1.3 + sectionBundleInfo.H[8] + 15) / 10); double a = 0; if (style == eOutflowStyle.中心出口_垂直法兰面流出) { a = 0; } else { a = (int)((geomBaseInfo.D3 + sectionBundleInfo.H[8]) / 2); } _outflowParas = new OtuflowParas(); _outflowParas.Offset = a; _outflowParas.Heigh = height; _outflowParas.H1 = 5; _outflowParas.H2 = 5; _outflowParas.Dia = GetStdDia(outer_dia); _outflowParas.Septalradius = 2; if (_stype == eOutflowStyle.侧面出口_直线连接) { _sideCurveExitControl.SetBindingData(_outflowParas); } else { _sidelineExitControl.InitialParas(hdrBaseInfo, geomBaseInfo, sectionBundleInfo); _sidelineExitControl.IsInvokeRefreshShapeAble = false; _sidelineExitControl.SetBindingData(_outflowParas); _sidelineExitControl.IsInvokeRefreshShapeAble = true; } } private static double GetStdDia(double mm) { var iFlangeCodeList = new int[] {10,15,20,25,32, 40,50,65,80,100, 125,150,200,250,300, 350,400,450,500,600, 700,800,900,1000,1200, 1400,1600,1800,2000,5000,100000}; for (int i = 0; i < iFlangeCodeList.Count() - 1; i++) { if (mm < iFlangeCodeList[i]) return iFlangeCodeList[i]; } return iFlangeCodeList.Last(); } // public ViewModel.OtuflowParas GetBindingData(out string error) { error = ""; if (_stype == eOutflowStyle.侧面出口_直线连接) { _outflowParas = _sideCurveExitControl.GetBindingData(out error); } else { _outflowParas = _sidelineExitControl.GetBindingData(out error); } return _outflowParas; } public void SetBindingData(eOutflowStyle style, ViewModel.OtuflowParas paras) { SetOutflowStyle(style); if (_stype == eOutflowStyle.侧面出口_直线连接) { _sideCurveExitControl.SetBindingData(_outflowParas); } else { _sidelineExitControl.SetBindingData(_outflowParas); } } private void BuildAllTips() { metroToolTip第六步提示.SetToolTip(this.metroTile扩散管形状, "断面图"); } public void ShowPage(DPumpHydr.ViewModel.eWizardStepDiretion step_direction) { if (step_direction == DPumpHydr.ViewModel.eWizardStepDiretion.前进) { var resp = OnRefreshShape3D(_outflowParas); if (resp != null) { if (_stype == eOutflowStyle.侧面出口_直线连接) { _sideCurveExitControl.SetBindingData(resp); } else { _sidelineExitControl.SetBindingData(resp); } } } else { } } private void mBtn更新模型_Click(object sender, EventArgs e) { string error; var resp = OnRefreshShape3D(GetBindingData(out error)); if (resp != null) { if (_stype == eOutflowStyle.侧面出口_直线连接) { _sideCurveExitControl.SetBindingData(resp); } else { _sidelineExitControl.SetBindingData(resp); } } } public Action OnMoveSectPosi = null; internal void SetSect9Posi(double sect9Posi) { ctrlSection910Posi1.SetSect9Posi(sect9Posi); } internal void SetSect10Posi(double sect9Posi) { ctrlSection910Posi1.SetSect10Posi(sect9Posi); } } }