From c9585ab171fb973d16792d7a290994bf8279da63 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期六, 09 十一月 2024 09:56:41 +0800 Subject: [PATCH] 属性视图调整 --- WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/01-reservoir/HydroReservoirListCtrl.cs | 167 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 86 insertions(+), 81 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/03-waterbox/HydroWaterboxListCtrl.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/01-reservoir/HydroReservoirListCtrl.cs similarity index 66% copy from WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/03-waterbox/HydroWaterboxListCtrl.cs copy to WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/01-reservoir/HydroReservoirListCtrl.cs index d894cd2..933d7dc 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/03-waterbox/HydroWaterboxListCtrl.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/01-reservoir/HydroReservoirListCtrl.cs @@ -1,11 +1,10 @@ -锘縰sing DevExpress.XtraEditors; -using Yw.Model; +锘縰sing Yw.Model; namespace Yw.WinFrmUI { - public partial class HydroWaterboxListCtrl : DevExpress.XtraEditors.XtraUserControl, IHydroParterList + public partial class HydroReservoirListCtrl : DevExpress.XtraEditors.XtraUserControl, IHydroVisualList { - public HydroWaterboxListCtrl() + public HydroReservoirListCtrl() { InitializeComponent(); this.gridView1.SetNormalView(30); @@ -16,11 +15,19 @@ /// <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<Yw.Model.HydroParterInfo>> HydroChangedEvent; + public event Action<List<Yw.Model.HydroVisualInfo>> HydroChangedInfoEvent; + /// <summary> + /// 姘村姏鏀瑰彉瑙嗗浘浜嬩欢 + /// </summary> + public event Action<List<HydroVisualViewModel>> HydroChangedViewEvent; /// <summary> /// 鏄剧ず鏌ヨ闈㈡澘 @@ -35,30 +42,29 @@ } /// <summary> - /// 鏄惁鎷ユ湁姘村埄鍒楄〃 + /// 鏄惁鎷ユ湁姘村姏鍒楄〃 /// </summary> public bool HasHydroList { get { return _allList != null && _allList.Count > 0; } } - //鎵�鏈夊垪琛� - private List<HydroWaterboxViewModel> _allList = null; + private List<HydroReservoirViewModel> _allList = null; //鎵�鏈夌粦瀹氬垪琛� - private List<HydroWaterboxViewModel> _allBindingList = null; + private List<HydroReservoirViewModel> _allBindingList = null; /// <summary> /// 缁戝畾鏁版嵁 /// </summary> public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo) { - _allList = new List<HydroWaterboxViewModel>(); - if (hydroInfo != null && hydroInfo.Waterboxs != null && hydroInfo.Waterboxs.Count > 0) + _allList = new List<HydroReservoirViewModel>(); + if (hydroInfo != null && hydroInfo.Reservoirs != null && hydroInfo.Reservoirs.Count > 0) { - foreach (var waterbox in hydroInfo.Waterboxs) + foreach (var visual in hydroInfo.Reservoirs) { - var vm = new HydroWaterboxViewModel(waterbox, hydroInfo); + var vm = new HydroReservoirViewModel(visual, hydroInfo); _allList.Add(vm); } } @@ -70,13 +76,13 @@ /// </summary> public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList) { - _allList = new List<HydroWaterboxViewModel>(); - if (hydroInfo != null && hydroInfo.Waterboxs != null && hydroInfo.Waterboxs.Count > 0) + _allList = new List<HydroReservoirViewModel>(); + if (hydroInfo != null && hydroInfo.Reservoirs != null && hydroInfo.Reservoirs.Count > 0) { - foreach (var waterbox in hydroInfo.Waterboxs) + foreach (var visual in hydroInfo.Reservoirs) { - var vm = new HydroWaterboxViewModel(waterbox, hydroInfo); - var calcuResult = allCalcuResultList?.Find(x => x.Code == waterbox.Code); + var vm = new HydroReservoirViewModel(visual, hydroInfo); + var calcuResult = allCalcuResultList?.Find(x => x.Code == visual.Code); if (calcuResult != null) { vm.UpdateCalcuProperty(calcuResult); @@ -85,6 +91,30 @@ } } Search(); + } + + /// <summary> + /// 缁戝畾鏁版嵁 + /// </summary> + public void SetBindingData(List<HydroVisualViewModel> allVisualViewModelList) + { + _allList = new List<HydroReservoirViewModel>(); + allVisualViewModelList?.ForEach(x => + { + if (x.Catalog == HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Reservoir)) + { + _allList.Add(x as HydroReservoirViewModel); + } + }); + Search(); + } + + /// <summary> + /// 鏇存柊缁戝畾 + /// </summary> + public void UpdateBindingData() + { + this.hydroReservoirViewModelBindingSource.ResetBindings(false); } /// <summary> @@ -97,45 +127,45 @@ return; } _allList.ForEach(x => x.UpdateProperty()); - this.hydroWaterboxViewModelBindingSource.ResetBindings(false); + this.hydroReservoirViewModelBindingSource.ResetBindings(false); } /// <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; } vm.UpdateProperty(); - this.hydroWaterboxViewModelBindingSource.ResetBindings(false); + this.hydroReservoirViewModelBindingSource.ResetBindings(false); } /// <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) @@ -143,7 +173,7 @@ vm.UpdateProperty(); } }); - this.hydroWaterboxViewModelBindingSource.ResetBindings(false); + this.hydroReservoirViewModelBindingSource.ResetBindings(false); } /// <summary> @@ -155,15 +185,15 @@ { 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.hydroWaterboxViewModelBindingSource.ResetBindings(false); + this.hydroReservoirViewModelBindingSource.ResetBindings(false); } } } @@ -191,8 +221,8 @@ { _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.ModelType) && x.ModelType.Contains(modelType)).ToList(); } - this.hydroWaterboxViewModelBindingSource.DataSource = _allBindingList; - this.hydroWaterboxViewModelBindingSource.ResetBindings(false); + this.hydroReservoirViewModelBindingSource.DataSource = _allBindingList; + this.hydroReservoirViewModelBindingSource.ResetBindings(false); } //閲嶇疆 @@ -210,20 +240,19 @@ Search(); if (_allBindingList == null || _allBindingList.Count < 1) { - XtraMessageBox.Show("鏃犲彲璁剧疆姘寸鏁版嵁"); + TipFormHelper.ShowWarn("鏃犳暟鎹紒"); return; } - var dlg = new SetHydroWaterboxDlg(); + var dlg = new SetHydroReservoirDlg(); dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList()); dlg.ReloadDataEvent += (list) => { - _allBindingList.ForEach(x => - { - x.UpdateProperty(); - }); - this.hydroWaterboxViewModelBindingSource.ResetBindings(false); - var allParterList = _allBindingList.Select(x => x.Vmo as Yw.Model.HydroParterInfo).ToList(); - this.HydroChangedEvent?.Invoke(allParterList); + _allBindingList.ForEach(x => x.UpdateProperty()); + this.hydroReservoirViewModelBindingSource.ResetBindings(false); + 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(); } @@ -234,22 +263,16 @@ public void SetSimpleView() { this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; - this.colDbLocked.Visible = true; + this.colDbLocked.Visible = false; this.colName.Visible = true; this.colCode.Visible = true; this.colModelType.Visible = true; - this.colPoolElev.Visible = false; - this.colInitLevel.Visible = false; - this.colMinLevel.Visible = false; - this.colMaxLevel.Visible = false; - this.colDN.Visible = false; - this.colMinVol.Visible = false; - this.colCurve.Visible = false; - this.colOverFlow.Visible = false; + this.colPoolElev.Visible = true; + this.colHead.Visible = true; this.colCalcuPress.Visible = false; this.colCalcuHead.Visible = false; this.colCalcuDemand.Visible = false; - this.colHasDb.Visible = true; + this.colHasDb.Visible = false; this.colFlags.Visible = true; this.colDescription.Visible = true; this.colSet.Visible = false; @@ -266,13 +289,7 @@ this.colCode.Visible = true; this.colModelType.Visible = true; this.colPoolElev.Visible = true; - this.colInitLevel.Visible = true; - this.colMinLevel.Visible = true; - this.colMaxLevel.Visible = true; - this.colDN.Visible = true; - this.colMinVol.Visible = true; - this.colCurve.Visible = true; - this.colOverFlow.Visible = true; + this.colHead.Visible = true; this.colCalcuPress.Visible = false; this.colCalcuHead.Visible = false; this.colCalcuDemand.Visible = false; @@ -293,13 +310,7 @@ this.colCode.Visible = true; this.colModelType.Visible = true; this.colPoolElev.Visible = true; - this.colInitLevel.Visible = true; - this.colMinLevel.Visible = true; - this.colMaxLevel.Visible = true; - this.colDN.Visible = true; - this.colMinVol.Visible = true; - this.colCurve.Visible = true; - this.colOverFlow.Visible = true; + this.colHead.Visible = true; this.colCalcuPress.Visible = true; this.colCalcuHead.Visible = true; this.colCalcuDemand.Visible = true; @@ -310,7 +321,7 @@ } /// <summary> - /// 璁剧疆璁剧疆鐣岄潰妯″紡 + /// 璁剧疆鎵归噺璁剧疆妯″紡 /// </summary> public void SetBulkSetView() { @@ -320,13 +331,7 @@ this.colCode.Visible = true; this.colModelType.Visible = true; this.colPoolElev.Visible = true; - this.colInitLevel.Visible = true; - this.colMinLevel.Visible = true; - this.colMaxLevel.Visible = true; - this.colDN.Visible = true; - this.colMinVol.Visible = true; - this.colCurve.Visible = true; - this.colOverFlow.Visible = true; + this.colHead.Visible = true; this.colCalcuPress.Visible = false; this.colCalcuHead.Visible = false; this.colCalcuDemand.Visible = false; @@ -335,7 +340,6 @@ this.colDescription.Visible = true; this.colSet.Visible = true; } - //鏌ヨ private void btnSearch_Click(object sender, EventArgs e) @@ -355,10 +359,9 @@ Set(); } - //鍗曞厓鏍肩偣鍑� private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { - var row = this.gridView1.GetRow(e.RowHandle) as HydroWaterboxViewModel; + var row = this.gridView1.GetRow(e.RowHandle) as HydroReservoirViewModel; if (row == null) { return; @@ -366,19 +369,21 @@ if (e.Column == this.colSet) { - var dlg = new SetHydroWaterboxDlg(); + var dlg = new SetHydroReservoirDlg(); dlg.SetBindingData(row.Vmo); dlg.ReloadDataEvent += (list) => { row.UpdateProperty(); this.gridView1.RefreshRow(e.RowHandle); - this.HydroChangedEvent?.Invoke(new List<Model.HydroParterInfo>() { row.Vmo }); + this.HydroChangedViewEvent?.Invoke(new List<HydroVisualViewModel>() { row }); + this.HydroChangedInfoEvent?.Invoke(new List<HydroVisualInfo>() { row.Vmo }); }; dlg.ShowDialog(); } else { - this.HydroClickEvent?.Invoke(row.Vmo); + this.HydroClickViewEvent?.Invoke(row); + this.HydroClickInfoEvent?.Invoke(row.Vmo); } } -- Gitblit v1.9.3