using DevExpress.PivotGrid.PivotTable;
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 HStation.WinFrmUI
{
public partial class SimulationPumpParallelCtrl : DevExpress.XtraEditors.XtraUserControl
{
public SimulationPumpParallelCtrl()
{
InitializeComponent();
this.layoutControl1.SetupLayoutControl();
this.hydroPumpListExtendGridCtrl1.StateChangedEvent += HydroPumpListExtendGridCtrl1_StateChangedEvent;
}
///
/// 保存事件
///
public event Action> SaveEvent;
///
/// 绑定列表
///
public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
{
this.hydroPumpListExtendGridCtrl1.SetBindingData(hydroInfo);
}
//状态改变事件
private void HydroPumpListExtendGridCtrl1_StateChangedEvent(List allPumpStateList)
{
}
//保存
private void btnSave_Click(object sender, EventArgs e)
{
var result = XtraMessageBox.Show("是否将现有水泵状态更新模型?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes;
if (!result)
{
return;
}
var allStateList = this.hydroPumpListExtendGridCtrl1.GetStateList();
if (allStateList == null || allStateList.Count < 1)
{
return;
}
var allSaveList = allStateList.Select(x => new SimulationPumpParallelSaveItemViewModel()
{
Code = x.Code,
LinkStatus = x.RunStatus ? Yw.Hydro.PumpStatus.Open : Yw.Hydro.PumpStatus.Closed,
SpeedRatio = Math.Round(x.Hz / x.Vmo.RatedHz, 2)
}).ToList();
this.SaveEvent?.Invoke(allSaveList);
}
}
}