duheng
2024-11-03 28402b6df09de5e106422878246f7ac814d353b0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
namespace Yw.WinFrmUI
{
    public partial class BimfaceInterop3dContainer : UserControl, IBimfaceInterop3dContainer
    {
        public BimfaceInterop3dContainer()
        {
            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 bool IsInitialized
        {
            get
            {
                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>
        /// 初始话容器
        /// </summary>
        public async Task InitialContainer()
        {
            var callBackObj = GetCallBackObj();
            await this.webViewControl1.InitialWebBrower(BimfaceUrlHelper.Interop3dUrl, callBackObj, true);
        }
 
        /// <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 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);
        }
 
 
        #endregion
 
 
 
    }
}