ÎļþÃû´Ó WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/19-compressor/HydroCompressorListCtrl.cs ÐÞ¸Ä |
| | |
| | | |
| | | namespace Yw.WinFrmUI |
| | | { |
| | | public partial class HydroCompressorListCtrl : DevExpress.XtraEditors.XtraUserControl, IHydroParterList |
| | | public partial class HydroCompressorListCtrl : DevExpress.XtraEditors.XtraUserControl, IHydroVisualList |
| | | { |
| | | public HydroCompressorListCtrl() |
| | | { |
| | |
| | | /// <summary> |
| | | /// æ°´åç¹å»äºä»¶ |
| | | /// </summary> |
| | | public event Action<Yw.Model.HydroParterInfo> HydroClickEvent; |
| | | public event Action<Yw.Model.HydroVisualInfo> HydroClickInfoEvent; |
| | | /// <summary> |
| | | /// æ°´åç¹å»è§å¾äºä»¶ |
| | | /// </summary> |
| | | public event Action<HydroVisualViewModel> HydroClickViewEvent; |
| | | /// <summary> |
| | | /// æ°´åæ¹åäºä»¶ |
| | | /// </summary> |
| | | public event Action<List<HydroParterInfo>> HydroChangedEvent; |
| | | public event Action<List<Yw.Model.HydroVisualInfo>> HydroChangedInfoEvent; |
| | | /// <summary> |
| | | /// æ°´åæ¹åè§å¾äºä»¶ |
| | | /// </summary> |
| | | public event Action<List<HydroVisualViewModel>> HydroChangedViewEvent; |
| | | |
| | | /// <summary> |
| | | /// æ¾ç¤ºæ¥è¯¢é¢æ¿ |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦æ¥ææ°´å©å表 |
| | | /// æ¯å¦æ¥ææ°´åå表 |
| | | /// </summary> |
| | | public bool HasHydroList |
| | | { |
| | |
| | | /// <summary> |
| | | /// ç»å®æ°æ® |
| | | /// </summary> |
| | | public void SetBindingData(HydroModelInfo hydroInfo) |
| | | public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo) |
| | | { |
| | | _allList = new List<HydroCompressorViewModel>(); |
| | | if (hydroInfo != null && hydroInfo.Compressors != null && hydroInfo.Compressors.Count > 0) |
| | | { |
| | | foreach (var valve in hydroInfo.Compressors) |
| | | foreach (var visual in hydroInfo.Compressors) |
| | | { |
| | | var vm = new HydroCompressorViewModel(valve, hydroInfo); |
| | | var vm = new HydroCompressorViewModel(visual, hydroInfo); |
| | | _allList.Add(vm); |
| | | } |
| | | } |
| | |
| | | _allList = new List<HydroCompressorViewModel>(); |
| | | if (hydroInfo != null && hydroInfo.Compressors != null && hydroInfo.Compressors.Count > 0) |
| | | { |
| | | foreach (var valve in hydroInfo.Compressors) |
| | | foreach (var visual in hydroInfo.Compressors) |
| | | { |
| | | var vm = new HydroCompressorViewModel(valve, hydroInfo); |
| | | var calcuResult = allCalcuResultList?.Find(x => x.Code == valve.Code); |
| | | var vm = new HydroCompressorViewModel(visual, hydroInfo); |
| | | var calcuResult = allCalcuResultList?.Find(x => x.Code == visual.Code); |
| | | if (calcuResult != null) |
| | | { |
| | | vm.UpdateCalcuProperty(calcuResult); |
| | |
| | | } |
| | | } |
| | | Search(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ç»å®æ°æ® |
| | | /// </summary> |
| | | public void SetBindingData(List<HydroVisualViewModel> allVisualViewModelList) |
| | | { |
| | | _allList = new List<HydroCompressorViewModel>(); |
| | | allVisualViewModelList?.ForEach(x => |
| | | { |
| | | if (x.Catalog == HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Compressor)) |
| | | { |
| | | _allList.Add(x as HydroCompressorViewModel); |
| | | } |
| | | }); |
| | | Search(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ´æ°ç»å® |
| | | /// </summary> |
| | | public void UpdateBindingData() |
| | | { |
| | | this.hydroCompressorViewModelBindingSource.ResetBindings(false); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <summary> |
| | | /// æ´æ°å±æ§ |
| | | /// </summary> |
| | | public void UpdateProperty(Yw.Model.HydroParterInfo parter) |
| | | public void UpdateProperty(Yw.Model.HydroVisualInfo visual) |
| | | { |
| | | if (_allList == null || _allList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | if (parter == null) |
| | | if (visual == null) |
| | | { |
| | | return; |
| | | } |
| | | var vm = _allList.Find(x => x.Code == parter.Code); |
| | | var vm = _allList.Find(x => x.Code == visual.Code); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | |
| | | /// <summary> |
| | | /// æ´æ°å±æ§ |
| | | /// </summary> |
| | | public void UpdateProperty(List<Yw.Model.HydroParterInfo> parterList) |
| | | public void UpdateProperty(List<Yw.Model.HydroVisualInfo> visualList) |
| | | { |
| | | if (_allList == null || _allList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | if (parterList == null || parterList.Count < 1) |
| | | if (visualList == null || visualList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | parterList.ForEach(x => |
| | | visualList.ForEach(x => |
| | | { |
| | | var vm = _allList.Find(t => x.Code == x.Code); |
| | | if (vm != null) |
| | |
| | | { |
| | | if (_allList != null && _allList.Count > 0) |
| | | { |
| | | foreach (var parter in _allList) |
| | | foreach (var visual in _allList) |
| | | { |
| | | var calcuResult = allCalcuResultList.Find(x => x.Code == parter.Code); |
| | | var calcuResult = allCalcuResultList.Find(x => x.Code == visual.Code); |
| | | if (calcuResult != null) |
| | | { |
| | | parter.UpdateCalcuProperty(calcuResult); |
| | | visual.UpdateCalcuProperty(calcuResult); |
| | | } |
| | | } |
| | | this.hydroCompressorViewModelBindingSource.ResetBindings(false); |
| | |
| | | Search(); |
| | | if (_allBindingList == null || _allBindingList.Count < 1) |
| | | { |
| | | XtraMessageBox.Show("æ å¯è®¾ç½®é鍿°æ®"); |
| | | TipFormHelper.ShowWarn("æ æ°æ®ï¼"); |
| | | return; |
| | | } |
| | | var dlg = new SetHydroCompressorDlg(); |
| | | dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList()); |
| | | dlg.ReloadDataEvent += (list) => |
| | | { |
| | | _allBindingList.ForEach(x => |
| | | { |
| | | x.UpdateProperty(); |
| | | }); |
| | | _allBindingList.ForEach(x => x.UpdateProperty()); |
| | | this.hydroCompressorViewModelBindingSource.ResetBindings(false); |
| | | var allParterList = _allBindingList.Select(x => x.Vmo as Yw.Model.HydroParterInfo).ToList(); |
| | | this.HydroChangedEvent?.Invoke(allParterList); |
| | | var allVisualViewModelList = _allBindingList.Select(x => x as HydroVisualViewModel).ToList(); |
| | | this.HydroChangedViewEvent?.Invoke(allVisualViewModelList); |
| | | var allVisualInfoList = allVisualViewModelList.Select(x => x.Vmo).ToList(); |
| | | this.HydroChangedInfoEvent?.Invoke(allVisualInfoList); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //æ¥è¯¢ |
| | | 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 HydroCompressorViewModel; |
| | | if (row == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (e.Column == this.colSet) |
| | | { |
| | | var dlg = new SetHydroCompressorDlg(); |
| | | dlg.SetBindingData(row.Vmo); |
| | | dlg.ReloadDataEvent += (list) => |
| | | { |
| | | row.UpdateProperty(); |
| | | this.gridView1.RefreshRow(e.RowHandle); |
| | | this.HydroChangedViewEvent?.Invoke(new List<HydroVisualViewModel>() { row }); |
| | | this.HydroChangedInfoEvent?.Invoke(new List<HydroVisualInfo>() { row.Vmo }); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | else |
| | | { |
| | | this.HydroClickViewEvent?.Invoke(row); |
| | | this.HydroClickInfoEvent?.Invoke(row.Vmo); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | 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 HydroCompressorViewModel; |
| | | if (row == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (e.Column == this.colSet) |
| | | { |
| | | var dlg = new SetHydroCompressorDlg(); |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | |