namespace HStation.WinFrmUI
{
public partial class XhsProjectSimulationSearchCtrl : DevExpress.XtraEditors.XtraUserControl
{
public XhsProjectSimulationSearchCtrl()
{
InitializeComponent();
this.gridView1.SetNormalView();
this.searchControl1.SetSearchSettings(Search, Recover);
}
///
/// 应用查询事件
///
public event Action> ApplySearchEvent;
//水力信息方法
private Func _hydroInfoFunc;
private List _allBindingList = null;
///
/// 初始化数据
///
public void InitialData(Func hydroInfoFunc)
{
_hydroInfoFunc = hydroInfoFunc;
}
//查询
private void Search(object sender, EventArgs e)
{
var condition = this.searchControl1.Text.Trim();
if (string.IsNullOrEmpty(condition))
{
return;
}
var hydroInfo = _hydroInfoFunc?.Invoke();
if (hydroInfo == null)
{
return;
}
var allParterList = hydroInfo.GetAllParters();
var parters = allParterList?.Where(x => (!string.IsNullOrEmpty(x.Code) && x.Code.Contains(condition))
|| (!string.IsNullOrEmpty(x.Name) && x.Name.Contains(condition))
|| (!string.IsNullOrEmpty(x.Catalog) && x.Catalog.Contains(condition))
|| (!string.IsNullOrEmpty(x.Description) && x.Description.Contains(condition))
).ToList();
_allBindingList = new List();
if (parters != null && parters.Count > 0)
{
foreach (var parter in parters)
{
var vm = new XhsProjectSimulationSearchViewModel(parter);
_allBindingList.Add(vm);
}
}
this.xhsProjectSimulationSearchViewModelBindingSource.DataSource = _allBindingList;
this.xhsProjectSimulationSearchViewModelBindingSource.ResetBindings(false);
this.ApplySearchEvent?.Invoke(parters);
}
//覆盖
private void Recover(object sender, EventArgs e)
{
var hydroInfo = _hydroInfoFunc?.Invoke();
if (hydroInfo == null)
{
return;
}
this.ApplySearchEvent?.Invoke(null);
}
//行点击事件
private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
{
var row = this.gridView1.GetRow(e.RowHandle) as XhsProjectSimulationSearchViewModel;
if (row == null)
{
return;
}
this.ApplySearchEvent?.Invoke(new List() { row.Vmo });
}
}
}