lixiaojun
2024-09-15 f62dd6b3de7dae88ac638267a040e48a4d941e08
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
namespace HStation.WinFrmUI
{
    public partial class XhsProjectSimulationBimfaceCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public XhsProjectSimulationBimfaceCtrl()
        {
            InitializeComponent();
            this.bimfaceInterop3dContainer1.LoadCompletedEvent += BimfaceInterop3dContainer1_LoadCompletedEvent;
            this.bimfaceInterop3dContainer1.ClickInEvent += BimfaceInterop3dContainer1_ClickInEvent;
        }
 
        /// <summary>
        /// 点击组件事件
        /// </summary>
        public event Action<string> ClickParterEvent;
 
        private HStation.Vmo.XhsProjectVmo _project = null;
        private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public async Task SetBindingData(HStation.Vmo.XhsProjectVmo project, HStation.Vmo.XhsProjectSiteVmo projectSite)
        {
            if (project == null)
            {
                return;
            }
            _project = project;
            _projectSite = projectSite;
            if (_projectSite == null)
            {
                _projectSite = await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_project.ID);
            }
            await this.bimfaceInterop3dContainer1.InitialContainer();
        }
 
        //页面加载完成后触发
        private async void BimfaceInterop3dContainer1_LoadCompletedEvent()
        {
            if (_projectSite == null)
            {
                return;
            }
 
            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 this.bimfaceInterop3dContainer1.LoadView(viewToken);
        }
 
        //构件点击
        private void BimfaceInterop3dContainer1_ClickInEvent(Yw.WinFrmUI.Bimface.ClickIn3dInfo obj)
        {
            if (obj == null)
            {
                return;
            }
            this.ClickParterEvent?.Invoke(obj.ObjectId);
        }
 
        /// <summary>
        /// 显示构件
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task ShowComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.ShowComponents(elementIds);
        }
 
        /// <summary>
        /// 隐藏构件
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task HideComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.HideComponents(elementIds);
        }
 
        /// <summary>
        /// 显示所有构件
        /// </summary>
        /// <returns></returns>
        public async Task ShowAllComponents()
        {
            await this.bimfaceInterop3dContainer1.ShowAllComponents();
        }
 
        /// <summary>
        /// 半透明构件
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task TranslucentComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.TranslucentComponents(elementIds);
        }
 
        /// <summary>
        /// 取消构件半透明
        /// </summary>
        /// <param name="elementIds">构件id列表</param>
        /// <returns></returns>
        public async Task OpaqueComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.OpaqueComponents(elementIds);
        }
 
    }
}