lixiaojun
2025-02-25 83ef19757135f7748c65dbf73abdf1bbd87fae72
WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/11-cooling/HydroCoolingListCtrl.cs
@@ -1,4 +1,6 @@
using Yw.Model;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraPrinting;
using Yw.Model;
namespace Yw.WinFrmUI
{
@@ -40,34 +42,54 @@
            get { return _allList != null && _allList.Count > 0; }
        }
        //所有列表
        private List<HydroCoolingViewModel> _allList = null;
        //所有绑定列表
        private List<HydroCoolingViewModel> _allBindingList = null;
        private List<HydroCoolingViewModel> _allList = null;//所有列表
        private List<HydroCoolingViewModel> _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
            )
        {
            SetBindingData(hydroInfo, allCalcuResultVisualDict: null);
            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);
            SetBindingData(hydroInfo, allCalcuResultVisualDict, changeHelper, propStatusHelper);
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict)
        public void SetBindingData
            (
                HydroModelInfo hydroInfo,
                Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            _allList = new List<HydroCoolingViewModel>();
            _changeHelper = changeHelper;
            _propStatusHelper = propStatusHelper;
            if (hydroInfo != null && hydroInfo.Coolings != null && hydroInfo.Coolings.Count > 0)
            {
                foreach (var visual in hydroInfo.Coolings)
@@ -87,9 +109,16 @@
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<HydroVisualViewModel> allVisualViewModelList)
        public void SetBindingData
            (
                List<HydroVisualViewModel> allVisualViewModelList,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            _allList = new List<HydroCoolingViewModel>();
            _changeHelper = changeHelper;
            _propStatusHelper = propStatusHelper;
            allVisualViewModelList?.ForEach(x =>
            {
                if (x.Vmo.Catalog == Yw.Hydro.ParterCatalog.Cooling)
@@ -244,9 +273,13 @@
                return;
            }
            var dlg = new SetHydroCoolingDlg();
            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.hydroCoolingViewModelBindingSource.ResetBindings(false);
                var allVisualViewModelList = _allBindingList.Select(x => x as HydroVisualViewModel).ToList();
@@ -268,9 +301,13 @@
            if (e.Column == this.colSet)
            {
                var dlg = new SetHydroCoolingDlg();
                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 });
@@ -293,6 +330,7 @@
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            this.colDbLocked.Visible = false;
            this.colBeginGroup.Visible = false;
            this.colName.Visible = true;
            this.colCode.Visible = true;
            this.colModelType.Visible = true;
@@ -301,7 +339,6 @@
            this.colCoefficient.Visible = true;
            this.colLowerLimit.Visible = true;
            this.colElev.Visible = false;
            this.colMinorLoss.Visible = false;
            this.colHasDb.Visible = false;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
@@ -317,6 +354,7 @@
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            this.colDbLocked.Visible = true;
            this.colBeginGroup.Visible = true;
            this.colName.Visible = true;
            this.colCode.Visible = true;
            this.colModelType.Visible = true;
@@ -325,7 +363,6 @@
            this.colCoefficient.Visible = true;
            this.colLowerLimit.Visible = true;
            this.colElev.Visible = true;
            this.colMinorLoss.Visible = true;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
@@ -341,6 +378,7 @@
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            this.colDbLocked.Visible = true;
            this.colBeginGroup.Visible = true;
            this.colCode.Visible = true;
            this.colName.Visible = true;
            this.colModelType.Visible = true;
@@ -349,7 +387,6 @@
            this.colCoefficient.Visible = true;
            this.colLowerLimit.Visible = true;
            this.colElev.Visible = true;
            this.colMinorLoss.Visible = true;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
@@ -365,6 +402,7 @@
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            this.colDbLocked.Visible = true;
            this.colBeginGroup.Visible = true;
            this.colName.Visible = true;
            this.colCode.Visible = true;
            this.colModelType.Visible = true;
@@ -373,7 +411,6 @@
            this.colCoefficient.Visible = true;
            this.colLowerLimit.Visible = true;
            this.colElev.Visible = true;
            this.colMinorLoss.Visible = true;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
@@ -389,6 +426,7 @@
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            this.colDbLocked.Visible = true;
            this.colBeginGroup.Visible = true;
            this.colName.Visible = true;
            this.colCode.Visible = true;
            this.colModelType.Visible = true;
@@ -397,7 +435,6 @@
            this.colCoefficient.Visible = true;
            this.colLowerLimit.Visible = true;
            this.colElev.Visible = true;
            this.colMinorLoss.Visible = true;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
@@ -405,5 +442,34 @@
            this.colCalcuQ.Visible = true;
            this.colSet.Visible = false;
        }
        /// <summary>
        ///
        /// </summary>
        public GridView GetGridView()
        {
            return this.gridView1;
        }
        /// <summary>
        ///
        /// </summary>
        public void ExportToXlsx()
        {
            var filePath = FileDialogHelper.SaveFile("导出Excel文件", "Excel文件|*.xlsx");
            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }
            var options = new XlsxExportOptions
            {
                ExportMode = XlsxExportMode.SingleFile, // 导出模式
                ShowGridLines = true, // 显示网格线
                TextExportMode = TextExportMode.Value, // 导出文本模式
                SheetName = "冷却塔" // 工作表名称
            };
            this.gridView1.ExportToXlsx(filePath, options);
        }
    }
}