From fd206ba4e3e792eb01898fea540d50c2fd92f364 Mon Sep 17 00:00:00 2001
From: qin <a@163.com>
Date: 星期二, 18 三月 2025 13:46:34 +0800
Subject: [PATCH] IBox封装隐藏按钮

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-info/CreateXhsSchemeInfoPage.cs |  187 +++++++++++++++++++++++++---------------------
 1 files changed, 103 insertions(+), 84 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-info/CreateXhsSchemeInfoPage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-info/CreateXhsSchemeInfoPage.cs
index 47a1d1a..948927c 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-info/CreateXhsSchemeInfoPage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-info/CreateXhsSchemeInfoPage.cs
@@ -1,92 +1,51 @@
-锘縰sing DevExpress.Utils.Svg;
-
-namespace HStation.WinFrmUI
+锘縩amespace HStation.WinFrmUI
 {
-    public partial class CreateXhsSchemeInfoPage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPage<CreateXhsSchemeViewModel>
+    public partial class CreateXhsSchemeInfoPage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPageAsync<CreateXhsSchemeViewModel>
     {
         public CreateXhsSchemeInfoPage()
         {
             InitializeComponent();
-        } 
+            this.layoutControl1.SetupLayoutControl();
+            this.xhsSchemeChangeTypeCheckedListHorizCtrl1.CheckedChangedEvent += XhsSchemeChangeTypeCheckedListHorizCtrl1_CheckedChangedEvent;
+        }
 
         /// <summary>
         /// 椤甸潰鐘舵�佹敼鍙樹簨浠�
         /// </summary>
         public event Action PageStateChangedEvent;
-         
-        /// <summary>
-        /// 鍙樻洿绫诲瀷鏀瑰彉浜嬩欢
-        /// </summary>
-        public event Action<List<string>> ChangeTypeChangedEvent;
 
         private CreateXhsSchemeViewModel _vm = null;//鎿嶄綔瀵硅薄
-        private bool _isInitialize = false;//鏄惁鍒濆鍖�
-        private bool _allow_next = false;//鍏佽涓嬩竴姝�  
+
 
         /// <summary>
         /// 鍒濆鍖�
         /// </summary>
-        public async void InitialPage(CreateXhsSchemeViewModel t)
+        public async void InitialPage(CreateXhsSchemeViewModel vm)
         {
-          
-            if (_isInitialize)
+            if (vm == null)
             {
                 return;
             }
-            _vm = t;
-            _isInitialize = true;
+            _vm = vm;
+            if (vm.Scheme == null)
+            {
+                vm.Scheme = new XhsSchemeVmo() { SiteID = vm.ProjectSite.ID };
+                vm.Scheme.Name = Yw.Untity.UniqueHelper.CreateFromFirst("鏂规", vm.AllSchemeList?.Select(x => x.Name).Distinct().ToList());
+                vm.Scheme.SortCode = vm.AllSchemeList == null || vm.AllSchemeList.Count < 1 ? 1 : vm.AllSchemeList.Max(x => x.SortCode) + 1;
+            }
+            this.txtName.EditValue = vm.Scheme.Name;
+            this.txtNO.EditValue = vm.Scheme.NO;
             var allFlagList = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(HStation.Xhs.DataType.XhsScheme);
-            if (allFlagList != null&& allFlagList.Any())
-            {
-                this.setFlagsEditCtrl1.SetBindingData(allFlagList.Select(x => x.Name).ToList(), null);
-            }
-         
-            this.xhsSchemeChangeTypeCheckedListHorizCtrl1.SetBindingData(t.HydroInfo);
-            this.xhsSchemeChangeTypeCheckedListHorizCtrl1.CheckedChangedEvent += (change_type_list) =>
-            {
-                if (change_type_list == null || !change_type_list.Any())
-                {
-                    _allow_next = false;
-                }
-                else
-                {
-                    _allow_next = true;
-                }
-                this.ChangeTypeChangedEvent?.Invoke(change_type_list);
-                this.PageStateChangedEvent?.Invoke();
-            };
-            if (t.Scheme == null)
-            {
-                t.Scheme = new XhsSchemeVmo();
-                if (t.AllSchemeList != null && t.AllSchemeList.Count > 0)
-                {
-                    var sort_code= t.AllSchemeList.Max(x => x.SortCode) + 1;
-                    t.Scheme.SortCode = sort_code;
-                    this.txtName.EditValue = $"鏂规{sort_code}";
-                }
-            }
+            this.setFlagsEditCtrl1.SetBindingData(allFlagList?.Select(x => x.Name).ToList(), vm.Scheme.Flags);
+            this.ckAllowCustom.Checked = vm.Scheme.AllowCustom;
+            this.txtDescription.EditValue = vm.Scheme.Description;
+            this.xhsSchemeChangeTypeCheckedListHorizCtrl1.SetBindingData(vm.HydroInfo, vm.Scheme.ChangeTypes);
         }
 
-        //淇濆瓨
-        private bool Save()
+        //閫夋嫨鏀瑰彉
+        private void XhsSchemeChangeTypeCheckedListHorizCtrl1_CheckedChangedEvent(List<string> changeTypes)
         {
-            if (!_isInitialize)
-            {
-                return false;
-            }
-            this.dxErrorProvider1.ClearErrors();
-            if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
-            {
-                this.dxErrorProvider1.SetError(this.txtName, "蹇呭~椤�");
-                return false;
-            }
-            _vm.Scheme.Name = this.txtName.Text.Trim();
-            _vm.Scheme.NO = this.txtNO.Text.Trim();
-            _vm.Scheme.Flags = this.setFlagsEditCtrl1.SelectedFlagList;
-            _vm.Scheme.AllowCustom = this.ckAllowCustom.Checked;
-            _vm.Scheme.ChangeTypes = this.xhsSchemeChangeTypeCheckedListHorizCtrl1.GetCheckedList();
-            _vm.Scheme.Description = this.txtDescription.Text.Trim();
-            return true;
+            this.PageStateChangedEvent?.Invoke();
         }
 
         /// <summary>
@@ -107,7 +66,7 @@
         {
             get
             {
-                return _allow_next;
+                return true;
             }
         }
 
@@ -129,52 +88,112 @@
         {
             get
             {
-                if (!_isInitialize)
-                    return false;
-
-                return !_allow_next;
+                return false;
             }
-
         }
 
         /// <summary>
         /// 鑳藉惁涓婁竴姝�
         /// </summary>
-        public bool CanPrev()
+        public Task<bool> CanPrev()
         {
-            return false;
+            return Task.Run(() => false);
         }
 
         /// <summary>
         /// 鑳藉惁涓嬩竴姝�
         /// </summary>
-        public bool CanNext()
+        public Task<bool> CanNext()
         {
-            if (!_isInitialize)
-            {
-                return false;
-            }
-            return Save();
+            return Task.Run(() => Save());
         }
 
         /// <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 Save();
+            return Task.Run(() => false);
+        }
+
+        //楠岃瘉
+        private bool Valid()
+        {
+            this.dxErrorProvider1.ClearErrors();
+            var name = this.txtName.Text.Trim();
+            if (string.IsNullOrEmpty(name))
+            {
+                this.dxErrorProvider1.SetError(this.txtName, "蹇呭~椤�");
+                return false;
+            }
+
+
+            return true;
+        }
+
+        //淇濆瓨
+        private bool Save()
+        {
+            if (!Valid())
+            {
+                return false;
+            }
+            _vm.Scheme.Name = this.txtName.Text.Trim();
+            _vm.Scheme.NO = this.txtNO.Text.Trim();
+            _vm.Scheme.Flags = this.setFlagsEditCtrl1.SelectedFlagList;
+            _vm.Scheme.AllowCustom = this.ckAllowCustom.Checked;
+            _vm.Scheme.ChangeTypes = this.xhsSchemeChangeTypeCheckedListHorizCtrl1.GetCheckedList();
+            _vm.Scheme.Description = this.txtDescription.Text.Trim();
+            InitialVisualViewModelList();
+            return true;
+        }
+
+        //鍒濆鍖栧彲瑙佽鍥惧垪琛�
+        private void InitialVisualViewModelList()
+        {
+            if (_vm == null)
+            {
+                return;
+            }
+            if (_vm.HydroInfo == null)
+            {
+                return;
+            }
+            if (_vm.AllVisualViewModelList != null)
+            {
+                return;
+            }
+            if (_vm.Scheme.ChangeTypes == null || _vm.Scheme.ChangeTypes.Count < 1)
+            {
+                return;
+            }
+            _vm.AllVisualViewModelList = new List<HydroVisualViewModel>();
+            var allVisualList = _vm.HydroInfo.GetAllVisuals();
+            foreach (var visual in allVisualList)
+            {
+                var vm = HydroVisualViewModelBuilder.CreateVisualViewModel(visual, _vm.HydroInfo);
+                _vm.AllVisualViewModelList.Add(vm);
+            }
         }
 
 
-        
+
+
+
+
+
+
+
+
+
 
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3