ningshuxia
2025-03-13 982cde7e9372dc218f23b204265d8e54f7e9ce4f
WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/16-translation/HydroTranslationListCtrl.cs
@@ -1,4 +1,6 @@
using Yw.Model;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraPrinting;
using Yw.Model;
namespace Yw.WinFrmUI
{
@@ -31,10 +33,6 @@
        /// 水力改变视图事件
        /// </summary>
        public event Action<List<HydroVisualViewModel>> HydroChangedViewEvent;
        /// <summary>
        /// 构件改变事件
        /// </summary>
        public event Action<HydroParterInfo, eChangeType> ParterChangedEvent;
        /// <summary>
        /// 是否拥有水力列表
@@ -44,34 +42,54 @@
            get { return _allList != null && _allList.Count > 0; }
        }
        //所有列表
        private List<HydroTranslationViewModel> _allList = null;
        //所有绑定列表
        private List<HydroTranslationViewModel> _allBindingList = null;
        private List<HydroTranslationViewModel> _allList = null;//所有列表
        private List<HydroTranslationViewModel> _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(Yw.Model.HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict)
        public void SetBindingData
            (
                HydroModelInfo hydroInfo,
                Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            _allList = new List<HydroTranslationViewModel>();
            _changeHelper = changeHelper;
            _propStatusHelper = propStatusHelper;
            if (hydroInfo != null && hydroInfo.Translations != null && hydroInfo.Translations.Count > 0)
            {
                foreach (var visual in hydroInfo.Translations)
@@ -91,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<HydroTranslationViewModel>();
            _changeHelper = changeHelper;
            _propStatusHelper = propStatusHelper;
            allVisualViewModelList?.ForEach(x =>
            {
                if (x.Vmo.Catalog == Yw.Hydro.ParterCatalog.Translation)
@@ -209,18 +234,19 @@
            {
                return;
            }
            var name = this.txtName.Text.Trim();
            var code = this.txtCode.Text.Trim();
            var modelType = this.txtModelType.Text.Trim();
            _allBindingList = _allList;
            var name = this.txtName.Text.Trim();
            if (!string.IsNullOrEmpty(name))
            {
                _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains(name)).ToList();
            }
            var code = this.txtCode.Text.Trim();
            if (!string.IsNullOrEmpty(code))
            {
                _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.Code) && x.Code.Contains(code)).ToList();
            }
            var modelType = this.txtModelType.Text.Trim();
            if (!string.IsNullOrEmpty(modelType))
            {
                _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.ModelType) && x.ModelType.Contains(modelType)).ToList();
@@ -248,7 +274,7 @@
                return;
            }
            var dlg = new SetHydroTranslationDlg();
            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)
@@ -261,7 +287,6 @@
                this.HydroChangedViewEvent?.Invoke(allVisualViewModelList);
                var allVisualInfoList = allVisualViewModelList.Select(x => x.Vmo).ToList();
                this.HydroChangedInfoEvent?.Invoke(allVisualInfoList);
                list.ForEach(x => this.ParterChangedEvent?.Invoke(x, eChangeType.Update));
            };
            dlg.ShowDialog();
        }
@@ -278,7 +303,7 @@
            if (e.Column == this.colSet)
            {
                var dlg = new SetHydroTranslationDlg();
                dlg.SetBindingData(row.Vmo);
                dlg.SetBindingData(row.Vmo, _changeHelper, _propStatusHelper);
                dlg.ReloadDataEvent += (list) =>
                {
                    if (list == null || list.Count < 1)
@@ -289,7 +314,6 @@
                    this.gridView1.RefreshRow(e.RowHandle);
                    this.HydroChangedViewEvent?.Invoke(new List<HydroVisualViewModel>() { row });
                    this.HydroChangedInfoEvent?.Invoke(new List<HydroVisualInfo>() { row.Vmo });
                    this.ParterChangedEvent?.Invoke(row.Vmo, eChangeType.Update);
                };
                dlg.ShowDialog();
            }
@@ -307,9 +331,12 @@
        {
            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;
            this.colTranslationType.Visible = true;
            this.colElev.Visible = false;
            this.colMaterial.Visible = true;
            this.colStartDiameter.Visible = true;
            this.colEndDiameter.Visible = true;
@@ -331,9 +358,12 @@
        {
            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;
            this.colTranslationType.Visible = true;
            this.colElev.Visible = true;
            this.colMaterial.Visible = true;
            this.colStartDiameter.Visible = true;
            this.colEndDiameter.Visible = true;
@@ -355,9 +385,12 @@
        {
            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;
            this.colTranslationType.Visible = true;
            this.colElev.Visible = true;
            this.colMaterial.Visible = true;
            this.colStartDiameter.Visible = true;
            this.colEndDiameter.Visible = true;
@@ -379,9 +412,12 @@
        {
            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;
            this.colTranslationType.Visible = true;
            this.colElev.Visible = true;
            this.colMaterial.Visible = true;
            this.colStartDiameter.Visible = true;
            this.colEndDiameter.Visible = true;
@@ -403,9 +439,12 @@
        {
            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;
            this.colTranslationType.Visible = true;
            this.colElev.Visible = true;
            this.colMaterial.Visible = true;
            this.colStartDiameter.Visible = true;
            this.colEndDiameter.Visible = true;
@@ -420,6 +459,34 @@
            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);
        }
    }
}