duheng
2024-09-23 6f8c6a3b2277b92a24319f672811da113861cfc1
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-AutoMatching/02-AsstesFormCtrl/ValveMatchingCtrl.cs
@@ -9,5 +9,61 @@
            this.gridView1.OptionsView.ShowDetailButtons = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
        }
        private List<ValveFormViewModel> _allBindingList = new List<ValveFormViewModel>();
        /// <summary>
        /// 点击事件
        /// </summary>
        public event Action<string> RowClickEvent;
        public void SetBindingData(List<ValveMatchingViewModel> valveMatchingViewModels)
        {
            if (valveMatchingViewModels != null)
            {
                foreach (var item in valveMatchingViewModels)
                {
                    _allBindingList.Add(new ValveFormViewModel(item));
                }
                this.valveFormViewModelBindingSource.DataSource = _allBindingList;
            }
        }
        public List<ValveMatchingViewModel> SetMatching(List<ValveMatchingViewModel> inputs, List<ValveMainVmo> alllist)
        {
            if (inputs == null)
                return null;
            var finishList = new List<ValveMatchingViewModel>();
            foreach (var item in inputs)
            {
                var result = AssetsMatchingHelper.MatchingValves(item, alllist);
                if (result != null)
                {
                    finishList.Add(result);
                }
                else
                {
                    finishList.Add(item);
                }
            }
            _allBindingList.Clear();
            foreach (var item in finishList)
            {
                _allBindingList.Add(new ValveFormViewModel(item));
            }
            this.valveFormViewModelBindingSource.ResetBindings(false);
            return finishList;
        }
        //行点击事件
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            var row = this.gridView1.GetCurrentViewModel(_allBindingList);
            if (row == null)
            {
                return;
            }
            this.RowClickEvent?.Invoke(row.Code);
        }
    }
}