From d672ca82c49f01dae2c5c955202b5857ef680a71 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期五, 03 一月 2025 22:16:48 +0800
Subject: [PATCH] 创建方案

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/02-change/01-pump/CreateXhsSchemePumpChangePage.cs |  217 ++++++++++++++++++++++--------------------------------
 1 files changed, 88 insertions(+), 129 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/02-change/01-pump/CreateXhsSchemePumpChangePage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/02-change/01-pump/CreateXhsSchemePumpChangePage.cs
index 59cf979..2f25d57 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/02-change/01-pump/CreateXhsSchemePumpChangePage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/02-change/01-pump/CreateXhsSchemePumpChangePage.cs
@@ -4,14 +4,19 @@
 
 namespace HStation.WinFrmUI
 {
-    public partial class CreateXhsSchemePumpChangePage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPage<CreateXhsSchemeViewModel>
+    /// <summary>
+    /// 
+    /// </summary>
+    public partial class CreateXhsSchemePumpChangePage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPageAsync<CreateXhsSchemeViewModel>
     {
+        /// <summary>
+        /// 
+        /// </summary>
         public CreateXhsSchemePumpChangePage()
         {
             InitializeComponent();
-            InitialLinkStatus();
-            this.layoutView1.SetDefuaulView();
-            this.layoutView1.SetFindPanel();
+            this.xhsSchemePumpChangeListCtrl1.HydroViewEvent += XhsSchemePumpChangeListCtrl1_HydroViewEvent;
+            this.xhsSchemePumpChangeListCtrl1.HydroChangeEvent += XhsSchemePumpChangeListCtrl1_HydroChangeEvent;
         }
 
         /// <summary>
@@ -20,75 +25,73 @@
         public event Action PageStateChangedEvent;
 
         private CreateXhsSchemeViewModel _vm = null;//鎿嶄綔瀵硅薄
-        private bool _isInitialize = false;//鏄惁鍒濆鍖�
-
-        private HStation.Vmo.XhsProjectVmo _project = null;//椤圭洰
-        private HStation.Vmo.XhsProjectSiteVmo _project_site = null;//椤圭洰绔� 
-        private List<CreateXhsSchemePumpChangeViewMdoel> _vm_list = null;
-
-
-        //鍒濆鍖栫姸鎬�
-        private void InitialLinkStatus()
-        {
-            this.repImgCmbStatus.BeginUpdate();
-            this.repImgCmbStatus.Items.Clear();
-            this.repImgCmbStatus.Items.Add("寮�鍚�", "寮�鍚�", -1);
-            this.repImgCmbStatus.Items.Add("鍏抽棴", "鍏抽棴", -1);
-            this.repImgCmbStatus.EndUpdate();
-        }
+        private List<HydroPumpViewModel> _allViewModelList = null;//鎵�鏈夎鍥惧垪琛�
 
         /// <summary>
         /// 鍒濆鍖�
         /// </summary>
-        public void InitialPage(CreateXhsSchemeViewModel t)
+        public void InitialPage(CreateXhsSchemeViewModel vm)
         {
-            if (_isInitialize)
+            if (vm == null)
             {
                 return;
             }
-            _vm = t;
-            _isInitialize = true;
-            _project = t.Project;
-            _project_site = t.ProjectSite;
-            if (t.HydroInfo.Pumps != null && t.HydroInfo.Pumps.Any())
+            _vm = vm;
+            _allViewModelList = new List<HydroPumpViewModel>();
+            if (vm.HydroInfo.Pumps != null && vm.HydroInfo.Pumps.Count > 0)
             {
-                var svg = SvgImage.FromStream(new MemoryStream(HStation.WinFrmUI.Xhs.Core.Properties.Resources.pump));
-                _vm_list = new List<CreateXhsSchemePumpChangeViewMdoel>();
-                foreach (var pump in t.HydroInfo.Pumps)
+                foreach (var visualViewModel in vm.AllVisualViewModelList)
                 {
-                    var vm = new Yw.WinFrmUI.HydroPumpViewModel(pump, t.HydroInfo);
-                    _vm_list.Add(new CreateXhsSchemePumpChangeViewMdoel(vm, svg));
+                    if (visualViewModel.Vmo.Catalog == Yw.Hydro.ParterCatalog.Pump)
+                    {
+                        var vmPump = visualViewModel as HydroPumpViewModel;
+                        if (vmPump != null)
+                        {
+                            _allViewModelList.Add(vmPump);
+                        }
+                    }
                 }
             }
 
-            this.createXhsSchemePumpChangeViewMdoelBindingSource.DataSource = _vm_list;
-            this.createXhsSchemePumpChangeViewMdoelBindingSource.ResetBindings(false);
-
             ShowBimfaceCtrl();
+            this.xhsSchemePumpChangeListCtrl1.SetBindingData(_allViewModelList);
             this.PageStateChangedEvent?.Invoke();
         }
 
         #region Bimface
 
         //bimface鎺т欢
-        private SimulationBimfaceCtrl _bimfaceCtrl = null;
+        private CreateXhsSchemeBimfaceCtrl _bimfaceCtrl = null;
 
         //鑾峰彇 bimface 鎺т欢
-        private async Task<SimulationBimfaceCtrl> GetBimfaceCtrl()
+        private async Task<CreateXhsSchemeBimfaceCtrl> GetBimfaceCtrl()
         {
             if (_vm == null)
-                return null;
+            {
+                return default;
+            }
             if (_bimfaceCtrl == null)
             {
-                _bimfaceCtrl = new SimulationBimfaceCtrl();
+                _bimfaceCtrl = new CreateXhsSchemeBimfaceCtrl();
                 _bimfaceCtrl.Dock = DockStyle.Fill;
-                await _bimfaceCtrl.InitialData(_project, _project_site);
+                await _bimfaceCtrl.InitialData(_vm.Project, _vm.ProjectSite, _vm.HydroInfo, _vm.AllVisualViewModelList);
                 _bimfaceCtrl.HydroMouseLeftClickEvent += (code) =>
                 {
-                    if (_vm_list == null || !_vm_list.Any())
+                    if (_allViewModelList == null || _allViewModelList.Count < 1)
+                    {
                         return;
-                    var index = _vm_list.FindIndex(x => x.ViewModel.Code == code);
-                    this.layoutView1.FocusedRowHandle = index; 
+                    }
+                    var index = _allViewModelList.FindIndex(x => x.Vmo.Code == code);
+                    this.xhsSchemePumpChangeListCtrl1.SetFocusedRow(index);
+                };
+                _bimfaceCtrl.SelectVisualEvent += (code) =>
+                {
+                    if (_allViewModelList == null || _allViewModelList.Count < 1)
+                    {
+                        return;
+                    }
+                    var index = _allViewModelList.FindIndex(x => x.Vmo.Code == code);
+                    this.xhsSchemePumpChangeListCtrl1.SetFocusedRow(index);
                 };
             }
             return _bimfaceCtrl;
@@ -98,86 +101,21 @@
         private async void ShowBimfaceCtrl()
         {
             var bimfaceCtrl = await GetBimfaceCtrl();
-            this.sidePanel3dModel.Controls.Clear();
-            this.sidePanel3dModel.Controls.Add(bimfaceCtrl);
+            this.panelControl1.Controls.Clear();
+            this.panelControl1.Controls.Add(bimfaceCtrl);
         }
+
 
 
         #endregion
 
-        //淇濆瓨
-        private bool Save()
-        {
-            if (!_isInitialize)
-            {
-                return false;
-            }
-            if (_vm_list == null || !_vm_list.Any())
-            {
-                return false;
-            }
-            _vm_list.ForEach(x => x.ViewModel.UpdateVmoProperty());
-            _vm.HydroInfo.Pumps = _vm_list.Select(x => x.ViewModel.Vmo).ToList();
-            return true;
-        }
-
-        //鐐瑰嚮
-        private async void layoutView1_CardClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.CardClickEventArgs e)
-        {
-            var row = this.layoutView1.GetRow(e.RowHandle) as CreateXhsSchemePumpChangeViewMdoel;
-            if (row == null)
-                return;
-            await _bimfaceCtrl?.ZoomAndSelectComponent(row.ViewModel.Code);
-        }
-
-        //閫変腑鍒楀彉鎹�
-        private void layoutView1_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e)
-        {
-            if (e.FocusedColumn == this.colModelType)
-            {
-                this.layoutView1.FocusedColumn = null;
-                if (this.layoutView1.GetFocusedRow() is not CreateXhsSchemePumpChangeViewMdoel row)
-                    return;
-
-                var link_status = row.LinkStatus;
-                var current_hz = row.CurrentHz;
-                var input = Yw.WinFrmUI.HydroMatchingHelper.Create(row.ViewModel.Vmo, _vm.HydroInfo);
-                var dlg = new SimulationPumpSingleMatchingDlg();
-                dlg.SetBindingData(input);
-                dlg.ReloadDataEvent += (output) =>
-                {
-                    Yw.WinFrmUI.HydroMatchingHelper.Apply(row.ViewModel, output);
-                    row.LinkStatus = link_status;
-                    row.CurrentHz = current_hz;
-                    if (!_vm.ChangeRecordList.Exists(x => x.Code == row.ViewModel.Code))
-                    {
-                        _vm.ChangeRecordList.Add(new(Yw.Hydro.ParterCatalog.Pump, row.ViewModel.Code, row.Name, row.SvgImage));
-                    }
-                };
-                dlg.ShowDialog();
-            }
-        }
-
-        //鍗曞厓鏍煎�煎彉鎹�
-        private void layoutView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
-        {
-            if (this.layoutView1.GetRow(e.RowHandle) is not CreateXhsSchemePumpChangeViewMdoel row)
-                return;
-            if (!_vm.ChangeRecordList.Exists(x => x.Code == row.ViewModel.Code))
-            {
-                _vm.ChangeRecordList.Add(new(Yw.Hydro.ParterCatalog.Pump, row.ViewModel.Code, row.Name,row.SvgImage));
-            }
-        }
 
         /// <summary>
         /// 鍏佽涓婁竴姝�
         /// </summary>
         public bool AllowPrev
         {
-            get
-            {
-                return true;
-            }
+            get { return true; }
         }
 
         /// <summary>
@@ -185,10 +123,7 @@
         /// </summary>
         public bool AllowNext
         {
-            get
-            {
-                return _isInitialize;
-            }
+            get { return true; }
         }
 
         /// <summary>
@@ -196,7 +131,7 @@
         /// </summary>
         public bool AllowCancel
         {
-            get { return false; }
+            get { return true; }
         }
 
         /// <summary>
@@ -210,37 +145,61 @@
         /// <summary>
         /// 鑳藉惁涓婁竴姝�
         /// </summary>
-        public bool CanPrev()
+        public Task<bool> CanPrev()
         {
-            return true;
+            return Task.Run(() => true);
         }
 
         /// <summary>
         /// 鑳藉惁涓嬩竴姝�
         /// </summary>
-        public bool CanNext()
+        public Task<bool> CanNext()
         {
-            if (!_isInitialize)
-            {
-                return false;
-            }
-            return Save();
+            return Task.Run(() => true);
         }
 
         /// <summary>
         /// 鑳藉惁鍏抽棴
         /// </summary>
-        public bool CanCancel()
+        public Task<bool> CanCancel()
         {
-            return true;
+            return Task.Run(() => true);
         }
 
         /// <summary>
         /// 鑳藉惁瀹屾垚
         /// </summary>
-        public bool CanComplete()
+        public Task<bool> CanComplete()
         {
-            return false;
+            return Task.Run(() => false);
+        }
+
+        //鏀瑰彉
+        private void XhsSchemePumpChangeListCtrl1_HydroChangeEvent(HydroPumpViewModel obj)
+        {
+            if (_vm == null)
+            {
+                return;
+            }
+            if (_vm.allChangeRecordList == null)
+            {
+                _vm.allChangeRecordList = new List<XhsSchemeChangeRecordViewModel>();
+            }
+            _vm.allChangeRecordList.Update(obj);
+        }
+
+        //瀹氫綅
+        private void XhsSchemePumpChangeListCtrl1_HydroViewEvent(string obj)
+        {
+            if (string.IsNullOrEmpty(obj))
+            {
+                return;
+            }
+            if (_vm == null)
+            {
+                return;
+            }
+            _bimfaceCtrl?.ZoomAndSelectComponent(obj);
         }
 
 

--
Gitblit v1.9.3