lixiaojun
2025-01-03 d672ca82c49f01dae2c5c955202b5857ef680a71
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/02-change/01-pump/CreateXhsSchemePumpChangePage.cs
@@ -1,12 +1,22 @@
namespace HStation.WinFrmUI
using DevExpress.Utils.Svg;
using Mapster;
using Yw;
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();
            InitialStatus();
            this.layoutView1.OptionsFilter.AllowFilterEditor = false;
            this.xhsSchemePumpChangeListCtrl1.HydroViewEvent += XhsSchemePumpChangeListCtrl1_HydroViewEvent;
            this.xhsSchemePumpChangeListCtrl1.HydroChangeEvent += XhsSchemePumpChangeListCtrl1_HydroChangeEvent;
        }
        /// <summary>
@@ -15,71 +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 Yw.Model.HydroModelInfo _hydro_info = null;//水力信息
        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;
            _hydro_info = t.HydroInfo;
            this.createXhsSchemePumpChangeViewMdoelBindingSource.DataSource = _hydro_info.Pumps;
            this.createXhsSchemePumpChangeViewMdoelBindingSource.ResetBindings(false);
            _vm = vm;
            _allViewModelList = new List<HydroPumpViewModel>();
            if (vm.HydroInfo.Pumps != null && vm.HydroInfo.Pumps.Count > 0)
            {
                foreach (var visualViewModel in vm.AllVisualViewModelList)
                {
                    if (visualViewModel.Vmo.Catalog == Yw.Hydro.ParterCatalog.Pump)
                    {
                        var vmPump = visualViewModel as HydroPumpViewModel;
                        if (vmPump != null)
                        {
                            _allViewModelList.Add(vmPump);
                        }
                    }
                }
            }
            ShowBimfaceCtrl();
        }
        private void InitialStatus()
        {
            this.repImgCmbStatus.BeginUpdate();
            this.repImgCmbStatus.Items.Clear();
            this.repImgCmbStatus.Items.Add("开启", Yw.Hydro.PumpStatus.Open, -1);
            this.repImgCmbStatus.Items.Add("关闭", Yw.Hydro.PumpStatus.Closed, -1);
            this.repImgCmbStatus.EndUpdate();
            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);
                _bimfaceCtrl.LoadCompletedEvent += () =>
                await _bimfaceCtrl.InitialData(_vm.Project, _vm.ProjectSite, _vm.HydroInfo, _vm.AllVisualViewModelList);
                _bimfaceCtrl.HydroMouseLeftClickEvent += (code) =>
                {
                    //view加载完成事件
                    if (_hydro_info == null)
                    if (_allViewModelList == null || _allViewModelList.Count < 1)
                    {
                        return;
                    }
                    var index = _allViewModelList.FindIndex(x => x.Vmo.Code == code);
                    this.xhsSchemePumpChangeListCtrl1.SetFocusedRow(index);
                };
                _bimfaceCtrl.HydroMouseLeftClickEvent += (obj) =>
                {//鼠标左键点击事件
                    if (_hydro_info == null)
                _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;
@@ -89,9 +101,10 @@
        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
@@ -102,10 +115,7 @@
        /// </summary>
        public bool AllowPrev
        {
            get
            {
                return true;
            }
            get { return true; }
        }
        /// <summary>
@@ -113,10 +123,7 @@
        /// </summary>
        public bool AllowNext
        {
            get
            {
                return _isInitialize;
            }
            get { return true; }
        }
        /// <summary>
@@ -124,7 +131,7 @@
        /// </summary>
        public bool AllowCancel
        {
            get { return false; }
            get { return true; }
        }
        /// <summary>
@@ -138,42 +145,63 @@
        /// <summary>
        /// 能否上一步
        /// </summary>
        public bool CanPrev()
        public Task<bool> CanPrev()
        {
            return false;
            return Task.Run(() => true);
        }
        /// <summary>
        /// 能否下一步
        /// </summary>
        public bool CanNext()
        public Task<bool> CanNext()
        {
            if (!_isInitialize)
            {
                return false;
            }
            return true;
            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 layoutView1_CardClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.CardClickEventArgs e)
        {
        //改变
        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);
        }
    }
}