using DevExpress.Utils.Svg; namespace HStation.WinFrmUI { public partial class CreateXhsSchemePipeChangePage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPage { public CreateXhsSchemePipeChangePage() { InitializeComponent(); this.layoutView1.SetDefuaulView(); this.layoutView1.SetFindPanel(); } /// /// 页面状态改变事件 /// 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 List _vm_list = null; /// /// 初始化 /// public void InitialPage(CreateXhsSchemeViewModel t) { if (_isInitialize) { return; } _vm = t; _isInitialize = true; _project = t.Project; _project_site = t.ProjectSite; if (t.HydroInfo.Pipes != null && t.HydroInfo.Pipes.Any()) { var svg = SvgImage.FromStream(new MemoryStream(HStation.WinFrmUI.Xhs.Core.Properties.Resources.pipe)); _vm_list = new List(); foreach (var pipe in t.HydroInfo.Pipes) { var vm = new Yw.WinFrmUI.HydroPipeViewModel(pipe, t.HydroInfo); _vm_list.Add(new CreateXhsSchemePipeChangeViewMdoel(vm, svg)); } } this.createXhsSchemePipeChangeViewMdoelBindingSource.DataSource = _vm_list; this.createXhsSchemePipeChangeViewMdoelBindingSource.ResetBindings(false); ShowBimfaceCtrl(); } #region Bimface //bimface控件 private SimulationBimfaceCtrl _bimfaceCtrl = null; //获取 bimface 控件 private async Task GetBimfaceCtrl() { if (_vm == null) return null; if (_bimfaceCtrl == null) { _bimfaceCtrl = new SimulationBimfaceCtrl(); _bimfaceCtrl.Dock = DockStyle.Fill; await _bimfaceCtrl.InitialData(_project, _project_site); _bimfaceCtrl.HydroMouseLeftClickEvent += (code) => { if (_vm_list == null || !_vm_list.Any()) return; var index = _vm_list.FindIndex(x => x.ViewModel.Code == code); this.layoutView1.FocusedRowHandle = index; }; } return _bimfaceCtrl; } //显示 bimface 控件 private async void ShowBimfaceCtrl() { var bimfaceCtrl = await GetBimfaceCtrl(); this.sidePanel3dModel.Controls.Clear(); this.sidePanel3dModel.Controls.Add(bimfaceCtrl); } #endregion //保存 private bool Save() { if (!_isInitialize) { return false; } if (_vm_list == null || !_vm_list.Any()) { return false; } _vm_list.ForEach(x => x.ViewModel.UpdateVmoProperty()); _vm.HydroInfo.Pipes = _vm_list.Select(x => x.ViewModel.Vmo).ToList(); return true; } //点击 private async void layoutView1_CardClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.CardClickEventArgs e) { if (this.layoutView1.GetRow(e.RowHandle) is not CreateXhsSchemePipeChangeViewMdoel row) return; await _bimfaceCtrl?.ZoomAndSelectComponent(row.ViewModel.Code); } //选中列变换 private void layoutView1_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e) { if (e.FocusedColumn == this.colModelType) { this.layoutView1.FocusedColumn = null; if (this.layoutView1.GetFocusedRow() is not CreateXhsSchemePipeChangeViewMdoel row) return; var link_status = row.LinkStatus; var input = Yw.WinFrmUI.HydroMatchingHelper.Create(row.ViewModel.Vmo, _vm.HydroInfo); var dlg = new SimulationPipeSingleMatchingDlg(); dlg.SetBindingData(input); dlg.ReloadDataEvent += (output) => { Yw.WinFrmUI.HydroMatchingHelper.Apply(row.ViewModel, output); row.LinkStatus = link_status; if (!_vm.ChangeRecordList.Exists(x => x.Code == row.ViewModel.Code)) { _vm.ChangeRecordList.Add(new(Yw.Hydro.ParterCatalog.Pipe, row.ViewModel.Code, row.Name, row.SvgImage)); } }; dlg.ShowDialog(); } } //单元格值变换 private void layoutView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (this.layoutView1.GetRow(e.RowHandle) is not CreateXhsSchemePipeChangeViewMdoel row) return; if (!_vm.ChangeRecordList.Exists(x => x.Code == row.ViewModel.Code)) { _vm.ChangeRecordList.Add(new(Yw.Hydro.ParterCatalog.Pipe, row.ViewModel.Code, row.Name, row.SvgImage)); } } /// /// 允许上一步 /// public bool AllowPrev { get { return true; } } /// /// 允许下一步 /// public bool AllowNext { get { return _isInitialize; } } /// /// 允许取消 /// public bool AllowCancel { get { return false; } } /// /// 允许完成 /// public bool AllowComplete { get { return false; } } /// /// 能否上一步 /// public bool CanPrev() { return true; } /// /// 能否下一步 /// public bool CanNext() { if (!_isInitialize) { return false; } return Save(); } /// /// 能否关闭 /// public bool CanCancel() { return true; } /// /// 能否完成 /// public bool CanComplete() { return false; } } }