From b26ae60e85d4a03a2426e6607e7afe89e1c10a5f Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期四, 05 十二月 2024 11:50:35 +0800
Subject: [PATCH] 水池单独匹配界面修改

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/AddXhsSchemeDlg.cs |  295 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 245 insertions(+), 50 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/AddXhsSchemeDlg.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/AddXhsSchemeDlg.cs
index fcffee1..88cdc43 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/AddXhsSchemeDlg.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/AddXhsSchemeDlg.cs
@@ -1,4 +1,4 @@
-锘縰sing DevExpress.XtraBars;
+锘縰sing Mapster;
 
 namespace HStation.WinFrmUI
 {
@@ -9,43 +9,75 @@
             InitializeComponent();
             this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
             this.ribbon.SetFormStyle();
+            this.gridView1.SetNormalView();
+            this.gridView2.SetNormalView();
+            this.gridView2.OptionsView.EnableAppearanceOddRow = false;   // 浣胯兘 // 鍜屽拰涓婇潰缁戝畾 鍚屾椂浣跨敤鏈夋晥  
+            this.gridView2.OptionsView.EnableAppearanceEvenRow = false;
 
-         
-            //this.flyoutPanel1.BorderStyle = BorderStyle.None;
-            //this.flyoutPanel1.OwnerControl = this.sidePanel3dModel;
-            //this.flyoutPanel1.Options.AnimationType = DevExpress.Utils.Win.PopupToolWindowAnimation.Fade;
-            //this.flyoutPanel1.Options.AnchorType = DevExpress.Utils.Win.PopupToolWindowAnchor.Bottom;
-
-
-            this.setSchemePumpListCtrl1.ShowFindPanel = false;
-            this.setSchemeValveListCtrl1.ShowFindPanel = false;
-            this.setSchemePipeListCtrl1.ShowFindPanel = false;
+            this.gridView1.OptionsView.ShowIndicator = false;
+            this.gridView2.OptionsView.ShowIndicator = false;
 
             foreach (var page in this.tabPane1.Pages)
             {
-                if (page.Controls[0] is IHydroParterList ctrl)
+                if (page.Controls[0] is ISetSchemeParterList ctrl)
                 {
                     ctrl.ShowFindPanel = false;
                     ctrl.HydroClickEvent += async (parter) =>
                     {
-                        _selectedParter = parter;
-                        await  _bimfaceCtrl?.ZoomAndSelectComponent(_selectedParter.Code);
-                   
+                        _selected_parter = parter;
+                        await _bimfaceCtrl?.ZoomAndSelectComponent(_selected_parter.Code);
+                    };
+                    ctrl.HydroRecordChangedEvent += (record) =>
+                    {
+                        _set_record_list.Add(record);
+                        this.setSchemeParterRecordBindingSource.ResetBindings(false);
                     };
                     ctrl.HydroChangedEvent += (parterList) =>
                     {
-                        
+
                     };
                 }
             }
+
         }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public event Action<HStation.Vmo.XhsSchemeVmo> ReloadDataEvent;
 
 
         private HStation.Vmo.XhsProjectVmo _project = null;//椤圭洰
-        private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//椤圭洰绔�
-        private Yw.Model.HydroModelInfo _hydroInfo = null;//姘村姏淇℃伅
-                                                         
-        private Yw.Model.HydroParterInfo _selectedParter = null; //閫夋嫨鏋勪欢
+        private HStation.Vmo.XhsProjectSiteVmo _project_site = null;//椤圭洰绔�
+        private Yw.Model.HydroModelInfo _hydro_info = null;//姘村姏淇℃伅
+        private Yw.Model.HydroModelInfo _hydro_info_init = null;//鍒濆 姘村姏淇℃伅
+
+        private Yw.Model.HydroParterInfo _selected_parter = null; //閫夋嫨鏋勪欢
+        private List<SetSchemeParterRecord> _set_record_list = null;
+
+
+        #region Initial
+
+        //鍒濆鍖栨枃浠舵牸寮�
+        private void InitialSchemeType()
+        {
+            this.imgCmbSchemeType.Properties.BeginUpdate();
+            this.imgCmbSchemeType.Properties.Items.Clear();
+            this.imgCmbSchemeType.Properties.Items.AddEnum(typeof(HStation.Xhs.eSchemeType), false);
+            this.imgCmbSchemeType.EditValue = eSchemeType.Common;
+            this.imgCmbSchemeType.Properties.EndUpdate();
+        }
+        //鍒濆鍖栨爣绛�
+        private async Task InitialFlags()
+        {
+            var allFlagList = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(HStation.Xhs.DataType.XhsScheme);
+            var allFlagNameList = allFlagList?.Select(x => x.Name).ToList();
+            this.setFlagsEditCtrl1.SetBindingData(allFlagNameList, null);
+        }
+
+        #endregion
+
+        #region SetBindingData
 
         /// <summary>
         /// 缁戝畾鏁版嵁
@@ -53,34 +85,82 @@
         public async Task SetBindingData
             (
                 HStation.Vmo.XhsProjectVmo project,
-                HStation.Vmo.XhsProjectSiteVmo projectSite,
-                Yw.Model.HydroModelInfo hydroInfo
+                HStation.Vmo.XhsProjectSiteVmo project_site,
+                Yw.Model.HydroModelInfo hydro_info
             )
-        { 
+        {
             if (project == null)
             {
                 return;
             }
             _project = project;
-            _projectSite = projectSite;
-            _hydroInfo = hydroInfo;
-            if (_projectSite == null)
+            _project_site = project_site;
+            _hydro_info_init = hydro_info;
+            _set_record_list = new List<SetSchemeParterRecord>();
+            if (_project_site == null)
             {
-                _projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_project.ID);
+                _project_site = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_project.ID);
             }
-            if (_hydroInfo == null)
+
+            if (_hydro_info_init == null)
             {
                 var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
-                    .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
-                _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
+                    .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _project_site.ID, HStation.Xhs.Purpose.Simulation);
+                _hydro_info_init = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
             }
 
-            this.setSchemePumpListCtrl1.SetBindingData(_hydroInfo);
-            this.setSchemeValveListCtrl1.SetBindingData(_hydroInfo);
-            this.setSchemePipeListCtrl1.SetBindingData(_hydroInfo);
-
+            this.setSchemeParterRecordBindingSource.DataSource = _set_record_list;
+            this.setSchemeParterRecordBindingSource.ResetBindings(false);
+            SetBindingData();
             ShowBimfaceCtrl();
+            FastShowHidden(false);
+
+            InitialSchemeType();
+            await InitialFlags();
         }
+
+        private void SetBindingData(List<SetSchemeParterRecord> set_record_list = null)
+        {
+            _hydro_info = _hydro_info_init.Adapt<Yw.Model.HydroModelInfo, Yw.Model.HydroModelInfo>();
+            if (set_record_list != null && set_record_list.Any())
+            {
+                foreach (var item in set_record_list)
+                {
+                    switch (item.Catalog)
+                    {
+                        case Yw.Hydro.ParterCatalog.Pump:
+                            {
+                                var vm = item.MatchingModel as PumpMatchingViewModel;
+                                var bol = AssetsMatchingParasHelper.Apply(_hydro_info, vm);
+                            }
+                            break;
+
+                        case Yw.Hydro.ParterCatalog.Valve:
+                            {
+                                var vm = item.MatchingModel as ValveMatchingViewModel;
+                                var bol = AssetsMatchingParasHelper.Apply(_hydro_info, vm);
+                            }
+                            break;
+                        case Yw.Hydro.ParterCatalog.Pipe:
+                            {
+                                var vm = item.MatchingModel as PipeMatchingViewModel;
+                                var bol = AssetsMatchingParasHelper.Apply(_hydro_info, vm);
+                            }
+                            break;
+                        default:
+                            break;
+                    }
+                }
+            }
+
+            this.setSchemePumpListCtrl1.SetBindingData(_hydro_info);
+            this.setSchemeValveListCtrl1.SetBindingData(_hydro_info);
+            this.setSchemePipeListCtrl1.SetBindingData(_hydro_info);
+
+        }
+
+
+        #endregion
 
         #region Bimface
 
@@ -94,18 +174,18 @@
             {
                 _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl();
                 _bimfaceCtrl.Dock = DockStyle.Fill;
-                await _bimfaceCtrl.InitialData(_project, _projectSite, () => _hydroInfo);
+                await _bimfaceCtrl.InitialData(_project, _project_site);
                 _bimfaceCtrl.LoadCompletedEvent += () =>
                 {
                     //view鍔犺浇瀹屾垚浜嬩欢
-                    if (_hydroInfo == null)
+                    if (_hydro_info == null)
                     {
                         return;
                     }
                 };
                 _bimfaceCtrl.HydroMouseLeftClickEvent += (obj) =>
                 {//榧犳爣宸﹂敭鐐瑰嚮浜嬩欢
-                    if (_hydroInfo == null)
+                    if (_hydro_info == null)
                     {
                         return;
                     }
@@ -129,29 +209,144 @@
 
         #endregion
 
-        //鏇存柊閫夋嫨缁勪欢灞炴��
-        private void UpdateSelectedParterProperty()
+        #region Menu
+
+        #region FastShowHidden
+
+        //涓�閿樉闅�
+        private void barBtnFastShowHidden_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            if (_selectedParter == null)
+            _show_hidden = !_show_hidden;
+            FastShowHidden(_show_hidden);
+        }
+
+        private bool _show_hidden = false;
+        private async void FastShowHidden(bool visible)
+        {
+            var code_list = _hydro_info.Decorators.Select(x => x.Code).ToList();
+            if (code_list == null)
             {
                 return;
             }
-
-        }
-
-        private void barCek_CheckedChanged(object sender, ItemClickEventArgs e)
-        {
-
-            if (!this.flyoutPanel1.Visible)
+            if (visible)
             {
-                this.flyoutPanel1.ShowPopup();
+                await _bimfaceCtrl?.ShowComponents(code_list);
             }
             else
             {
-                this.flyoutPanel1.HidePopup();
+                await _bimfaceCtrl?.HideComponents(code_list);
+            }
+        }
+
+
+        #endregion
+
+        #endregion
+
+        #region Save
+
+        private bool Verify()
+        {
+            this.dxErrorProvider1.ClearErrors();
+            if (string.IsNullOrEmpty(this.txtNo.Text))
+            {
+                this.dxErrorProvider1.SetError(this.txtNo, "蹇呭~椤�");
+                return false;
+            }
+            if (string.IsNullOrEmpty(this.txtName.Text))
+            {
+                this.dxErrorProvider1.SetError(this.txtName, "蹇呭~椤�");
+                return false;
             }
 
+            return true;
         }
-         
+
+        private async void btnSave_Click(object sender, EventArgs e)
+        {
+            if (_hydro_info == null)
+            {
+                return;
+            }
+            if (!Verify())
+            {
+                return;
+            }
+            var bll_hydro_model = new Yw.BLL.HydroModel();
+            var bll_xhs_scheme = new BLL.XhsScheme();
+            var hydro_model_id = await bll_hydro_model.Copy(_hydro_info.ID);
+            if (hydro_model_id > 0)
+            {
+                var xhs_scheme = new Vmo.XhsSchemeVmo();
+                xhs_scheme.SiteID = _project_site.ID;
+                xhs_scheme.NO = this.txtNo.Text.Trim();
+                xhs_scheme.Name = this.txtName.Text.Trim();
+                xhs_scheme.SchemeType = eSchemeType.Common;
+                xhs_scheme.Paras = null;
+                xhs_scheme.Flags = null;
+                xhs_scheme.UseStatus = Yw.Model.eUseStatus.Enable;
+
+                var xhs_scheme_id = await bll_xhs_scheme.Insert(xhs_scheme);
+                if (xhs_scheme_id < 0)
+                {
+                    await bll_hydro_model.DeleteByID(hydro_model_id);
+                    XtraMessageBox.Show("鏂规鍒涘缓澶辫触!");
+                    return;
+                }
+
+
+                var hydro_relation = new Yw.Vmo.HydroModelRelationVmo();
+                hydro_relation.ObjectType = HStation.Xhs.DataType.XhsScheme;
+                hydro_relation.ObjectID = xhs_scheme_id;
+                hydro_relation.ModelID = hydro_model_id;
+                hydro_relation.Purpose = HStation.Xhs.Purpose.Simulation;
+                hydro_relation.Content = null;
+                hydro_relation.Description = this.memoDescription.Text.Trim();
+
+                var hydro_relation_id = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance.Insert(hydro_relation);
+                if (hydro_relation_id < 1)
+                {
+                    await bll_hydro_model.DeleteByID(hydro_model_id);
+                    await bll_xhs_scheme.DeleteByID(xhs_scheme_id);
+                    XtraMessageBox.Show("妯″瀷渚濊禆鍒涘缓澶辫触!");
+                    return;
+                }
+
+                var scheme = await BLLFactory<HStation.BLL.XhsScheme>.Instance.GetByID(xhs_scheme_id);
+                this.ReloadDataEvent?.Invoke(scheme);
+            }
+
+            TipFormHelper.Show(eTipStatus.Succeed, "鍒涘缓鎴愬姛!");
+            this.Close();
+
+        }
+
+        #endregion
+
+        #region GridView
+
+        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
+        {
+            var row = this.gridView1.GetRow(e.FocusedRowHandle) as SetSchemeParterRecord;
+            this.setSchemeParterRecordItemBindingSource.DataSource = row?.Items;
+            this.setSchemeParterRecordItemBindingSource.ResetBindings(false);
+        }
+
+        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
+        {
+            if (e.Column == this.colDelete)
+            {
+                var row = this.gridView1.GetRow(e.RowHandle) as SetSchemeParterRecord;
+                _set_record_list.Remove(row);
+                this.setSchemeParterRecordBindingSource.ResetBindings(false);
+                SetBindingData(_set_record_list);
+
+            }
+        }
+
+
+        #endregion
+
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3