namespace Yw.WinFrmUI { public partial class BimfaceInterop3dContainer : UserControl, IBimfaceInterop3dContainer { public BimfaceInterop3dContainer() { InitializeComponent(); } /// /// Html加载完成事件 /// public event Action LoadCompletedEvent; /// /// Html加载失败事件 /// public event Action LoadFailedEvent; /// /// 处理错误事件 /// public event Action HandingErrorEvent; /// /// View加载完成事件 /// public event Action LoadViewCompletedEvent; /// /// View加载失败事件 /// public event Action LoadViewFailedEvent; /// /// 点击构件事件 /// public event Action ClickInEvent; /// /// 鼠标左键点击构件事件 /// public event Action MouseLeftClickInEvent; /// /// 点击外部事件 /// public event Action ClickOutEvent; /// /// 鼠标左键点击外部事件 /// public event Action MouseLeftClickOutEvent; /// /// 是否初始化 /// public bool IsInitialized { get { return _isInitialized; } } private bool _isInitialized; /// /// 视图是否初始化 /// public bool IsViewInitialized { get { return _isViewInitialized; } } private bool _isViewInitialized; //获取交互对象 private BimfaceInterop3dCallBackObj GetCallBackObj() { if (_callBackObj == null) { _callBackObj = new BimfaceInterop3dCallBackObj(); _callBackObj.LoadCompletedEvent += () => { _isInitialized = true; this.LoadCompletedEvent?.Invoke(); }; _callBackObj.LoadFailedEvent += () => { this.LoadFailedEvent?.Invoke(); }; _callBackObj.HandingErrorEvent += (obj) => { this.HandingErrorEvent?.Invoke(obj); }; _callBackObj.LoadViewCompletedEvent += () => { _isViewInitialized = true; this.LoadViewCompletedEvent?.Invoke(); }; _callBackObj.LoadViewFailedEvent += (obj) => { this.LoadViewFailedEvent?.Invoke(obj); }; _callBackObj.ClickInEvent += (obj) => { this.ClickInEvent?.Invoke(obj); }; _callBackObj.MouseLeftClickInEvent += (obj) => { this.MouseLeftClickInEvent?.Invoke(obj); }; _callBackObj.ClickOutEvent += (obj) => { this.ClickOutEvent?.Invoke(obj); }; _callBackObj.MouseLeftClickOutEvent += (obj) => { this.MouseLeftClickOutEvent?.Invoke(obj); }; } return _callBackObj; } private BimfaceInterop3dCallBackObj _callBackObj; /// /// 初始话容器 /// public async Task InitialContainer() { var callBackObj = GetCallBackObj(); await this.webViewControl1.InitialWebBrower(BimfaceUrlHelper.Interop3dUrl, callBackObj, true); } /// /// 加载视图 /// public async Task LoadView(string viewToken) { if (!_isInitialized) { return false; } return await this.webViewControl1.EvaluateScriptAsync("loadView", viewToken); } #region 构件显隐 /// /// 显示构件 /// /// 构件id列表 public async Task ShowComponents(List ids) { if (ids == null || ids.Count < 1) { return; } if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("showComponents", ids); } /// /// 隐藏构件 /// /// 构件id列表 public async Task HideComponents(List ids) { if (ids == null || ids.Count < 1) { return; } if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("hideComponents", ids); } /// /// 显示所有构件 /// public async Task ShowAllComponents() { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("showAllComponents()"); } #endregion #region 构件半透明与取消 /// /// 半透明组件(鼠标不可选) /// /// 构件id列表 /// public async Task TranslucentComponents(List ids) { if (ids == null || ids.Count < 1) { return; } if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("translucentComponents", ids); } /// /// 取消构件半透明 /// /// 构件id列表 /// public async Task OpaqueComponents(List ids) { if (ids == null || ids.Count < 1) { return; } if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("opaqueComponents", ids); } #endregion #region 构件的选择与取消 /// /// 设置选择的构件列表 /// /// 构件id列表 public async Task SetSelectedComponents(List ids) { if (ids == null || ids.Count < 1) { return; } if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("setSelectedComponents", ids); } /// /// 增加选择的构件列表 /// /// 构件id列表 public async Task AddSelectedComponents(List ids) { if (ids == null || ids.Count < 1) { return; } if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("addSelectedComponents", ids); } /// /// 移除选择的构件列表 /// /// 构件id列表 public async Task RemoveSelectedComponents(List ids) { if (ids == null || ids.Count < 1) { return; } if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("removeSelectedComponents", ids); } /// /// 清除选择的构件列表 /// public async Task ClearSelectedComponents() { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("clearSelectedComponents()"); } #endregion #region 缩放 /// /// 缩放至包围盒 /// public async Task ZoomToBoundingBox(BoundingBox boundingbox) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("zoomToBoundingBox", boundingbox); } /// /// 缩放至构件 /// public async Task ZoomToComponent(string id) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("zoomToComponent", id); } /// /// 缩放至选择的构件 /// public async Task ZoomToSelectedComponents() { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("zoomToSelectedComponents()"); } /// /// 缩放并选择构件 /// public async Task ZoomAndSelectComponents(List ids) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("zoomAndSelectComponents", ids); } #endregion #region 强调构件 /// /// 设置强调构件 /// /// 构件id列表 /// #32D3A6 /// 0.8 public async Task SetBlinkComponents(List ids, string color, double transparency) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("setBlinkComponents", new ComponentsBlink(ids, color, transparency)); } /// /// 清除强调构件 /// public async Task ClearBlinkComponents() { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("clearBlinkComponents()"); } #endregion #region 构件着色 /// /// 改变构件颜色 /// /// 构件id列表 /// #32D3A6 /// 0.8 public async Task OverrideComponentsColor(List ids, string color, double transparency) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("overrideComponentsColor", new ComponentsColor(ids, color, transparency)); } /// /// /// public async Task RestoreComponentsColor(List ids) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("restoreComponentsColor", ids); } #endregion #region 业务计算自定义标签 /// /// 设置业务计算自定义标签 /// public async Task SetLogicCalcuCustomLabels(List obj) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("setLogicCalcuCustomLabels", obj); } /// /// 清除业务计算自定义标签 /// public async Task ClearLogicCalcuCustomLabels() { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("clearLogicCalcuCustomLabels()"); } #endregion #region 业务标注引线标签 /// /// 设置业务标注引线标签 /// public async Task SetLogicMarkLeadLabels(List obj) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("setLogicMarkLeadLabels", obj); } /// /// 更新业务标注引线标签 /// public async Task UpdateLogicMarkLeadLabel(LogicMarkLeadLabel obj) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("updateLogicMarkLeadLabel", obj); } /// /// 更新业务标注引线标签 /// public async Task UpdateLogicMarkLeadLabels(List obj) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("updateLogicMarkLeadLabels", obj); } /// /// 清除业务标注引线标签 /// public async Task ClearLogicMarkLeadLabels() { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("clearLogicMarkLeadLabels()"); } #endregion #region 业务水流动画 /// /// 加载水流动画 /// public async Task LoadFlowEffect(LogicFlowEffect obj) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("loadFlowEffect", obj); } /// /// 加载水流动画列表 /// public async Task LoadFlowEffectList(List obj) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("loadFlowEffectList", obj); } /// /// 更新水流动画 /// public async Task UpdateFlowEffect(LogicFlowEffect obj) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("updateFlowEffect", obj); } /// /// 更新水流动画列表 /// public async Task UpdateFlowEffectList(List obj) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("updateFlowEffectList", obj); } /// /// 卸载水流动画 /// public async Task UnloadFlowEffect() { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("unloadFlowEffect()"); } /// /// 通过 Id 卸载水流动画 /// public async Task UnloadFlowEffectById(string Id) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("unloadFlowEffectById", Id); } #endregion #region 业务监测点 /// /// 设置业务监测点 /// public async Task SetLogicMonitors(List obj) { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("setLogicMonitors", obj); } /// /// 清除业务监测点 /// public async Task ClearLogicMonitors() { if (!_isViewInitialized) { return; } await this.webViewControl1.EvaluateScriptAsync("clearLogicMonitors()"); } #endregion } }