namespace HStation.WinFrmUI { public partial class DeleteVariableSpeedDlg : DevExpress.XtraEditors.XtraForm { public DeleteVariableSpeedDlg() { InitializeComponent(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; this.layoutControl1.SetupLayoutControl(); this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent; this.gridView2.SetNormalView(); } /// /// /// public event Func, bool> ReloadDataEvent; private class CurrentViewModel { public double Hz { get; set; } public double N { get; set; } } private List _hz_list = null; private List _delete_id_list = null; /// /// /// public void SetBindingData(List<(double Hz, double N)> list) { _hz_list = new List(); ; _delete_id_list = new(); if (list == null || !list.Any()) return; list = list.DistinctBy(x => x.Hz).ToList(); _hz_list = list.OrderByDescending(x => x.Hz).Select(x => new CurrentViewModel() { Hz = x.Hz, N = x.N, }).ToList(); this.gridControl2.DataSource = _hz_list; this.gridControl2.RefreshDataSource(); } //删除 private void gridView2_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { if (_hz_list == null || _hz_list.Count < 1) return; if (e.Column == this.colDelete) { var item = _hz_list.ElementAt(e.RowHandle); _delete_id_list.Add(item.Hz); _hz_list.RemoveAt(e.RowHandle); this.gridControl2.RefreshDataSource(); } } //验证 private bool Valid() { this.dxErrorProvider1.ClearErrors(); return true; } //确定 private void GeneralOkAndCancelCtrl1_OkEvent() { if (_delete_id_list == null || !_delete_id_list.Any()) { return; } if (!Valid()) { return; } if (this.ReloadDataEvent == null) return; var bol = this.ReloadDataEvent.Invoke(_delete_id_list); if (!bol) { return; } this.DialogResult = DialogResult.OK; this.Close(); } } }