using DevExpress.Utils.Svg; using Mapster; using Yw; namespace HStation.WinFrmUI { public partial class CreateXhsSchemePipeChangePage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPage { public CreateXhsSchemePipeChangePage() { InitializeComponent(); InitialLinkStatus(); this.layoutView1.SetDefuaulView(); } /// /// 页面状态改变事件 /// 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; //初始化状态 private void InitialLinkStatus() { this.repImgCmbStatus.BeginUpdate(); this.repImgCmbStatus.Items.Clear(); this.repImgCmbStatus.Items.Add("开启", "开启", -1); this.repImgCmbStatus.Items.Add("关闭", "关闭", -1); this.repImgCmbStatus.EndUpdate(); } /// /// 初始化 /// 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_img = 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).Adapt(); vm.SvgImage = svg_img; _vm_list.Add(vm); } } //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); } 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.HydroInfo.Pipes = _vm_list.Adapt>(); return true; } // private async void layoutView1_CardClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.CardClickEventArgs e) { var row = this.layoutView1.GetRow(e.RowHandle) as CreateXhsSchemePipeChangeViewMdoel; if (row == null) return; await _bimfaceCtrl?.ZoomAndSelectComponent(row.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.Vmo, _vm.HydroInfo); var dlg = new SimulationPipeSingleMatchingDlg(); dlg.SetBindingData(input); dlg.ReloadDataEvent += (output) => { Yw.WinFrmUI.HydroMatchingHelper.Apply(row, output); row.LinkStatus = link_status; }; dlg.ShowDialog(); } } /// /// 允许上一步 /// 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; } } }