duheng
2024-12-24 038b668a0a4dc1568e753008ff549a870166723c
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/17-compressor/AssetsCompressorSingleMatchingCtrl.cs
@@ -1,4 +1,6 @@
using DevExpress.XtraEditors;
using DevExpress.XtraBars.Ribbon.Drawing;
using DevExpress.XtraEditors;
using DevExpress.XtraMap;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -18,14 +20,29 @@
            InitializeComponent();
            this.layoutControl1.SetupLayoutControl();
            this.gridView1.SetLimitView();
            this.gridView1.RegistCustomDrawCell();
            this.gridView1.RegistCustomDrawCell(Color.BurlyWood, Color.White);
            this.generalSearchCtrl1.SearchEvent += Search;
            this.generalSearchCtrl1.ClearEvent += Clear;
            this.phartDiagramRelationGridViewCtrl1.SelectDataEvent += SelectData;
        }
        public List<AssetsCompressorSingleMatchingViewModel> _allList = null;//所有列表
        private List<AssetsCompressorSingleMatchingViewModel> _allBindingList = null;//所有绑定列表
        private AssetsCompressorMainVmo _selected = null;//当前选中
        private AssetsCompressorSingleMatchingViewModel _row;
        private CompressorMatchingViewModel _viewModel;
        public class CompressorMatchingViewModel
        {
            public CompressorMatchingViewModel()
            {
            }
            public AssetsCompressorMainVmo Vmo { get; set; }
            public string MatchingCurveDbId { get; set; }
            public List<HydroCurvePointViewModel> MatchingCurve { get; set; }
        }
        /// <summary>
        /// 绑定数据
@@ -41,19 +58,17 @@
                _selected = item;
            }
            Search();
            await Task.Delay(300);
            if (_selected != null)
            {
                if (_allBindingList != null && _allBindingList.Count > 0)
                {
                    await Task.Run(() =>
                     {
                         var dataSourceIndex = _allBindingList.FindIndex(x => x.Vmo == _selected);
                         if (dataSourceIndex >= 0)
                         {
                             var rowIndex = this.gridView1.GetRowHandle(dataSourceIndex);
                             this.gridView1.FocusedRowHandle = rowIndex;
                         }
                     });
                    var dataSourceIndex = _allBindingList.FindIndex(x => x.Vmo == _selected);
                    if (dataSourceIndex >= 0)
                    {
                        var rowIndex = this.gridView1.GetRowHandle(dataSourceIndex);
                        this.gridView1.FocusedRowHandle = rowIndex;
                    }
                }
            }
        }
@@ -99,28 +114,47 @@
        /// <summary>
        /// 获取
        /// </summary>
        public AssetsCompressorMainVmo Get()
        public CompressorMatchingViewModel Get()
        {
            var vm = this.gridView1.GetFocusedRow() as AssetsCompressorSingleMatchingViewModel;
            if (vm == null)
            {
                return default;
            }
            return vm.Vmo;
            /*            var vm = this.gridView1.GetFocusedRow() as AssetsCompressorSingleMatchingViewModel;
                        if (vm == null)
                        {
                            return default;
                        }
                        _viewModel.Vmo = vm;
            */
            return _viewModel;
        }
        //聚焦改变
        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            _viewModel = new CompressorMatchingViewModel();
            var row = this.gridView1.GetFocusedRow() as AssetsCompressorSingleMatchingViewModel;
            if (row == null)
            {
                return;
            }
            _row = row;
            _viewModel.Vmo = row.Vmo;
            this.phartDiagramRelationGridViewCtrl1.SetBindingData(HStation.Assets.DataType.CompressorMain, row.Vmo.ID);
        }
        //曲线数据关联变化
        private void SelectData(List<PhartDiagramRelationExtensionsVmo> list)
        {
            if (list != null && list.Count > 0)
            {
                var def = list.OrderByDescending(x => x.Importance).First();
                _viewModel.MatchingCurveDbId = def.ID.ToString();
                var curve = def.Diagram.GraphList[0].GetFeatPointList();
                _viewModel.MatchingCurve = new List<HydroCurvePointViewModel>();
                foreach (var item in curve)
                {
                    _viewModel.MatchingCurve.Add(new HydroCurvePointViewModel(item.X, item.Y));
                }
            }
        }
    }
}
}