namespace HStation.WinFrmUI
|
{
|
public partial class XhsProjectBimfaceViewPage : DocumentPage
|
{
|
public XhsProjectBimfaceViewPage()
|
{
|
InitializeComponent();
|
this.PageTitle.Caption = "模型视图";
|
this.PageTitle.HeaderSvgImage = Yw.WinFrmUI.BimfaceMainSvgImageHelper.Bimface;
|
this.PageTitle.SvgImageSize = new Size(24, 24);
|
}
|
|
private XhsProjectVmo _project = null;//项目
|
private XhsProjectSiteVmo _projectSite = null;//项目站
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public async Task SetBindingData(long projectId)
|
{
|
var project = await BLLFactory<HStation.BLL.XhsProject>.Instance.GetByID(projectId);
|
if (project == null)
|
{
|
return;
|
}
|
SetBindingData(project);
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(XhsProjectVmo project)
|
{
|
if (project == null)
|
{
|
return;
|
}
|
_project = project;
|
this.PageTitle.Caption = $"{_project.Name}\r\n模型视图";
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(XhsProjectExtensionsVmo project)
|
{
|
if (project == null)
|
{
|
return;
|
}
|
_project = project;
|
_projectSite = project.SiteList.FirstOrDefault();
|
this.PageTitle.Caption = $"{_project.Name}\r\n模型视图";
|
}
|
|
/// <summary>
|
/// 初始化数据源
|
/// </summary>
|
public override void InitialDataSource()
|
{
|
base.InitialDataSource();
|
InitialData();
|
}
|
|
/// <summary>
|
/// 初始化数据
|
/// 仅支持调用一次
|
/// </summary>
|
public async void InitialData()
|
{
|
var bimfaceInteropContainer = GetBimfaceInteropContainer();
|
this.Controls.Clear();
|
this.Controls.Add(bimfaceInteropContainer);
|
await bimfaceInteropContainer.InitialContainer();
|
}
|
|
#region 交互容器
|
|
//bimface 交互容器
|
private BimfaceInterop3dContainer _bimfaceInteropContainer = null;
|
|
//获取Bimface 交互容器
|
private BimfaceInterop3dContainer GetBimfaceInteropContainer()
|
{
|
if (_bimfaceInteropContainer == null)
|
{
|
_bimfaceInteropContainer = new BimfaceInterop3dContainer();
|
_bimfaceInteropContainer.Dock = DockStyle.Fill;
|
_bimfaceInteropContainer.LoadCompletedEvent += async () =>
|
{
|
if (_project == null)
|
{
|
return;
|
}
|
if (_projectSite == null)
|
{
|
_projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance
|
.GetDefaultByProjectID(_project.ID);
|
}
|
|
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 BLLFactory<Yw.BLL.BimfaceFile>.Instance.GetByID(relation.BimfaceFileID);
|
if (bimfaceFile == null)
|
{
|
return;
|
}
|
|
var viewToken = await BimfaceHelper.GetViewToken(bimfaceFile.BimfaceId);
|
if (string.IsNullOrEmpty(viewToken))
|
{
|
return;
|
}
|
await _bimfaceInteropContainer.LoadView(viewToken);
|
};
|
_bimfaceInteropContainer.LoadFailedEvent += () =>
|
{
|
TipFormHelper.ShowError("三维模型容器加载失败");
|
};
|
_bimfaceInteropContainer.LoadViewFailedEvent += (obj) =>
|
{
|
TipFormHelper.ShowError($"三维模型加载失败");
|
};
|
}
|
return _bimfaceInteropContainer;
|
}
|
|
|
#endregion
|
|
}
|
}
|