From 1c3e5bc50d3045d51cb9a9f747d53442b82d9e2c Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期五, 27 十二月 2024 17:50:22 +0800
Subject: [PATCH] 资产修改

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/00-core/CreateXhsSchemeDlg.cs |  295 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 285 insertions(+), 10 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/00-core/CreateXhsSchemeDlg.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/00-core/CreateXhsSchemeDlg.cs
index 8b2602f..0041f94 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/00-core/CreateXhsSchemeDlg.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/00-core/CreateXhsSchemeDlg.cs
@@ -1,13 +1,5 @@
-锘縰sing DevExpress.XtraEditors;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
+锘縰sing DevExpress.XtraLayout.Utils;
+using Mapster;
 
 namespace HStation.WinFrmUI
 {
@@ -17,9 +9,292 @@
         {
             InitializeComponent();
             this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
+        }
 
+        private readonly CreateXhsSchemeViewModel _vm = new();
+        private CreateXhsSchemeManager _wizard=null; 
+
+        private bool _initial_wizard_manager = false;//杩愯涓嬩竴姝�
+        private List<string> _change_type_list = null;
+ 
+        /// <summary>
+        ///
+        /// </summary>
+        public CreateXhsSchemeViewModel ViewModel
+        {
+            get { return _vm; }
         }
 
 
+        /// <summary>
+        /// 
+        /// </summary>
+        public int SelectedPageIndex
+        {
+            get
+            {
+                return this.navigationFrameMain.SelectedPageIndex;
+            }
+            set
+            {
+                if (value == 0)
+                {
+                    _initial_wizard_manager = false;
+                    InitialButtonStatus(_change_type_list);
+                }
+                else
+                {
+                    _initial_wizard_manager = true;
+                    InitialWizardManager(_change_type_list);
+                }
+                this.navigationFrameMain.SelectedPageIndex = value;
+            }
+        }
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public event Action<HStation.Vmo.XhsSchemeVmo> ReloadDataEvent;
+
+        /// <summary>
+        ///
+        /// </summary>
+        public async void SetBindingData
+             (
+                HStation.Vmo.XhsProjectVmo project,
+                HStation.Vmo.XhsProjectSiteVmo project_site,
+                Yw.Model.HydroModelInfo hydro_info
+            )
+        {
+            this.itemForNext.Visibility = LayoutVisibility.Never;
+            this.itemForPrev.Visibility = LayoutVisibility.Never;
+            this.itemForComplete.Visibility = LayoutVisibility.Always;
+            this.itemForCancel.Visibility = LayoutVisibility.Always;
+            if (project == null)
+                return;
+            _vm.Project = project;
+            _vm.ProjectSite = project_site;
+            _vm.HydroInfo = hydro_info.Adapt<Yw.Model.HydroModelInfo>();
+            _vm.ProjectSite ??= await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_vm.Project.ID);
+            if (_vm.HydroInfo == null)
+            {
+                var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
+                    .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _vm.ProjectSite.ID, HStation.Xhs.Purpose.Simulation);
+                _vm.HydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
+            }
+            _vm.AllSchemeList = await BLLFactory<HStation.BLL.XhsScheme>.Instance.GetBySiteID(_vm.ProjectSite.ID);
+  
+            this.createXhsSchemeInfoPage1.InitialPage(_vm);
+            this.createXhsSchemeInfoPage1.ChangeTypeChangedEvent += (List<string> change_type_list) =>
+            {
+                _initial_wizard_manager = false;
+                _change_type_list = change_type_list;
+                InitialButtonStatus(change_type_list);
+            };
+
+            this.FormClosing += (s, e) =>
+            {
+                if (_wizard != null)
+                {
+                    if (this.DialogResult == DialogResult.OK)
+                    {
+                        if (!_wizard.Complete())
+                        {
+                            e.Cancel = true;
+                        }
+                    }
+                    else if (this.DialogResult == DialogResult.Cancel)
+                    {
+                        //if (!_wizard.Cancel())
+                        //{
+                        //    e.Cancel = true;
+                        //}
+                    }
+                    else
+                    {
+                        e.Cancel = true;
+                    }
+                }
+            };
+             
+        }
+         
+        //娣诲姞姝ラ椤�
+        private void AddStepProgressBarItem(string caption)
+        {
+            this.stepProgressBar1.BeginInit();
+            var item = new StepProgressBarItem();
+            item.ContentBlock2.Caption = caption;
+            item.Options.Indicator.ActiveStateDrawMode = IndicatorDrawMode.Full;
+            item.Options.Indicator.ActiveStateImageOptions.SvgImage = null;
+            item.Options.Indicator.InactiveStateImageOptions.SvgImage = null;
+            item.State = StepProgressBarItemState.Inactive;
+            this.stepProgressBar1.Items.Add(item);
+            this.stepProgressBar1.EndInit(); 
+        }
+
+        //鍒濆鍖栨寜閽姸鎬�
+        private void InitialButtonStatus(List<string> change_type_list)
+        {
+            if (change_type_list == null || !change_type_list.Any())
+            {
+                this.itemForNext.Visibility = LayoutVisibility.Never;
+                this.itemForComplete.Visibility = LayoutVisibility.Always;
+            }
+            else
+            {
+                this.itemForPrev.Visibility = LayoutVisibility.Never;
+                this.itemForNext.Visibility = LayoutVisibility.Always;
+                this.itemForComplete.Visibility = LayoutVisibility.Never;
+                this.itemForCancel.Visibility = LayoutVisibility.Always;
+            }
+        }
+
+        //鍒濆鍖栨楠ょ鐞嗗櫒
+        private void InitialWizardManager(List<string> change_type_list)
+        {
+            if (change_type_list == null || !change_type_list.Any())
+                return;
+            var overlay = this.ShowOverlay();
+            this.stepProgressBar1.Items.Clear();
+            this.navigationFrameStep.Pages.Clear();
+            var page_list = new List<IWizardPage<CreateXhsSchemeViewModel>>();
+            if (change_type_list.Contains(Yw.Hydro.ParterCatalog.Pipe))
+            {
+                var caption = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pipe);
+                AddStepProgressBarItem(caption);
+                page_list.Add(new CreateXhsSchemePipeChangePage());
+            }
+            if (change_type_list.Contains(Yw.Hydro.ParterCatalog.Pump))
+            {
+                var caption = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pump);
+                AddStepProgressBarItem(caption);
+                page_list.Add(new CreateXhsSchemePumpChangePage());
+            }
+            if (change_type_list.Contains(Yw.Hydro.ParterCatalog.Valve))
+            {
+                var caption = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Valve);
+                AddStepProgressBarItem(caption);
+                page_list.Add(new CreateXhsSchemeValveChangePage());
+            }
+
+            AddStepProgressBarItem("鍙樻洿璁板綍");
+            page_list.Add(new CreateXhsSchemeChangeRecordPage());
+
+            foreach (var item in page_list)
+            {
+                var ctrl = item as XtraUserControl;
+                ctrl.Dock = DockStyle.Fill;
+                this.navigationFrameStep.AddPage(ctrl);
+            }
+
+            _wizard = new CreateXhsSchemeManager(_vm);
+            _wizard.SelectedPageChangedEvent += _wizard_SelectedPageChangedEvent;
+            _wizard.SelectedPageStateChangedEvent += _wizard_SelectedPageStateChangedEvent;
+            _wizard.InitialManager(page_list.ToArray());
+            overlay.Close();
+        }
+         
+        //閫夋嫨椤甸潰鏀瑰彉
+        private void _wizard_SelectedPageChangedEvent(IWizardPage<CreateXhsSchemeViewModel> page, int index)
+        {
+            this.itemForPrev.Visibility = page.AllowPrev ? LayoutVisibility.Always : LayoutVisibility.Never;
+            this.itemForNext.Visibility = page.AllowNext ? LayoutVisibility.Always : LayoutVisibility.Never;
+            this.itemForCancel.Visibility = page.AllowCancel ? LayoutVisibility.Always : LayoutVisibility.Never;
+            this.itemForComplete.Visibility = page.AllowComplete ? LayoutVisibility.Always : LayoutVisibility.Never; 
+            this.navigationFrameStep.SelectedPageIndex = index; 
+            this.stepProgressBar1.SelectedItemIndex = index;
+        }
+
+        //閫夋嫨椤甸潰鐘舵�佹敼鍙�
+        private void _wizard_SelectedPageStateChangedEvent(IWizardPage<CreateXhsSchemeViewModel> page, int index)
+        {
+            this.itemForPrev.Visibility = page.AllowPrev ? LayoutVisibility.Always : LayoutVisibility.Never;
+            this.itemForNext.Visibility = page.AllowNext ? LayoutVisibility.Always : LayoutVisibility.Never;
+            this.itemForCancel.Visibility = page.AllowCancel ? LayoutVisibility.Always : LayoutVisibility.Never;
+            this.itemForComplete.Visibility = page.AllowComplete ? LayoutVisibility.Always : LayoutVisibility.Never;
+        }
+
+        //涓婁竴姝�
+        private void btnPrev_Click(object sender, EventArgs e)
+        {
+            if (_wizard != null)
+            {
+                if (_wizard.SelectedIndex == 0)
+                {  
+                    this.SelectedPageIndex = 0;
+                }
+                else
+                {
+                    _wizard.Prev();
+                }
+            }
+        }
+
+        //涓嬩竴姝�
+        private void btnNext_Click(object sender, EventArgs e)
+        {
+            if (!_initial_wizard_manager)
+            {
+                if (this.createXhsSchemeInfoPage1.CanNext())
+                {
+                    this.SelectedPageIndex = 1;
+                }   
+            }
+            else
+            {
+                if (_wizard != null)
+                {
+                    _wizard.Next();
+                }
+            }
+        
+        }
+
+        //鍙栨秷
+        private void btnCancel_Click(object sender, EventArgs e)
+        {
+            if (_wizard != null)
+            {
+                var bol = _wizard.Cancel();
+                if (bol)
+                {
+                    this.DialogResult = DialogResult.Cancel;
+                    this.Close();
+                }
+            }
+
+        }
+
+        //瀹屾垚
+        private void btnComplete_Click(object sender, EventArgs e)
+        {
+            if (this.SelectedPageIndex == 0)
+            {
+                if (this.createXhsSchemeInfoPage1.CanComplete())
+                {
+                    this.ReloadDataEvent?.Invoke(_vm.Scheme);
+                    this.DialogResult = DialogResult.OK;
+                    this.Close();
+                }
+            }
+            else
+            {
+                if (_wizard != null)
+                {
+                    var bol = _wizard.Complete();
+                    if (bol)
+                    {
+                        this.ReloadDataEvent?.Invoke(_vm.Scheme);
+                        this.DialogResult = DialogResult.OK;
+                        this.Close();
+                    }
+                }
+            }
+        }
+         
+
+         
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3