Shuxia Ning
2024-11-11 f866efa3f12f68bc1f21ed5c9b76ead436009b04
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/AddXhsSchemeDlg.cs
@@ -1,4 +1,4 @@
using DevExpress.XtraBars;
using Mapster;
namespace HStation.WinFrmUI
{
@@ -8,8 +8,15 @@
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.ribbon.SetFormStyle();
            this.ribbon.SetFormStyle();
            this.gridView1.SetNormalView();
            this.gridView2.SetNormalView();
            this.gridView2.OptionsView.EnableAppearanceOddRow = false;   // 使能 // 和和上面绑定 同时使用有效
            this.gridView2.OptionsView.EnableAppearanceEvenRow = false;
            this.gridView1.OptionsView.ShowIndicator = false;
            this.gridView2.OptionsView.ShowIndicator = false;
            foreach (var page in this.tabPane1.Pages)
            {
                if (page.Controls[0] is ISetSchemeParterList ctrl)
@@ -18,27 +25,29 @@
                    ctrl.HydroClickEvent += async (parter) =>
                    {
                        _selectedParter = parter;
                        await  _bimfaceCtrl?.ZoomAndSelectComponent(_selectedParter.Code);
                        await _bimfaceCtrl?.ZoomAndSelectComponent(_selectedParter.Code);
                    };
                    ctrl.HydroRecordChangedEvent += (record) =>
                    {
                    {
                        _set_record_list.Add(record);
                        this.setSchemeParterRecordBindingSource.ResetBindings(false);
                    };
                    };
                    ctrl.HydroChangedEvent += (parterList) =>
                    {
                    };
                }
            }
        }
        private HStation.Vmo.XhsProjectVmo _project = null;//项目
        private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//项目站
        private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息
        private Yw.Model.HydroModelInfo _hydroInfo_init = null;//初始 水力信息
        private Yw.Model.HydroParterInfo _selectedParter = null; //选择构件
        private List<SetSchemeParterRecord> _set_record_list = null;
@@ -58,27 +67,24 @@
            }
            _project = project;
            _projectSite = projectSite;
            _hydroInfo = hydroInfo;
            _hydroInfo_init = hydroInfo;
            _set_record_list = new List<SetSchemeParterRecord>();
            if (_projectSite == null)
            {
                _projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_project.ID);
            }
            if (_hydroInfo == null)
            if (_hydroInfo_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);
            }
                _hydroInfo_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);
            ShowBimfaceCtrl();
            LoadData();
            ShowBimfaceCtrl();
        }
        #region Bimface
@@ -127,21 +133,68 @@
        }
        #endregion
        private void barCek_CheckedChanged(object sender, ItemClickEventArgs e)
        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);
        }
            if (!this.flyoutPanel1.Visible)
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            if (e.Column == this.colDelete)
            {
                this.flyoutPanel1.ShowPopup();
                var row = this.gridView1.GetRow(e.RowHandle) as SetSchemeParterRecord;
                _set_record_list.Remove(row);
                this.setSchemeParterRecordBindingSource.ResetBindings(false);
                LoadData(_set_record_list);
            }
            else
        }
        private void LoadData( List<SetSchemeParterRecord> set_record_list=null)
        {
            _hydroInfo = _hydroInfo_init.Adapt<Yw.Model.HydroModelInfo, Yw.Model.HydroModelInfo>();
            if (set_record_list != null && set_record_list.Any())
            {
                this.flyoutPanel1.HidePopup();
                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(_hydroInfo, vm);
                            }
                            break;
                        case Yw.Hydro.ParterCatalog.Valve:
                            {
                                var vm = item.MatchingModel as ValveMatchingViewModel;
                                var bol = AssetsMatchingParasHelper.Apply(_hydroInfo, vm);
                            }
                            break;
                        case Yw.Hydro.ParterCatalog.Pipe:
                            {
                                var vm = item.MatchingModel as PipeMatchingViewModel;
                                var bol = AssetsMatchingParasHelper.Apply(_hydroInfo, vm);
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
            this.setSchemePumpListCtrl1.SetBindingData(_hydroInfo);
            this.setSchemeValveListCtrl1.SetBindingData(_hydroInfo);
            this.setSchemePipeListCtrl1.SetBindingData(_hydroInfo);
        }
    }
}