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/12-flowmeter/HydroFlowmeterListCtrl.cs |  165 +++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 107 insertions(+), 58 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/12-flowmeter/HydroFlowmeterListCtrl.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/12-flowmeter/HydroFlowmeterListCtrl.cs
similarity index 74%
rename from WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/12-flowmeter/HydroFlowmeterListCtrl.cs
rename to WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/12-flowmeter/HydroFlowmeterListCtrl.cs
index aa1081d..ac82066 100644
--- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/12-flowmeter/HydroFlowmeterListCtrl.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/12-flowmeter/HydroFlowmeterListCtrl.cs
@@ -3,7 +3,7 @@
 
 namespace Yw.WinFrmUI
 {
-    public partial class HydroFlowmeterListCtrl : DevExpress.XtraEditors.XtraUserControl, IHydroParterList
+    public partial class HydroFlowmeterListCtrl : DevExpress.XtraEditors.XtraUserControl, IHydroVisualList
     {
         public HydroFlowmeterListCtrl()
         {
@@ -16,11 +16,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<HydroParterInfo>> HydroChangedEvent;
+        public event Action<List<Yw.Model.HydroVisualInfo>> HydroChangedInfoEvent;
+        /// <summary>
+        /// 姘村姏鏀瑰彉瑙嗗浘浜嬩欢
+        /// </summary>
+        public event Action<List<HydroVisualViewModel>> HydroChangedViewEvent;
 
         /// <summary>
         /// 鏄剧ず鏌ヨ闈㈡澘
@@ -35,14 +43,14 @@
         }
 
         /// <summary>
-        /// 鏄惁鎷ユ湁姘村埄鍒楄〃
+        /// 鏄惁鎷ユ湁姘村姏鍒楄〃
         /// </summary>
         public bool HasHydroList
         {
             get { return _allList != null && _allList.Count > 0; }
         }
 
-        //鎵�鏈夋瀯浠跺垪琛�
+        //鎵�鏈夊垪琛�
         private List<HydroFlowmeterViewModel> _allList = null;
         //鎵�鏈夌粦瀹氬垪琛�
         private List<HydroFlowmeterViewModel> _allBindingList = null;
@@ -50,14 +58,14 @@
         /// <summary>
         /// 缁戝畾鏁版嵁
         /// </summary>
-        public void SetBindingData(HydroModelInfo hydroInfo)
+        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
         {
             _allList = new List<HydroFlowmeterViewModel>();
             if (hydroInfo != null && hydroInfo.Flowmeters != null && hydroInfo.Flowmeters.Count > 0)
             {
-                foreach (var flowmeter in hydroInfo.Flowmeters)
+                foreach (var visual in hydroInfo.Flowmeters)
                 {
-                    var vm = new HydroFlowmeterViewModel(flowmeter, hydroInfo);
+                    var vm = new HydroFlowmeterViewModel(visual, hydroInfo);
                     _allList.Add(vm);
                 }
             }
@@ -72,10 +80,10 @@
             _allList = new List<HydroFlowmeterViewModel>();
             if (hydroInfo != null && hydroInfo.Flowmeters != null && hydroInfo.Flowmeters.Count > 0)
             {
-                foreach (var flowmeter in hydroInfo.Flowmeters)
+                foreach (var visual in hydroInfo.Flowmeters)
                 {
-                    var vm = new HydroFlowmeterViewModel(flowmeter, hydroInfo);
-                    var calcuResult = allCalcuResultList?.Find(x => x.Code == flowmeter.Code);
+                    var vm = new HydroFlowmeterViewModel(visual, hydroInfo);
+                    var calcuResult = allCalcuResultList?.Find(x => x.Code == visual.Code);
                     if (calcuResult != null)
                     {
                         vm.UpdateCalcuProperty(calcuResult);
@@ -84,6 +92,30 @@
                 }
             }
             Search();
+        }
+
+        /// <summary>
+        /// 缁戝畾鏁版嵁
+        /// </summary>
+        public void SetBindingData(List<HydroVisualViewModel> allVisualViewModelList)
+        {
+            _allList = new List<HydroFlowmeterViewModel>();
+            allVisualViewModelList?.ForEach(x =>
+            {
+                if (x.Catalog == HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Flowmeter))
+                {
+                    _allList.Add(x as HydroFlowmeterViewModel);
+                }
+            });
+            Search();
+        }
+
+        /// <summary>
+        /// 鏇存柊缁戝畾
+        /// </summary>
+        public void UpdateBindingData()
+        {
+            this.hydroFlowmeterViewModelBindingSource.ResetBindings(false);
         }
 
         /// <summary>
@@ -102,17 +134,17 @@
         /// <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;
@@ -124,17 +156,17 @@
         /// <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)
@@ -154,12 +186,12 @@
             {
                 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.hydroFlowmeterViewModelBindingSource.ResetBindings(false);
@@ -209,25 +241,69 @@
             Search();
             if (_allBindingList == null || _allBindingList.Count < 1)
             {
-                XtraMessageBox.Show("鏃犲彲璁剧疆娴侀噺璁℃暟鎹�");
+                TipFormHelper.ShowWarn("鏃犳暟鎹紒");
                 return;
             }
             var dlg = new SetHydroFlowmeterDlg();
             dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList());
             dlg.ReloadDataEvent += (list) =>
             {
-                _allBindingList.ForEach(x =>
-                {
-                    x.Elev = x.Vmo.Elev;
-                    x.MinorLoss = x.Vmo.MinorLoss;
-                    x.Demand = x.Vmo.Demand;
-                });
+                _allBindingList.ForEach(x => x.UpdateProperty());
                 this.hydroFlowmeterViewModelBindingSource.ResetBindings(false);
-                var allParterList = _allBindingList.Select(x => x.Vmo as 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 HydroFlowmeterViewModel;
+            if (row == null)
+            {
+                return;
+            }
+
+            if (e.Column == this.colSet)
+            {
+                var dlg = new SetHydroFlowmeterDlg();
+                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>
         /// 璁剧疆绠�鍗曟樉绀烘ā寮�
@@ -235,7 +311,7 @@
         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;
@@ -243,7 +319,7 @@
             this.colMinorLoss.Visible = false;
             this.colCurrentFlow.Visible = true;
             this.colCalcuQ.Visible = false;
-            this.colHasDb.Visible = true;
+            this.colHasDb.Visible = false;
             this.colFlags.Visible = true;
             this.colDescription.Visible = true;
             this.colSet.Visible = false;
@@ -307,33 +383,6 @@
             this.colFlags.Visible = true;
             this.colDescription.Visible = true;
             this.colSet.Visible = true;
-        }
-
-
-        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
-        {
-            var row = this.gridView1.GetRow(e.RowHandle) as HydroFlowmeterViewModel;
-            if (row == null)
-            {
-                return;
-            }
-
-            if (e.Column == this.colSet)
-            {
-                var dlg = new SetHydroFlowmeterDlg();
-                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);
-            }
         }
 
 

--
Gitblit v1.9.3