| | |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using HStation.WinFrmUI.Xhs; |
| | | using Yw.Model; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | |
| | | public XhsProjectSimulationPropertyCtrl() |
| | | { |
| | | InitializeComponent(); |
| | | this.hydroVisualPropertyCtrl1.MatchingDbEvent += HydroVisualPropertyCtrl1_MatchingDbEvent; |
| | | this.hydroVisualPropertyCtrl1.SetCurveEvent += HydroVisualPropertyCtrl1_SetCurveEvent; |
| | | this.hydroVisualPropertyCtrl1.SetPatternEvent += HydroVisualPropertyCtrl1_SetPatternEvent; |
| | | |
| | | this.hydroParterPropertyCtrl1.PropertyValueChangedEvent += HydroParterPropertyCtrl1_PropertyValueChangedEvent; |
| | | this.hydroParterPropertyCtrl1.PropertyValueChangingEvent += HydroParterPropertyCtrl1_PropertyValueChangingEvent; |
| | | this.hydroParterPropertyCtrl1.MatchingDbEvent += HydroParterPropertyCtrl1_MatchingDbEvent; |
| | | this.hydroParterPropertyCtrl1.SetCurveEvent += HydroParterPropertyCtrl1_SetCurveEvent; |
| | | this.hydroParterPropertyCtrl1.SetPatternEvent += HydroParterPropertyCtrl1_SetPatternEvent; |
| | | this.hydroParterPropertyCtrl1.BlinkLinkParterEvent += HydroParterPropertyCtrl1_BlinkLinkParterEvent; |
| | | this.hydroVisualPropertyCtrl1.HydroViewEvent += HydroVisualPropertyCtrl1_HydroViewEvent; |
| | | this.hydroVisualPropertyCtrl1.BlinkLinkNodeEvent += HydroVisualPropertyCtrl1_BlinkLinkNodeEvent; |
| | | this.hydroVisualPropertyCtrl1.PropertyValueChangedEvent += HydroVisualPropertyCtrl1_PropertyValueChangedEvent; |
| | | this.hydroVisualPropertyCtrl1.MarkPropertyValueChangedEvent += HydroVisualPropertyCtrl1_MarkPropertyValueChangedEvent; |
| | | this.hydroVisualPropertyCtrl1.GradingPropertyValueChangedEvent += HydroPVisualPropertyCtrl1_GradingPropertyValueChangedEvent; |
| | | this.hydroVisualPropertyCtrl1.FlowEffectPropertyValueChangedEvent += HydroVisualPropertyCtrl1_FlowEffectPropertyValueChangedEvent; |
| | | } |
| | | |
| | | #region 事件集 |
| | | |
| | | /// <summary> |
| | | /// 构件查看事件 |
| | | /// </summary> |
| | | public event Action<HydroVisualInfo> HydroViewEvent; |
| | | |
| | | /// <summary> |
| | | /// 强调连接组件事件 |
| | | /// 第一个参数为组件Code |
| | | /// 第二个参数为连接组件Code |
| | | /// 第一个参数为组件 |
| | | /// 第二个参数为连接节点Code |
| | | /// </summary> |
| | | public event Action<string, string> BlinkLinkParterEvent; |
| | | |
| | | //水力信息方法 |
| | | private Func<Yw.Model.HydroModelInfo> _hydroInfoFunc = null; |
| | | private Func<List<HydroCalcuResult>> _allHydroCalcuResultListFunc = null; |
| | | public event Action<HydroLinkInfo, string> BlinkLinkNodeEvent; |
| | | |
| | | /// <summary> |
| | | /// 初始化数据 |
| | | /// 属性值改变事件 |
| | | /// </summary> |
| | | public void InitialData(Func<Yw.Model.HydroModelInfo> hydroInfoFunc, Func<List<HydroCalcuResult>> allHydroCalcuResultListFunc) |
| | | public event Action<HydroVisualInfo> PropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 标注属性值改变事件 |
| | | /// </summary> |
| | | public event Action<HydroVisualInfo> MarkPropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 分级属性值改变事件 |
| | | /// </summary> |
| | | public event Action<HydroVisualInfo> GradingPropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 水流动画属性值改变事件 |
| | | /// </summary> |
| | | public event Action<HydroVisualInfo> FlowEffectPropertyValueChangedEvent; |
| | | |
| | | #endregion 事件集 |
| | | |
| | | #region 属性赋值 |
| | | |
| | | /// <summary> |
| | | /// 选择对象 |
| | | /// </summary> |
| | | public HydroVisualViewModel SelectedObject |
| | | { |
| | | _hydroInfoFunc = hydroInfoFunc; |
| | | _allHydroCalcuResultListFunc = allHydroCalcuResultListFunc; |
| | | this.hydroParterPropertyCtrl1.InitialData(hydroInfoFunc); |
| | | get { return this.hydroVisualPropertyCtrl1.SelectedObject; } |
| | | set { this.hydroVisualPropertyCtrl1.SelectedObject = value; } |
| | | } |
| | | |
| | | #endregion 属性赋值 |
| | | |
| | | #region 属性更新 |
| | | |
| | | /// <summary> |
| | | /// 重新载入数据 |
| | | /// </summary> |
| | | public void UpdateData() |
| | | { |
| | | this.hydroVisualPropertyCtrl1?.UpdateData(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 选择组件 |
| | | /// 更新行,样式不变 |
| | | /// </summary> |
| | | public void SelectParter(long id) |
| | | public void UpdateRows() |
| | | { |
| | | 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; |
| | | this.hydroVisualPropertyCtrl1?.UpdateRows(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 选择组件 |
| | | /// 更新属性 |
| | | /// </summary> |
| | | public void SelectParter(string code) |
| | | public void UpdateProperty() |
| | | { |
| | | 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; |
| | | } |
| | | |
| | | /// <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; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新计算属性 |
| | | /// </summary> |
| | | public void UpdateCalcuProperty(Yw.WinFrmUI.IHydroCalcuResult rhs) |
| | | { |
| | | var vm = this.hydroParterPropertyCtrl1.SelectedObject; |
| | | var vm = this.hydroVisualPropertyCtrl1.SelectedObject; |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | vm.UpdateCalcuProperty(rhs); |
| | | this.hydroParterPropertyCtrl1.UpdateRows(); |
| | | vm.UpdateProperty(); |
| | | this.hydroVisualPropertyCtrl1.UpdateRows(); |
| | | } |
| | | |
| | | #endregion 属性更新 |
| | | |
| | | #region 事件实现 |
| | | |
| | | //匹配Db |
| | | private bool HydroVisualPropertyCtrl1_MatchingDbEvent(HydroVisualViewModel vm) |
| | | { |
| | | if (vm == null) |
| | | { |
| | | return false; |
| | | } |
| | | var bol = false; |
| | | var catalog = HydroParterCatalogHelper.GetCode(vm.Catalog); |
| | | switch (catalog) |
| | | { |
| | | case Yw.Hydro.ParterCatalog.Pump://水泵 |
| | | { |
| | | /* var pumpInfo = vm.HydroInfo.Pumps?.Find(x => x.Code == vm.Code); |
| | | if (pumpInfo == null) |
| | | { |
| | | break; |
| | | } |
| | | |
| | | var input = AssetsMatchingParasHelper.Create(vm.HydroInfo, pumpInfo, null); |
| | | var dlg = new PumpSingleMatchingDlg(); |
| | | dlg.SetBindingData(input); |
| | | dlg.ReloadDataEvent += (output) => |
| | | { |
| | | bol = AssetsMatchingParasHelper.Apply(vm.HydroInfo, output); |
| | | if (bol) |
| | | { |
| | | vm.UpdateProperty(); |
| | | } |
| | | }; |
| | | dlg.ShowDialog();*/ |
| | | } |
| | | break; |
| | | |
| | | case Yw.Hydro.ParterCatalog.Valve://阀门 |
| | | { |
| | | /* var valveInfo = vm.HydroInfo.Valves?.Find(x => x.Code == vm.Code); |
| | | if (valveInfo == null) |
| | | { |
| | | break; |
| | | } |
| | | var input = AssetsMatchingParasHelper.Create(vm.HydroInfo, valveInfo, null); |
| | | var dlg = new ValveSingleMatchingDlg(); |
| | | dlg.SetBindingData(input); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | { |
| | | bol = AssetsMatchingParasHelper.Apply(vm.HydroInfo, rhs); |
| | | if (bol) |
| | | { |
| | | vm.UpdateProperty(); |
| | | this.hydroVisualPropertyCtrl1.UpdateRows(); |
| | | } |
| | | }; |
| | | dlg.ShowDialog();*/ |
| | | } |
| | | break; |
| | | |
| | | case Yw.Hydro.ParterCatalog.Pipe://管道 |
| | | { |
| | | } |
| | | break; |
| | | |
| | | case Yw.Hydro.ParterCatalog.Elbow://弯头 |
| | | { |
| | | var elbowInfo = vm.HydroInfo.Elbows?.Find(x => x.Code == vm.Code); |
| | | if (elbowInfo == null) |
| | | { |
| | | break; |
| | | } |
| | | var input = HydroMatchingHelper.Create(elbowInfo, vm.HydroInfo, null); |
| | | var dlg = new ElbowSingMatchingDlg(); |
| | | dlg.SetBindingData(input); |
| | | dlg.ReloadDataEvent += (output) => |
| | | { |
| | | bol = HydroMatchingHelper.Apply(vm.HydroInfo, null, output); |
| | | if (bol) |
| | | { |
| | | vm.UpdateProperty(); |
| | | this.hydroVisualPropertyCtrl1.UpdateRows(); |
| | | } |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | break; |
| | | |
| | | case Yw.Hydro.ParterCatalog.Threelink://三通 |
| | | { |
| | | } |
| | | break; |
| | | |
| | | case Yw.Hydro.ParterCatalog.Fourlink://四通 |
| | | { |
| | | } |
| | | break; |
| | | |
| | | default: break; |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | //选择曲线 |
| | | private bool HydroParterPropertyCtrl1_SetCurveEvent(HydroParterPropertyViewModel propViewModel, string curveType) |
| | | private bool HydroVisualPropertyCtrl1_SetCurveEvent(HydroVisualViewModel vm, string curveType) |
| | | { |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | if (vm == null) |
| | | { |
| | | return false; |
| | | } |
| | | switch (curveType) |
| | | { |
| | | case Yw.WinFrmUI.HydroCurve.Pump: |
| | | case HydroCurve.Pump: |
| | | { |
| | | var pumpInfo = hydroInfo.Pumps?.Find(x => x.Code == propViewModel.Code); |
| | | if (pumpInfo == null) |
| | | { |
| | | 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) |
| | | { |
| | | propViewModel.UpdateProperty(pumpInfo, hydroInfo.GetAllParters()); |
| | | this.hydroParterPropertyCtrl1.UpdateRows(); |
| | | } |
| | | return bol; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | //var pumpInfo = vm.HydroInfo.Pumps?.Find(x => x.Code == vm.Code); |
| | | //if (pumpInfo == null) |
| | | //{ |
| | | // break; |
| | | //} |
| | | //var input = AssetsMatchingParasHelper.Create(vm.HydroInfo, pumpInfo, null); |
| | | //var dlg = new SinglePumpAnalyDlg(); |
| | | //dlg.SetBindindData(input); |
| | | //dlg.ReloadDataEvent += (output) => |
| | | //{ |
| | | // var bol = AssetsMatchingParasHelper.Apply(vm.HydroInfo, output); |
| | | // if (bol) |
| | | // { |
| | | // vm.UpdateProperty(); |
| | | // this.hydroVisualPropertyCtrl1.UpdateRows(); |
| | | // } |
| | | // return bol; |
| | | //}; |
| | | //dlg.ShowDialog(); |
| | | return true; |
| | | } |
| | | case Yw.WinFrmUI.HydroCurve.PumpQH: |
| | | case HydroCurve.PumpQH: |
| | | { |
| | | return false; |
| | | } |
| | | case Yw.WinFrmUI.HydroCurve.PumpQP: |
| | | case HydroCurve.PumpQP: |
| | | { |
| | | return false; |
| | | } |
| | | case Yw.WinFrmUI.HydroCurve.PumpQE: |
| | | case HydroCurve.PumpQE: |
| | | { |
| | | return false; |
| | | } |
| | | case Yw.WinFrmUI.HydroCurve.Valve: |
| | | case HydroCurve.Valve: |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | case Yw.WinFrmUI.HydroCurve.ValveQL: |
| | | case HydroCurve.ValveQL: |
| | | { |
| | | return false; |
| | | } |
| | |
| | | } |
| | | |
| | | //选择模式 |
| | | private bool HydroParterPropertyCtrl1_SetPatternEvent(HydroParterPropertyViewModel propViewModel, string patternType) |
| | | private bool HydroVisualPropertyCtrl1_SetPatternEvent(HydroVisualViewModel vm, string patternType) |
| | | { |
| | | switch (patternType) |
| | | { |
| | | case Yw.WinFrmUI.HydroPattern.Demand: |
| | | case HydroPattern.Head: |
| | | { |
| | | return false; |
| | | } |
| | | break; |
| | | |
| | | case Yw.WinFrmUI.HydroPattern.Head: |
| | | case HydroPattern.Demand: |
| | | { |
| | | return false; |
| | | } |
| | | break; |
| | | |
| | | default: break; |
| | | } |
| | | return true; |
| | | return false; |
| | | } |
| | | |
| | | #endregion 事件实现 |
| | | |
| | | #region 事件穿透 |
| | | |
| | | //构件查看事件 |
| | | private void HydroVisualPropertyCtrl1_HydroViewEvent(HydroVisualViewModel vm) |
| | | { |
| | | this.HydroViewEvent?.Invoke(vm?.Vmo); |
| | | } |
| | | |
| | | //强调连接节点 |
| | | private void HydroVisualPropertyCtrl1_BlinkLinkNodeEvent(HydroLinkViewModel vm, string linkNodeCode) |
| | | { |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(linkNodeCode)) |
| | | { |
| | | return; |
| | | } |
| | | this.BlinkLinkNodeEvent?.Invoke(vm?.Vmo, linkNodeCode); |
| | | } |
| | | |
| | | //属性发生改变 |
| | | private bool HydroParterPropertyCtrl1_PropertyValueChangedEvent(HydroParterPropertyViewModel obj) |
| | | private void HydroVisualPropertyCtrl1_PropertyValueChangedEvent(HydroVisualViewModel vm) |
| | | { |
| | | return false; |
| | | this.PropertyValueChangedEvent?.Invoke(vm?.Vmo); |
| | | } |
| | | |
| | | //属性正在发生改变 |
| | | private bool HydroParterPropertyCtrl1_PropertyValueChangingEvent(HydroParterPropertyViewModel arg) |
| | | //标注属性发生改变 |
| | | private void HydroVisualPropertyCtrl1_MarkPropertyValueChangedEvent(HydroVisualViewModel vm) |
| | | { |
| | | return false; |
| | | this.MarkPropertyValueChangedEvent?.Invoke(vm?.Vmo); |
| | | } |
| | | |
| | | //匹配Db |
| | | private bool HydroParterPropertyCtrl1_MatchingDbEvent(HydroParterPropertyViewModel propertyViewModel) |
| | | //分级属性发生改变 |
| | | private void HydroPVisualPropertyCtrl1_GradingPropertyValueChangedEvent(HydroVisualViewModel vm) |
| | | { |
| | | var bol = false; |
| | | if (propertyViewModel == null) |
| | | { |
| | | return bol; |
| | | } |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | { |
| | | return bol; |
| | | } |
| | | var catalog = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogCode(propertyViewModel.Catalog); |
| | | switch (catalog) |
| | | { |
| | | case Yw.Hydro.ParterCatalog.Pump://水泵 |
| | | { |
| | | 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 += (output) => |
| | | { |
| | | bol = AssetsMatchingParasHelper.Apply(hydroInfo, output); |
| | | if (bol) |
| | | { |
| | | propertyViewModel.UpdateProperty(pumpInfo, hydroInfo.GetAllParters()); |
| | | } |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | break; |
| | | case Yw.Hydro.ParterCatalog.Valve://阀门 |
| | | { |
| | | 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) => |
| | | { |
| | | bol = AssetsMatchingParasHelper.Apply(hydroInfo, rhs); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | break; |
| | | case Yw.Hydro.ParterCatalog.Pipe://管道 |
| | | { |
| | | } |
| | | break; |
| | | case Yw.Hydro.ParterCatalog.Elbow://弯头 |
| | | { |
| | | 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 += (output) => |
| | | { |
| | | bol = AssetsMatchingParasHelper.Apply(hydroInfo, output); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | break; |
| | | case Yw.Hydro.ParterCatalog.Threelink://三通 |
| | | { |
| | | } |
| | | break; |
| | | case Yw.Hydro.ParterCatalog.Fourlink://四通 |
| | | { |
| | | } |
| | | break; |
| | | default: break; |
| | | } |
| | | return bol; |
| | | this.GradingPropertyValueChangedEvent?.Invoke(vm?.Vmo); |
| | | } |
| | | |
| | | //强调连接组件 |
| | | private void HydroParterPropertyCtrl1_BlinkLinkParterEvent(string code, string linkCode) |
| | | //水流动画属性发生改变 |
| | | private void HydroVisualPropertyCtrl1_FlowEffectPropertyValueChangedEvent(HydroVisualViewModel vm) |
| | | { |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(linkCode)) |
| | | { |
| | | return; |
| | | } |
| | | this.BlinkLinkParterEvent?.Invoke(code, linkCode); |
| | | this.FlowEffectPropertyValueChangedEvent?.Invoke(vm?.Vmo); |
| | | } |
| | | |
| | | |
| | | #endregion 事件穿透 |
| | | } |
| | | } |