namespace HStation.WinFrmUI { public partial class XhsProjectQ3dViewPage : DocumentPage { public XhsProjectQ3dViewPage() { InitializeComponent(); this.PageTitle.Caption = "水力视图"; this.PageTitle.HeaderSvgImage = Yw.WinFrmUI.HydroMainSvgImageHelper.Hydro; this.PageTitle.SvgImageSize = new Size(24, 24); } private XhsProjectVmo _project = null;//项目 private XhsProjectSiteVmo _projectSite = null;//项目站 /// /// 绑定数据 /// public async Task SetBindingData(long projectId) { var project = await BLLFactory.Instance.GetByID(projectId); if (project == null) { return; } SetBindingData(project); } /// /// 绑定数据 /// public void SetBindingData(XhsProjectVmo project) { if (project == null) { return; } _project = project; this.PageTitle.Caption = $"{_project.Name}\r\n水力视图"; } /// /// 绑定数据 /// public void SetBindingData(XhsProjectExtensionsVmo project) { if (project == null) { return; } _project = project; _projectSite = project.SiteList.FirstOrDefault(); this.PageTitle.Caption = $"{_project.Name}\r\n水力视图"; } /// /// 初始化数据源 /// public override void InitialDataSource() { base.InitialDataSource(); InitialData(); } //初始化数据 private async void InitialData() { var drawer = GetDrawer(); this.Controls.Clear(); this.Controls.Add(drawer); if (_project == null) { return; } if (_projectSite == null) { _projectSite = await BLLFactory.Instance.GetDefaultByProjectID(_project.ID); } var relation = await BLLFactory.Instance .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, Yw.Hydro.Purpose.Simulation); if (relation == null) { return; } var hydroInfo = await BLLFactory.Instance.GetByID(relation.ModelID); if (hydroInfo == null) { return; } var network = hydroInfo.ToNetworkViewModel(); drawer.SetData(network); } #region 绘制容器 //获取绘制器 private Yw.WinFrmUI.Q3d.Drawer GetDrawer() { if (_drawer == null) { _drawer = new Yw.WinFrmUI.Q3d.Drawer(); _drawer.Dock = DockStyle.Fill; } return _drawer; } //Q3d绘制器 private Yw.WinFrmUI.Q3d.Drawer _drawer = null; #endregion } }