yangyin
2024-08-21 04e1d0a290ff76bf623bd9de075b350b8b77ba25
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
namespace HStation.WinFrmUI
{
    public partial class XhsSchemeMultiMgrPage_Bak : DocumentPage
    {
        public XhsSchemeMultiMgrPage_Bak()
        {
            InitializeComponent();
            this.PageTitle.Caption = "项目方案";
            this.PageTitle.HeaderSvgImage = this.svgImg32[0];
            this.PageTitle.SvgImageSize = new Size(24, 24);
        }
 
        private XhsProjectStdDto _project = null;
        private Yw.Model.HydroModelInfo _hydroInfo = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="projectId">项目id</param>
        public async Task SetBindingData(long projectId)
        {
            _project = await new BLL.XhsProjectStd().GetByID(projectId);
            this.PageTitle.Caption = $"{_project?.Name}\r\n方案管理";
            var projectSite = await new BLL.XhsProjectSiteStd().GetDefaultByProjectID(_project.ID);
            if (projectSite == null)
            {
                return;
            }
 
            var relation = await new Yw.BLL.HydroModelRelation()
                .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, projectSite.ID, Yw.Bimface.Purpose.Simulation);
            if (relation == null)
            {
                return;
            }
 
            _hydroInfo = await new Yw.BLL.HydroModelInfo().GetByID(relation.ModelID);
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="project">项目</param>
        public void SetBindingData(HStation.Dto.XhsProjectStdDto project)
        {
            _project = project;
            this.PageTitle.Caption = $"{_project?.Name}\n方案管理";
        }
 
        /// <summary>
        /// 初始化数据源
        /// </summary>
        public override async void InitialDataSource()
        {
            base.InitialDataSource();
            this.bimfaceInterop3dContainer1.LoadCompletedEvent += BimfaceInterop3dContainer1_LoadCompletedEvent;
            this.bimfaceInterop3dContainer1.ClickInEvent += BimfaceInterop3dContainer1_ClickInEvent;
            await this.bimfaceInterop3dContainer1.InitialContainer();
        }
 
        /// <summary>
        /// 页面加载完成后触发
        /// </summary>
        private async void BimfaceInterop3dContainer1_LoadCompletedEvent()
        {
            if (_project == null)
            {
                return;
            }
 
            var projectSite = await new BLL.XhsProjectSiteStd().GetDefaultByProjectID(_project.ID);
            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);
 
        }
 
        /// <summary>
        /// 点击事件
        /// </summary>
        private void BimfaceInterop3dContainer1_ClickInEvent(Yw.WinFrmUI.Bimface.ClickIn3dInfo obj)
        {
            //if (_hydroInfo == null)
            //{
            //    return;
            //}
            //var allParterList = _hydroInfo.GetAllParters();
            //var parter = allParterList.Find(x => x.Code == obj.ObjectId);
            //if (parter != null)
            //{
            //    var vm = HydroParterPropertyViewModelBuilder.CreateViewModel(parter, allParterList);
            //    this.hydroParterPropertyCtrl1.SelectedObject = vm;
            //}
        }
    }
}