From 278e94cb1b045288d1205f36b67f60cb5224754c Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期三, 06 十一月 2024 11:50:19 +0800
Subject: [PATCH] 属性调整

---
 WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/14-pipe/HydroPipeListCtrl.cs |  302 +++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 237 insertions(+), 65 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/14-pipe/HydroPipeListCtrl.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/14-pipe/HydroPipeListCtrl.cs
index 2b2d4f9..318440f 100644
--- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/14-pipe/HydroPipeListCtrl.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/14-pipe/HydroPipeListCtrl.cs
@@ -1,4 +1,5 @@
-锘縰sing Yw.Model;
+锘縰sing DevExpress.XtraEditors;
+using Yw.Model;
 
 namespace Yw.WinFrmUI
 {
@@ -9,12 +10,17 @@
             InitializeComponent();
             this.gridView1.SetNormalView(30);
             this.gridView1.RegistCustomDrawRowIndicator(40);
+            this.layoutControl1.SetupLayoutControl();
+            InitialLinkStatus();
         }
 
         /// <summary>
         /// 姘村姏鐐瑰嚮浜嬩欢
         /// </summary>
         public event Action<Yw.Model.HydroParterInfo> HydroClickEvent;
+        /// <summary>
+        /// 姘村姏鏀瑰彉浜嬩欢
+        /// </summary>
         public event Action<List<HydroParterInfo>> HydroChangedEvent;
 
         /// <summary>
@@ -34,38 +40,192 @@
         /// </summary>
         public bool HasHydroList
         {
-            get { return _allBindingList != null && _allBindingList.Count > 0; }
+            get { return _allList != null && _allList.Count > 0; }
         }
 
-
+        //鎵�鏈夊垪琛�
+        private List<HydroPipeViewModel> _allList = null;
         //鎵�鏈夌粦瀹氬垪琛�
         private List<HydroPipeViewModel> _allBindingList = null;
 
         /// <summary>
         /// 缁戝畾鏁版嵁
         /// </summary>
-        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList)
+        public void SetBindingData(HydroModelInfo hydroInfo)
         {
-            _allBindingList = new List<HydroPipeViewModel>();
+            _allList = new List<HydroPipeViewModel>();
             if (hydroInfo != null && hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0)
             {
                 foreach (var pipe in hydroInfo.Pipes)
                 {
-                    var calcuLinkResult = allCalcuResultList?.Find(x => x.Code == pipe.Code) as HydroCalcuLinkResult;
                     var vm = new HydroPipeViewModel(pipe, hydroInfo);
-                    _allBindingList.Add(vm);
+                    _allList.Add(vm);
                 }
+            }
+            Search();
+        }
+
+        /// <summary>
+        /// 缁戝畾鏁版嵁
+        /// </summary>
+        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList)
+        {
+            _allList = new List<HydroPipeViewModel>();
+            if (hydroInfo != null && hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0)
+            {
+                foreach (var pipe in hydroInfo.Pipes)
+                {
+                    var vm = new HydroPipeViewModel(pipe, hydroInfo);
+                    var calcuResult = allCalcuResultList?.Find(x => x.Code == pipe.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.hydroPipeViewModelBindingSource.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.hydroPipeViewModelBindingSource.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.hydroPipeViewModelBindingSource.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.hydroPipeViewModelBindingSource.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.hydroPipeViewModelBindingSource.DataSource = _allBindingList;
             this.hydroPipeViewModelBindingSource.ResetBindings(false);
-            if (allCalcuResultList == null || allCalcuResultList.Count < 1)
+        }
+
+        //閲嶇疆
+        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)
             {
-                SetNormalView();
+                XtraMessageBox.Show("鏃犲彲璁剧疆绠¢亾鏁版嵁");
+                return;
             }
-            else
+            var dlg = new SetHydroPipeDlg();
+            dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList());
+            dlg.ReloadDataEvent += (list) =>
             {
-                SetCalcuView();
-            }
+                _allBindingList.ForEach(x =>
+                {
+                    x.UpdateProperty();
+                });
+                this.hydroPipeViewModelBindingSource.ResetBindings(false);
+                var allParterList = _allBindingList.Select(x => x.Vmo as HydroParterInfo).ToList();
+                this.HydroChangedEvent?.Invoke(allParterList);
+            };
+            dlg.ShowDialog();
         }
 
         /// <summary>
@@ -73,24 +233,24 @@
         /// </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.colLinkStatus.Visible = false;
+            this.colMaterial.Visible = true;
+            this.colDiameter.Visible = true;
             this.colLength.Visible = false;
-            this.colMaterial.Visible = false;
-            this.colRoughness.Visible = true;
-            this.colMinorLoss.Visible = true;
+            this.colRoughness.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>
@@ -98,24 +258,24 @@
         /// </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.colMaterial.Visible = true;
             this.colDiameter.Visible = true;
             this.colLength.Visible = true;
-            this.colMaterial.Visible = true;
             this.colRoughness.Visible = true;
             this.colMinorLoss.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>
@@ -123,35 +283,60 @@
         /// </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.colMaterial.Visible = true;
             this.colDiameter.Visible = true;
             this.colLength.Visible = true;
-            this.colMaterial.Visible = true;
             this.colRoughness.Visible = true;
             this.colMinorLoss.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.colLength.Visible = true;
+            this.colRoughness.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 gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
         {
             var row = this.gridView1.GetRow(e.RowHandle) as HydroPipeViewModel;
             if (row == null)
             {
                 return;
             }
-            if (e.Clicks > 1)
+
+            if (e.Column == this.colSet)
             {
                 var dlg = new SetHydroPipeDlg();
                 dlg.SetBindingData(row.Vmo);
@@ -159,40 +344,27 @@
                 {
                     row.UpdateProperty();
                     this.gridView1.RefreshRow(e.RowHandle);
+                    this.HydroChangedEvent?.Invoke(new List<Model.HydroParterInfo>() { row.Vmo });
                 };
                 dlg.ShowDialog();
             }
-            this.HydroClickEvent?.Invoke(row.Vmo);
+            else
+            {
+                this.HydroClickEvent?.Invoke(row.Vmo);
+            }
         }
 
-        public void SetBindingData(HydroModelInfo hydroInfo)
+
+        //鍒濆鍖栫娈电姸鎬�
+        private void InitialLinkStatus()
         {
-            throw new NotImplementedException();
+            this.imgCmbLinkStatus.Properties.BeginUpdate();
+            this.imgCmbLinkStatus.Properties.Items.Clear();
+            this.imgCmbLinkStatus.Properties.Items.Add("鍏ㄩ儴", string.Empty, -1);
+            this.imgCmbLinkStatus.Properties.Items.Add(HydroLinkStatusHelper.GetStatusName(Yw.Hydro.LinkStatus.Open), Yw.Hydro.LinkStatus.Open, -1);
+            this.imgCmbLinkStatus.Properties.Items.Add(HydroLinkStatusHelper.GetStatusName(Yw.Hydro.LinkStatus.Closed), Yw.Hydro.LinkStatus.Closed, -1);
+            this.imgCmbLinkStatus.Properties.EndUpdate();
         }
 
-        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();
-        }
     }
 }

--
Gitblit v1.9.3