lixiaojun
2024-12-05 f5cdfeae3594e3e6e1461300e93c266ce79c1a8a
WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/19-compressor/HydroCompressorListCtrl.cs
@@ -1,5 +1,4 @@
using DevExpress.XtraEditors;
using Yw.Model;
using Yw.Model;
namespace Yw.WinFrmUI
{
@@ -8,9 +7,12 @@
        public HydroCompressorListCtrl()
        {
            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>
@@ -31,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
@@ -60,16 +50,7 @@
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
        {
            _allList = new List<HydroCompressorViewModel>();
            if (hydroInfo != null && hydroInfo.Compressors != null && hydroInfo.Compressors.Count > 0)
            {
                foreach (var visual in hydroInfo.Compressors)
                {
                    var vm = new HydroCompressorViewModel(visual, hydroInfo);
                    _allList.Add(vm);
                }
            }
            Search();
            SetBindingData(hydroInfo, allCalcuResultVisualDict: null);
        }
        /// <summary>
@@ -77,13 +58,22 @@
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuResultList)
        {
            var allCalcuResultVisualDict = allCalcuResultList?.ToDictionary(x => x.Code);
            SetBindingData(hydroInfo, allCalcuResultVisualDict);
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict)
        {
            _allList = new List<HydroCompressorViewModel>();
            if (hydroInfo != null && hydroInfo.Compressors != null && hydroInfo.Compressors.Count > 0)
            if (hydroInfo != null && hydroInfo.Exchangers != null && hydroInfo.Exchangers.Count > 0)
            {
                foreach (var visual in hydroInfo.Compressors)
                {
                    var vm = new HydroCompressorViewModel(visual, hydroInfo);
                    var calcuResult = allCalcuResultList?.Find(x => x.Code == visual.Code);
                    var calcuResult = allCalcuResultVisualDict?.GetValue(visual.Code);
                    if (calcuResult != null)
                    {
                        vm.UpdateCalcuProperty(calcuResult);
@@ -102,7 +92,7 @@
            _allList = new List<HydroCompressorViewModel>();
            allVisualViewModelList?.ForEach(x =>
            {
                if (x.Catalog == HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Compressor))
                if (x.Vmo.Catalog == Yw.Hydro.ParterCatalog.Compressor)
                {
                    _allList.Add(x as HydroCompressorViewModel);
                }
@@ -182,13 +172,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);
@@ -258,24 +257,7 @@
            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 HydroCompressorViewModel;
@@ -374,9 +356,9 @@
        }
        /// <summary>
        /// 设置批量设置模式
        /// 设置批量模式
        /// </summary>
        public void SetBulkSetView()
        public void SetBulkView()
        {
            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            this.colDbLocked.Visible = true;
@@ -396,6 +378,27 @@
            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.colLinkStatus.Visible = true;
            this.colMaterial.Visible = true;
            this.colDiameter.Visible = true;
            this.colMinorLoss.Visible = true;
            this.colHasDb.Visible = true;
            this.colFlags.Visible = true;
            this.colDescription.Visible = true;
            this.colCalcuFlow.Visible = true;
            this.colCalcuVelocity.Visible = true;
            this.colCalcuHeadLoss.Visible = true;
            this.colSet.Visible = false;
        }
    }
}