lixiaojun
2024-09-23 03da721341232b6054d5d25f94a3bd1014771805
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/02-bimface/XhsProjectSimulationBimfaceCtrl.cs
@@ -1,4 +1,7 @@
namespace HStation.WinFrmUI
using DevExpress.Office.Utils;
using DevExpress.Xpo.Helpers;
namespace HStation.WinFrmUI
{
    public partial class XhsProjectSimulationBimfaceCtrl : DevExpress.XtraEditors.XtraUserControl
    {
@@ -9,36 +12,49 @@
            this.bimfaceInterop3dContainer1.ClickInEvent += BimfaceInterop3dContainer1_ClickInEvent;
        }
        /// <summary>
        /// 点击组件事件
        /// </summary>
        public event Action<string> ClickParterEvent;
        private long _projectId;//项目id
        private HStation.Vmo.XhsProjectVmo _project = null;
        private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;
        /// <summary>
        /// 绑定数据
        /// </summary>
        public async void SetBindingData(long projectId)
        public async Task SetBindingData(HStation.Vmo.XhsProjectVmo project, HStation.Vmo.XhsProjectSiteVmo projectSite)
        {
            _projectId = projectId;
            if (project == null)
            {
                return;
            }
            _project = project;
            _projectSite = projectSite;
            if (_projectSite == null)
            {
                _projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_project.ID);
            }
            await this.bimfaceInterop3dContainer1.InitialContainer();
        }
        //页面加载完成后触发
        private async void BimfaceInterop3dContainer1_LoadCompletedEvent()
        {
            var projectSite = await new BLL.XhsProjectSiteStd().GetDefaultByProjectID(_projectId);
            if (projectSite == null)
            if (_projectSite == null)
            {
                return;
            }
            var relation = await new Yw.BLL.BimfaceFileRelationStd()
                .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, projectSite.ID, Yw.Bimface.Purpose.Simulation);
            var relation = await BLLFactory<Yw.BLL.BimfaceFileRelation>.Instance
                .GetDefaultByObjectTypeAndObjectIDOfPurpose
                    (HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
            if (relation == null)
            {
                return;
            }
            var bimfaceFile = await new Yw.BLL.BimfaceFileStd().GetByID(relation.BimfaceFileID);
            var bimfaceFile = await BLLFactory<Yw.BLL.BimfaceFile>.Instance.GetByID(relation.BimfaceFileID);
            if (bimfaceFile == null)
            {
                return;
@@ -50,7 +66,6 @@
                return;
            }
            await this.bimfaceInterop3dContainer1.LoadView(viewToken);
        }
        //构件点击
@@ -63,30 +78,133 @@
            this.ClickParterEvent?.Invoke(obj.ObjectId);
        }
        public async Task HideComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.HideComponents(elementIds);
        }
        #region 构件的显示与隐藏
        /// <summary>
        /// 显示构件
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task ShowComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.ShowComponents(elementIds);
        }
        /// <summary>
        /// 隐藏构件
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task HideComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.HideComponents(elementIds);
        }
        /// <summary>
        /// 显示所有构件
        /// </summary>
        /// <returns></returns>
        public async Task ShowAllComponents()
        {
            await this.bimfaceInterop3dContainer1.ShowAllComponents();
        }
        #endregion
        #region 构件的半透明与取消
        /// <summary>
        /// 半透明构件
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task TranslucentComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.TranslucentComponents(elementIds);
        }
        /// <summary>
        /// 取消构件半透明
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task OpaqueComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.OpaqueComponents(elementIds);
        }
        #endregion
        #region 构件的选中与取消
        /// <summary>
        /// 设置选择的构件
        /// </summary>
        /// <returns></returns>
        public async Task SetSelectedComponents(List<string> elements)
        {
            await this.bimfaceInterop3dContainer1.SetSelectedComponents(elements);
        }
        /// <summary>
        /// 增加选择的构件
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public async Task AddSelectedComponents(List<string> elements)
        {
            await this.bimfaceInterop3dContainer1.AddSelectedComponents(elements);
        }
        /// <summary>
        /// 移除选择的构件
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public async Task RemoveSelectedComponents(List<string> elements)
        {
            await this.bimfaceInterop3dContainer1.RemoveSelectedComponents(elements);
        }
        /// <summary>
        /// 清除选择的构件
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public async Task ClearSelectedComponents()
        {
            await this.bimfaceInterop3dContainer1.ClearSelectedComponents();
        }
        #endregion
        #region 缩放
        /// <summary>
        /// 缩放至构件
        /// </summary>
        public async Task ZoomToComponent(string elementId)
        {
            await this.bimfaceInterop3dContainer1.ZoomToComponent(elementId);
        }
        /// <summary>
        /// 缩放至选择构件
        /// </summary>
        public async Task ZoomToSelectedComponents()
        {
            await this.bimfaceInterop3dContainer1.ZoomToSelectedComponents();
        }
        /// <summary>
        /// 缩放至选择构件
        /// </summary>
        public async Task ZoomAndSelectComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.ZoomAndSelectComponents(elementIds);
        }
        #endregion
    }
}