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