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 long _projectId;//项目id
///
/// 绑定数据
///
public async void SetBindingData(long projectId)
{
_projectId = projectId;
await this.bimfaceInterop3dContainer1.InitialContainer();
}
//页面加载完成后触发
private async void BimfaceInterop3dContainer1_LoadCompletedEvent()
{
var projectSite = await BLLFactory.Instance.GetDefaultByProjectID(_projectId);
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);
}
public async Task HideComponents(List elementIds)
{
await this.bimfaceInterop3dContainer1.HideComponents(elementIds);
}
public async Task ShowComponents(List elementIds)
{
await this.bimfaceInterop3dContainer1.ShowComponents(elementIds);
}
public async Task ShowAllComponents()
{
await this.bimfaceInterop3dContainer1.ShowAllComponents();
}
///
/// 半透明构件
///
/// 构件id列表
///
public async Task TranslucentComponents(List elementIds)
{
await this.bimfaceInterop3dContainer1.TranslucentComponents(elementIds);
}
///
/// 取消构件半透明
///
/// 构件id列表
///
public async Task OpaqueComponents(List elementIds)
{
await this.bimfaceInterop3dContainer1.OpaqueComponents(elementIds);
}
}
}