duheng
2024-12-05 b26ae60e85d4a03a2426e6607e7afe89e1c10a5f
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/AddXhsSchemeDlg.cs
@@ -41,6 +41,11 @@
        }
        /// <summary>
        ///
        /// </summary>
        public event Action<HStation.Vmo.XhsSchemeVmo> ReloadDataEvent;
        private HStation.Vmo.XhsProjectVmo _project = null;//项目
        private HStation.Vmo.XhsProjectSiteVmo _project_site = null;//项目站
@@ -49,6 +54,30 @@
        private Yw.Model.HydroParterInfo _selected_parter = null; //选择构件
        private List<SetSchemeParterRecord> _set_record_list = null;
        #region Initial
        //初始化文件格式
        private void InitialSchemeType()
        {
            this.imgCmbSchemeType.Properties.BeginUpdate();
            this.imgCmbSchemeType.Properties.Items.Clear();
            this.imgCmbSchemeType.Properties.Items.AddEnum(typeof(HStation.Xhs.eSchemeType), false);
            this.imgCmbSchemeType.EditValue = eSchemeType.Common;
            this.imgCmbSchemeType.Properties.EndUpdate();
        }
        //初始化标签
        private async Task InitialFlags()
        {
            var allFlagList = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(HStation.Xhs.DataType.XhsScheme);
            var allFlagNameList = allFlagList?.Select(x => x.Name).ToList();
            this.setFlagsEditCtrl1.SetBindingData(allFlagNameList, null);
        }
        #endregion
        #region SetBindingData
        /// <summary>
        /// 绑定数据
@@ -90,23 +119,6 @@
            await InitialFlags();
        }
        //初始化文件格式
        private void InitialSchemeType()
        {
            this.imgCmbSchemeType.Properties.BeginUpdate();
            this.imgCmbSchemeType.Properties.Items.Clear();
            this.imgCmbSchemeType.Properties.Items.AddEnum(typeof(HStation.Xhs.eSchemeType), false);
            this.imgCmbSchemeType.EditValue = eSchemeType.Common;
            this.imgCmbSchemeType.Properties.EndUpdate();
        }
        //初始化标签
        private async Task InitialFlags()
        {
            var allFlagList = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(HStation.Xhs.DataType.XhsScheme);
            var allFlagNameList = allFlagList?.Select(x => x.Name).ToList();
            this.setFlagsEditCtrl1.SetBindingData(allFlagNameList, null);
        }
        private void SetBindingData(List<SetSchemeParterRecord> set_record_list = null)
        {
            _hydro_info = _hydro_info_init.Adapt<Yw.Model.HydroModelInfo, Yw.Model.HydroModelInfo>();
@@ -147,26 +159,8 @@
        }
        //按钮
        private void buttonEdit_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (e.Button.Tag is not string tag)
            {
                return;
            }
            switch (tag)
            {
                case "showhide":
                    {
                        _show_hidden = !_show_hidden;
                        FastShowHidden(_show_hidden);
                    }
                    break;
                default:
                    break;
            }
        }
        #endregion
        #region Bimface
@@ -180,7 +174,7 @@
            {
                _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl();
                _bimfaceCtrl.Dock = DockStyle.Fill;
                await _bimfaceCtrl.InitialData(_project, _project_site, () => _hydro_info);
                await _bimfaceCtrl.InitialData(_project, _project_site);
                _bimfaceCtrl.LoadCompletedEvent += () =>
                {
                    //view加载完成事件
@@ -215,7 +209,16 @@
        #endregion
        #region Menu
        #region FastShowHidden
        //一键显隐
        private void barBtnFastShowHidden_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _show_hidden = !_show_hidden;
            FastShowHidden(_show_hidden);
        }
        private bool _show_hidden = false;
        private async void FastShowHidden(bool visible)
@@ -238,30 +241,9 @@
        #endregion
        #region GridView
        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            var row = this.gridView1.GetRow(e.FocusedRowHandle) as SetSchemeParterRecord;
            this.setSchemeParterRecordItemBindingSource.DataSource = row?.Items;
            this.setSchemeParterRecordItemBindingSource.ResetBindings(false);
        }
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            if (e.Column == this.colDelete)
            {
                var row = this.gridView1.GetRow(e.RowHandle) as SetSchemeParterRecord;
                _set_record_list.Remove(row);
                this.setSchemeParterRecordBindingSource.ResetBindings(false);
                SetBindingData(_set_record_list);
            }
        }
        #endregion
        #region Save
        private bool Verify()
        {
@@ -329,6 +311,9 @@
                    XtraMessageBox.Show("模型依赖创建失败!");
                    return;
                }
                var scheme = await BLLFactory<HStation.BLL.XhsScheme>.Instance.GetByID(xhs_scheme_id);
                this.ReloadDataEvent?.Invoke(scheme);
            }
            TipFormHelper.Show(eTipStatus.Succeed, "创建成功!");
@@ -336,6 +321,32 @@
        }
        #endregion
        #region GridView
        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            var row = this.gridView1.GetRow(e.FocusedRowHandle) as SetSchemeParterRecord;
            this.setSchemeParterRecordItemBindingSource.DataSource = row?.Items;
            this.setSchemeParterRecordItemBindingSource.ResetBindings(false);
        }
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            if (e.Column == this.colDelete)
            {
                var row = this.gridView1.GetRow(e.RowHandle) as SetSchemeParterRecord;
                _set_record_list.Remove(row);
                this.setSchemeParterRecordBindingSource.ResetBindings(false);
                SetBindingData(_set_record_list);
            }
        }
        #endregion
    }
}