namespace Yw.WinFrmUI
{
public partial class SetHydroNozzleDlg : DevExpress.XtraEditors.XtraForm
{
public SetHydroNozzleDlg()
{
InitializeComponent();
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
this.layoutControl1.SetupLayoutControl();
this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
}
///
/// 返回数据事件
///
public event Action> ReloadDataEvent;
//所有构件列表
private List _allVisualList = null;
///
/// 绑定数据
///
public void SetBindingData(Yw.Model.HydroNozzleInfo parter)
{
var allParterList = parter == null ? null : new List() { parter };
SetBindingData(allParterList);
}
///
/// 绑定数据
///
public void SetBindingData(List allNozzleList)
{
_allVisualList = allNozzleList;
if (_allVisualList != null && _allVisualList.Count == 1)
{
var parter = _allVisualList.First();
this.txtElev.EditValue = Math.Round(parter.Elev, 4);
this.txtMinorLoss.EditValue = parter.MinorLoss;
this.txtCoefficient.EditValue = parter.Coefficient;
this.txtDemand.EditValue = parter.Demand;
}
}
//确定
private void GeneralOkAndCancelCtrl1_OkEvent()
{
if (_allVisualList == null || _allVisualList.Count < 1)
{
return;
}
double? elev = this.txtElev.EditValue == null ? null : double.Parse(this.txtElev.EditValue.ToString());
double? minorLoss = this.txtMinorLoss.EditValue == null ? null : double.Parse(this.txtMinorLoss.EditValue.ToString());
double? demand = this.txtDemand.EditValue == null ? null : double.Parse(this.txtDemand.EditValue.ToString());
double? coefficient = this.txtCoefficient.EditValue == null ? null : double.Parse(this.txtCoefficient.EditValue.ToString());
_allVisualList.ForEach(x =>
{
if (elev.HasValue)
{
x.Elev = elev.Value;
}
if (minorLoss.HasValue)
{
x.MinorLoss = minorLoss.Value;
}
if (demand.HasValue)
{
x.Demand = demand.Value;
}
if (coefficient.HasValue)
{
x.Coefficient = coefficient.Value;
}
});
this.ReloadDataEvent?.Invoke(_allVisualList);
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}