lixiaojun
2024-08-26 a990956c484b788bde0f7eae0202d8303d76a106
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
namespace HStation.WinFrmUI
{
    public partial class XhsProjectAssetsBimfaceCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public XhsProjectAssetsBimfaceCtrl()
        {
            InitializeComponent();
            this.bimfaceInterop3dContainer1.LoadCompletedEvent += BimfaceInterop3dContainer1_LoadCompletedEvent;
            this.bimfaceInterop3dContainer1.ClickInEvent += BimfaceInterop3dContainer1_ClickInEvent;
        }
 
        public event Action<string> ClickParterEvent;
 
        private long _projectId;//项目id
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public async void SetBindingData(long projectId)
        {
            _projectId = projectId;
            await this.bimfaceInterop3dContainer1.InitialContainer();
        }
 
        //页面加载完成后触发
        private async void BimfaceInterop3dContainer1_LoadCompletedEvent()
        {
            var projectSite = await new BLL.XhsProjectSiteStd().GetDefaultByProjectID(_projectId);
            if (projectSite == null)
            {
                return;
            }
 
            var relation = await new Yw.BLL.BimfaceFileRelationStd()
                .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, projectSite.ID, Yw.Bimface.Purpose.Simulation);
            if (relation == null)
            {
                return;
            }
 
            var bimfaceFile = await new Yw.BLL.BimfaceFileStd().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);
        }
 
        public async Task HideComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.HideComponents(elementIds);
        }
 
        public async Task ShowComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.ShowComponents(elementIds);
        }
 
        public async Task ShowAllComponents()
        {
            await this.bimfaceInterop3dContainer1.ShowAllComponents();
        }
 
        public async Task TranslucentComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.TranslucentComponents(elementIds);
        }
 
        public async Task OpaqueComponents(List<string> elementIds)
        {
            await this.bimfaceInterop3dContainer1.OpaqueComponents(elementIds);
        }
 
    }
}