duheng
2024-12-24 038b668a0a4dc1568e753008ff549a870166723c
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/18-exchanger/AssetsExchangerSingleMatchingCtrl.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;
@@ -21,11 +23,26 @@
            this.gridView1.RegistCustomDrawCell(Color.BurlyWood, Color.White);
            this.generalSearchCtrl1.SearchEvent += Search;
            this.generalSearchCtrl1.ClearEvent += Clear;
            this.phartDiagramRelationGridViewCtrl1.SelectDataEvent += SelectData;
        }
        public List<AssetsExchangerSingleMatchingViewModel> _allList = null;//所有列表
        private List<AssetsExchangerSingleMatchingViewModel> _allBindingList = null;//所有绑定列表
        private AssetsExchangerMainVmo _selected = null;//当前选中
        private AssetsExchangerSingleMatchingViewModel _row;
        private ExchangerMatchingViewModel _viewModel;
        public class ExchangerMatchingViewModel
        {
            public ExchangerMatchingViewModel()
            {
            }
            public AssetsExchangerMainVmo Vmo { get; set; }
            public string MatchingCurveDbId { get; set; }
            public List<HydroCurvePointViewModel> MatchingCurve { get; set; }
        }
        /// <summary>
        /// 绑定数据
@@ -97,25 +114,47 @@
        /// <summary>
        /// 获取
        /// </summary>
        public AssetsExchangerMainVmo Get()
        public ExchangerMatchingViewModel Get()
        {
            var vm = this.gridView1.GetFocusedRow() as AssetsExchangerSingleMatchingViewModel;
            if (vm == null)
            {
                return default;
            }
            return vm.Vmo;
            /*            var vm = this.gridView1.GetFocusedRow() as AssetsExchangerSingleMatchingViewModel;
                        if (vm == null)
                        {
                            return default;
                        }
                        _viewModel.Vmo = vm;
            */
            return _viewModel;
        }
        //聚焦改变
        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            _viewModel = new ExchangerMatchingViewModel();
            var row = this.gridView1.GetFocusedRow() as AssetsExchangerSingleMatchingViewModel;
            if (row == null)
            {
                return;
            }
            _row = row;
            _viewModel.Vmo = row.Vmo;
            this.phartDiagramRelationGridViewCtrl1.SetBindingData(HStation.Assets.DataType.ExchangerMain, 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));
                }
            }
        }
    }
}