lixiaojun
2025-01-13 1c30ee4068eb5dba3c6b9a4987b98034f2a622d0
WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/08-fourlink/HydroFourlinkListCtrl.cs
@@ -7,9 +7,12 @@
        public HydroFourlinkListCtrl()
        {
            InitializeComponent();
            this.layoutControl1.SetupLayoutControl();
            this.gridView1.SetNormalView(30);
            this.gridView1.RegistCustomDrawRowIndicator(40);
            this.layoutControl1.SetupLayoutControl();
            this.generalSearchAndSetCtrl1.SearchEvent += Search;
            this.generalSearchAndSetCtrl1.ClearEvent += Reset;
            this.generalSearchAndSetCtrl1.SetEvent += Set;
        }
        /// <summary>
@@ -30,18 +33,6 @@
        public event Action<List<HydroVisualViewModel>> HydroChangedViewEvent;
        /// <summary>
        /// 显示查询面板
        /// </summary>
        [Browsable(true)]
        [Description("显示查询面板")]
        [DefaultValue(true)]
        public bool ShowFindPanel
        {
            get { return this.gridView1.OptionsFind.AlwaysVisible; }
            set { this.gridView1.OptionsFind.AlwaysVisible = value; }
        }
        /// <summary>
        /// 是否拥有水力列表
        /// </summary>
        public bool HasHydroList
@@ -49,40 +40,60 @@
            get { return _allList != null && _allList.Count > 0; }
        }
        //所有列表
        private List<HydroFourlinkViewModel> _allList = null;
        //所有绑定列表
        private List<HydroFourlinkViewModel> _allBindingList = null;
        private List<HydroFourlinkViewModel> _allList = null;//所有列表
        private List<HydroFourlinkViewModel> _allBindingList = null;//所有绑定列表
        private HydroChangeHelper _changeHelper = null;//改变辅助类
        private HydroPropStatusHelper _propStatusHelper = null;//属性状态辅助类
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
        public void SetBindingData
            (
                Yw.Model.HydroModelInfo hydroInfo,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            _allList = new List<HydroFourlinkViewModel>();
            if (hydroInfo != null && hydroInfo.Fourlinks != null && hydroInfo.Fourlinks.Count > 0)
            {
                foreach (var visual in hydroInfo.Fourlinks)
                {
                    var vm = new HydroFourlinkViewModel(visual, hydroInfo);
                    _allList.Add(vm);
                }
            }
            Search();
            SetBindingData(hydroInfo, allCalcuResultVisualDict: null, changeHelper, propStatusHelper);
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuResultList)
        public void SetBindingData
            (
                Yw.Model.HydroModelInfo hydroInfo,
                List<HydroCalcuVisualResult> allCalcuResultList,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            var allCalcuResultVisualDict = allCalcuResultList?.ToDictionary(x => x.Code);
            SetBindingData(hydroInfo, allCalcuResultVisualDict, changeHelper, propStatusHelper);
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData
            (
                HydroModelInfo hydroInfo,
                Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            _allList = new List<HydroFourlinkViewModel>();
            _changeHelper = changeHelper;
            _propStatusHelper = propStatusHelper;
            if (hydroInfo != null && hydroInfo.Fourlinks != null && hydroInfo.Fourlinks.Count > 0)
            {
                foreach (var visual in hydroInfo.Fourlinks)
                {
                    var vm = new HydroFourlinkViewModel(visual, hydroInfo);
                    var calcuResult = allCalcuResultList?.Find(x => x.Code == visual.Code);
                    var calcuResult = allCalcuResultVisualDict?.GetValue(visual.Code);
                    if (calcuResult != null)
                    {
                        vm.UpdateCalcuProperty(calcuResult);
@@ -96,12 +107,19 @@
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<HydroVisualViewModel> allVisualViewModelList)
        public void SetBindingData
            (
                List<HydroVisualViewModel> allVisualViewModelList,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            _allList = new List<HydroFourlinkViewModel>();
            _changeHelper = changeHelper;
            _propStatusHelper = propStatusHelper;
            allVisualViewModelList?.ForEach(x =>
            {
                if (x.Catalog == HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Fourlink))
                if (x.Vmo.Catalog == Yw.Hydro.ParterCatalog.Fourlink)
                {
                    _allList.Add(x as HydroFourlinkViewModel);
                }
@@ -181,13 +199,22 @@
        /// </summary>
        public void UpdateCalcuProperty(List<HydroCalcuVisualResult> allCalcuResultList)
        {
            if (allCalcuResultList != null && allCalcuResultList.Count > 0)
            var allCalcuResultVisualDict = allCalcuResultList?.ToDictionary(x => x.Code);
            UpdateCalcuProperty(allCalcuResultVisualDict);
        }
        /// <summary>
        /// 更新计算属性
        /// </summary>
        public void UpdateCalcuProperty(Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict)
        {
            if (allCalcuResultVisualDict != null && allCalcuResultVisualDict.Count > 0)
            {
                if (_allList != null && _allList.Count > 0)
                {
                    foreach (var visual in _allList)
                    {
                        var calcuResult = allCalcuResultList.Find(x => x.Code == visual.Code);
                        var calcuResult = allCalcuResultVisualDict.GetValue(visual.Code);
                        if (calcuResult != null)
                        {
                            visual.UpdateCalcuProperty(calcuResult);
@@ -244,9 +271,13 @@
                return;
            }
            var dlg = new SetHydroFourlinkDlg();
            dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList());
            dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList(), _changeHelper, _propStatusHelper);
            dlg.ReloadDataEvent += (list) =>
            {
                if (list == null || list.Count < 1)
                {
                    return;
                }
                _allBindingList.ForEach(x => x.UpdateProperty());
                this.hydroFourlinkViewModelBindingSource.ResetBindings(false);
                var allVisualViewModelList = _allBindingList.Select(x => x as HydroVisualViewModel).ToList();
@@ -257,24 +288,8 @@
            dlg.ShowDialog();
        }
        //查询
        private void btnSearch_Click(object sender, EventArgs e)
        {
            Search();
        }
        //重置
        private void btnReset_Click(object sender, EventArgs e)
        {
            Reset();
        }
        //设置
        private void btnSet_Click(object sender, EventArgs e)
        {
            Set();
        }
        //行单元点击事件
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            var row = this.gridView1.GetRow(e.RowHandle) as HydroFourlinkViewModel;
@@ -286,9 +301,13 @@
            if (e.Column == this.colSet)
            {
                var dlg = new SetHydroFourlinkDlg();
                dlg.SetBindingData(row.Vmo);
                dlg.SetBindingData(row.Vmo, _changeHelper, _propStatusHelper);
                dlg.ReloadDataEvent += (list) =>
                {
                    if (list == null || list.Count < 1)
                    {
                        return;
                    }
                    row.UpdateProperty();
                    this.gridView1.RefreshRow(e.RowHandle);
                    this.HydroChangedViewEvent?.Invoke(new List<HydroVisualViewModel>() { row });
@@ -319,6 +338,7 @@
            this.colMinorLoss.Visible = false;
            this.colCalcuPress.Visible = false;
            this.colCalcuHead.Visible = false;
            this.colCalcuDemand.Visible = false;
            this.colHasDb.Visible = false;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
@@ -341,6 +361,7 @@
            this.colMinorLoss.Visible = true;
            this.colCalcuPress.Visible = false;
            this.colCalcuHead.Visible = false;
            this.colCalcuDemand.Visible = false;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
@@ -363,6 +384,7 @@
            this.colMinorLoss.Visible = true;
            this.colCalcuPress.Visible = true;
            this.colCalcuHead.Visible = true;
            this.colCalcuDemand.Visible = true;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
@@ -372,7 +394,7 @@
        /// <summary>
        /// 设置批量设置模式
        /// </summary>
        public void SetBulkSetView()
        public void SetBulkView()
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            this.colDbLocked.Visible = true;
@@ -385,12 +407,35 @@
            this.colMinorLoss.Visible = true;
            this.colCalcuPress.Visible = false;
            this.colCalcuHead.Visible = false;
            this.colCalcuDemand.Visible = false;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
            this.colSet.Visible = true;
        }
        /// <summary>
        /// 设置结果模式
        /// </summary>
        public void SetResultView()
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            this.colDbLocked.Visible = true;
            this.colName.Visible = true;
            this.colCode.Visible = true;
            this.colModelType.Visible = true;
            this.colMaterial.Visible = true;
            this.colCaliber.Visible = true;
            this.colElev.Visible = true;
            this.colMinorLoss.Visible = true;
            this.colCalcuPress.Visible = true;
            this.colCalcuHead.Visible = true;
            this.colCalcuDemand.Visible = true;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
            this.colSet.Visible = true;
        }
    }