| | |
| | | using HStation.WinFrmUI.Xhs; |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using HStation.WinFrmUI.Xhs; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | |
| | | public XhsProjectSimulationPropertyCtrl() |
| | | { |
| | | InitializeComponent(); |
| | | this.hydroVisualPropertyCtrl1.MatchingDbEvent += HydroParterPropertyCtrl1_MatchingDbEvent; |
| | | this.hydroVisualPropertyCtrl1.SetCurveEvent += HydroParterPropertyCtrl1_SetCurveEvent; |
| | | this.hydroVisualPropertyCtrl1.SetPatternEvent += HydroParterPropertyCtrl1_SetPatternEvent; |
| | | this.hydroVisualPropertyCtrl1.BlinkLinkParterEvent += HydroParterPropertyCtrl1_BlinkLinkParterEvent; |
| | | this.hydroVisualPropertyCtrl1.HydroViewEvent += HydroParterPropertyCtrl1_ViewParterEvent; |
| | | |
| | | 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; |
| | | this.hydroVisualPropertyCtrl1.PropertyValueChangedEvent += HydroParterPropertyCtrl1_PropertyValueChangedEvent; |
| | | this.hydroVisualPropertyCtrl1.MarkPropertyValueChangedEvent += HydroParterPropertyCtrl1_MarkPropertyValueChangedEvent; |
| | | this.hydroVisualPropertyCtrl1.GradingPropertyValueChangedEvent += HydroParterPropertyCtrl1_GradingPropertyValueChangedEvent; |
| | | this.hydroVisualPropertyCtrl1.FlowDirectionPropertyValueChangedEvent += HydroParterPropertyCtrl1_FlowDirectionPropertyValueChangedEvent; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 强调连接组件事件 |
| | | /// 第一个参数为组件Code |
| | | /// 第二个参数为连接组件Code |
| | | /// </summary> |
| | | public event Action<string, string> BlinkLinkParterEvent; |
| | | |
| | | /// <summary> |
| | | /// 属性值改变事件 |
| | | /// </summary> |
| | | public event Action<Yw.Model.HydroVisualInfo> PropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 标注属性值改变事件 |
| | | /// </summary> |
| | | public event Action<Yw.Model.HydroVisualInfo> MarkPropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 分级属性值改变事件 |
| | | /// </summary> |
| | | public event Action<Yw.Model.HydroVisualInfo> GradingPropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 流向属性值改变事件 |
| | | /// </summary> |
| | | public event Action<Yw.Model.HydroVisualInfo> FlowDirectionPropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 查看构件事件 |
| | | /// </summary> |
| | | public event Action<Yw.Model.HydroVisualInfo> ViewParterEvent; |
| | | |
| | | //水力信息方法 |
| | | private Func<Yw.Model.HydroModelInfo> _hydroInfoFunc = null; |
| | | private Func<List<HydroCalcuResult>> _allHydroCalcuResultListFunc = null; |
| | | |
| | | /// <summary> |
| | | /// 初始化数据 |
| | | /// </summary> |
| | | public void InitialData(Func<Yw.Model.HydroModelInfo> hydroInfoFunc) |
| | | public void InitialData(Func<Yw.Model.HydroModelInfo> hydroInfoFunc, Func<List<HydroCalcuResult>> allHydroCalcuResultListFunc) |
| | | { |
| | | _hydroInfoFunc = hydroInfoFunc; |
| | | _allHydroCalcuResultListFunc = allHydroCalcuResultListFunc; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 选择组件 |
| | | /// </summary> |
| | | public void SelectParter(long id) |
| | | //获取水力信息 |
| | | private Yw.Model.HydroModelInfo GetHydroInfo() |
| | | { |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | { |
| | | this.hydroParterPropertyCtrl1.SelectedObject = null; |
| | | return; |
| | | this.hydroVisualPropertyCtrl1.SelectedObject = null; |
| | | return default; |
| | | } |
| | | var allParterList = hydroInfo.GetAllParters(); |
| | | var parter = allParterList.Find(x => x.ID == id); |
| | | var vm = Yw.WinFrmUI.HydroParterPropertyViewModelBuilder.CreateViewModel(parter, allParterList); |
| | | this.hydroParterPropertyCtrl1.SelectedObject = vm; |
| | | return hydroInfo; |
| | | } |
| | | |
| | | |
| | | public HydroVisualViewModel SelectedObject |
| | | { |
| | | get { return this.hydroVisualPropertyCtrl1.SelectedObject; } |
| | | set { this.hydroVisualPropertyCtrl1.SelectedObject = value; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 选择组件 |
| | | /// 更新行,样式不变 |
| | | /// </summary> |
| | | public void SelectParter(string code) |
| | | public void UpdateRows() |
| | | { |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | this.hydroVisualPropertyCtrl1?.UpdateRows(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 重新载入数据 |
| | | /// </summary> |
| | | public void UpdateData() |
| | | { |
| | | this.hydroVisualPropertyCtrl1?.UpdateData(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新属性 |
| | | /// </summary> |
| | | public void UpdateProperty() |
| | | { |
| | | var vm = this.hydroVisualPropertyCtrl1.SelectedObject; |
| | | if (vm == 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; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 选择组件 |
| | | /// </summary> |
| | | public void SelectParter(Yw.Model.HydroParterInfo parter, List<Yw.Model.HydroParterInfo> allParterList) |
| | | { |
| | | var vm = Yw.WinFrmUI.HydroParterPropertyViewModelBuilder.CreateViewModel(parter, allParterList); |
| | | this.hydroParterPropertyCtrl1.SelectedObject = vm; |
| | | vm.UpdateProperty(); |
| | | this.hydroVisualPropertyCtrl1.UpdateRows(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新计算属性 |
| | | /// </summary> |
| | | public void UpdateCalcuProperty(Yw.WinFrmUI.IHydroCalcuResult rhs) |
| | | public void UpdateCalcuProperty(Yw.WinFrmUI.HydroCalcuResult calcuResult) |
| | | { |
| | | var vm = this.hydroParterPropertyCtrl1.SelectedObject; |
| | | if (calcuResult == null) |
| | | { |
| | | return; |
| | | } |
| | | var vm = this.hydroVisualPropertyCtrl1.SelectedObject; |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | vm.UpdateCalcuProperty(rhs); |
| | | this.hydroParterPropertyCtrl1.UpdateRows(); |
| | | vm.UpdateCalcuProperty(calcuResult); |
| | | this.hydroVisualPropertyCtrl1.UpdateRows(); |
| | | } |
| | | |
| | | //选择曲线 |
| | | private bool HydroParterPropertyCtrl1_SelectCurveEvent(HydroParterPropertyViewModel propViewModel, string curveType) |
| | | private bool HydroParterPropertyCtrl1_SetCurveEvent(HydroParterViewModel propViewModel, string curveType) |
| | | { |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | { |
| | | return false; |
| | | } |
| | | 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 PumpSingleMatchingDlg(); |
| | | dlg.SetBindingData(input); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | if (pumpInfo == null) |
| | | { |
| | | var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs); |
| | | break; |
| | | } |
| | | var input = AssetsMatchingParasHelper.Create(hydroInfo, pumpInfo, _allHydroCalcuResultListFunc?.Invoke()); |
| | | var dlg = new SinglePumpAnalyDlg(); |
| | | dlg.SetBindindData(input); |
| | | dlg.ReloadDataEvent += (output) => |
| | | { |
| | | var bol = AssetsMatchingParasHelper.Apply(hydroInfo, output); |
| | | if (bol) |
| | | { |
| | | TipFormHelper.ShowSucceed("匹配成功"); |
| | | propViewModel.UpdateProperty(); |
| | | this.hydroVisualPropertyCtrl1.UpdateRows(); |
| | | } |
| | | else |
| | | { |
| | | TipFormHelper.ShowWarn("匹配失败"); |
| | | } |
| | | return bol; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | return true; |
| | |
| | | } |
| | | |
| | | //选择模式 |
| | | private bool HydroParterPropertyCtrl1_SelectPatternEvent(HydroParterPropertyViewModel propViewModel, string patternType) |
| | | private bool HydroParterPropertyCtrl1_SetPatternEvent(HydroParterViewModel propViewModel, string patternType) |
| | | { |
| | | switch (patternType) |
| | | { |
| | |
| | | } |
| | | |
| | | //属性发生改变 |
| | | private bool HydroParterPropertyCtrl1_PropertyValueChangedEvent(HydroParterPropertyViewModel obj) |
| | | private void HydroParterPropertyCtrl1_PropertyValueChangedEvent(HydroVisualViewModel vm) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | //属性正在发生改变 |
| | | private bool HydroParterPropertyCtrl1_PropertyValueChangingEvent(HydroParterPropertyViewModel arg) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | //匹配Db事件 |
| | | private void HydroParterPropertyCtrl1_MatchingDbEvent(Yw.Model.HydroParterInfo parter) |
| | | { |
| | | if (parter == null) |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | this.PropertyValueChangedEvent?.Invoke(vm.Vmo); |
| | | } |
| | | |
| | | //标注属性发生改变 |
| | | private void HydroParterPropertyCtrl1_MarkPropertyValueChangedEvent(HydroVisualViewModel vm) |
| | | { |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | this.MarkPropertyValueChangedEvent?.Invoke(vm.Vmo); |
| | | } |
| | | |
| | | //分级属性发生改变 |
| | | private void HydroParterPropertyCtrl1_GradingPropertyValueChangedEvent(HydroVisualViewModel vm) |
| | | { |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | this.GradingPropertyValueChangedEvent?.Invoke(vm.Vmo); |
| | | } |
| | | |
| | | //流向属性发生改变 |
| | | private void HydroParterPropertyCtrl1_FlowDirectionPropertyValueChangedEvent(HydroVisualViewModel vm) |
| | | { |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | this.FlowDirectionPropertyValueChangedEvent?.Invoke(vm.Vmo); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //属性正在发生改变 |
| | | private bool HydroParterPropertyCtrl1_PropertyValueChangingEvent(HydroParterViewModel arg) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | //匹配Db |
| | | private bool HydroParterPropertyCtrl1_MatchingDbEvent(HydroParterViewModel propertyViewModel) |
| | | { |
| | | var bol = false; |
| | | if (propertyViewModel == null) |
| | | { |
| | | return bol; |
| | | } |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | { |
| | | return; |
| | | return bol; |
| | | } |
| | | switch (parter.Catalog) |
| | | var catalog = Yw.WinFrmUI.HydroParterCatalogHelper.GetCode(propertyViewModel.Catalog); |
| | | switch (catalog) |
| | | { |
| | | case Yw.Hydro.ParterCatalog.Pump://水泵 |
| | | { |
| | | var pumpInfo = hydroInfo.Pumps?.Find(x => x.Code == parter.Code); |
| | | var input = AssetsMatchingParasHelper.Create(hydroInfo, pumpInfo); |
| | | var pumpInfo = hydroInfo.Pumps?.Find(x => x.Code == propertyViewModel.Code); |
| | | if (pumpInfo == null) |
| | | { |
| | | break; |
| | | } |
| | | |
| | | var input = AssetsMatchingParasHelper.Create(hydroInfo, pumpInfo, _allHydroCalcuResultListFunc?.Invoke()); |
| | | var dlg = new PumpSingleMatchingDlg(); |
| | | dlg.SetBindingData(input); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | dlg.ReloadDataEvent += (output) => |
| | | { |
| | | var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs); |
| | | bol = AssetsMatchingParasHelper.Apply(hydroInfo, output); |
| | | if (bol) |
| | | { |
| | | TipFormHelper.ShowSucceed("匹配成功"); |
| | | } |
| | | else |
| | | { |
| | | TipFormHelper.ShowWarn("匹配失败"); |
| | | propertyViewModel.UpdateProperty(); |
| | | } |
| | | }; |
| | | 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 valveInfo = hydroInfo.Valves?.Find(x => x.Code == propertyViewModel.Code); |
| | | if (valveInfo == null) |
| | | { |
| | | break; |
| | | } |
| | | var input = AssetsMatchingParasHelper.Create(hydroInfo, valveInfo, _allHydroCalcuResultListFunc?.Invoke()); |
| | | var dlg = new ValveSingleMatchingDlg(); |
| | | dlg.SetBindingData(input); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | |
| | | var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs); |
| | | if (bol) |
| | | { |
| | | TipFormHelper.ShowSucceed("匹配成功"); |
| | | } |
| | | else |
| | | { |
| | | TipFormHelper.ShowWarn("匹配失败"); |
| | | propertyViewModel.UpdateProperty(); |
| | | this.hydroVisualPropertyCtrl1.UpdateRows(); |
| | | } |
| | | }; |
| | | 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 elbowInfo = hydroInfo.Elbows?.Find(x => x.Code == propertyViewModel.Code); |
| | | if (elbowInfo == null) |
| | | { |
| | | break; |
| | | } |
| | | var input = AssetsMatchingParasHelper.Create(hydroInfo, elbowInfo, _allHydroCalcuResultListFunc?.Invoke()); |
| | | var dlg = new ElbowSingMatchingDlg(); |
| | | dlg.SetBindingData(input); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | dlg.ReloadDataEvent += (output) => |
| | | { |
| | | var bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs); |
| | | var bol = AssetsMatchingParasHelper.Apply(hydroInfo, output); |
| | | if (bol) |
| | | { |
| | | TipFormHelper.ShowSucceed("匹配成功"); |
| | | } |
| | | else |
| | | { |
| | | TipFormHelper.ShowWarn("匹配失败"); |
| | | propertyViewModel.UpdateProperty(); |
| | | this.hydroVisualPropertyCtrl1.UpdateRows(); |
| | | } |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | break; |
| | | |
| | | case Yw.Hydro.ParterCatalog.Threelink://三通 |
| | | { |
| | | } |
| | | break; |
| | | |
| | | case Yw.Hydro.ParterCatalog.Fourlink://四通 |
| | | { |
| | | } |
| | | break; |
| | | default: break; |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | //强调连接组件 |
| | | private void HydroParterPropertyCtrl1_BlinkLinkParterEvent(string code, string linkCode) |
| | | { |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(linkCode)) |
| | | { |
| | | return; |
| | | } |
| | | this.BlinkLinkParterEvent?.Invoke(code, linkCode); |
| | | } |
| | | |
| | | //查看构件 |
| | | private void HydroParterPropertyCtrl1_ViewParterEvent(HydroVisualViewModel vm) |
| | | { |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | this.ViewParterEvent?.Invoke(vm.Vmo); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |