duheng
2024-09-23 a1730187c168a5d0bd54eb27c1083eb1cc98be96
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-AutoMatching/02-AsstesFormCtrl/ThreeLinkMatchingCtrl.cs
@@ -1,4 +1,6 @@
namespace HStation.WinFrmUI
using DevExpress.Dialogs.Core.View;
namespace HStation.WinFrmUI
{
    public partial class ThreeLinkMatchingCtrl : DevExpress.XtraEditors.XtraUserControl
    {
@@ -9,5 +11,61 @@
            this.gridView1.OptionsView.ShowDetailButtons = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
        }
        private List<ThreeLinkFormViewModel> _allBindingList = new List<ThreeLinkFormViewModel>();
        /// <summary>
        /// 点击事件
        /// </summary>
        public event Action<string> RowClickEvent;
        public void SetBindingData(List<ThreeLinkMatchingViewModel> threeLinkMatchingViewModels)
        {
            if (threeLinkMatchingViewModels != null)
            {
                foreach (var item in threeLinkMatchingViewModels)
                {
                    _allBindingList.Add(new ThreeLinkFormViewModel(item));
                }
                this.threeLinkFormViewModelBindingSource.DataSource = _allBindingList;
            }
        }
        public List<ThreeLinkMatchingViewModel> SetMatching(List<ThreeLinkMatchingViewModel> inputs, List<AdaptingManageVmo> alllist)
        {
            if (inputs == null || inputs.Count == 0)
                return null;
            var resultList = new List<ThreeLinkMatchingViewModel>();
            foreach (var item in inputs)
            {
                var result = AssetsMatchingHelper.MatchingThreeLink(item, alllist);
                if (result != null)
                {
                    resultList.Add(result);
                }
                else
                {
                    resultList.Add(item);
                }
            }
            _allBindingList.Clear();
            foreach (var item in resultList)
            {
                _allBindingList.Add(new ThreeLinkFormViewModel(item));
            }
            this.threeLinkFormViewModelBindingSource.ResetBindings(false);
            return resultList;
        }
        //行点击事件
        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);
        }
    }
}