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(); _parasControl1 = new SetOutflowParasCtrl1() { Name = "SetOutflowParasCtrl1" }; _parasControl1.OnRefreshShape += (para) => { if (OnRefreshShape2D != null) return OnRefreshShape2D(para); else return false; }; _parasControl1.Dock = DockStyle.Top; _parasControl2 = new SetOutflowParasCtrl2() { Name = "SetOutflowParasCtrl2" }; _parasControl2.OnRefreshShape += (para) => { if (OnRefreshShape2D != null) return OnRefreshShape2D(para); else return false; }; _parasControl2.Dock = DockStyle.Top; this.ctrlSection910Posi1.OnMoveSectPosi += (sect_index, posi) => { if (this.OnMoveSectPosi != null) { OnMoveSectPosi.Invoke(sect_index, posi); } }; BuildAllTips(); } public Func OnRefreshShape3D = null; public Func OnRefreshShape2D = null; //控件 SetOutflowParasCtrl1 _parasControl1 = null; SetOutflowParasCtrl2 _parasControl2 = null; DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle _sharp_type = DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.未知; public DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle CurrentOutflowShapeStyle { get { return _sharp_type; } } private void InitialOutflowStyle() { tabPage1.Controls.Clear(); switch (_sharp_type) { case DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.中心出口_垂直法兰面流出: metroTile出口图片.BackgroundImage = GlobalResource.BuildImage("Central-exit.png", 878, 238); _parasControl1.SetA_state(false); tabPage1.Controls.Add(_parasControl1); return; case DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.侧面出口_曲线连接: metroTile出口图片.BackgroundImage = GlobalResource.BuildImage("Side-exit-curve.png", 878, 238); _parasControl1.SetA_state(true); tabPage1.Controls.Add(_parasControl1); return; case DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.侧面出口_直线连接: metroTile出口图片.BackgroundImage = GlobalResource.BuildImage("Side-exit-straight-line.png", 878, 238); tabPage1.Controls.Add(_parasControl2); return; default: throw new ArgumentException("Invalid control type"); } } ViewModel.HdrBaseInfo _hdrBaseInfo = null; ViewModel.GeomBaseInfo _geomBaseInfo = null; ViewModel.SectionBundleInfo _sectionBundleInfo = null; public void InitialParas( ViewModel.HdrBaseInfo hdrBaseInfo, ViewModel.GeomBaseInfo geomBaseInfo, ViewModel.SectionBundleInfo sectionBundleInfo) { this._hdrBaseInfo = hdrBaseInfo; this._geomBaseInfo = geomBaseInfo; this._sectionBundleInfo = sectionBundleInfo; //出口直径标准化 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); var outflowParas1 = new OutflowParas(); outflowParas1.Offset = 0; outflowParas1.Heigh = height; outflowParas1.H1 = 5; outflowParas1.H2 = 5; outflowParas1.Dia = GetStdDia(outer_dia); outflowParas1.Septalradius = 2; _parasControl1.InitialParas(hdrBaseInfo, geomBaseInfo, sectionBundleInfo); _parasControl1.IsInvokeRefreshShapeAble = false; _parasControl1.SetBindingData(outflowParas1); _parasControl1.IsInvokeRefreshShapeAble = true; var outflowParas2 = new OutflowParas(); outflowParas2.Offset = (int)((geomBaseInfo.D3 + sectionBundleInfo.H[8]) / 2); outflowParas2.Heigh = height; outflowParas2.H1 = 5; outflowParas2.H2 = 5; outflowParas2.Dia = GetStdDia(outer_dia); outflowParas2.Septalradius = 2; _parasControl2.InitialParas(hdrBaseInfo, geomBaseInfo, sectionBundleInfo); _parasControl2.IsInvokeRefreshShapeAble = false; _parasControl2.SetBindingData(outflowParas2); _parasControl2.IsInvokeRefreshShapeAble = true; _sharp_type = DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.中心出口_垂直法兰面流出; comboBoxType.SelectedIndex = 0; } 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.OutflowParas GetBindingData(out string error) { error = ""; ViewModel.OutflowParas _outflowParas = null; switch (_sharp_type) { case DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.中心出口_垂直法兰面流出: _outflowParas = _parasControl1.GetBindingData(out error); break; case DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.侧面出口_曲线连接: _outflowParas = _parasControl1.GetBindingData(out error); break; case DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.侧面出口_直线连接: _outflowParas = _parasControl2.GetBindingData(out error); break; default: return null; } if (_outflowParas == null) { return null; } _outflowParas.ShapeStyle = _sharp_type; return _outflowParas; } public void SetBindingData(ViewModel.OutflowParas paras) { if (paras == null) return; if(_sectionBundleInfo == null) { throw new Exception("未初始化ctrlSetOutflowParas控件"); } this._sharp_type = paras.ShapeStyle; var paras1 = new ViewModel.OutflowParas(paras); var paras2 = new ViewModel.OutflowParas(paras); _parasControl1.SetBindingData(paras1); if (paras2.ShapeStyle == DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.中心出口_垂直法兰面流出) { paras2.Offset = (int)((_geomBaseInfo.D3 + _sectionBundleInfo.H[8]) / 2); } _parasControl2.SetBindingData(paras2); if (_sharp_type == DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.中心出口_垂直法兰面流出) { comboBoxType.SelectedIndex = 0; } else if (_sharp_type == DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.侧面出口_曲线连接) { comboBoxType.SelectedIndex = 1; } else if (_sharp_type == DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.侧面出口_直线连接) { comboBoxType.SelectedIndex = 2; } InitialOutflowStyle(); } 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) { RefreshModel(); } private void RefreshModel() { string error; var resp = OnRefreshShape3D(GetBindingData(out error)); if (resp != null) { if (_sharp_type == eOutflowShapeStyle.侧面出口_直线连接) { _parasControl2.SetBindingData(resp); } else { _parasControl1.SetBindingData(resp); } } } public Action OnMoveSectPosi = null; internal void SetSect9Posi(double sect9Posi) { ctrlSection910Posi1.SetSect9Posi(sect9Posi); } internal void SetSect10Posi(double sect9Posi) { ctrlSection910Posi1.SetSect10Posi(sect9Posi); } private void comboBoxType_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxType.SelectedIndex == 0) { _sharp_type = DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.中心出口_垂直法兰面流出; } else if (comboBoxType.SelectedIndex == 1) { _sharp_type = DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.侧面出口_曲线连接; } else if (comboBoxType.SelectedIndex == 2) { _sharp_type = DPumpHydr.WinFrmUI.Volute.ViewModel.eOutflowShapeStyle.侧面出口_直线连接; } InitialOutflowStyle(); RefreshModel(); } private void btnNextStep_Click(object sender, EventArgs e) { NextStep(); } } }