namespace Yw.WinFrmUI
|
{
|
public partial class HydroPumpListViewCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public HydroPumpListViewCtrl()
|
{
|
InitializeComponent();
|
}
|
|
/// <summary>
|
/// 选择改变事件
|
/// </summary>
|
public event Action<Yw.Model.HydroPumpInfo> SelectedChangedEvent;
|
|
private List<HydroPumpListViewItemViewModel> _allBindingList = null;//绑定列表
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
|
{
|
if (hydroInfo == null)
|
{
|
return;
|
}
|
SetBindingData(hydroInfo.Pumps, hydroInfo);
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(List<Yw.Model.HydroPumpInfo> pumps, Yw.Model.HydroModelInfo hydroInfo)
|
{
|
_allBindingList = new List<HydroPumpListViewItemViewModel>();
|
pumps?.ForEach(x => _allBindingList.Add(new HydroPumpListViewItemViewModel(x, hydroInfo)));
|
this.hydroPumpListViewItemViewModelBindingSource.DataSource = _allBindingList;
|
this.hydroPumpListViewItemViewModelBindingSource.ResetBindings(false);
|
}
|
|
//选择改变
|
private void imageListBoxControl1_SelectedValueChanged(object sender, EventArgs e)
|
{
|
if (_allBindingList == null || _allBindingList.Count < 1)
|
{
|
return;
|
}
|
var item = this.imageListBoxControl1.SelectedItem;
|
var pump = item as HydroPumpListViewItemViewModel;
|
if (pump == null)
|
{
|
return;
|
}
|
this.SelectedChangedEvent?.Invoke(pump.Vmo);
|
}
|
|
|
}
|
}
|