using DevExpress.Office.Utils; using DevExpress.Xpo.Helpers; namespace HStation.WinFrmUI { public partial class XhsProjectSimulationBimfaceCtrl : DevExpress.XtraEditors.XtraUserControl { public XhsProjectSimulationBimfaceCtrl() { InitializeComponent(); this.bimfaceInterop3dContainer1.LoadCompletedEvent += BimfaceInterop3dContainer1_LoadCompletedEvent; this.bimfaceInterop3dContainer1.ClickInEvent += BimfaceInterop3dContainer1_ClickInEvent; } /// /// 点击组件事件 /// public event Action ClickParterEvent; private HStation.Vmo.XhsProjectVmo _project = null; private HStation.Vmo.XhsProjectSiteVmo _projectSite = null; /// /// 绑定数据 /// public async Task SetBindingData(HStation.Vmo.XhsProjectVmo project, HStation.Vmo.XhsProjectSiteVmo projectSite) { if (project == null) { return; } _project = project; _projectSite = projectSite; if (_projectSite == null) { _projectSite = await BLLFactory.Instance.GetDefaultByProjectID(_project.ID); } await this.bimfaceInterop3dContainer1.InitialContainer(); } //页面加载完成后触发 private async void BimfaceInterop3dContainer1_LoadCompletedEvent() { if (_projectSite == null) { return; } var relation = await BLLFactory.Instance .GetDefaultByObjectTypeAndObjectIDOfPurpose (HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation); if (relation == null) { return; } var bimfaceFile = await BLLFactory.Instance.GetByID(relation.BimfaceFileID); if (bimfaceFile == null) { return; } var viewToken = await BimfaceHelper.GetViewToken(bimfaceFile.BimfaceId); if (string.IsNullOrEmpty(viewToken)) { return; } await this.bimfaceInterop3dContainer1.LoadView(viewToken); } //构件点击 private void BimfaceInterop3dContainer1_ClickInEvent(Yw.WinFrmUI.Bimface.ClickIn3dInfo obj) { if (obj == null) { return; } this.ClickParterEvent?.Invoke(obj.ObjectId); } #region 构件的显示与隐藏 /// /// 显示构件 /// /// 构件id列表 /// public async Task ShowComponents(List elementIds) { await this.bimfaceInterop3dContainer1.ShowComponents(elementIds); } /// /// 隐藏构件 /// /// 构件id列表 /// public async Task HideComponents(List elementIds) { await this.bimfaceInterop3dContainer1.HideComponents(elementIds); } /// /// 显示所有构件 /// /// public async Task ShowAllComponents() { await this.bimfaceInterop3dContainer1.ShowAllComponents(); } #endregion #region 构件的半透明与取消 /// /// 半透明构件 /// /// 构件id列表 /// public async Task TranslucentComponents(List elementIds) { await this.bimfaceInterop3dContainer1.TranslucentComponents(elementIds); } /// /// 取消构件半透明 /// /// 构件id列表 /// public async Task OpaqueComponents(List elementIds) { await this.bimfaceInterop3dContainer1.OpaqueComponents(elementIds); } #endregion #region 构件的选中与取消 /// /// 设置选择的构件 /// /// public async Task SetSelectedComponents(List elements) { await this.bimfaceInterop3dContainer1.SetSelectedComponents(elements); } /// /// 增加选择的构件 /// /// /// public async Task AddSelectedComponents(List elements) { await this.bimfaceInterop3dContainer1.AddSelectedComponents(elements); } /// /// 移除选择的构件 /// /// /// public async Task RemoveSelectedComponents(List elements) { await this.bimfaceInterop3dContainer1.RemoveSelectedComponents(elements); } /// /// 清除选择的构件 /// /// /// public async Task ClearSelectedComponents() { await this.bimfaceInterop3dContainer1.ClearSelectedComponents(); } #endregion #region 缩放 /// /// 缩放至构件 /// public async Task ZoomToComponent(string elementId) { await this.bimfaceInterop3dContainer1.ZoomToComponent(elementId); } /// /// 缩放至选择构件 /// public async Task ZoomToSelectedComponents() { await this.bimfaceInterop3dContainer1.ZoomToSelectedComponents(); } /// /// 缩放至选择构件 /// public async Task ZoomAndSelectComponents(List elementIds) { await this.bimfaceInterop3dContainer1.ZoomAndSelectComponents(elementIds); } #endregion } }