using Mapster; namespace HStation.WinFrmUI { public partial class AddXhsSchemeDlg : DevExpress.XtraBars.Ribbon.RibbonForm { public AddXhsSchemeDlg() { InitializeComponent(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; 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) { ctrl.ShowFindPanel = false; ctrl.HydroClickEvent += async (parter) => { _selectedParter = parter; 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 _set_record_list = null; /// /// 绑定数据 /// public async Task SetBindingData ( HStation.Vmo.XhsProjectVmo project, HStation.Vmo.XhsProjectSiteVmo projectSite, Yw.Model.HydroModelInfo hydroInfo ) { if (project == null) { return; } _project = project; _projectSite = projectSite; _hydroInfo_init = hydroInfo; _set_record_list = new List(); if (_projectSite == null) { _projectSite = await BLLFactory.Instance.GetDefaultByProjectID(_project.ID); } if (_hydroInfo_init == null) { var hydroRelation = await BLLFactory.Instance .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation); _hydroInfo_init = await BLLFactory.Instance.GetByID(hydroRelation.ModelID); } this.setSchemeParterRecordBindingSource.DataSource = _set_record_list; this.setSchemeParterRecordBindingSource.ResetBindings(false); LoadData(); ShowBimfaceCtrl(); } #region Bimface //bimface控件 private XhsProjectSimulationBimfaceCtrl _bimfaceCtrl = null; //获取 bimface 控件 private async Task GetBimfaceCtrl() { if (_bimfaceCtrl == null) { _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl(); _bimfaceCtrl.Dock = DockStyle.Fill; await _bimfaceCtrl.InitialData(_project, _projectSite, () => _hydroInfo); _bimfaceCtrl.LoadCompletedEvent += () => { //view加载完成事件 if (_hydroInfo == null) { return; } }; _bimfaceCtrl.HydroMouseLeftClickEvent += (obj) => {//鼠标左键点击事件 if (_hydroInfo == null) { return; } }; } return _bimfaceCtrl; } //显示 bimface 控件 private async void ShowBimfaceCtrl() { var bimfaceCtrl = await GetBimfaceCtrl(); this.sidePanel3dModel.Controls.Clear(); this.sidePanel3dModel.Controls.Add(bimfaceCtrl); } private void SelectBimfaceParter() { } #endregion 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); } private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { if (e.Column == this.colDelete) { var row = this.gridView1.GetRow(e.RowHandle) as SetSchemeParterRecord; _set_record_list.Remove(row); this.setSchemeParterRecordBindingSource.ResetBindings(false); LoadData(_set_record_list); } } private void LoadData( List set_record_list=null) { _hydroInfo = _hydroInfo_init.Adapt(); if (set_record_list != null && set_record_list.Any()) { 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); } } }