| | |
| | | using Yw.Model; |
| | | using DevExpress.XtraEditors; |
| | | using Yw.Model; |
| | | |
| | | namespace Yw.WinFrmUI |
| | | { |
| | |
| | | InitializeComponent(); |
| | | this.gridView1.SetNormalView(30); |
| | | this.gridView1.RegistCustomDrawRowIndicator(40); |
| | | this.layoutControl1.SetupLayoutControl(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 水力点击事件 |
| | | /// </summary> |
| | | public event Action<Yw.Model.HydroParterInfo> HydroClickEvent; |
| | | /// <summary> |
| | | /// 水力改变事件 |
| | | /// </summary> |
| | | public event Action<List<HydroParterInfo>> HydroChangedEvent; |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public bool HasHydroList |
| | | { |
| | | get { return _allBindingList != null && _allBindingList.Count > 0; } |
| | | get { return _allList != null && _allList.Count > 0; } |
| | | } |
| | | |
| | | |
| | | private List<HydroExchangerViewModel> _allBindingList = null;//所有绑定列表 |
| | | //所有列表 |
| | | private List<HydroExchangerViewModel> _allList = null; |
| | | //所有绑定列表 |
| | | private List<HydroExchangerViewModel> _allBindingList = null; |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | /// <param name="allExchangerList"></param> |
| | | public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList) |
| | | public void SetBindingData(HydroModelInfo hydroInfo) |
| | | { |
| | | _allBindingList = new List<HydroExchangerViewModel>(); |
| | | _allList = new List<HydroExchangerViewModel>(); |
| | | if (hydroInfo != null && hydroInfo.Exchangers != null && hydroInfo.Exchangers.Count > 0) |
| | | { |
| | | foreach (var exchanger in hydroInfo.Exchangers) |
| | | foreach (var valve in hydroInfo.Exchangers) |
| | | { |
| | | var calcuLinkResult = allCalcuResultList?.Find(x => x.Code == exchanger.Code) as HydroCalcuLinkResult; |
| | | var vm = new HydroExchangerViewModel(exchanger, hydroInfo); |
| | | _allBindingList.Add(vm); |
| | | var vm = new HydroExchangerViewModel(valve, hydroInfo); |
| | | _allList.Add(vm); |
| | | } |
| | | } |
| | | Search(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList) |
| | | { |
| | | _allList = new List<HydroExchangerViewModel>(); |
| | | if (hydroInfo != null && hydroInfo.Exchangers != null && hydroInfo.Exchangers.Count > 0) |
| | | { |
| | | foreach (var valve in hydroInfo.Exchangers) |
| | | { |
| | | var vm = new HydroExchangerViewModel(valve, hydroInfo); |
| | | var calcuResult = allCalcuResultList?.Find(x => x.Code == valve.Code); |
| | | if (calcuResult != null) |
| | | { |
| | | vm.UpdateCalcuProperty(calcuResult); |
| | | } |
| | | _allList.Add(vm); |
| | | } |
| | | } |
| | | Search(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新属性 |
| | | /// </summary> |
| | | public void UpdateProperty() |
| | | { |
| | | if (_allList == null || _allList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | _allList.ForEach(x => x.UpdateProperty()); |
| | | this.hydroExchangerViewModelBindingSource.ResetBindings(false); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新属性 |
| | | /// </summary> |
| | | public void UpdateProperty(Yw.Model.HydroParterInfo parter) |
| | | { |
| | | if (_allList == null || _allList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | if (parter == null) |
| | | { |
| | | return; |
| | | } |
| | | var vm = _allList.Find(x => x.Code == parter.Code); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | vm.UpdateProperty(); |
| | | this.hydroExchangerViewModelBindingSource.ResetBindings(false); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新属性 |
| | | /// </summary> |
| | | public void UpdateProperty(List<Yw.Model.HydroParterInfo> parterList) |
| | | { |
| | | if (_allList == null || _allList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | if (parterList == null || parterList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | parterList.ForEach(x => |
| | | { |
| | | var vm = _allList.Find(t => x.Code == x.Code); |
| | | if (vm != null) |
| | | { |
| | | vm.UpdateProperty(); |
| | | } |
| | | }); |
| | | this.hydroExchangerViewModelBindingSource.ResetBindings(false); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新计算属性 |
| | | /// </summary> |
| | | public void UpdateCalcuProperty(List<HydroCalcuResult> allCalcuResultList) |
| | | { |
| | | if (allCalcuResultList != null && allCalcuResultList.Count > 0) |
| | | { |
| | | if (_allList != null && _allList.Count > 0) |
| | | { |
| | | foreach (var parter in _allList) |
| | | { |
| | | var calcuResult = allCalcuResultList.Find(x => x.Code == parter.Code); |
| | | if (calcuResult != null) |
| | | { |
| | | parter.UpdateCalcuProperty(calcuResult); |
| | | } |
| | | } |
| | | this.hydroExchangerViewModelBindingSource.ResetBindings(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //查询 |
| | | private void Search() |
| | | { |
| | | if (_allList == null || _allList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var name = this.txtName.Text.Trim(); |
| | | var code = this.txtCode.Text.Trim(); |
| | | var modelType = this.txtModelType.Text.Trim(); |
| | | _allBindingList = _allList; |
| | | if (!string.IsNullOrEmpty(name)) |
| | | { |
| | | _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains(name)).ToList(); |
| | | } |
| | | if (!string.IsNullOrEmpty(code)) |
| | | { |
| | | _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.Code) && x.Code.Contains(code)).ToList(); |
| | | } |
| | | if (!string.IsNullOrEmpty(modelType)) |
| | | { |
| | | _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.ModelType) && x.ModelType.Contains(modelType)).ToList(); |
| | | } |
| | | this.hydroExchangerViewModelBindingSource.DataSource = _allBindingList; |
| | | this.hydroExchangerViewModelBindingSource.ResetBindings(false); |
| | | if (allCalcuResultList == null || allCalcuResultList.Count < 1) |
| | | { |
| | | SetNormalView(); |
| | | } |
| | | else |
| | | { |
| | | SetCalcuView(); |
| | | } |
| | | } |
| | | |
| | | //重置 |
| | | private void Reset() |
| | | { |
| | | this.txtName.EditValue = null; |
| | | this.txtCode.EditValue = null; |
| | | this.txtModelType.EditValue = null; |
| | | Search(); |
| | | } |
| | | |
| | | //设置 |
| | | private void Set() |
| | | { |
| | | Search(); |
| | | if (_allBindingList == null || _allBindingList.Count < 1) |
| | | { |
| | | XtraMessageBox.Show("无可设置阀门数据"); |
| | | return; |
| | | } |
| | | var dlg = new SetHydroExchangerDlg(); |
| | | dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList()); |
| | | dlg.ReloadDataEvent += (list) => |
| | | { |
| | | _allBindingList.ForEach(x => |
| | | { |
| | | x.UpdateProperty(); |
| | | }); |
| | | this.hydroExchangerViewModelBindingSource.ResetBindings(false); |
| | | var allParterList = _allBindingList.Select(x => x.Vmo as Yw.Model.HydroParterInfo).ToList(); |
| | | this.HydroChangedEvent?.Invoke(allParterList); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设置简单显示模式 |
| | | /// </summary> |
| | | public void SetSimpleView() |
| | | { |
| | | this.colDbLocked.Visible = true; |
| | | this.colCode.Visible = true; |
| | | this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | this.colDbLocked.Visible = false; |
| | | this.colName.Visible = true; |
| | | this.colCode.Visible = true; |
| | | this.colModelType.Visible = true; |
| | | this.colHasDb.Visible = true; |
| | | this.colStartCode.Visible = false; |
| | | this.colEndCode.Visible = false; |
| | | this.colLinkStatus.Visible = true; |
| | | this.colDiameter.Visible = false; |
| | | this.colLength.Visible = false; |
| | | this.colMaterial.Visible = false; |
| | | this.colRoughness.Visible = true; |
| | | this.colMinorLoss.Visible = true; |
| | | this.colMinorLossK.Visible = true; |
| | | this.colDiameter.Visible = false; |
| | | this.colMinorLoss.Visible = false; |
| | | this.colCalcuFlow.Visible = false; |
| | | this.colCalcuVelocity.Visible = false; |
| | | this.colCalcuHeadLoss.Visible = false; |
| | | this.colFlagsString.Visible = true; |
| | | this.colHasDb.Visible = false; |
| | | this.colFlags.Visible = true; |
| | | this.colDescription.Visible = true; |
| | | this.colSet.Visible = false; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public void SetNormalView() |
| | | { |
| | | this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | this.colDbLocked.Visible = true; |
| | | this.colCode.Visible = true; |
| | | this.colName.Visible = true; |
| | | this.colCode.Visible = true; |
| | | this.colModelType.Visible = true; |
| | | this.colHasDb.Visible = true; |
| | | this.colStartCode.Visible = false; |
| | | this.colEndCode.Visible = false; |
| | | this.colLinkStatus.Visible = true; |
| | | this.colDiameter.Visible = true; |
| | | this.colLength.Visible = true; |
| | | this.colMaterial.Visible = true; |
| | | this.colRoughness.Visible = true; |
| | | this.colDiameter.Visible = true; |
| | | this.colMinorLoss.Visible = true; |
| | | this.colMinorLossK.Visible = true; |
| | | this.colCalcuFlow.Visible = false; |
| | | this.colCalcuVelocity.Visible = false; |
| | | this.colCalcuHeadLoss.Visible = false; |
| | | this.colFlagsString.Visible = true; |
| | | this.colHasDb.Visible = true; |
| | | this.colFlags.Visible = true; |
| | | this.colDescription.Visible = true; |
| | | this.colSet.Visible = true; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public void SetCalcuView() |
| | | { |
| | | this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | this.colDbLocked.Visible = true; |
| | | this.colCode.Visible = true; |
| | | this.colName.Visible = true; |
| | | this.colCode.Visible = true; |
| | | this.colModelType.Visible = true; |
| | | this.colHasDb.Visible = true; |
| | | this.colStartCode.Visible = false; |
| | | this.colEndCode.Visible = false; |
| | | this.colLinkStatus.Visible = true; |
| | | this.colDiameter.Visible = true; |
| | | this.colLength.Visible = true; |
| | | this.colMaterial.Visible = true; |
| | | this.colRoughness.Visible = true; |
| | | this.colDiameter.Visible = true; |
| | | this.colMinorLoss.Visible = true; |
| | | this.colMinorLossK.Visible = true; |
| | | this.colCalcuFlow.Visible = true; |
| | | this.colCalcuVelocity.Visible = true; |
| | | this.colCalcuHeadLoss.Visible = true; |
| | | this.colFlagsString.Visible = true; |
| | | this.colHasDb.Visible = true; |
| | | this.colFlags.Visible = true; |
| | | this.colDescription.Visible = true; |
| | | this.colSet.Visible = true; |
| | | } |
| | | |
| | | //行点击事件 |
| | | private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) |
| | | /// <summary> |
| | | /// 设置批量设置模式 |
| | | /// </summary> |
| | | public void SetBulkSetView() |
| | | { |
| | | this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
| | | this.colDbLocked.Visible = true; |
| | | this.colName.Visible = true; |
| | | this.colCode.Visible = true; |
| | | this.colModelType.Visible = true; |
| | | this.colLinkStatus.Visible = true; |
| | | this.colMaterial.Visible = true; |
| | | this.colDiameter.Visible = true; |
| | | this.colMinorLoss.Visible = true; |
| | | this.colCalcuFlow.Visible = false; |
| | | this.colCalcuVelocity.Visible = false; |
| | | this.colCalcuHeadLoss.Visible = false; |
| | | this.colHasDb.Visible = true; |
| | | this.colFlags.Visible = true; |
| | | this.colDescription.Visible = true; |
| | | this.colSet.Visible = true; |
| | | } |
| | | |
| | | //查询 |
| | | private void btnSearch_Click(object sender, EventArgs e) |
| | | { |
| | | Search(); |
| | | } |
| | | |
| | | //重置 |
| | | private void btnReset_Click(object sender, EventArgs e) |
| | | { |
| | | Reset(); |
| | | } |
| | | |
| | | //设置 |
| | | private void btnSet_Click(object sender, EventArgs e) |
| | | { |
| | | Set(); |
| | | } |
| | | |
| | | //单元格点击 |
| | | private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) |
| | | { |
| | | var row = this.gridView1.GetRow(e.RowHandle) as HydroExchangerViewModel; |
| | | if (row == null) |
| | | { |
| | | return; |
| | | } |
| | | this.HydroClickEvent?.Invoke(row.Vmo); |
| | | |
| | | if (e.Column == this.colSet) |
| | | { |
| | | var dlg = new SetHydroExchangerDlg(); |
| | | dlg.SetBindingData(row.Vmo); |
| | | dlg.ReloadDataEvent += (list) => |
| | | { |
| | | row.UpdateProperty(); |
| | | this.gridView1.RefreshRow(e.RowHandle); |
| | | this.HydroChangedEvent?.Invoke(new List<Model.HydroParterInfo>() { row.Vmo }); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | else |
| | | { |
| | | this.HydroClickEvent?.Invoke(row.Vmo); |
| | | } |
| | | } |
| | | |
| | | public void SetBindingData(HydroModelInfo hydroInfo) |
| | | { |
| | | throw new NotImplementedException(); |
| | | } |
| | | |
| | | public void SetBulkSetView() |
| | | { |
| | | throw new NotImplementedException(); |
| | | } |
| | | |
| | | public void UpdateProperty() |
| | | { |
| | | throw new NotImplementedException(); |
| | | } |
| | | |
| | | public void UpdateProperty(HydroParterInfo parter) |
| | | { |
| | | throw new NotImplementedException(); |
| | | } |
| | | |
| | | public void UpdateProperty(List<HydroParterInfo> parterList) |
| | | { |
| | | throw new NotImplementedException(); |
| | | } |
| | | |
| | | public void UpdateCalcuProperty(List<HydroCalcuResult> allCalcuResultList) |
| | | { |
| | | throw new NotImplementedException(); |
| | | } |
| | | } |
| | | } |