using DevExpress.Utils.Layout;
|
using DevExpress.XtraEditors;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace Yw.WinFrmUI
|
{
|
public partial class SetHydroNozzleCalcuPrefixListCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public SetHydroNozzleCalcuPrefixListCtrl()
|
{
|
InitializeComponent();
|
}
|
|
/// <summary>
|
/// 查看喷嘴事件
|
/// </summary>
|
public event Action<Yw.Model.HydroNozzleInfo> ViewParterEvent;
|
|
private Yw.Model.HydroModelInfo _hydroInfo = null;
|
private List<SetHydroNozzleCalcuPrefixCtrl> _allCalcuPrefixCtrlList = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
|
{
|
_hydroInfo = hydroInfo;
|
InitialControls();
|
}
|
|
/// <summary>
|
/// 更新绑定数据
|
/// </summary>
|
public void UpdateBindingData()
|
{
|
_allCalcuPrefixCtrlList?.ForEach(x => x.UpdateBindingData());
|
}
|
|
//初始化控件
|
private void InitialControls()
|
{
|
if (_hydroInfo == null)
|
{
|
return;
|
}
|
if (_allCalcuPrefixCtrlList == null)
|
{
|
_allCalcuPrefixCtrlList = new List<SetHydroNozzleCalcuPrefixCtrl>();
|
this.tablePanel.Rows.Add(new TablePanelRow(TablePanelEntityStyle.Relative, 55F));
|
if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0)
|
{
|
for (int i = 0; i < _hydroInfo.Pumps.Count; i++)
|
{
|
this.tablePanel.Columns.Add(new TablePanelColumn(TablePanelEntityStyle.AutoSize, 250F));
|
var ctrl = new SetHydroNozzleCalcuPrefixCtrl();
|
ctrl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;
|
ctrl.ViewParterEvent += (nozzle) =>
|
{
|
if (nozzle == null)
|
{
|
return;
|
}
|
this.ViewParterEvent?.Invoke(nozzle);
|
};
|
_allCalcuPrefixCtrlList.Add(ctrl);
|
this.tablePanel.Controls.Add(ctrl);
|
this.tablePanel.SetCell(ctrl, 0, i);
|
}
|
this.tablePanel.Columns.Add(new TablePanelColumn(TablePanelEntityStyle.AutoSize, 150F));
|
}
|
}
|
if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count == _allCalcuPrefixCtrlList.Count)
|
{
|
for (int i = 0; i < _allCalcuPrefixCtrlList.Count; i++)
|
{
|
_allCalcuPrefixCtrlList[i].SetBindingData(_hydroInfo.Nozzles[i]);
|
}
|
}
|
}
|
}
|
}
|