using HStation.WinFrmUI.Xhs; namespace HStation.WinFrmUI { /// /// 项目模拟属性控件 /// public partial class XhsProjectSimulationPropertyCtrl : DevExpress.XtraEditors.XtraUserControl { public XhsProjectSimulationPropertyCtrl() { InitializeComponent(); this.hydroParterPropertyCtrl1.SelectCurveEvent += HydroParterPropertyCtrl1_SelectCurveEvent; this.hydroParterPropertyCtrl1.SelectPatternEvent += HydroParterPropertyCtrl1_SelectPatternEvent; this.hydroParterPropertyCtrl1.PropertyValueChangedEvent += HydroParterPropertyCtrl1_PropertyValueChangedEvent; this.hydroParterPropertyCtrl1.PropertyValueChangingEvent += HydroParterPropertyCtrl1_PropertyValueChangingEvent; this.hydroParterPropertyCtrl1.MatchingDbEvent += HydroParterPropertyCtrl1_MatchingDbEvent; } //水力信息方法 private Func _hydroInfoFunc = null; /// /// 初始化数据 /// public void InitialData(Func hydroInfoFunc) { _hydroInfoFunc = hydroInfoFunc; } /// /// 选择组件 /// public void SelectParter(long id) { var hydroInfo = _hydroInfoFunc?.Invoke(); if (hydroInfo == null) { this.hydroParterPropertyCtrl1.SelectedObject = null; return; } var allParterList = hydroInfo.GetAllParters(); var parter = allParterList.Find(x => x.ID == id); var vm = Yw.WinFrmUI.HydroParterPropertyViewModelBuilder.CreateViewModel(parter, allParterList); this.hydroParterPropertyCtrl1.SelectedObject = vm; } /// /// 选择组件 /// public void SelectParter(string code) { var hydroInfo = _hydroInfoFunc?.Invoke(); if (hydroInfo == null) { this.hydroParterPropertyCtrl1.SelectedObject = null; return; } var allParterList = hydroInfo.GetAllParters(); var parter = allParterList.Find(x => x.Code == code); var vm = Yw.WinFrmUI.HydroParterPropertyViewModelBuilder.CreateViewModel(parter, allParterList); this.hydroParterPropertyCtrl1.SelectedObject = vm; } /// /// 选择组件 /// public void SelectParter(Yw.Model.HydroParterInfo parter, List allParterList) { var vm = Yw.WinFrmUI.HydroParterPropertyViewModelBuilder.CreateViewModel(parter, allParterList); this.hydroParterPropertyCtrl1.SelectedObject = vm; } /// /// 更新计算属性 /// public void UpdateCalcuProperty(Yw.WinFrmUI.IHydroCalcuResult rhs) { var vm = this.hydroParterPropertyCtrl1.SelectedObject; if (vm == null) { return; } vm.UpdateCalcuProperty(rhs); this.hydroParterPropertyCtrl1.UpdateRows(); } //选择曲线 private bool HydroParterPropertyCtrl1_SelectCurveEvent(HydroParterPropertyViewModel propViewModel, string curveType) { switch (curveType) { case Yw.WinFrmUI.HydroCurve.Pump: { var hydroInfo = _hydroInfoFunc?.Invoke(); if (hydroInfo == null) { return false; } var pumpInfo = hydroInfo.Pumps?.Find(x => x.Code == propViewModel.Code); var input = AssetsMatchingParasHelper.Create(hydroInfo, pumpInfo); var dlg = new PumpMainCurveChoiceDlg(); dlg.SetBindingData(input); dlg.ReloadDataEvent += (rhs) => { var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs); if (bol) { TipFormHelper.ShowSucceed("匹配成功"); } else { TipFormHelper.ShowWarn("匹配失败"); } }; dlg.ShowDialog(); return true; } case Yw.WinFrmUI.HydroCurve.PumpQH: { return false; } case Yw.WinFrmUI.HydroCurve.PumpQP: { return false; } case Yw.WinFrmUI.HydroCurve.PumpQE: { return false; } case Yw.WinFrmUI.HydroCurve.Valve: { return true; } case Yw.WinFrmUI.HydroCurve.ValveQL: { return false; } default: break; } return false; } //选择模式 private bool HydroParterPropertyCtrl1_SelectPatternEvent(HydroParterPropertyViewModel propViewModel, string patternType) { switch (patternType) { case Yw.WinFrmUI.HydroPattern.Demand: { } break; case Yw.WinFrmUI.HydroPattern.Head: { } break; default: break; } return true; } //属性发生改变 private bool HydroParterPropertyCtrl1_PropertyValueChangedEvent(HydroParterPropertyViewModel obj) { return false; } //属性正在发生改变 private bool HydroParterPropertyCtrl1_PropertyValueChangingEvent(HydroParterPropertyViewModel arg) { return false; } //匹配Db事件 private void HydroParterPropertyCtrl1_MatchingDbEvent(Yw.Model.HydroParterInfo parter) { if (parter == null) { return; } var hydroInfo = _hydroInfoFunc?.Invoke(); if (hydroInfo == null) { return; } switch (parter.Catalog) { case Yw.Hydro.ParterCatalog.Pump://水泵 { var pumpInfo = hydroInfo.Pumps?.Find(x => x.Code == parter.Code); var input = AssetsMatchingParasHelper.Create(hydroInfo, pumpInfo); var dlg = new PumpMainCurveChoiceDlg(); dlg.SetBindingData(input); dlg.ReloadDataEvent += (rhs) => { var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs); if (bol) { TipFormHelper.ShowSucceed("匹配成功"); } else { TipFormHelper.ShowWarn("匹配失败"); } }; dlg.ShowDialog(); } break; case Yw.Hydro.ParterCatalog.Valve://阀门 { var valveInfo = hydroInfo.Valves?.Find(x => x.Code == parter.Code); var input = AssetsMatchingParasHelper.Create(hydroInfo, valveInfo); var dlg = new ValveMainCurveChoiceDlg(); dlg.SetBindingData(input); dlg.ReloadDataEvent += (rhs) => { var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs); if (bol) { TipFormHelper.ShowSucceed("匹配成功"); } else { TipFormHelper.ShowWarn("匹配失败"); } }; dlg.ShowDialog(); } break; case Yw.Hydro.ParterCatalog.Pipe://管道 { } break; case Yw.Hydro.ParterCatalog.Elbow://弯头 { var elbowInfo = hydroInfo.Elbows?.Find(x => x.Code == parter.Code); var input = AssetsMatchingParasHelper.Create(hydroInfo, elbowInfo); var dlg = new ElbowSingMatchingDlg(); dlg.SetBindingData(input); dlg.ReloadDataEvent += (rhs) => { var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs); if (bol) { TipFormHelper.ShowSucceed("匹配成功"); } else { TipFormHelper.ShowWarn("匹配失败"); } }; dlg.ShowDialog(); } break; case Yw.Hydro.ParterCatalog.Threelink://三通 { } break; case Yw.Hydro.ParterCatalog.Fourlink://四通 { } break; } } } }