namespace Yw.WinFrmUI
{
public partial class SetHydroWaterboxDlg : DevExpress.XtraEditors.XtraForm
{
public SetHydroWaterboxDlg()
{
InitializeComponent();
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
this.layoutControl1.SetupLayoutControl();
}
///
/// 返回数据事件
///
public event Action> ReloadDataEvent;
//所有部件列表
private List _allVisualList = null;
///
/// 绑定数据
///
public void SetBindingData(Yw.Model.HydroWaterboxInfo visual)
{
var allVisualList = visual == null ? null : new List() { visual };
SetBindingData(allVisualList);
}
///
/// 绑定数据
///
public void SetBindingData(List allVisualList)
{
_allVisualList = allVisualList;
if (_allVisualList != null && _allVisualList.Count == 1)
{
var visual = _allVisualList.First();
this.txtPoolElev.EditValue = Math.Round(visual.PoolElev, 4);
this.txtInitLevel.EditValue = Math.Round(visual.InitLevel, 4);
this.txtMinLevel.EditValue = Math.Round(visual.MinLevel, 4);
this.txtMaxLevel.EditValue = Math.Round(visual.MaxLevel, 4);
this.txtDN.EditValue = Math.Round(visual.DN, 4);
}
}
//确定
private void btnOk_Click(object sender, EventArgs e)
{
if (_allVisualList == null || _allVisualList.Count < 1)
{
return;
}
double? poolElev = this.txtPoolElev.EditValue == null ? null : double.Parse(this.txtPoolElev.EditValue.ToString());
double? initLevel = this.txtInitLevel.EditValue == null ? null : double.Parse(this.txtInitLevel.EditValue.ToString());
double? minLevel = this.txtMinLevel.EditValue == null ? null : double.Parse(this.txtMinLevel.EditValue.ToString());
double? maxLevel = this.txtMaxLevel.EditValue == null ? null : double.Parse(this.txtMaxLevel.EditValue.ToString());
double? dn = this.txtDN.EditValue == null ? null : double.Parse(this.txtDN.EditValue.ToString());
_allVisualList.ForEach(x =>
{
if (poolElev.HasValue)
{
x.PoolElev = poolElev.Value;
}
if (initLevel.HasValue)
{
x.InitLevel = initLevel.Value;
}
if (minLevel.HasValue)
{
x.MinLevel = minLevel.Value;
}
if (maxLevel.HasValue)
{
x.MaxLevel = maxLevel.Value;
}
if (dn.HasValue)
{
x.DN = dn.Value;
}
});
this.ReloadDataEvent?.Invoke(_allVisualList);
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}